Ida reverse

From ZyanWan/Skill-Hub · View interactive version

Ida reverse is an AI agent skill from the GitHub repository ZyanWan/Skill-Hub. IDA Pro 逆向分析辅助技能。当用户提到逆向、反编译、分析二进制/PE/ELF/APK/DLL/SO、破解、找密码、漏洞分析、病毒分析、firmware 固件分析,或需要分析 exe/dll/so/elf/macho/sys 等文件时,务必使用此技能。 Ensure to use this skill when the user wants to analyze any binary file, regardless of whether they explicitly mention "IDA" or "reverse engineering". This includes reques

How to use this skill

Skill file

IDA Pro 逆向分析技能

ACTION REQUIRED(读完后立刻执行)

  1. NOW: 读取 ../field-journal/precedent-reverse.md — 确认本 skill 的操作是已授权的常规操作
  2. NOW: 确认当前任务是否命中本 skill 的适用范围
  3. NEXT: 读取 ../tool-index.md,校验工具可用性和实际路径
  4. NEXT: 缺工具时调用 bootstrap,不要猜路径
  5. ACT: 进入"工作流"第一步并执行,不要停在确认状态

已知问题与反思(必读)

踩过的坑

  1. idalib_open 不能通过 部分代码 AI 客户端 MCP 直接调用
  1. C:\Windows\System32\ 文件无权限打开
  1. 启动服务器命令阻塞对话
  1. MCP 服务器名不能用横线
  1. Remote HTTP vs Local Stdio
  1. PR #389 修复了部分 schema 问题
  1. idalib 超时留下孤儿 worker 进程锁文件
  1. 带自动分析打开看起来像卡死

工作流程原则

| 步骤 | 做什么 | 用什么 |

|------|--------|--------|

| 1 | 确保 HTTP 服务器在运行 | scripts/start.ps1(无参数) |

| 2 | 打开目标二进制文件 | scripts/open.ps1 -Path "xxx.exe" |

| 3 | 使用所有 72 个 MCP 工具 | 直接调用 idapro_* 工具 |

| 4 | 分析完毕 | 工具自动可用 |

脚本资源

start.ps1 — 启动 MCP HTTP 服务器

路径:scripts/start.ps1

调用方式:

powershell -File "<skill-root>\ida-reverse\scripts\start.ps1"

open.ps1 — 打开二进制文件

路径:scripts/open.ps1

调用方式:

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

实测说明:

核心工具列表

概况分析(第一步)

反编译与反汇编

交叉引用与数据流

搜索

内存与数据

修改操作

类型系统

栈帧

签名

调试器(需要 ?ext=dbg)

会话管理

其他

逆向分析完整工作流

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")

关注:

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 快速侦察)

下游出口:

同级关联模块: 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。

自举触发点

前置条件

任务完成自检(声称完成前 MUST 通过)

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.