gurudeepmallam-cmd/mcppt
GitHub: gurudeepmallam-cmd/mcppt
MCPTROTTER 是一款用于测试 MCP 服务器安全性的框架,支持 31 项自动化安全检查与交互式手动渗透测试。
Stars: 0 | Forks: 0
# MCPTROTTER — MCP 安全框架
→ connect → list → scan
Manual test: call | raw | fuzz
```
**逐条粘贴以下命令:**
```
target http://127.0.0.1:8888/mcp
token valid-token-abc123
connect
list
scan
findings
report demo.md
```
## 预期输出 — 演示服务器扫描
设置了 token 后运行 `scan` 会产生以下结果(60秒内):
```
Duration: ~45s Findings: 6 CRITICAL 6 HIGH 13 MEDIUM 3 LOW
```
| 严重程度 | 检查项 | 发现 |
|---|---|---|
| CRITICAL | `auth` | `get_notes` 上的认证绕过 — 无需 token |
| CRITICAL | `auth` | `get_notes` 上的认证绕过 — 接受无效 token |
| CRITICAL | `publish` | `publish_report` 可在没有确认机制的情况下调用 |
| CRITICAL | `stored` | 确认存储型注入:`save_note` → `get_notes` 未转义 |
| CRITICAL | `replay` | 确认在 WRITE tool `publish_report` 上的重放攻击 |
| CRITICAL | `poison_all` | 注入标记反映在 `result.content[0].text` 中 |
| HIGH | `injection` | Prompt 注入反映在 `publish_report.title` 中 |
| HIGH | `replay` | 确认在 `get_notes` 上的重放攻击 |
| HIGH | `session` | 短 session ID(3 个字符):`108` |
| HIGH | `session` | 非 UUID/非十六进制的 session 格式:`108` |
| HIGH | `session` | 近似顺序的 ID(diffs=[1,7,1,1])— 低熵 |
| MEDIUM | `enum` | 在没有 Authorization header 的情况下可访问 `tools/list` |
| MEDIUM | `schema` | 多个字段接受错误类型(string/int/null 绕过) |
| MEDIUM | `context_overflow` | 接受 10,000 字符的 payload 且未截断 |
| LOW | `rate` | 无速率限制 — 在 1.5 秒内完成 30/30 个请求 |
| LOW | `headers` | 缺失:X-Content-Type-Options, CSP, X-Frame-Options |
| LOW | `headers` | Server header 泄露:`Werkzeug/3.1.8 Python/3.13.5` |
## 所有命令
### 设置
```
target Set MCP server URL
token Set primary auth token
token2 Set second user token (IDOR / scope / tenant checks)
noverify Toggle SSL verification skip (needed for self-signed certs)
proxy Set Burp proxy: proxy http://127.0.0.1:8080
verbose Toggle raw HTTP request/response logging
status Show current session configuration
```
### 手动探索
```
connect Test connection + show server name, version, capabilities
list List all tools the server exposes (names, schemas, params)
inspect Show full JSON schema for a specific tool
call [json] Call any tool directly with your own arguments
call get_notes
call get_user {"id": 1}
call save_note {"text": "test injection payload"}
raw [params] Send any raw JSON-RPC method
raw tools/list
raw resources/list
raw sampling/createMessage {...}
resources [read ] List resources or read a specific URI
prompts [get ] List prompts or get a specific prompt
headers Show HTTP response headers from the last request
```
### 针对性测试
```
fuzz Fuzz a specific tool parameter
Built-in wordlists:
sqli SQL injection payloads
xss XSS and template injection
traversal Path traversal (../etc/passwd, encoded variants)
cmd OS command injection (; id, $(id), | whoami)
ssrf SSRF targets (169.254.169.254, localhost)
ssti Server-side template injection
inject Prompt injection payloads for LLM tools
Custom: fuzz read_file path /path/to/payloads.txt
Examples:
fuzz get_user id sqli
fuzz save_note text inject
fuzz read_file path traversal
```
### 自动扫描
```
scan Run all 31 checks
scan auth ssrf idor Run specific checks only
scan stored injection Mix and match any check names
```
### 发现结果
```
note [| detail] Manually log a finding
note HIGH manual_test Input reflected | seen in 500 response
findings Colour-coded findings table (scan + manual notes)
clear Clear findings and tool cache
report out.md Export Markdown report
report out.json Export JSON report
```
### AI 分析(可选)
```
ai claude sk-ant-... Configure Claude for analysis
ai openai sk-... Configure OpenAI GPT-4o
analyze Attack narrative + remediation priority from findings
```
## 单行命令(非交互式 / CI)
```
# 全量扫描,保存 Markdown 报告
mcppt scan --url https://target.com/mcp --token eyJ... --output report.md
# 使用 second token(启用 IDOR、scope、tenant 检查)
mcppt scan --url https://target.com/mcp --token t1 --token2 t2 --output report.md
# 通过 Burp proxy,跳过 SSL
mcppt scan --url https://target.com/mcp --token eyJ... --proxy http://127.0.0.1:8080 --no-verify
# 仅执行针对性检查
mcppt scan --url https://target.com/mcp --token eyJ... --checks auth,ssrf,stored,idor
```
## Burp Suite 集成 — 步骤详解
将每个 MCPTROTTER 请求通过 Burp 路由,以便手动检查、重放和模糊测试。
### 第 1 步 — 设置 Burp 监听器
Burp Suite → **Proxy → Proxy Settings**
确认监听器为 `127.0.0.1:8080`(这是默认设置)。无需更改。
### 第 2 步 — 通过代理运行
在 shell 中:
```
proxy http://127.0.0.1:8080
noverify
scan
```
或者作为单行命令运行:
```
mcppt scan --url https://target.com/mcp --token eyJ... --proxy http://127.0.0.1:8080 --no-verify
```
必须使用 `noverify` / `--no-verify`,因为 Burp 会使用自己的证书拦截 TLS。
### 第 3 步 — 在 HTTP History 中查看请求
Burp → **Proxy → HTTP History**
每个 MCP tool 调用都显示为 `POST /mcp` 请求。你会看到针对每项检查的 `initialize`、`tools/list`、`tools/call`。手动命令(`call`、`raw`、`fuzz`)也会显示在这里 — MCPTROTTER 发出的每个请求都会经过 Burp。
### 第 4 步 — 发送到 Repeater 进行手动测试
右键点击任何请求 → **Send to Repeater** (`Ctrl+R`)。
```
POST /mcp HTTP/1.1
Host: target.com
Authorization: Bearer eyJ...
Content-Type: application/json
{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"get_notes","arguments":{}}}
```
将 `"id": 2` 改为 `"id": 1` 来测试 IDOR。将 token 替换为另一个用户的。修改 `"name"` 以调用不同的 tool。
如果出现 session 错误,请先将 HTTP History 中的 `initialize` 请求复制到 Repeater 中,发送请求,然后将 `mcp-session-id` header 的值复制到你的目标请求中。
### 第 5 步 — 使用 Intruder 进行模糊测试
右键点击任何 Repeater 请求 → **Send to Intruder**。高亮选中参数值,点击 **Add §**,加载字典,运行攻击。
## 全部 31 项检查
| # | 检查项 | 严重程度 | 测试内容 |
|---|---|---|---|
| 1 | `enum` | MEDIUM | 未经认证即可访问 `tools/list` |
| 2 | `auth` | CRITICAL | 没有 token 或使用无效 token 也能成功调用 tool |
| 3 | `idor` | HIGH | 跨用户资源访问(需要 `token2`) |
| 4 | `injection` | HIGH | Prompt 注入 payload 反映在响应中 |
| 5 | `schema` | MEDIUM | 类型混淆、null 绕过、超大输入 |
| 6 | `ssrf` | CRITICAL | tool 参数中接受了云元数据 URL |
| 7 | `publish` | CRITICAL | 没有确认机制即可调用破坏性 tool |
| 8 | `rate` | LOW | tool 调用没有速率限制 |
| 9 | `stored` | CRITICAL | 写入注入 payload,回读时未转义 |
| 10 | `scope` | HIGH | 只读 token 可访问写入 tools |
| 11 | `replay` | CRITICAL | 相同的请求被接受两次 — 没有 nonce |
| 12 | `context_overflow` | HIGH | 接受 5万–10万字符的 payload 且未截断 |
| 13 | `poison_all` | CRITICAL | 注入 payload 出现在每个响应字段中 |
| 14 | `tenant` | CRITICAL | token2 读取了 token1 的数据 — 隔离失效 |
| 15 | `session` | HIGH | 脆弱或顺序的 session ID |
| 16 | `rug_pull` | CRITICAL | tool 描述在多次 `tools/list` 调用之间发生变化 |
| 17 | `headers` | HIGH | CORS 通配符、缺少 CSP/HSTS、Server header 泄露 |
| 18 | `error_disclosure` | MEDIUM | 错误信息中包含堆栈跟踪、文件路径、数据库凭证 |
| 19 | `tool_poisoning` | CRITICAL | tool 描述中包含隐藏的 Unicode (U+200B/202E) |
| 20 | `resources` | HIGH | 未经认证即可访问 `resources/list` 或 `prompts/list` |
| 21 | `cmd_injection` | CRITICAL | 参数中包含 shell 元字符(`;id`, `$(id)`) |
| 22 | `path_traversal` | CRITICAL | 文件/路径参数中包含 `../../../etc/passwd` |
| 23 | `jwt_audit` | CRITICAL | 接受 `alg=none`、没有 `exp` 或已过期的 token |
| 24 | `oauth_discovery` | LOW | 暴露了 `/.well-known/oauth-authorization-server` |
| 25 | `secret_scan` | CRITICAL | tool 响应中包含 AWS 密钥、GitHub PAT、数据库连接字符串 |
| 26 | `tool_shadowing` | CRITICAL | 重复的 tool 名称、同形异义词、名称/描述不匹配 |
| 27 | `sampling` | CRITICAL | 未经认证即可访问 `sampling/createMessage` |
| 28 | `schema_leak` | LOW | tool schema 中包含敏感字段名或枚举值 |
| 29 | `http_method_confusion` | MEDIUM | MCP endpoint 接受 GET/DELETE/PUT/PATCH 方法 |
| 30 | `protocol_downgrade` | MEDIUM | 接受旧的协议版本,泄露服务器版本 |
| 31 | `batch_injection` | MEDIUM | JSON-RPC 批量请求,异常方法名注入 |
## MCPTROTTER 与手动测试对比 — 节省的时间
| 任务 | 在 Burp 中手动操作 | MCPTROTTER |
|---|---|---|
| 对每个 tool 测试认证绕过 | 10–30 分钟 | `scan auth` — 5秒 |
| 测试存储型注入(写入 + 读取) | 20 分钟 | `scan stored` — 3秒 |
| 检查所有响应字段是否存在注入 | 30+ 分钟 | `scan poison_all` — 5秒 |
| 验证 session ID 熵 | 10 分钟 | `scan session` — 2秒 |
| 检查每个 tool 的重放攻击 | 20 分钟 | `scan replay` — 5秒 |
| 完整的 31 项检查评估 | 3–6 小时 | `scan` — 60秒以内 |
| 测试前检查 tool schema | 5 分钟看文档 | `inspect ` — 即时 |
| 使用自定义 payload 调用 tool | 在 Burp Repeater 中设置 | `call {"param": "payload"}` |
| 用 50 个 payload 模糊测试参数 | 设置并运行 Intruder | `fuzz sqli` — 30秒 |
| 直接测试任何 JSON-RPC 方法 | 在 Repeater 中构建请求 | `raw ` |
MCPTROTTER 在 60 秒内为你提供基线,并将所有请求放入 Burp HTTP History 中。你可以把时间花在重要的事情上:在 Repeater 中手动验证发现,并将它们串联成一条经过演示的攻击路径。
## Bugtrotter 的一部分
MCPTROTTER 是从 **Bugtrotter** 中提取的公开自动扫描器 — Bugtrotter 是一个为现代攻击面构建的完整的红队和应用程序安全平台。
### Bugtrotter 在 MCPTROTTER 基础上增加的功能
| 功能 | MCPTROTTER | Bugtrotter |
|---|---|---|
| 自动化 MCP 扫描(31 项检查) | ✓ | ✓ |
| 手动 tool 探索框架 | ✓ | ✓ |
| 跨 tool 的链式利用路径 | — | ✓ 完整攻击链 |
| MCP 服务器代码的 SAST 审查 | — | ✓ |
| Burp Suite MCP — 滥用业务逻辑 | — | ✓ AI 驱动 |
| AI agent 红队对抗 | — | ✓ 多 agent pipeline |
| Active Directory 攻击链 | — | ✓ 从外部渗透到 DA |
| Web / API / 网络渗透测试 | — | ✓ 完整的实战测试 |
| 最终的渗透测试报告 | 导出 Markdown | 专业测试级别的报告 |
**Bugtrotter 中的 MCPTROTTER:**
在 Bugtrotter 中,MCPTROTTER 作为一个注册的 MCP 服务器运行。Claude Code 或 Claude Desktop 可以直接调用它:
```
"Scan https://target.com/mcp for security issues and prioritise findings"
→ Claude calls scan_target tool
→ MCPTROTTER runs all 31 checks
→ Findings returned as structured JSON to Claude
→ Claude reasons over them, chains the critical ones, drafts the report section
```
无需复制粘贴。无需切换上下文。扫描输出直接输入到 AI 驱动的测试工作流中 — SSRF 发现变成一次 SSRF 利用尝试,认证绕过变成一条凭证窃取链,存储型注入变成一次经过演示的 prompt 劫持。
## 将 MCPTROTTER 本身作为 MCP 服务器使用
MCPTROTTER 可以将其扫描能力作为 tools 暴露出来,供任何 MCP 客户端(如 Claude Desktop、MCP Inspector其他 agent)调用。
```
mcppt serve-mcp --port 8899
```
添加到 Claude Desktop 配置 (`claude_desktop_config.json`) 中:
```
{
"mcpServers": {
"mcptrotter": {
"command": "mcppt",
"args": ["serve-mcp", "--port", "8899"]
}
}
}
```
暴露的 tools:
- `scan_target` — 完整扫描,返回 JSON 格式的发现
- `list_tools` — 枚举任何 MCP 服务器上的 tools
- `call_tool` — 调用任何 MCP 服务器上的任何 tool
- `get_checks` — 列出全部 31 项检查及其描述
## 作者
**Gurudeep Mallam** — 安全研究员
- GitHub: [github.com/gurudeepmallam-cmd](https://github.com/gurudeepmallam-cmd)
- LinkedIn: [Mallam Gurudeep](https://in.linkedin.com/in/mallam-gurudeep-7734941aa)
- Email: gurudeep.mallam@gmail.com
## 许可证
MIT
作者:Gurudeep Mallam · LinkedIn
## 简介 MCPTROTTER 是一个用于测试 MCP (Model Context Protocol) 服务器的**安全框架**。它有两种工作方式: **手动探索** — 连接到任何 MCP server 并像攻击者一样与它交互。直接调用 tools,检查 schema,模糊测试参数,读取 resources,发送原始 JSON-RPC 方法。无需扫描。你控制每一个请求。 **自动扫描** — 在 60 秒内运行 31 项安全检查。包括认证绕过、存储型注入、重放攻击、session 熵、租户隔离、tool 投毒、命令注入等。 两种模式都通过 Burp Suite 路由,因此你可以在 HTTP History 中查看每个请求,并在 Repeater 中进行后续操作。 ## 安装说明 **从 PyPI 安装(推荐):** ``` pip install mcppt ``` **从源码安装:** ``` git clone https://github.com/gurudeepmallam-cmd/mcppt cd mcppt/mcppt_tool pip install -e . ``` 要求 Python 3.10+。 ## 快速入门 — 立即尝试(无需目标) MCPTROTTER 内置了一个故意设计为易受攻击的演示服务器,它会触发所有的检查。 **终端 1 — 启动演示服务器:** ``` cd mcppt_tool python test_server.py ``` ``` ======================================================= Vulnerable MCP Test Server URL: http://127.0.0.1:8888/mcp Token: valid-token-abc123 ======================================================= ``` **终端 2 — 打开交互式 shell:** ``` mcppt ``` ``` __ __ ___ ___ _____ ____ ___ _____ _____ ___ ___ | \/ | / __|| _ \|_ _| _ \ / _ \_ _|_ _| __| _ \ | |\/| || (__| _/ | | | / | (_) || | | | | _|| / |_| |_| \___||_| |_| |_|_\ \___/ |_| |_| |___|_|_\ MCP Pentest Framework v3.0 -- 31 checks + manual exploration by Gurudeep Mallam Quick start: target标签:CISA项目, MCP协议, Python, Web安全, Web报告查看器, 安全测试, 攻击性安全, 无后门, 蓝队分析, 逆向工具