关于 rev-symbol
rev-symbol 是用于逆向分析的技能,根据代码模式、常量、导入项和交叉引用推断函数名称。它可使用 IDA Pro MCP 或导出的分析文件。
主要功能
- 01检查字符串和数值常量
- 02分析调用者、被调用者及导入项
- 03依据代码和返回模式推断名称
- 04提供建议名称、置信度和依据
适用场景
- 01识别二进制文件中的未命名函数
- 02根据调用上下文推断函数用途
MCP 相关
连接 IDA Pro MCP 时可直接查询 IDA;否则使用 IDA-NO-MCP 导出的数据。
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ p4nda0s/ reverse-skills --skill rev-symbol安装后在 Claude Code 中输入/rev-symbol确认已加载。
详细介绍
符号恢复 - rev-symbol
分析函数代码特征,以恢复/识别函数符号和名称。
预检查
确定可用的 IDA 访问方式:
选项 A — IDA Pro MCP(已连接时优先使用):
检查 IDA Pro MCP 服务是否已连接(查看是否有活动的 ida-pro 或同等 MCP 连接)。如果已连接,可以直接通过 MCP 工具查询 IDA,无需导出文件。使用 MCP 进行分析。
选项 B — IDA-NO-MCP 导出数据: 如果 MCP 未连接,请检查当前目录中是否存在 IDA-NO-MCP 导出数据:
- 检查
decompile/目录是否存在 - 检查其中是否有
.c文件
如果 MCP 和导出数据均不可用,请提示用户:
No IDA access method detected. Choose one of the following:
Option A — IDA Pro MCP (recommended):
Connect the IDA Pro MCP server so Claude can query IDA directly.
Option B — IDA-NO-MCP export:
1. Download plugin: https://github.com/P4nda0s/IDA-NO-MCP
2. Copy INP.py to IDA plugins directory
3. Press Ctrl-Shift-E in IDA to export
4. Open the exported directory with Claude Code
导出目录结构
./
├── decompile/ # Decompiled C code directory
│ ├── 0x401000.c # One file per function, named by hex address
│ ├── 0x401234.c
│ └── ...
├── decompile_failed.txt # Failed decompilation list
├── decompile_skipped.txt # Skipped functions list
├── strings.txt # String table (address, length, type, content)
├── imports.txt # Import table (address:function_name)
├── exports.txt # Export table (address:function_name)
└── memory/ # Memory hexdump (1MB chunks)
函数文件格式(decompile/*.c)
每个 .c 文件都包含函数元数据注释和反编译代码:
/*
* func-name: sub_401000
* func-address: 0x401000
* callers: 0x402000, 0x403000 // List of functions that call this function
* callees: 0x404000, 0x405000 // List of functions called by this function
*/
int __fastcall sub_401000(int a1, int a2)
{
// Decompiled code...
}
符号恢复步骤
步骤 1:分析内部特征
仔细检查目标函数,关注以下内容:
- 字符串常量:函数中使用的字符串可能揭示其用途
- 数值常量/魔数:
- MD5:
0x67452301、0xEFCDAB89、0x98BADCFE、0x10325476 - CRC32:
0xEDB88320 - Base64 字符集:
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/ - AES S-Box:
0x63, 0x7C, 0x77, 0x7B... - Zlib:
0x78、0x9C(压缩头) - 其他常量/魔数……
- MD5:
- 代码结构:循环模式、位运算、特定算法流程
如果可以根据常量/结构识别出已知算法,请直接告知用户。
步骤 2:分析交叉引用
分析被调用函数(被调用方):
-
阅读被调用方列表中的函数
-
对每个被调用方,检查其地址是否存在于
imports.txt中 -
即使缺少符号,也要识别调用模式:
成对函数模式(通过匹配调用对进行识别):
// malloc/free, new/delete, alloc/dealloc xx = sub_A(0x100); // alloc: takes size, returns pointer ... sub_B(xx); // free: takes the same pointer // mutex_lock/mutex_unlock, pthread_mutex_lock/unlock sub_A(lock_ptr); // lock ... // critical section sub_B(lock_ptr); // unlock (same lock object) // open/close, fopen/fclose, CreateFile/CloseHandle fd = sub_A("/path", 0); // open: path + flags, returns handle ... sub_B(fd); // close: takes the handle // pthread_create/pthread_join sub_A(&tid, 0, func, arg); // create: out param, attr, func, arg ... sub_B(tid, &ret); // join: tid, out param **Argument pattern recognition:** ```c // socket(AF_INET, SOCK_STREAM, 0) - fixed constants sub_XXX(2, 1, 0); // socket: domain=2, type=1, protocol=0 // connect/bind(sockfd, addr, addrlen) sub_XXX(fd, &var, 16); // addr struct, len=16 for IPv4 // memcpy/memmove(dst, src, size) sub_XXX(dst, src, n); // 3 params: dst, src, count // memset(ptr, value, size) sub_XXX(ptr, 0, 0x100); // 3 params: ptr, byte value, count // read/write(fd, buf, count) ret = sub_XXX(fd, buf, n); // returns bytes read/written // strcmp/strncmp(s1, s2) or (s1, s2, n) if (sub_XXX(s1, s2) == 0) // returns 0 on equal返回值模式:
// file/socket operations: -1 on error if ((fd = sub_XXX(...)) == -1) goto error; // allocation: NULL on failure if (!(ptr = sub_XXX(size))) goto error; // success/error: 0 = success if (sub_XXX(...) != 0) goto error; // strlen: returns size_t len = sub_XXX(str); sub_YYY(dst, src, len); // len used in memcpy
分析调用方(调用该函数的函数):
- 阅读调用方列表中的函数
- 如果调用方有符号(检查
exports.txt),则根据上下文推断被调用方的用途 - 递归检查:沿调用链向上追踪,直到找到有符号的函数
- 分析调用方如何使用返回值
步骤 3:收集信息并进行搜索
收集以下信息:
- 函数中的字符串(检查
strings.txt,查找函数中使用的地址) - 魔数/常量
- 已知的被调用导入项(将被调用方与
imports.txt交叉引用) exports.txt中的调用方/被调用方符号- 已识别的成对函数模式
根据收集到的信息:
-
首先尝试通过本地推理进行分析,依据包括:
- 函数签名(参数数量和类型)
- 成对调用模式(分配/释放、加锁/解锁)
- 调用链中的已知导入项
- 与已知算法相似的代码结构
-
如果无法确定,请使用网页搜索进行搜索:
- 搜索魔数:
0x67452301 0xEFCDAB89 algorithm - 搜索代码模式:
rotate left xor constant algorithm - 搜索函数中发现的独特字符串
- 搜索参数模式:
function(int, int, 0) socket
- 搜索魔数:
输出格式
## Symbol Recovery Analysis: <function_address>
### Function Characteristics
- Strings: <list discovered strings>
- Constants: <list key constants>
- Called imports: <list>
### Cross-Reference Analysis
- Callers: <callers and their symbols>
- Callees: <callees and their symbols>
### Inference Result
- **Suggested symbol name**: <suggested_name>
- **Confidence**: High / Medium / Low
- **Reasoning**: <explain why this name is suggested>
### Similar Open Source Implementation
- <if similar open source code is found, provide link>
评论
支持 Markdown