调试增强工具

基于x64dbg的MCP服务器,采用领域驱动设计(DDD)架构,支持LLM辅助调试和逆向工程。

  • by JordanRO2
  • Python
  • 本地部署
  • 1 星标
  • 更新于
在 GitHub 查看 JordanRO2/MCP-x64dbg

使用说明

MCP-x64dbg

x64dbg MCP服务器,采用域驱动设计(DDD)架构,用于LLM辅助调试和逆向工程。

基于 wasdubya/x64dbgmcp,采用DDD架构进行重构,以获得更好的可维护性、可测试性和可扩展性。

建筑

该项目遵循领域驱动设计原则,采用分层架构:

src/x64dbg_mcp/
  domain/           # Business logic: entities, value objects
  application/      # Services, DTOs
  infrastructure/   # HTTP client, debugger adapter
  interface/        # MCP tools (6 modules)
  zeromcp/          # Custom MCP protocol implementation

27个MCP工具 跨越6个接口模块:

  • 调试控制:i调试、运行、暂停、停止、介入、跨步、退出
  • 断点:设置断点、删除断点
  • 寄存器:RegisterGet,RegisterSet,FlagGet,FlagSet
  • 内存:内存读取、内存写入、内存检查、模式查找
  • 拆解:拆解、GetCurrent指令、组装、组装到内存
  • 堆栈:StackPop、StackPush、StackPeek
  • 模块:GetModuleList、ParseExpression、ExecCommand

先决条件

安装

1.安装插件

将插件文件复制到x64dbg安装中:

build/MCPx64dbg.dp32 -> x64dbg/release/x32/plugins/
build/MCPx64dbg.dp64 -> x64dbg/release/x64/plugins/

或者从源代码构建:

mkdir build && cd build
cmake .. -G "Visual Studio 17 2022"
cmake --build . --config Release --target all_plugins

2.安装Python包

pip install https://github.com/JordanRO2/MCP-x64dbg/archive/refs/heads/main.zip

或用于开发:

git clone https://github.com/JordanRO2/MCP-x64dbg.git
cd MCP-x64dbg
pip install -e .

3.配置MCP客户端

克劳德代码(~/.claude.json):

{
  "mcpServers": {
    "x64dbg-mcp": {
      "type": "http",
      "url": "http://127.0.0.1:13339/mcp"
    }
  }
}

适用于克劳德桌面(claude_desktop_config.json):

{
  "mcpServers": {
    "x64dbg-mcp": {
      "command": "python",
      "args": ["-m", "x64dbg_mcp", "--stdio"]
    }
  }
}

用法

自动启动(推荐)

  1. 创建 start_mcp.bat 在项目根目录中:
@echo off
cd /d "C:\path\to\MCP-x64dbg\src"
set PYTHONPATH=C:\path\to\MCP-x64dbg\src
python -m x64dbg_mcp --host 0.0.0.0
  1. 启动x64dbg-插件会自动启动:
    • 端口8888上的HTTP服务器(x64dbg API)
    • 端口13339上的MCP服务器(AI接口)

手动启动

# Start x64dbg first, then:
cd src
python -m x64dbg_mcp --host 0.0.0.0 --port 13339

插件命令

在x64dbg命令栏中:

  • httpserver -打开/关闭HTTP服务器
  • httpport <port> -更改HTTP服务器端口
  • mcpserver -打开/关闭MCP服务器

用法示例

设置断点并分析:

"Set a breakpoint at the main function and step through the first few instructions"

内存分析:

"Read 100 bytes from address 0x401000 and show me what's there"

登记检查:

"What's the current value of RAX and RIP registers?"

模式搜索:

"Find the pattern '48 8B 05' in the current module"

WSL2配置

对于WSL2访问Windows托管的x64dbg:

  1. 查找Windows主机IP:
cat /etc/resolv.conf | grep nameserver | awk '{print $2}'
  1. 添加防火墙规则(PowerShell作为管理员):
New-NetFirewallRule -DisplayName "MCP x64dbg" -Direction Inbound -LocalPort 13339 -Protocol TCP -Action Allow
  1. 配置Claude(~/.claude.json):
{
  "mcpServers": {
    "x64dbg-mcp": {
      "type": "http",
      "url": "http://<WINDOWS_HOST_IP>:13339/mcp"
    }
  }
}

项目结构

MCP-x64dbg/
  src/
    x64dbg_mcp/           # Python MCP server
      domain/             # Entities: Register, Memory, Breakpoint, Module, Instruction
      application/        # DebuggerService
      infrastructure/     # HTTP client, DebuggerAdapter
      interface/tools/    # MCP tool implementations
      zeromcp/            # MCP protocol
    MCPx64dbg.cpp         # C++ plugin source
  deps/
    x64dbg_sdk/           # x64dbg plugin SDK
  build/                  # Compiled plugins (.dp32, .dp64)
  start_mcp.bat           # Auto-start batch file

学分

许可证

MIT许可证-请参阅 许可证 了解详情。