I'm learning buffer overflow exploiting. I wrote a vulnerable program like this:
#include <stdio.h>
#include <string.h>
main(int argc, char *argv[])
{
char buffer[80];
strcpy(buffer, argv[1]);
return 1;
}
Very simple program. The idea is to overwrite the return address that's used to return to the libc function start_main
. Everything went fine and I used GDB to verify that the return address is overwritten with the right address that points to the shellcode
in the memory.
But when I'm suppose to get a shell this appears:
Program received signal SIGSEGV, Segmentation fault. 0xbffff178 in ?? ()
0xbffff178
is the return overwritten return address and it does point to the shellcode
I'm pretty sure. Any help?
You probably have a no-execute stack, which prohibits code from being executed from certain address ranges. You need to compile with -z execstack
to force the stack to be executable.