首页 > 解决方案 > 如何强制 gdb 将 plt 地址解析为反汇编输出中的名称?

问题描述

我得到了一个二进制文件。使用 gdb 加载并启动它后,我发现在disass输出中call指令总是显示 plt 地址而不是 plt 名称。在以下示例中,0x8048430显示的是地址而不是函数名printf()

(gdb) disas chall
Dump of assembler code for function chall:
   0x08048603 <+0>:     push   %ebp
   0x08048604 <+1>:     mov    %esp,%ebp
   0x08048606 <+3>:     sub    $0x418,%esp
   0x0804860c <+9>:     sub    $0x8,%esp
   0x0804860f <+12>:    lea    -0x40c(%ebp),%eax
   0x08048615 <+18>:    push   %eax
   0x08048616 <+19>:    push   $0x8048818
   0x0804861b <+24>:    call   0x8048430
   0x08048620 <+29>:    add    $0x10,%esp
   0x08048623 <+32>:    sub    $0xc,%esp
   0x08048626 <+35>:    push   $0x8048830
   0x0804862b <+40>:    call   0x8048430 <========= PLT address
---Type <return> to continue, or q <return> to quit---q
Quit
(gdb) x/i 0x8048430
   0x8048430:   jmp    *0x8049fe4 <================ GOT address
(gdb) 

使用 pwntools 的 python 代码揭示了为什么0x80484300x8049fe4声称是的原因printf()

#!/usr/bin/python3.6
from pwn import *

filename = './ez_pz_hackover_2016'
e = ELF(filename)

log.level = 'DEBUG'
for k, v in e.got.items():
    log.debug(f'got:{k}={hex(v)}')

具有以下输出:

[DEBUG] got:setbuf=0x8049fdc
[DEBUG] got:strcmp=0x8049fe0 
[DEBUG] got:printf=0x8049fe4 <=====================

在 gdb 中阅读这样的程序集不是很方便disass。是否有任何方便的方法可以自动将 plt 地址转换为 gdb 程序集中的名称?

标签: linuxassemblygdbelf

解决方案


推荐阅读