I was just trying to get a buffer overflow to work on OSX(10.6) on the following program; I need to make foo execute by overflowing the buffer.
#include <string.h>
#include <stdio.h>
void foo() {
printf("hacked!");
}
int main(int argc, const char *argv[]) {
char s[100];
strcpy(s, argv[1]);
}
I compile it as:-
$ gcc -o test test.c -arch i386
On disassembling test
I get the address of foo
as 0x00001eda
. The exploit does not work as intended; probably because the return address is supposed to be overflowed with 0x00001eda
with contains a \x00
.
In cases where the target address has a \x00
, how can a buffer overflow exploit be performed?