我使用的是 Kali 32 位(基于 Debian)。我禁用了 ASLR、NX 和堆栈金丝雀。这不是连续的 ret2ret 利用,因为我使用主返回语句跳转到 shellcode 所在的缓冲区。这是我的代码:
void foo(char *args)
{
char buffer[512];
strcpy(buffer, args);
}
int main (int argc, char *argv[])
{
if(argc > 1)
foo(argv[1]);
else
printf("no input args\n");
printf("no good\n");
return 0;
}
void exploit()
{
printf("bravo !!!\n");
exit(0);
}
我在 ebp 上的溢出实际上发生在偏移量 520 处。它用 0x00 覆盖了 ebp 的最低有效字节。
我的第一个测试是尝试跳转到 exploit(),所以我用 516 NOP 和最后 4 个字节的漏洞地址填充了我的缓冲区。它有效,但这是我的第一个问题: 当在 main 中执行 ret 语句时,我们跳转到执行 NOP 的缓冲区中的某个位置。为什么当我到达漏洞利用地址时,它会自动跳转,即使我的缓冲区中没有用于跳转的 asm 指令?
我的第二个问题是:当我这次想要使用 exit(0) 指令执行 shellcode 时:python -c 'print "\x90"*514+"\x31\xdb\xb0\x01\xcd\x80"'
为什么我会得到这个错误的含义是什么:
Program received signal SIGSEGV, Segmentation fault.
_IO_new_file_write (f=0xb7ff59b0, data=0x0, n=-1209570250) at fileops.c:1286
1286 fileops.c: Aucun fichier ou dossier de ce type.
最佳答案
您正试图将执行 exit(0) 的 shellcode 放入已保存的返回地址中?如果您尝试执行 exit(0),您将需要“exit”调用的地址并将 0 以外的内容作为参数推送 :)
关于c - 在 ret2ret 漏洞上执行 shellcode,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21767097/