D
Dnspy MCP Plugin
by @susuya233
这是一个dnSpy插件,方便我的小牛马挖洞。
Created 2/3/2026
Updated about 12 hours ago
README
Repository documentation and setup instructions
dnSpy MCP Plugin
一个为 dnSpy 提供 MCP (Model Context Protocol) 接口的插件,支持 AI 辅助代码分析和安全审计。
✨ 功能特性
🔍 代码分析
- 反编译查看 - 获取当前查看的代码内容
- 类型列表 - 列出所有加载的类型
- 交叉引用 - 查找方法的调用者和被调用者
- 类型层次 - 查看类的继承关系
- 接口实现 - 查找接口的所有实现类
🛡️ 安全扫描
- 漏洞扫描 - 自动识别危险函数调用
- SQL 注入 (ExecuteNonQuery, SqlCommand...)
- 命令执行 (Process.Start, cmd.exe...)
- 反序列化 (BinaryFormatter, XmlSerializer...)
- 文件操作/路径穿越
- XSS/SSRF/XXE
- 弱加密算法
- 调用链追溯 - 从危险函数向上追溯调用路径
- 入口点识别 - 自动标记 Controller、Handler 等用户可控入口
- 硬编码密钥扫描 - 发现代码中的敏感信息
📊 辅助工具
- 资源列表 - 查看嵌入资源
- 字符串提取 - 列出所有字符串常量
- 文件信息 - 获取程序集元数据和哈希
📦 安装
- 下载最新的
AICodeAnnotator.x.dll - 将 DLL 复制到 dnSpy 的
bin目录 - 重启 dnSpy
🚀 使用方法
Web 界面
启动 dnSpy 后,访问 http://127.0.0.1:13338/
/- 状态页面/dangerous.html- 漏洞扫描页面/types.html- 类型浏览器
MCP 接口
发送 JSON-RPC 请求到 http://127.0.0.1:13338/mcp
{
"jsonrpc": "2.0",
"method": "scan_vulnerabilities",
"params": {},
"id": 1
}
可用工具列表
| 工具名 | 描述 |
|--------|------|
| get_metadata | 获取程序集元数据 |
| list_types | 列出所有类型 |
| get_current_code | 获取当前查看的代码 |
| xrefs_to | 查找谁调用了指定方法 |
| xrefs_from | 查找指定方法调用了谁 |
| scan_vulnerabilities | 扫描安全漏洞 |
| trace_call_chain | 追溯调用链 |
| analyze_taint | 分析参数可控性 |
| get_type_hierarchy | 获取类型继承关系 |
| find_implementations | 查找接口实现 |
| list_resources | 列出嵌入资源 |
| list_strings | 列出字符串常量 |
| find_hardcoded_secrets | 扫描硬编码密钥 |
🤖 MCP 客户端配置
如需在 AI 工具中使用本插件,需配置包装脚本:
- 创建包装脚本
dnspy_mcp_wrapper.py:
import sys, json, urllib.request
URL = "http://127.0.0.1:13338/mcp"
for line in sys.stdin:
if not line.strip(): continue
req = json.loads(line)
data = json.dumps(req).encode()
r = urllib.request.Request(URL, data, {'Content-Type': 'application/json'})
res = urllib.request.urlopen(r, timeout=30)
print(json.dumps(json.loads(res.read())), flush=True)
- 配置
mcp_config.json:
{
"dnspy": {
"command": "python",
"args": ["path/to/dnspy_mcp_wrapper.py"],
"description": "dnSpy MCP - .NET逆向分析和漏洞扫描(需先启动dnSpy)"
}
}
⚠️ 注意:使用前必须先启动 dnSpy 并加载要分析的程序集
🔧 开发
编译
dotnet build AICodeAnnotator.csproj
项目结构
dnSpy_Plugin_Demo/
├── MCP/
│ ├── McpHandler.cs # MCP 请求处理
│ ├── McpServer.cs # HTTP 服务器
│ ├── McpCommands.cs # dnSpy 菜单命令
│ └── WebPages.cs # Web 界面
├── Plugin.cs # 插件入口
└── AICodeAnnotator.csproj
📄 License
MIT License
🙏 致谢
Quick Setup
Installation guide for this server
Installation Command (package not published)
git clone https://github.com/susuya233/dnSpy-MCP-Plugin
Manual Installation: Please check the README for detailed setup instructions and any additional dependencies required.
Cursor configuration (mcp.json)
{
"mcpServers": {
"susuya233-dnspy-mcp-plugin": {
"command": "git",
"args": [
"clone",
"https://github.com/susuya233/dnSpy-MCP-Plugin"
]
}
}
}
Author Servers
Other servers by susuya233