Re cpp abi

From dslsdzc/rev-skills · View interactive version

Re cpp abi is an AI agent skill from the GitHub repository dslsdzc/rev-skills. 现代 C++ 二进制逆向:RTTI/异常/虚表恢复、ABI 识别、mangling 解码。 触发词:C++逆向、RTTI、虚表恢复、异常处理、C++ ABI、mangling、C++反编译。

How to use this skill

Skill file

现代 C++ 逆向(RTTI / 异常 / 虚表)

何时使用 / 何时不用

工具准备

readelf / llvm-objdump(节表与异常表)

c++filt / undname(mangling 解码)

Ghidra / IDA(反编译底座,脚本化 RTTI 遍历)

gdb(异常断点,可选)

操作步骤

按顺序执行,每步产物存档(路径 + sha256,见 [[re-triage]])。

  1. ABI 识别:

```sh

readelf -s sample | grep -E '_ZN|_ZTV|_ZTI' | head # Itanium(GCC/Clang)

strings sample | grep -E '^\?\?_' | head # MSVC

```

  1. RTTI 重建(Itanium):

```sh

readelf -s sample | grep _ZTI | head

# _ZTI<类名> 指向 typeinfo:起始为 vptr(指向 _ZTVN10__cxxabiv1... 类型信息虚表),

# 下一 pointer-sized 槽为 __type_name;64 位通常 +0/+8、32 位 +0/+4

# 解析前先定 ELF class / 指针宽度;si_class_type_info / vmi_class_type_info 同样按目标 ABI 对齐与字段宽度解析

```

  1. 虚表恢复:

```sh

readelf -s sample | grep _ZTV | head

```

  1. 异常处理表:

```sh

readelf -S sample | grep -E 'eh_frame|gcc_except' # ELF:.eh_frame(readelf 不解析 PE,PE 走下方命令)

llvm-readobj --coff-unwind-info sample.exe # PE:.pdata/.xdata(或 objdump -h / pefile)

```

  1. 模板/lambda 识别:
  1. mangling 解码(批量):

```sh

readelf -s sample | grep -E '_ZN|_ZTV|_ZTI' | awk '{print $8}' | c++filt | head -20

```

跨域联合

常见坑与陷阱

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.