๐ŸฆŠELF x86 - Stack buffer overflow basic 2

Note : A JOURNEY TO GAIN KNOWLEDGE

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
 
void shell() {
    setreuid(geteuid(), geteuid());
    system("/bin/bash");
}
 
void sup() {
    printf("Hey dude ! Waaaaazzaaaaaaaa ?!\n");
}
 
void main()
{
    int var;
    void (*func)()=sup;
    char buf[128];
    fgets(buf,133,stdin);
    func();
}
  • Vแป cฦก bแบฃn รฝ tฦฐแปŸng vแบซn lร  ghi trร n biแบฟn buff ฤ‘แปƒ ghi ฤ‘รจ giรก trแป‹ lรชn biแบฟn trฦฐแป›c ฤ‘รณ

  • Lรบc nร y chรญnh lร  ฤ‘แป‹a chแป‰ cแปงa func : void (*func)()=sup; , tแปฉc lร  thay vรฌ trแป tแป›i ฤ‘แป‹a chแป‰ cแปงa sup nhฦฐ thฦฐแปng lแป‡:

  • Sau khi attack func lรบc nร y sแบฝ trแป tแป›i ฤ‘แป‹a chแป‰ shell vร  thแปฑc thi gแปi nรณ

  • ฤแปƒ biแบฟt ฤ‘ฦฐแปฃc ฤ‘แป‹a chแป‰ cแปงa hร m shell, ta cรณ thแปƒ dรนng gdb hoแบทc pwndbg:

  • Cuแป‘i cรนng ta chuyแปƒn ฤ‘แป‹a chแป‰ sang little-endian, get shell vร  cat flag:

flag: B33r1sSoG0oD4y0urBr4iN

Last updated