无IDA MCP
一个原生C++插件,将AI引入IDA逆向工程工作流程。
它通过以下方式展示了IDA的分析能力 模型上下文协议(MCP) --一个让LLM与工具通信的标准接口。该插件在IDA的进程中运行一个HTTP服务器,因此您的AI助手可以读取反汇编、反编译函数、遵循交叉引用、重命名变量、修补字节等。
用法
- 在IDA中打开二进制文件
- 编辑>插件>MCP (或 Ctrl+Alt+M)启动服务器
- 将您的MCP客户端连接到
http://127.0.0.1:13337/mcp - 按 Ctrl+Alt+M 再次停止
连接MCP客户端
# Claude Code
claude mcp add --transport http ida-mcp http://127.0.0.1:13337/mcp对于其他客户端(Claude Desktop、Cursor、Windsurf等),请在MCP配置中添加:
{
"mcpServers": {
"ida-mcp": {
"url": "http://127.0.0.1:13337/mcp"
}
}
}多个IDA实例
多个IDA会话可以同时运行MCP——如果已在使用中,端口会自动递增(最多10次尝试)。每个实例将其端口、PID和IDB路径写入 ~/.ida-mcp/instances/ .json。崩溃会话中的过期文件会自动清理。
环境变量
| 变量 | 描述 | 默认值 |
|---|---|---|
IDA_MCP_PORT | HTTP服务器的基本端口 | 13337 |
IDA_MCP_TOOL_TIMEOUT_SEC | 工具执行超时(秒) | -- |
IDA_MCP_URL | 下载大型输出的基本URL | `http://127.0.0.1: |
| ` |
需求
- CMake 3.16+, C++17 编译器(GCC、Clang或MSVC)
- IDA SDK (用于构建插件;测试不需要)
- IDA Pro/无IDA 9.0+
建筑
快速开始
# Linux / macOS
./build.sh
# Windows (Developer Command Prompt)
build.bat这两个脚本都构建测试、运行测试、构建插件并安装。Set IDASDK 覆盖SDK路径(默认: idasdk/src 子模块)。
手动构建
# Tests only (no IDA SDK required)
cmake -S . -B build/tests -DBUILD_PLUGIN=OFF -DBUILD_TESTS=ON
cmake --build build/tests --config Release
# Plugin
cmake -S . -B build/plugin -DBUILD_PLUGIN=ON -DBUILD_TESTS=OFF -DIDASDK=/path/to/idasdk
cmake --build build/plugin --config Release复制已构建的插件(ida_mcp.so / .dll / .dylib)到您的IDA plugins/ 目录。
预构建的二进制文件可在 发布页面.
建筑
IDA Plugin (plugin.cpp)
└─ McpPlugmod
├─ McpProtocol (mcp.h) ← Tool/resource registry, MCP methods
│ └─ JsonRpcRegistry ← JSON-RPC 2.0 dispatch
└─ McpHttpServer (server.h) ← HTTP routes, CORS, SSE所有IDA SDK调用都通过以下方式封送到IDA的主线程 execute_sync(MFF_WRITE) 具有超时和取消支持。
运输: 流式HTTP(POST /mcp)苏格兰和南方能源公司(GET /sse).
工具和资源
37工具 分为7组。每个工具都通过以下方式在IDA的主线程上运行 execute_sync 为了螺纹安全。
| 组 | 工具 |
|---|---|
| 核心 | int_convert, lookup_funcs, list_funcs, list_globals, imports, find_regex |
| 分析 | disasm, xrefs_to, xrefs_to_field, callees, callgraph, basic_blocks, find, find_bytes, export_funcs |
| 记忆 | get_bytes, get_string, get_int, get_global_value, patch, put_int |
| 修改 | set_comments, rename, patch_asm, define_func, define_code, undefine |
| 类型 | declare_type, read_struct, search_structs, set_type |
| 堆栈 | stack_frame, declare_stack, delete_stack |
| 反编译器 | decompile, hexrays_diag, debug_mode |
注: 这decompile该工具适用于IDA Pro和IDA Free。它使用基于GUI的反编译(触发F5并读取伪代码小部件)——不需要Hex Rays SDK初始化。这hexrays_diag工具报告SDK状态仅用于诊断;init_hexrays_plugin: false预计在IDA Free上运行,不会影响反编译。
11 MCP资源 对于IDA状态的读取访问: ida://idb/metadata, ida://idb/segments, ida://idb/entrypoints, ida://cursor, ida://selection, ida://types, ida://structs, ida://struct/{name}, ida://import/{name}, ida://export/{name}, ida://xrefs/from/{addr}.
依赖项
许可证
看 许可证 文件。
