调试位置无关的可执行 ELF

逆向工程 艾达 调试 数据库 小精灵 馅饼
2021-06-11 06:45:40

我正在尝试关注有关hackercalc(DEFCON 2015 quals的挑战)的文章。首先,通过将挑战加载到 gdb 中,我观察到:

(gdb) info files
...
Entry point: 0xcf8
...

所以我在 处设置了一个断点entry point并运行程序:

(gdb) break *0xcf8
Breakpoint 1 at 0xcf8
(gdb) run
Starting program: /home/tathanhdinh/CTFs/hackercalc
Error in re-setting breakpoint 1: Warning:
Cannot insert breakpoint 1.
Cannot access memory at address 0xcf8

Warning:
Cannot insert breakpoint 1.
Cannot access memory at address 0xcf8

看来这个断点不起作用。我不明白它为什么这么说,Cannot access memory at address 0xcf8但我猜之前运行的一些代码造成了一些干扰(因此程序无法到达该入口点),据我所知,此代码必须是elf interpreter程序的代码

所以,我查看程序的各个部分来检查这个解释器,一切似乎都很正常(除了readelf说程序是 a shared object file,但我认为这并不重要):

readelf --segments hackercalc

Elf file type is DYN (Shared object file)
Entry point 0xcf8
There are 8 program headers, starting at offset 52

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  PHDR           0x000034 0x00000034 0x00000034 0x00100 0x00100 R E 0x4
  INTERP         0x000154 0x00000154 0x00000154 0x00013 0x00013 R   0x1
      [Requesting program interpreter: /lib/ld-linux.so.2]
  LOAD           0x000000 0x00000000 0x00000000 0x16b4a 0x16b4a R E 0x1000
  LOAD           0x016eac 0x00017eac 0x00017eac 0x001e4 0x001ec RW  0x1000

现在,我尝试再次获取有关此过程的信息:

(gdb) info files
Symbols from "/home/tathanhdinh/CTFs/hackercalc".
Native process:
        Using the running image of child process 10545.
        While running this, GDB does not access memory from...
Local exec file:
        `/home/tathanhdinh/CTFs/hackercalc', file type elf32-i386.
        Entry point: 0x56555cf8

我完全迷失在这里,为什么elf interpreter(这是ld-linux.so.2)在这种情况下可以创建一个新进程?

我尝试了另一种方法,将挑战加载到 IDA,在入口点设置断点,然后运行,但 IDA 只是挂断了!!!

所以我的问题是:这怎么会发生?我对入口点之前执行的代码完全错误吗?挑战是否使用了一些特殊的技巧来绕过调试?

NB1。感谢@Igor,我终于找到了如何调试这个挑战。总之,我禁用 ALSR 以获得稳定的入口点地址。然后我将它加载到 gdbserver 中,使用 IDA 附加这个调试会话,在入口点设置一个断点(通过禁用 ALSR,其地址是稳定的)。

0个回答
没有发现任何回复~