lun4t1c@home:~$

GDB 调试

查看内存

Examine memory: x/FMT ADDRESS.
ADDRESS is an expression for the memory address to examine.
FMT is a repeat count followed by a format letter and a size letter.
Format letters are o(octal), x(hex), d(decimal), u(unsigned decimal),
  t(binary), f(float), a(address), i(instruction), c(char), s(string)
  and z(hex, zero padded on the left).
Size letters are b(byte), h(halfword), w(word), g(giant, 8 bytes).
The specified number of objects of the specified size are printed
according to the format.
Defaults for format and size letters are those previously used.
Default count is 1.  Default address is following last thing printed
with this command or "print".
  • x /g addr 为查看以指定地址为起点的 8 字节的内存内容

  • x /w addr 为查看以指定地址为起点的 4 字节的内存内容

查看堆上的信息

  • heap chunks 为查看各个 chunk 上的内容

  • heap bins 为查看各个 bin 上的内容

查看 GOT 和 PLT 表相关信息

  • got 命令可以查看文件的 GOT 相关信息

  • plt 命令可以方便地一次性为各函数下断点

跳过当前函数

  • 使用 finish 命令可将当前函数的剩余指令执行完毕,然后暂停执行
    • 合理使用 finish 命令可以查看指定栈帧上的情况。

查看源码

  • 使用 list 命令可查看 10 行源码

计算偏移

  • 使用 p/x 命令计算偏移
    p/x 0xf7e1e020 - 0xf7e0f940
    

查看栈上的内容

  • 使用 stack 命令查看栈
    stack 50
    

查看 libc 基址

  • 使用 vmmap 命令可以查看 libc 基址

忽略 SIGALRM

handle SIGALRM ignore

进入函数

  • 使用 step 命令可进入函数