原文https://www.freebuf.com/sectool/171632.html
HeapViewer 插件,它是一款专注于漏洞利用开发的工具,可用于对 glibc 堆进行测试。

HeapViewer - 图1

工具要求

  1. IDA PRO>= 6.9<br /> glibc<= 2.27x86x64)<br /> 注:HeapViewer 当前仅支持 glibc mallocptmalloc2)。

功能介绍

  1. 1. 堆栈跟踪(malloc/free/calloc/realloc
  2. 2. 查看区块分配信息
  3. 3. Bin 信息查看(fastbins,unsortedbin, smallbins y largebins
  4. 4. Tcache 信息查看(glibc >= 2.26
  5. 5. 图形化信息查看(bins/tcache
  6. 6. 等等…

工具安装

  1. 直接将 heap_viewer.py 文件和 heap_viewer 文件夹拷贝到 IDA 的插件目录(plugin)中即可。<br /> 因为 IDA 并不会在调试会话中加载 libc-dbg 符号,所以在使用该插件之前需要生成一份配置文件(config.json)。首先,需要在远程 Linux 设备中安装 libc6-dbg 包,并执行脚本 utils\get_config.py。接下来,将生成的内容拷贝到 heap_viewer\config.json 文件中。
  1. get_config.py
  2. $python get_config.py
  3. [*]config.json:
  4. {
  5. "libc_offsets": {
  6. "32": {
  7. "mp_": 1921312,
  8. "main_arena": 1922976,
  9. },
  10. "64": {
  11. "mp_": 3883648,
  12. "main_arena": 3886144,
  13. }
  14. },
  15. "libc_version": "2.27"
  16. }
  1. 如果你没有给定 libc dbg 符号,你可以选择使用 get_main_arena 工具,然后拿到给定 libc main_arena 偏移量,最后把 main_arena 偏移量写入 config.json 文件即可,这样就可以保证插件能够正常工作了。

样本:

  1. $./main_arena_offset
  2. [*]libc version: 2.27
  3. [*]libc file: /lib/i386-linux-gnu/libc-2.27.so
  4. [*]libc address: 0xf7ceb000
  5. [*]main_arena: 0xf7ec07a0
  6. [*]main_arena offset: 0x1d57a0
  7. $LD_PRELOAD=./libc_64.so.6 ./main_arena_offset
  8. ...

工具截图

  1. 堆栈跟踪器:

HeapViewer - 图2

  1. Arena&区块信息:

HeapViewer - 图3

  1. Tcache 实体:

HeapViewer - 图4

  1. Bins 信息查看:

HeapViewer - 图5

  1. Bin 数据图

HeapViewer - 图6

  1. Fastbin 数据图:

HeapViewer - 图7

  1. Tcache 信息图

HeapViewer - 图8

  1. 查看 fake fastbin

HeapViewer - 图9

  1. 合并信息查看:

HeapViewer - 图10

  1. 有用的 libc 偏移量:

HeapViewer - 图11

工具开发者

  1. Daniel García Gutiérrez - [@danigargu ](/danigargu )

工具下载

  1. HeapViewer:【[点我下载](https://github.com/danigargu/heap-viewer)】