
Ida Reverse
- 179 installs
- 18.1k repo stars
- Updated August 4, 2026
- zhaoxuya520/reverse-skill
IDA Reverse is an agent skill that documents 72 idapro MCP tools and PowerShell flows to open binaries and survey them in IDA Pro.
About
IDA Reverse is an agent skill that catalogs how to run and use the IDA Pro MCP server named idapro over HTTP, with PowerShell launch scripts and a fast-reference for dozens of reverse-engineering tools. Solo builders and small security-minded teams use it when they must open PE or unknown binaries, get a minimal survey of architecture, entry points, strings, segments, and import categories, then paginate and filter functions before deeper IDA work. The readme emphasizes session lifecycle—list, switch, close, save, health—and practical open flags for long analyzes or skipping auto-analysis on huge images. It is aimed at agent-driven workflows where the human already has IDA licensing and a Windows-oriented script path, not at casual code review. Expect advanced familiarity with disassembly concepts and MCP tool naming conventions.
- Documents 72 idapro_* MCP tools grouped by workflow: startup, sessions, survey, functions, and deeper analysis
- PowerShell helpers start.ps1, open.ps1 with OK:72 readiness signal and session_id binding
- survey_binary with minimal, standard, and full detail_level for architecture, imports, and hot xrefs
- Session management via idalib_list, switch, close, save, health, and server_warmup
- open.ps1 supports TimeoutSeconds and NoAutoAnalysis for large binaries
Ida Reverse by the numbers
- 179 all-time installs (skills.sh)
- +30 installs in the week ending Jul 28, 2026 (Skillselion tracking)
- Ranked #817 of 2,203 Security skills by installs in the Skillselion catalog
- Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/zhaoxuya520/reverse-skill --skill ida-reverseAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 179 |
|---|---|
| repo stars | ★ 18.1k |
| Last updated | August 4, 2026 |
| Repository | zhaoxuya520/reverse-skill ↗ |
What it does
Operate IDA Pro through the idapro MCP tool suite so an agent can survey binaries, list functions, and drive reverse-engineering sessions from PowerShell scripts.
Who is it for?
Advanced developers or security researchers automating IDA Pro via MCP on Windows with existing licenses and target executables.
Skip if: Beginners seeking source-level debugging only, teams without IDA Pro, or developers who cannot run PowerShell and local IDA workers.
When should I use this skill?
You are automating IDA Pro analysis via the idapro MCP HTTP server and need tool names, session steps, or open.ps1 parameters.
What you get
You get a structured survey and function listing workflow—start server, open target, survey_binary, list_funcs—with session hygiene and save paths spelled out.
- Running idapro session with survey_binary overview
- Paginated function lists with optional name filters
- Saved IDA database via idalib_save when analysis pauses
By the numbers
- 72 MCP tools documented for server idapro
- survey_binary supports 3 detail_level options: minimal, standard, full
Files
IDA Pro 逆向分析技能
已知问题与反思(必读)
踩过的坑
1. `idalib_open` 不能通过 部分代码 AI 客户端 MCP 直接调用
- 部分代码 AI 客户端 的 MCP 客户端对
idalib_open的 output schema 校验有 BUG - 报错:
Structured content does not match the tool's output schema - 解决办法:使用
scripts/open.ps1脚本通过 HTTP API 直调,绕过 MCP 校验层 - 文件打开后,数据库绑定到共享上下文,其他所有
idapro_*工具可直接使用
2. `C:\Windows\System32\` 文件无权限打开
- idalib 无法直接读取 System32 目录下的文件
- 解决办法:
open.ps1自动检测并复制到临时目录目录后再打开
3. 启动服务器命令阻塞对话
idalib-mcp启动后会持续输出 INFO 日志到控制台- 解决办法:使用
scripts/start.ps1(-WindowStyle Hidden后台静默启动) - 脚本会等待服务就绪后自动退出,不阻塞对话
4. MCP 服务器名不能用横线
- 之前用
ida-pro-mcp作为服务器名,可能引起工具注册问题 - 当前配置:服务器名
idapro,工具前缀idapro_*
5. Remote HTTP vs Local Stdio
type:"local"(stdio)模式:idalib_open同样有 schema 校验问题type:"remote"(HTTP)模式:可以先用脚本直开文件,再用 MCP 工具- 当前方案:Remote HTTP 模式
6. PR #389 修复了部分 schema 问题
- 作者 mrexodia 在 issue #388 后通过 PR #389 合并了修复
- 修复了 HTTP 模式下的 structuredContent schema,但 部分代码 AI 客户端 侧校验仍有问题
- 已安装最新
main分支版本
7. idalib 超时留下孤儿 worker 进程锁文件
- 第一次
open.ps1超时后,idalib 的 python worker 子进程变成孤儿进程,咬着.id0/.id1/.nam不放 - 后续任何工具或手动拖入 IDA GUI 都会报"权限不足"
- 解决办法:
start.ps1改用taskkill /F /T杀进程树,不再留孤儿 - 兜底:
open.ps1加了自动降级,检测到旧库被锁自动复制到 Temp 并加 GUID 前缀
8. 带自动分析打开看起来像卡死
idalib_open(run_auto_analysis=true)可能长时间不回包,但后端实际上仍在继续打开和分析- 之前用户侧看到的是“PowerShell 一直无输出”,容易误判成脚本卡死
- 当前解决办法:
open.ps1新增-TimeoutSeconds,并改为后台请求 + 前台轮询 + 定时进度输出 - 轮询到会话已就绪时会提前返回
OK:文件名:session_id,超时则返回ERR:open_timeout_xxs
工作流程原则
| 步骤 | 做什么 | 用什么 |
|---|---|---|
| 1 | 确保 HTTP 服务器在运行 | scripts/start.ps1(无参数) |
| 2 | 打开目标二进制文件 | scripts/open.ps1 -Path "xxx.exe" |
| 3 | 使用所有 72 个 MCP 工具 | 直接调用 idapro_* 工具 |
| 4 | 分析完毕 | 工具自动可用 |
脚本资源
start.ps1 — 启动 MCP HTTP 服务器
路径:scripts/start.ps1
- 用
taskkill /F /T杀旧进程树(连 worker 子进程一起清理)→ 后台启动idalib-mcp→ 等待就绪(最多 15 秒) - 成功输出
OK:72,失败输出ERR:timeout - 服务器在后台运行,不阻塞对话
调用方式:
powershell -File "<skill-root>\ida-reverse\scripts\start.ps1"open.ps1 — 打开二进制文件
路径:scripts/open.ps1
- 通过 HTTP API 直调
idalib_open,绕过 MCP schema 校验 - 自动检测 System32 路径并复制到临时目录
- 自动清理同名旧数据库文件(
.id0/.id1/.nam/.til/.i64) - 旧库被锁时自动降级:复制到 Temp 加 GUID 前缀后打开,不报错
- 将打开请求放到后台执行,避免长时间同步等待导致脚本无响应
- 支持
-TimeoutSeconds,超时后返回ERR:open_timeout_xxs,不会无限卡住 - 每隔 10 秒输出一次
INFO:opening:已用时/超时秒数,便于判断仍在分析中 - 成功输出
OK:文件名:session_id,降级时加(temp copy)标记 - 失败时自动重试走 Temp 副本
调用方式:
powershell -File "<skill-root>\ida-reverse\scripts\open.ps1" -Path "C:\path\to\file.exe"可选参数:
# 指定 SessionId
powershell -File "scripts\open.ps1" -Path "file.exe" -SessionId "my_session"
# 跳过自动分析(大文件推荐)
powershell -File "scripts\open.ps1" -Path "large.exe" -NoAutoAnalysis
# 设置超时,避免带自动分析时长时间无返回
powershell -File "scripts\open.ps1" -Path "file.exe" -TimeoutSeconds 600输出约定:
# 分析进行中(每 10 秒输出一次)
INFO:opening:11/600s
# 成功打开
OK:sample.exe:abcd1234
# 成功打开,但因锁文件降级到 Temp 副本
OK:1234abcd-sample.exe:abcd1234 (temp copy)
# 达到超时上限
ERR:open_timeout_600s实测说明:
Snipaste.exe带自动分析实测约324s才返回成功,属于“分析很久”而不是“脚本死锁”- 因此遇到 GUI 程序或较复杂样本时,建议优先显式设置
-TimeoutSeconds 600
核心工具列表
概况分析(第一步)
idapro_survey_binary(detail_level="minimal")— 快速概况:函数数、字符串、段、入口点、导入分类(加密/网络/文件IO)idapro_list_funcs(queries)— 列出函数(分页、按名称过滤)idapro_list_globals(queries)— 列出全局变量idapro_entity_query(kind, filter)— 统一查询:functions/globals/imports/strings/names
反编译与反汇编
idapro_decompile(addr)— 反编译为伪代码idapro_disasm(addr, max_instructions=N)— 反汇编idapro_analyze_function(addr, include_asm=false)— 综合分析(伪代码+字符串+常量+调用者+被调用者+块)idapro_func_profile(queries)— 函数概要指标
交叉引用与数据流
idapro_xrefs_to(addrs)— 查谁引用目标地址idapro_xref_query(addr, direction)— 高级 xref 查询(方向/类型过滤)idapro_callees(addrs)— 子函数列表idapro_callgraph(roots, max_depth)— 调用图idapro_trace_data_flow(addr, direction, max_depth)— 数据流追踪(forward/backward)
搜索
idapro_find_regex(pattern, limit)— 正则搜字符串idapro_search_text(pattern)— 在反汇编列表中搜文本idapro_find_bytes(patterns, limit)— 字节模式搜索(支持 ?? 通配符)idapro_find(type, targets)— 高级搜索(立即数/字符串/引用)
内存与数据
idapro_get_bytes(addrs)— 读原始字节idapro_get_string(addrs)— 读字符串idapro_get_int(queries)— 读整数值idapro_get_global_value(queries)— 读全局变量值idapro_read_struct(queries)— 读结构体字段值idapro_search_structs(filter)— 搜索结构体
修改操作
idapro_set_comments(items)— 添加注释(反汇编+反编译双向同步)idapro_append_comments(items)— 追加注释idapro_rename(batch)— 批量重命名(函数/全局/局部/栈变量)idapro_patch_asm(items)— Patch 汇编指令idapro_patch(patches)— Patch 字节idapro_define_func(items)— 定义函数idapro_undefine(items)— 取消定义idapro_define_code(items)— 将字节转为代码
类型系统
idapro_declare_type(decls)— 声明 C 结构体/枚举/联合体idapro_set_type(edits)— 应用类型到函数/全局/局部idapro_infer_types(addrs)— 推断类型idapro_type_query(queries)— 查询已声明类型idapro_type_inspect(queries)— 查看类型详情
栈帧
idapro_stack_frame(addrs)— 查看栈帧变量idapro_declare_stack(items)— 声明栈变量idapro_delete_stack(items)— 删除栈变量
签名
idapro_make_signature(addrs)— 为地址生成唯一字节签名idapro_make_signature_for_function(addrs)— 为函数生成签名idapro_find_xref_signatures(addrs)— 为引用地址的代码生成签名
调试器(需要 ?ext=dbg)
idapro_open_file(file_path)— 在 GUI IDA 实例中打开文件- 调试器工具默认隐藏,可通过 URL 参数
?ext=dbg启用
会话管理
idapro_idalib_open(input_path)— ⚠️ 有 schema 校验 BUG,改用open.ps1脚本idapro_idalib_list()— 列出所有 sessionidapro_idalib_current()— 当前上下文绑定的 sessionidapro_idalib_switch(session_id)— 切换到其他 sessionidapro_idalib_close(session_id)— 关闭 sessionidapro_idalib_save(path)— 保存数据库idapro_idalib_health(session_id)— 检查 worker 健康状态
其他
idapro_int_convert(inputs)— 进制转换(必须用这个,不要自己算进制!)idapro_export_funcs(addrs, format)— 导出函数(json/c_header/prototypes)idapro_py_eval(code)— 在 IDA 上下文执行 Pythonidapro_server_health()— 服务器健康检查idapro_server_warmup()— 预热子系统(字符串缓存、Hex-Rays 等)
逆向分析完整工作流
Step 1: 启动服务器
确保 HTTP 服务在后台运行。
powershell -File "scripts/start.ps1"输出 OK:72 表示就绪。
Step 2: 打开文件
powershell -File "scripts/open.ps1" -Path "C:\目标.exe" -TimeoutSeconds 600输出 OK:文件名:session_id 表示成功(后带 (temp copy) 表示自动降级到临时副本)。 若分析时间较长,会周期性输出 INFO:opening:...;若达到超时则输出 ERR:open_timeout_xxs。
Step 3: 全局概览
idapro_survey_binary(detail_level="minimal")关注:
- 架构(x86/x64/ARM)
- 入口点(main/WinMain/DllMain)
- 有趣的字符串(URL、路径、错误消息)
- 导入分类(加密函数?网络 API?文件操作?)
- 热门函数(高 xref 计数的函数通常是关键逻辑)
Step 4: 深入关键函数
idapro_analyze_function(addr="关键函数名")或:
idapro_decompile(addr="函数名")
idapro_disasm(addr="函数名", max_instructions=50)Step 5: 数据流和交叉引用
idapro_xrefs_to(addrs="关键地址/字符串")
idapro_callgraph(roots=["关键函数"], max_depth=3)
idapro_trace_data_flow(addr="关键地址", direction="backward", max_depth=5)Step 6: 记录和优化
idapro_set_comments(items=[{"addr": "0x140001000", "comment": "你的理解"}])
idapro_rename(batch={"func": [{"addr": "函数地址", "name": "有意义的名字"}]})Step 7: 输出报告
分析完成后,生成 report.md 记录发现和步骤。
Prompt 工程准则
1. 不要手动算进制 — 任何时候需要转换数字,用 idapro_int_convert 2. 先 survey 后深入 — 先看概况再针对性分析 3. 持续加注释和重命名 — 分析过程中不断更新函数名和变量名,提升后续分析的准确性 4. 跟踪交叉引用 — 发现有趣的数据/字符串,用 xrefs_to 看谁引用了它 5. 遇到混淆代码 — 先做字符串解密、导入哈希去除、控制流平坦化去除等预处理 6. C++ STL 代码 — 用 FLIRT/Lumina 识别库函数后,再分析业务逻辑 7. 不要暴力破解 — 分析应从反汇编中推导解决方案,用简单 Python 辅助计算 8. 遇到 "No database bound" — 还没有打开任何二进制文件,先执行 open.ps1 9. 遇到 "Failed to open database" — 可能是旧数据库文件被锁,open.ps1 会自动降级到 Temp 副本(输出含 (temp copy) 标记) 10. 带自动分析打开 GUI/复杂样本时 — 默认加 -TimeoutSeconds 600,不要把长时间 INFO:opening:... 误判成脚本卡死
---
路由上下文
上游入口: skills/SKILL.md(总控)、routing.md 上游备选: radare2/(如果不想开 IDA,可以先 r2 快速侦察) 下游出口:
- 需 Frida 动态验证 →
reverse-engineering/tools-dynamic.md - 需符号执行/angr →
reverse-engineering/tools-dynamic.md - 需通用逆向方法论 →
reverse-engineering/SKILL.md
同级关联模块: radare2/(IDA 不可用时替代方案)
---
按需自举(On-Demand Bootstrap)
本 skill 的入口脚本已接入统一自举系统。
自动化能力边界
| 工具 | 可自动安装 | 安装方式 | 说明 |
|---|---|---|---|
| idalib-mcp | ✓ | pip install (from GitHub) | start.ps1 缺失时自动安装 |
| IDA Pro 本体 | ✗ | 商业软件,需手动安装 | 设置 IDADIR 环境变量指向安装目录 |
安装步骤(已验证)
# 1. 设置 IDA 路径(替换为你的实际 IDA 安装目录)
setx IDADIR "<你的IDA安装目录>"
# 2. 从 GitHub 安装 ida-pro-mcp(PyPI 上的 ida-mcp 是另一个项目,不要装错!)
pip install git+https://github.com/mrexodia/ida-pro-mcp.git
# 3. 安装 IDA 插件(选择 Streamable HTTP + Global + 全选客户端)
ida-pro-mcp --install
# 4. 重启 IDA Pro,打开目标文件
# 插件自动监听 127.0.0.1:13337
# 5. 验证
ida-pro-mcp --config⚠️ 注意:PyPI 上的 ida-mcp 包(作者 jtsylve)是另一个项目,不是我们需要的。必须从 GitHub 安装 mrexodia/ida-pro-mcp。自举触发点
scripts/start.ps1:缺idalib-mcp时自动调用bootstrap-reverse.ps1- MCP 注册:bootstrap 会自动把
idapro写入 Claude MCP 配置
前置条件
- IDA Pro 已安装且
IDADIR环境变量已设置(或脚本内默认路径正确) - Python 已安装(idalib-mcp 依赖 Python)
IDA Pro MCP 工具速查
72 个 MCP 工具按功能分类,附常用参数和典型用法。
服务器名:idapro,工具前缀:idapro_*,HTTP 模式运行。
---
启动与会话管理
服务器启动
# 启动 MCP HTTP 服务器(后台静默)
powershell -File "scripts/start.ps1"
# 输出 OK:72 表示就绪
# 打开目标文件(绕过 schema 校验)
powershell -File "scripts/open.ps1" -Path "C:\target.exe"
# 输出 OK:filename:session_id
# 大文件/GUI 程序建议加超时
powershell -File "scripts/open.ps1" -Path "C:\big.exe" -TimeoutSeconds 600
# 跳过自动分析(快速打开)
powershell -File "scripts/open.ps1" -Path "C:\huge.sys" -NoAutoAnalysis会话工具
| 工具 | 用途 | 示例 |
|---|---|---|
idapro_idalib_list() | 列出所有 session | — |
idapro_idalib_current() | 当前绑定的 session | — |
idapro_idalib_switch(session_id) | 切换 session | 多文件对比时 |
idapro_idalib_close(session_id) | 关闭 session | 释放资源 |
idapro_idalib_save(path) | 保存数据库 | 保存分析进度 |
idapro_idalib_health(session_id) | 检查 worker 状态 | 排查卡死 |
idapro_server_health() | 服务器健康检查 | — |
idapro_server_warmup() | 预热子系统 | 首次使用前 |
---
第一步:全局概览
survey_binary — 快速概况
idapro_survey_binary(detail_level="minimal")返回:
- 架构(x86/x64/ARM/MIPS)
- 入口点
- 函数总数
- 字符串统计
- 段信息
- 导入分类(加密/网络/文件IO/注册表)
- 高 xref 热门函数
detail_level 选项:
"minimal"— 快速概况(推荐首选)"standard"— 包含更多细节"full"— 完整信息
函数列表
# 列出所有函数(分页)
idapro_list_funcs(queries=[{"offset": 0, "limit": 50}])
# 按名称过滤
idapro_list_funcs(queries=[{"filter": "crypt", "offset": 0, "limit": 20}])
idapro_list_funcs(queries=[{"filter": "main", "offset": 0, "limit": 10}])统一查询
# 查询导入函数
idapro_entity_query(kind="imports", filter="Create")
# 查询字符串
idapro_entity_query(kind="strings", filter="http")
# 查询所有命名符号
idapro_entity_query(kind="names", filter="")---
反编译与反汇编
反编译(伪代码)
# 按函数名
idapro_decompile(addr="main")
idapro_decompile(addr="sub_140001000")
# 按地址
idapro_decompile(addr="0x140001000")反汇编
# 默认指令数
idapro_disasm(addr="main")
# 指定指令数量
idapro_disasm(addr="0x401000", max_instructions=100)综合分析(推荐)
# 一次性获取:伪代码 + 字符串 + 常量 + 调用者 + 被调用者 + 基本块
idapro_analyze_function(addr="main", include_asm=false)
# 包含汇编
idapro_analyze_function(addr="sub_401000", include_asm=true)函数概要
# 批量获取函数指标(大小、块数、xref 数)
idapro_func_profile(queries=["main", "sub_401000", "sub_402000"])---
交叉引用与调用图
谁引用了目标
# 查看谁调用了某函数
idapro_xrefs_to(addrs=["sub_401000"])
# 查看谁引用了某字符串/数据
idapro_xrefs_to(addrs=["0x404000"])
# 批量查询
idapro_xrefs_to(addrs=["CreateFileW", "ReadFile", "WriteFile"])高级 xref 查询
# 指定方向和类型
idapro_xref_query(addr="0x401000", direction="to") # 谁引用我
idapro_xref_query(addr="0x401000", direction="from") # 我引用谁被调用函数列表
idapro_callees(addrs=["main"])调用图
# 从 main 开始,深度 3
idapro_callgraph(roots=["main"], max_depth=3)
# 多个起点
idapro_callgraph(roots=["sub_401000", "sub_402000"], max_depth=2)数据流追踪
# 向后追踪:这个值从哪来
idapro_trace_data_flow(addr="0x401050", direction="backward", max_depth=5)
# 向前追踪:这个值流向哪里
idapro_trace_data_flow(addr="0x401050", direction="forward", max_depth=5)---
搜索
字符串搜索(正则)
# 搜索 URL
idapro_find_regex(pattern="https?://", limit=20)
# 搜索文件路径
idapro_find_regex(pattern="C:\\\\", limit=20)
# 搜索错误信息
idapro_find_regex(pattern="error|fail|invalid", limit=30)
# 搜索密钥/密码相关
idapro_find_regex(pattern="key|password|secret|token", limit=20)反汇编文本搜索
# 在反汇编列表中搜索
idapro_search_text(pattern="call sub_")
idapro_search_text(pattern="xor eax, eax")字节模式搜索
# 精确字节
idapro_find_bytes(patterns=["48 8B 05"], limit=10)
# 带通配符
idapro_find_bytes(patterns=["48 89 ?? 24 ??"], limit=10)
# 多个模式
idapro_find_bytes(patterns=["CC CC CC CC", "90 90 90 90"], limit=5)高级搜索
# 搜索立即数
idapro_find(type="immediate", targets=["0xDEADBEEF"])
# 搜索字符串引用
idapro_find(type="string", targets=["password"])---
内存与数据读取
读原始字节
idapro_get_bytes(addrs=[{"addr": "0x401000", "size": 64}])读字符串
idapro_get_string(addrs=["0x404000", "0x404100"])读整数
idapro_get_int(queries=[{"addr": "0x405000", "size": 4}])读全局变量
idapro_get_global_value(queries=["g_flag", "g_key_size"])读结构体
idapro_read_struct(queries=[{"addr": "0x405000", "type": "HEADER"}])搜索结构体
idapro_search_structs(filter="FILE")---
修改操作
添加注释
# 单个注释
idapro_set_comments(items=[{"addr": "0x401000", "comment": "解密函数入口"}])
# 批量注释
idapro_set_comments(items=[
{"addr": "0x401000", "comment": "XOR 解密循环"},
{"addr": "0x401050", "comment": "密钥初始化"},
{"addr": "0x4010A0", "comment": "结果校验"}
])
# 追加注释(不覆盖已有)
idapro_append_comments(items=[{"addr": "0x401000", "comment": "补充:密钥长度 16"}])重命名
# 重命名函数
idapro_rename(batch={"func": [
{"addr": "sub_401000", "name": "decrypt_payload"},
{"addr": "sub_402000", "name": "verify_license"}
]})
# 重命名全局变量
idapro_rename(batch={"global": [
{"addr": "0x405000", "name": "g_encryption_key"}
]})
# 重命名局部变量
idapro_rename(batch={"local": [
{"func": "decrypt_payload", "old": "v1", "name": "plaintext_buf"}
]})Patch 汇编
# NOP 掉检测代码
idapro_patch_asm(items=[{"addr": "0x401050", "asm": "nop"}])
# 修改跳转
idapro_patch_asm(items=[{"addr": "0x401060", "asm": "jmp 0x401080"}])
# 强制返回 true
idapro_patch_asm(items=[
{"addr": "0x401000", "asm": "mov eax, 1"},
{"addr": "0x401005", "asm": "ret"}
])Patch 字节
# 直接写字节
idapro_patch(patches=[{"addr": "0x401050", "bytes": "9090909090"}])---
类型系统
声明结构体
idapro_declare_type(decls=[{
"name": "PacketHeader",
"decl": "struct PacketHeader { uint32_t magic; uint16_t type; uint16_t length; uint8_t data[0]; };"
}])应用类型
# 给函数设置原型
idapro_set_type(edits=[{
"addr": "sub_401000",
"type": "int __fastcall decrypt(void *buf, int size, const char *key)"
}])
# 给全局变量设置类型
idapro_set_type(edits=[{
"addr": "0x405000",
"type": "PacketHeader"
}])推断类型
idapro_infer_types(addrs=["sub_401000", "sub_402000"])查询/查看类型
idapro_type_query(queries=["Packet"])
idapro_type_inspect(queries=["PacketHeader"])---
栈帧分析
# 查看函数栈帧
idapro_stack_frame(addrs=["main", "sub_401000"])
# 声明栈变量
idapro_declare_stack(items=[{
"func": "sub_401000",
"offset": -0x20,
"name": "local_buf",
"type": "char [32]"
}])---
签名生成
# 为地址生成唯一字节签名
idapro_make_signature(addrs=["0x401000"])
# 为整个函数生成签名
idapro_make_signature_for_function(addrs=["decrypt_payload"])
# 为引用某地址的代码生成签名
idapro_find_xref_signatures(addrs=["0x405000"])---
进制转换
# 十六进制 → 十进制
idapro_int_convert(inputs=["0x401000"])
# 十进制 → 十六进制
idapro_int_convert(inputs=["4198400"])
# 批量转换
idapro_int_convert(inputs=["0xDEAD", "0xBEEF", "12345"])⚠️ 永远用这个工具做进制转换,不要自己算!
---
导出与脚本
导出函数
# JSON 格式
idapro_export_funcs(addrs=["main", "sub_401000"], format="json")
# C 头文件
idapro_export_funcs(addrs=["main", "sub_401000"], format="c_header")
# 函数原型
idapro_export_funcs(addrs=["main", "sub_401000"], format="prototypes")执行 Python 脚本
# 在 IDA 上下文中执行 Python
idapro_py_eval(code="import idautils; print(list(idautils.Functions())[:10])")
# 获取段信息
idapro_py_eval(code="import idc; print(idc.get_segm_name(0x401000))")
# 批量操作
idapro_py_eval(code="import ida_funcs; f=ida_funcs.get_func(0x401000); print(f.size())")---
典型分析流程
恶意软件分析
1. survey_binary → 看导入(网络API? 加密? 注册表?)
2. find_regex("http|socket|connect") → 找网络相关字符串
3. xrefs_to(网络字符串地址) → 找引用函数
4. decompile(引用函数) → 看通信逻辑
5. trace_data_flow(加密参数, "backward") → 追踪密钥来源
6. set_comments + rename → 标注发现注册验证破解
1. find_regex("serial|license|register|valid") → 找验证相关字符串
2. xrefs_to(验证字符串) → 定位验证函数
3. analyze_function(验证函数) → 理解逻辑
4. callgraph(验证函数, 2) → 看调用链
5. patch_asm(条件跳转地址, "jmp always_pass") → patchCTF 逆向
1. survey_binary → 确认架构和入口
2. decompile("main") → 看主逻辑
3. find_regex("flag|correct|wrong") → 找判断点
4. trace_data_flow(判断点, "backward") → 追踪输入变换
5. 用 Python 辅助计算/解密 → 得到 flag漏洞分析
1. entity_query(kind="imports", filter="strcpy|sprintf|gets") → 找危险函数
2. xrefs_to(危险函数) → 找调用点
3. analyze_function(调用点所在函数) → 看上下文
4. stack_frame(函数) → 确认缓冲区大小
5. trace_data_flow(危险参数, "backward") → 确认用户可控---
常见错误与解决
| 错误 | 原因 | 解决 |
|---|---|---|
| "No database bound" | 没有打开文件 | 执行 open.ps1 |
| "Failed to open database" | 旧库被锁 | open.ps1 自动降级到 Temp |
| schema 校验失败 | MCP 客户端 BUG | 用 open.ps1 代替 idalib_open |
| 工具超时 | 大文件分析中 | 加 -TimeoutSeconds 600 |
| "ERR:timeout" (start.ps1) | 服务器启动失败 | 检查 Python/idalib-mcp 安装 |
| 进制转换错误 | 手动计算出错 | 用 idapro_int_convert |
| 函数名找不到 | 名称不精确 | 用 list_funcs + filter 先搜索 |
<#
.SYNOPSIS
Open binary file via IDA HTTP API (bypass MCP schema issue)
.PARAMETER Path
Binary file path (required)
.PARAMETER SessionId
Session ID (optional, auto-generated)
.PARAMETER NoAutoAnalysis
Skip automatic analysis (faster open for large files)
.PARAMETER TimeoutSeconds
Open timeout in seconds, returns timeout instead of blocking forever
#>
param(
[Parameter(Mandatory=$true)]
[string]$Path,
[string]$SessionId = "",
[switch]$NoAutoAnalysis = $false,
[int]$TimeoutSeconds = 120
)
Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
if (-not [string]::IsNullOrWhiteSpace($env:IDADIR)) {
$env:IDADIR = $env:IDADIR
}
else {
# Fallback: check common IDA installation paths
$idaCandidates = @(
'C:\Program Files\IDA Pro',
'C:\IDA Pro',
'D:\IDA',
(Join-Path $env:USERPROFILE 'Tools\IDA')
)
$foundIda = $idaCandidates | Where-Object { Test-Path -LiteralPath $_ } | Select-Object -First 1
if ($foundIda) {
$env:IDADIR = $foundIda
} else {
Write-Error "ERR:IDADIR not set and IDA Pro not found at common paths. Set IDADIR environment variable to your IDA installation directory."
exit 1
}
}
$Port = 13337
$TempDir = Join-Path $env:TEMP 'reverse-skill'
if (-not (Test-Path -LiteralPath $TempDir)) {
New-Item -ItemType Directory -Path $TempDir -Force | Out-Null
}
$PollIntervalMs = 2000
$ProgressIntervalSeconds = 10
function Get-OpenReadySession {
param(
[string]$ExpectedSessionId,
[string]$ExpectedPath,
[int]$RequestPort
)
$listBody = '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"idalib_list","arguments":{}}}'
$listResult = Invoke-RestMethod "http://127.0.0.1:$RequestPort/mcp" -Method Post -Body $listBody `
-ContentType "application/json" -TimeoutSec 10 -ErrorAction Stop
$sessions = @($listResult.result.structuredContent.sessions)
foreach ($candidate in $sessions) {
if (-not $candidate) {
continue
}
$sameSession = $candidate.session_id -eq $ExpectedSessionId
$samePath = $candidate.input_path -eq $ExpectedPath
$sameFile = [System.IO.Path]::GetFileName($candidate.input_path) -eq [System.IO.Path]::GetFileName($ExpectedPath)
if (($sameSession -or $samePath -or $sameFile) -and $candidate.is_analyzing -eq $false) {
return $candidate
}
}
return $null
}
if (-not (Test-Path $Path)) {
Write-Output "ERR:file_not_found"
exit 1
}
if ($TimeoutSeconds -le 0) {
Write-Output "ERR:invalid_timeout"
exit 1
}
# 判断是否用了临时副本(避免递归复制)
$isTempCopy = $Path.StartsWith($TempDir, [StringComparison]::OrdinalIgnoreCase)
# System32 文件自动复制到 Temp
if (-not $isTempCopy -and $Path -match "C:\\Windows\\System32") {
$Filename = [System.IO.Path]::GetFileName($Path)
$TempPath = "$TempDir\$Filename"
Copy-Item $Path $TempPath -Force -ErrorAction SilentlyContinue
if ($?) {
$Path = $TempPath
$isTempCopy = $true
}
}
# 清理同名旧数据库文件(只在非 Temp 副本时尝试)
if (-not $isTempCopy) {
$dir = [System.IO.Path]::GetDirectoryName($Path)
$base = [System.IO.Path]::GetFileNameWithoutExtension($Path)
$oldExts = @(".id0", ".id1", ".id2", ".nam", ".til", ".i64")
$hasLocked = $false
foreach ($ext in $oldExts) {
$f = Join-Path $dir "$base$ext"
if (Test-Path $f) {
Remove-Item $f -Force -ErrorAction SilentlyContinue
if (Test-Path $f) { $hasLocked = $true }
}
}
# 旧数据库文件被锁,自动用 Temp 副本
if ($hasLocked) {
$guid = [System.Guid]::NewGuid().ToString("N").Substring(0, 8)
$newName = "$guid-$([System.IO.Path]::GetFileName($Path))"
$TempPath = "$TempDir\$newName"
Copy-Item $Path $TempPath -Force
$Path = $TempPath
$isTempCopy = $true
}
}
$autoAnalysis = if ($NoAutoAnalysis) { "false" } else { "true" }
$escapedPath = $Path -replace '\\', '\\'
# 始终使用明确的会话 ID,便于超时时轮询会话状态判断是否已成功打开
if (-not $SessionId) {
$SessionId = [System.Guid]::NewGuid().ToString("N").Substring(0, 8)
}
$body = @"
{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"idalib_open","arguments":{"input_path":"$escapedPath","run_auto_analysis":$autoAnalysis,"session_id":null}}}
"@
if ($SessionId) {
$body = @"
{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"idalib_open","arguments":{"input_path":"$escapedPath","run_auto_analysis":$autoAnalysis,"session_id":"$SessionId"}}}
"@
}
# 将打开请求放到后台,避免 HTTP 长时间不回包时阻塞整个脚本
$openJob = Start-Job -ScriptBlock {
param($RequestBody, $RequestPort)
try {
Invoke-RestMethod "http://127.0.0.1:$RequestPort/mcp" -Method Post -Body $RequestBody `
-ContentType "application/json" -ErrorAction Stop
} catch {
$_.Exception.Message
}
} -ArgumentList $body, $Port
$deadline = (Get-Date).AddSeconds($TimeoutSeconds)
$openCompleted = $false
$startTime = Get-Date
$lastProgressAt = $startTime.AddSeconds(-$ProgressIntervalSeconds)
try {
while ((Get-Date) -lt $deadline) {
if (Wait-Job -Job $openJob -Timeout 1) {
$openCompleted = $true
break
}
try {
$session = Get-OpenReadySession -ExpectedSessionId $SessionId -ExpectedPath $Path -RequestPort $Port
if ($session) {
$tag = if ($isTempCopy) { " (temp copy)" } else { "" }
Stop-Job -Job $openJob -ErrorAction SilentlyContinue
Remove-Job -Job $openJob -Force -ErrorAction SilentlyContinue
Write-Output "OK:$($session.filename):$($session.session_id)$tag"
exit 0
}
} catch {}
$now = Get-Date
if (($now - $lastProgressAt).TotalSeconds -ge $ProgressIntervalSeconds) {
$elapsed = [math]::Floor(($now - $startTime).TotalSeconds)
Write-Output "INFO:opening:$elapsed/${TimeoutSeconds}s"
$lastProgressAt = $now
}
Start-Sleep -Milliseconds $PollIntervalMs
}
if (-not $openCompleted) {
Stop-Job -Job $openJob -ErrorAction SilentlyContinue
Remove-Job -Job $openJob -Force -ErrorAction SilentlyContinue
try {
$session = Get-OpenReadySession -ExpectedSessionId $SessionId -ExpectedPath $Path -RequestPort $Port
if ($session) {
$tag = if ($isTempCopy) { " (temp copy)" } else { "" }
Write-Output "OK:$($session.filename):$($session.session_id)$tag"
exit 0
}
} catch {}
Write-Output "ERR:open_timeout_${TimeoutSeconds}s"
exit 1
}
$jobResult = Receive-Job -Job $openJob
Remove-Job -Job $openJob -Force -ErrorAction SilentlyContinue
if ($jobResult -is [string]) {
Write-Output "ERR:$jobResult"
exit 1
}
if ($jobResult.result.structuredContent.success -eq $true) {
$session = $jobResult.result.structuredContent.session
$tag = if ($isTempCopy) { " (temp copy)" } else { "" }
Write-Output "OK:$($session.filename):$($session.session_id)$tag"
} else {
# 自动降级:非 Temp 副本失败时,复制到 Temp 重试
if (-not $isTempCopy) {
$guid = [System.Guid]::NewGuid().ToString("N").Substring(0, 8)
$newName = "$guid-$([System.IO.Path]::GetFileName($Path))"
$TempPath = "$TempDir\$newName"
Copy-Item $Path $TempPath -Force
& $PSCommandPath -Path $TempPath -SessionId $SessionId -NoAutoAnalysis:$NoAutoAnalysis -TimeoutSeconds $TimeoutSeconds
} else {
Write-Output "ERR:$($jobResult.result.structuredContent.error)"
}
}
} finally {
if ($openJob) {
Stop-Job -Job $openJob -ErrorAction SilentlyContinue
Remove-Job -Job $openJob -Force -ErrorAction SilentlyContinue
}
}
<#
.SYNOPSIS
Start IDA Pro MCP HTTP server (background, non-blocking)
.DESCRIPTION
1. Kill old process
2. Start idalib-mcp HTTP server in hidden window mode
3. Wait for service ready (max 15 seconds)
4. Output result
Usage: run without parameters
#>
param(
[string]$IdaDir,
[int]$Port = 13337,
[string]$ServerPath
)
function Get-InstalledIdaDir {
$registryPaths = @(
'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*',
'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*',
'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*'
)
$fromRegistry = $registryPaths |
ForEach-Object {
Get-ItemProperty $_ -ErrorAction SilentlyContinue
} |
Where-Object {
($_.DisplayName -match 'IDA|Hex-Rays') -and
-not [string]::IsNullOrWhiteSpace($_.InstallLocation) -and
(Test-Path -LiteralPath $_.InstallLocation)
} |
Select-Object -ExpandProperty InstallLocation -First 1
if ($fromRegistry) {
return $fromRegistry
}
$idaCandidates = @(
'C:\Program Files\IDA Pro',
'C:\Program Files\IDA',
'C:\IDA Pro',
'C:\IDA',
'D:\IDA',
'E:\Program Files\IDA',
(Join-Path $env:USERPROFILE 'Tools\IDA')
) | Where-Object { -not [string]::IsNullOrWhiteSpace($_) }
return $idaCandidates | Where-Object { Test-Path -LiteralPath $_ } | Select-Object -First 1
}
if ([string]::IsNullOrWhiteSpace($IdaDir)) {
if (-not [string]::IsNullOrWhiteSpace($env:IDADIR)) {
$IdaDir = $env:IDADIR
} else {
$persistedIdaDir = [Environment]::GetEnvironmentVariable('IDADIR', 'User')
if ([string]::IsNullOrWhiteSpace($persistedIdaDir)) {
$persistedIdaDir = [Environment]::GetEnvironmentVariable('IDADIR', 'Machine')
}
if (-not [string]::IsNullOrWhiteSpace($persistedIdaDir) -and (Test-Path -LiteralPath $persistedIdaDir)) {
$IdaDir = $persistedIdaDir
} else {
# Search registry install records and common fallback paths
$foundIda = Get-InstalledIdaDir
if ($foundIda) {
$IdaDir = $foundIda
} else {
Write-Output "ERR:IDADIR not set and IDA Pro not found. Set IDADIR environment variable."
exit 1
}
}
}
}
$env:IDADIR = $IdaDir
if ([string]::IsNullOrWhiteSpace($ServerPath)) {
# Try both possible executable names (idalib-mcp is the HTTP server, ida-pro-mcp is the installer CLI)
$resolved = Get-Command idalib-mcp -ErrorAction SilentlyContinue
if (-not $resolved) {
$resolved = Get-Command ida-pro-mcp -ErrorAction SilentlyContinue
}
if ($resolved) {
$ServerPath = $resolved.Source
}
else {
$roamingPython = Join-Path $env:APPDATA 'Python'
if (Test-Path -LiteralPath $roamingPython) {
$candidate = Get-ChildItem -LiteralPath $roamingPython -Directory -ErrorAction SilentlyContinue |
ForEach-Object {
$scripts = Join-Path $_.FullName 'Scripts'
@('idalib-mcp.exe', 'ida-pro-mcp.exe') | ForEach-Object { Join-Path $scripts $_ }
} |
Where-Object { Test-Path -LiteralPath $_ } |
Select-Object -First 1
if ($candidate) {
$ServerPath = $candidate
}
}
}
}
# Auto-bootstrap if still not found
if ([string]::IsNullOrWhiteSpace($ServerPath)) {
$bootstrapScript = Join-Path $PSScriptRoot '..\..\scripts\bootstrap-reverse.ps1'
if (Test-Path -LiteralPath $bootstrapScript) {
Write-Output "INFO: ida-pro-mcp not found, attempting auto-bootstrap (installing mrexodia/ida-pro-mcp)..."
& powershell.exe -NoProfile -ExecutionPolicy Bypass -File $bootstrapScript -Capability @('idalib-mcp') -SkipRefresh
$resolved = Get-Command ida-pro-mcp -ErrorAction SilentlyContinue
if (-not $resolved) {
$resolved = Get-Command idalib-mcp -ErrorAction SilentlyContinue
}
if ($resolved) {
$ServerPath = $resolved.Source
}
else {
$roamingPython = Join-Path $env:APPDATA 'Python'
if (Test-Path -LiteralPath $roamingPython) {
$candidate = Get-ChildItem -LiteralPath $roamingPython -Directory -ErrorAction SilentlyContinue |
ForEach-Object {
$scripts = Join-Path $_.FullName 'Scripts'
@('ida-pro-mcp.exe', 'idalib-mcp.exe') | ForEach-Object { Join-Path $scripts $_ }
} |
Where-Object { Test-Path -LiteralPath $_ } |
Select-Object -First 1
if ($candidate) {
$ServerPath = $candidate
}
}
}
}
}
if ([string]::IsNullOrWhiteSpace($ServerPath)) {
throw 'Missing required CLI tool: ida-pro-mcp — auto-bootstrap failed. Install manually: pip install git+https://github.com/mrexodia/ida-pro-mcp.git && ida-pro-mcp --install'
}
# 清理旧进程(杀进程树,包括 worker 子进程)
$old = Get-Process -Name "ida-pro-mcp" -ErrorAction SilentlyContinue
if (-not $old) { $old = Get-Process -Name "idalib-mcp" -ErrorAction SilentlyContinue }
if ($old) { taskkill /F /T /PID $old.Id 2>$null | Out-Null; Start-Sleep 2 }
# 后台启动
Start-Process -WindowStyle Hidden -FilePath $ServerPath -ArgumentList "--host 127.0.0.1 --port $Port"
# 等待就绪
$ready = $false
for ($i = 0; $i -lt 15; $i++) {
Start-Sleep -Seconds 1
try {
$r = Invoke-RestMethod "http://127.0.0.1:$Port/mcp" -Method Post `
-Body '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}' `
-ContentType "application/json" -ErrorAction Stop
if ($r.result.tools.Count -gt 0) {
Write-Output "OK:$($r.result.tools.Count)"
$ready = $true
break
}
} catch {}
}
if (-not $ready) {
Write-Output "ERR:timeout"
}
Related skills
How it compares
This is an IDA MCP procedural catalog, not a generic static-analysis linter or a cloud-only malware sandbox.
FAQ
Who is ida-reverse for?
Experienced developers and reverse engineers who want Claude or Cursor to call idapro_* tools with correct session and survey_binary sequencing.
When should I use ida-reverse?
During Ship security reviews of suspicious binaries, before release signing decisions, and in Operate when investigating unexpected production executables or drivers.
Is ida-reverse safe to install?
It drives powerful local disassembly and file access; review the Security Audits panel on this page and only analyze binaries you are authorized to handle.