阿拉贡
用于Windows安全研究的直接内核调试器MCP服务器。通过kdnet连接到Windows VM内核,并在 模型上下文协议.
这个过程 是 调试器。它正在孕育 kd.exe 作为kdnet传输的子进程,然后通过 DebugConnect() 用于完全访问DbgEng COM。不需要Winchester GUI。
MCP Client ──stdio/http──► Aragorn ──DebugConnect(TCP)──► kd.exe ──kdnet──► VM kernel
快速开始
# 1. Install dependencies
pip install -r requirements.txt
# 2. Copy DbgEng DLLs from WinDbg Preview into dbgeng_bin/
# (dbgeng.dll, dbghelp.dll, dbgmodel.dll, dbgcore.dll, symsrv.dll, srcsrv.dll)
# 3. Configure
cp .env.example .env
# Edit .env: set KD_CONNECTION, KD_EXE_PATH, etc.
# 4. Run (stdio mode — for MCP clients like Claude Code)
python server.py
# Or HTTP mode (for remote/shared access)
python server.py --http
.mcp.json集成
{
"aragorn": {
"type": "stdio",
"command": "python",
"args": ["path/to/Aragorn/server.py"]
}
}
配置
所有设置都是通过环境变量(或 .env 文件):
| 变量 | 默认值 | 描述 |
|---|
KD_CONNECTION | net:port=55555,key=...,target=... | kdnet连接字符串 |
KD_EXE_PATH | Winchester预览版的kd.exe | kd.exe的路径 |
KD_SERVER_PORT | 14500 | kd.exe调试服务器的本地TCP端口 |
DBGENG_PATH | ./dbgeng_bin/dbgeng.dll | DbgEng DLL的路径 |
SYMBOL_PATH | Microsoft符号服务器 | 符号搜索路径 |
ARAGORN_HOST | 127.0.0.1 | HTTP模式绑定地址 |
ARAGORN_PORT | 14401 | HTTP模式端口 |
VM_AGENT_URL | http://YOUR_VM_IP:8080 | VM代理URL(用于工作流工具) |
VM_AGENT_API_KEY | *(空)* | 虚拟机代理API密钥 |
DbgEng二进制文件
这 dbgeng_bin/ 目录为gitignored。从WingePreview安装中复制以下DLL:
C:\Program Files\WindowsApps\Microsoft.WinDbg_*\amd64\
├── dbgeng.dll
├── dbghelp.dll
├── dbgmodel.dll
├── dbgcore.dll
├── symsrv.dll
└── srcsrv.dll
VM代理
这 vm_agent/ 目录包含一个运行的轻量级Flask服务器 在目标VM内部它通过HTTP公开进程执行、文件I/O和驱动程序服务管理。Aragorn的工作流工具(breakpoint_and_run, vm_exec等等)使用它来协调内核调试与VM端操作。
# On the VM:
cd vm_agent
pip install -r requirements.txt
cp .env.example .env
# Edit .env: set VM_AGENT_API_KEY
python server.py
VM代理是可选的——所有纯调试器工具都可以在没有它的情况下工作。您只需要它来协调工作流工具。
工具
会话和连接(9)
| 工具 | 说明 |
|---|
connect | 通过kd.exe连接到内核调试器 |
disconnect | 彻底断开连接 |
status | 获取连接状态和配置 |
target_info | 获取调试目标信息(类、处理器、页面大小) |
ensure_ready | 闯入、验证上下文、重新加载符号(重试5次) |
health_check | 轻便的探头,不会闯入目标 |
reconnect_debugger | 强制完全重新连接 |
test_kd_connection | 诊断kd.exe连接测试 |
get_debugger_state | 跨代理协调的完整跟踪状态 |
多会话(6)
| 工具 | 说明 |
|---|
session_create | 为VM创建隔离调试器会话 |
session_connect | 连接会话的调试器 |
session_disconnect | 断开连接而不破坏 |
session_destroy | 销毁和清理会话 |
session_list | 列出所有会话及其状态 |
session_set_active | 为刀具布线设置活动会话 |
命令执行(3)
| 工具 | 说明 |
|---|
execute | 执行原始调试器命令(例如。, lm, !process 0 0) |
execute_batch | 按顺序执行多个命令 |
evaluate | 计算表达式,返回数值 |
记忆(7)
| 工具 | 说明 |
|---|
read_memory | 读取虚拟内存(十六进制/qwords/dwords/ascii) |
write_memory | 将字节写入虚拟内存 |
search_memory | 搜索字节模式 |
read_physical | 读取物理内存 |
write_physical | 写入物理内存 |
virtual_to_physical | 将虚拟地址转换为物理地址 |
read_msr | 读取特定型号寄存器 |
登记簿(2)
| 工具 | 说明 |
|---|
read_registers | 读取所有通用寄存器 |
write_register | 写入寄存器值 |
堆栈(1)
| 工具 | 说明 |
|---|
get_stack | 使用符号获取结构化堆栈跟踪 |
断点(4)
| 工具 | 说明 |
|---|
set_breakpoint | 设置代码或数据/硬件断点 |
remove_breakpoint | 按ID删除断点 |
list_breakpoints | 列出所有断点及其状态 |
set_exception_filter | 配置异常处理(中断/忽略/输出) |
执行控制(4)
| 工具 | 说明 |
|---|
continue_exec | 恢复执行(稳健,重试以耗尽kdnet中断) |
step_into | 一步到位通话 |
step_over | 单步通话 |
break_in | 中断目标执行 |
检查(4)
| 工具 | 说明 |
|---|
list_modules | 列出已加载的模块,包括基/大小/名称 |
list_threads | 列出带有引擎/系统ID的线程 |
list_processes | 列出带有发动机/系统ID的进程 |
switch_process | 切换到进程上下文(.process/i) |
符号(4)
| 工具 | 说明 |
|---|
resolve_symbol | 双向符号/地址分辨率 |
get_field_offset | 获取结构体字段字节偏移量 |
get_type_size | 获取类型大小(以字节为单位) |
disassemble | 地址处的拆卸说明 |
活动(3)
| 工具 | 说明 |
|---|
wait_for_event | 阻塞直到下一个调试事件 |
poll_events | 返回排队的事件而不阻塞 |
clear_events | 丢弃所有排队的事件 |
内核对象(8)
| 工具 | 说明 |
|---|
read_struct | 读取类型结构(dt等效) |
get_pte | 获取页表条目信息 |
pool_info | 获取池分配元数据 |
get_driver_object | 显示驱动程序对象+调度表 |
get_device_objects | 显示设备对象信息 |
get_object_info | 显示对象目录中的内核对象 |
dump_ssdt | 转储系统服务描述符表 |
get_idt | 转储中断描述符表 |
工作流程(8)
| 工具 | 说明 |
|---|
breakpoint_and_run | 原子:设置BP、恢复、运行VM命令、等待命中、捕获状态 |
run_and_trace | 在多个地址设置日志BP,运行命令,捕获跟踪 |
inspect_at_breakpoint | 批量断点后检查命令 |
vm_exec | 在VM上执行命令 |
vm_read_file | 从VM读取文件 |
vm_write_file | 将文件写入VM |
vm_upload_file | 将文件从主机上传到VM |
vm_status | 检查VM可达性 |
建筑
Aragorn/
├── server.py # FastMCP entry point, registers all tool modules
├── config.py # Environment variable configuration
├── debugger.py # High-level Debugger class (lifecycle, commands, reconnect)
├── dbgeng.py # Pure ctypes COM interface definitions (6 interfaces)
├── callbacks.py # IDebugOutputCallbacks + IDebugEventCallbacks
├── sessions.py # Multi-session registry (parallel VM debugging)
├── vm_client.py # Async HTTP client to VM agent
├── dbgeng_bin/ # DbgEng DLLs (gitignored, ~15MB)
├── vm_agent/ # REST server for target VM (Flask + psutil)
│ ├── server.py # VM agent HTTP server
│ ├── requirements.txt
│ └── .env.example
└── tools/ # MCP tool modules (one per domain)
├── core.py # execute, execute_batch, evaluate
├── session.py # connect, disconnect, status, ensure_ready
├── multi_session.py # session_create/connect/destroy/list
├── memory.py # read/write virtual + physical memory, MSR
├── registers.py # read/write registers
├── stack.py # get_stack
├── breakpoints.py # set/remove/list breakpoints, exception filters
├── execution.py # continue, step_into, step_over, break_in
├── inspection.py # list modules/threads/processes, switch context
├── symbols.py # resolve symbols, field offsets, disassemble
├── events.py # wait/poll/clear debug events
├── kernel.py # read_struct, PTE, pool, driver/device objects, SSDT, IDT
└── workflow.py # breakpoint_and_run, run_and_trace, VM proxy tools
COM接口堆栈
Aragorn通过ctypes封装了六个DbgEng COM接口(不需要C++扩展):
- IDebuClient --会话生命周期,回调注册
- IDebugControl --命令执行、断点、执行状态
- IDebugDataSpaces2 --虚拟/物理内存、地址转换
- IDebugRegisters --寄存器读/写
- IDebugSymbols 2 --符号解析、类型信息、拆卸
- IDebugSystemObjects --进程/线程/模块枚举
所有阻塞COM操作都封装在 asyncio.to_thread() 用于MCP stdio兼容性。每个会话都有一个专用的COM线程(DbgEng具有线程关联性)。
许可证
WTFPL