我刚试图在OSX(10.6)上让缓冲区溢出,以下是需要操作的程序;我需要通过溢出缓冲区来执行foo。
#include <string.h>
#include <stdio.h>
void foo() {
printf("hacked!");
}
int main(int argc, const char *argv[]) {
char s[100];
strcpy(s, argv[1]);
}
我以如下方式编译它:-
$ gcc -o test test.c -arch i386
我将 test
进行反汇编,得到了 foo
的地址是 0x00001eda
。但是攻击代码没有按照预期的方式运行,可能是因为返回地址应该被溢出为包含 \x00
的 0x00001eda
。
当目标地址包含 \x00
时,如何执行缓冲区溢出攻击呢?