文艺复兴时期的假面舞会。坐上智能体的座位。
坐上智能体的座位。
这款 CLI 像模型一样说 MCP 与 OpenAI 兼容协议,然后像 linpeas 那样输出报告。报告既有发现,也有修复建议。不含利用载荷。不解密 CoT。
| 是什么 | 对智能体基础设施的实时侦察:MCP 配置、监听端口、会话日志、加密思维链回显、未认证 API、目录投毒、技能树。 |
| 面向谁 | Hermes、Grok、Claude、Cursor、VS Code、Codex 以及本地模型栈的运维者——他们需要看到智能体所能看到的东西。 |
| 不是什么 | 不是越狱提示生成器。不是 arXiv:2608.09867 的弱模型解码器。不是运行时网关。 |
| 状态 | Beta。公开门槛是离线 cargo test。实时 --lab 只用于你拥有的主机。 |
| 许可证 | MIT |
静态 MCP 扫描器(Invariant mcp-scan、mcp-security-scan)会对模式和配置做 lint。健康检查器只会 ping initialize。缺口在于座位:
initialize,你就是这个智能体。:11434、:8000)常常无 bearer 令牌地绑定 0.0.0.0。复用而非重写轮子:现成的目录检测器 + pin/check、netstat、仅 GET 的 ureq、以 OWASP MCP Top 10 作为发现分类体系。我们没有克隆 mcp-scan 或 mcp-security-scan。
git clone https://gitlab.com/WattoCyber/masq.git
cd masq
cargo install --path .
# binary: masq
cargo test
# expect: exit 0
World 套件(用二进制跑固定样本、本地 mock、本机侦察):
python scripts/world_suite.py
# field = ~/.grok/sessions lab = allowlisted hosts bench = frozen-corpus wall
python scripts/world_suite.py --lanes all
从桌面端部署到 Kali 风格的远程主机:
MASQ_REMOTE_HOST=user@host bash scripts/deploy_kali.sh
# on the box:
~/.local/bin/masq --plain
MASQ_LAB_HOSTS=... ~/.local/bin/masq --lab --plain
masq # live stream + posture report (includes skills)
masq --lab # same, plus allowlisted homelab hosts
masq tui # boxed TUI, stays until Ctrl+C
masq --plain # report only, no live stream
masq --json # machine report
masq recon # same dump, recon only
masq sniff ~/.grok/sessions # CoT / secrets in session logs
masq sniff --timeline PATH # file-order blob/secret/reason lines (no decrypt)
masq api # GET /v1/models on local (and --lab) ports
masq sit --url http://127.0.0.1:4443/mcp
masq chameleon --url http://127.0.0.1:4443/mcp -o /tmp/chameleon
masq chameleon --url ws://127.0.0.1:9000/mcp -o /tmp/chameleon
masq chameleon --url unix:///tmp/mcp.sock -o /tmp/chameleon
masq chameleon --token-file ~/.secrets/mcp.txt --url http://127.0.0.1:9/mcp -o /tmp/chameleon
masq chameleon -- python -m their_mcp -o /tmp/chameleon
# then: npx -y @copilotkit/aimock --config /tmp/chameleon/aimock.json
masq discover # find VS Code / Cursor / Claude / Grok / Hermes MCP configs
masq proxy --upstream http://127.0.0.1:4443/mcp --block
masq sast ./server # local sinks (semgrep if present)
masq classify --url http://127.0.0.1:4443/mcp --lab
masq overnight --lab --hours 6
masq map --from reports/overnight-YYYYMMDD/latest.json
# catalog
masq fixtures/t3_line_jump.json
masq fixtures/clean_calculator.json --trusted
masq pin fixtures/clean_calculator.json -k calc
masq check fixtures/clean_calculator.json -k calc
masq detectors
退出码:0 干净 · 2 发现数 ≥ --fail-on(默认 high)· 1 错误。
TUI 为可选开启(masq tui 或 --tui)。在 tty 上默认先是 linpeas 式实时流,然后输出报告。Cron 场景请用 --plain / --no-color。
别名:doctor / audit → scan。chameleon → mimic。posture → seat。
sit / chameleon 支持的传输:
http://)ws://unix: 与 npipe:--framing auto 先试 NDJSON,再试 Content-Length)认证(绝不会写入报告):
--token-file PATH(第一行会成为 Authorization: Bearer …)--token-env VAR--header "Name: value"(可重复)wss:// 未内置。用 Stunnel 转到 ws://,或使用 HTTP。HTTP 不跟随任何重定向。
Stdio 的 initialize 不会通告 sampling。标记服务器通告的 sampling / elicitation。文档 URL(model-catalog.json、/docs/)会被有意忽略。
$HOME / %USERPROFILE% 下的配置与技能根目录:
VS Code、Cursor、Windsurf、Claude Desktop、Claude Code、Grok、Hermes、Codex、Continue、Gemini CLI、Amp、Kiro、OpenCode、Amazon Q、Antigravity、OpenClaw。
以及 cwd 下的 .mcp.json 和 MASQ_EXTRA_CONFIG(OS 路径列表)。
--lab)--lab 是白名单,不是 /24 扫描。它由操作者配置。除回环地址外没有编译进任何内容。
MASQ_LAB_HOSTS 环境变量:以逗号、空格或换行分隔的 host:port 或主机名。.masq/lab-hosts 文件:每行一个主机,# 为注释。示例:
export MASQ_LAB_HOSTS="192.0.2.10,192.0.2.11"
masq --lab
API 探测和 TUI fleet 汇总会读取 MASQ_LAB_HOSTS。MASQ_SIT_URLS(或 --mcp-url)为 --lab 提供要 sit 的 MCP URL。
非回环的 sit --url 需要 --lab 且目标在白名单中。回环上的未认证 initialize 是 High。离开本机则是 Critical。
不要把 proxy 指向你不会 sit 的主机。
Sniff 优先级:先 chat_history.jsonl,再 Hermes 的 request_dump_*,然后其他 jsonl。遍历会完整走完,不会只保留 WalkDir 的前 300 个命中。要更深入,请用 masq sniff <单个会话目录>。
masq overnight --lab --hours 6 --interval-mins 20
# writes <cwd>/reports/overnight-YYYYMMDD/{latest.json,latest.md,latest.txt,delta.txt}
不修改配置。不会对实时服务器执行 tools/call。delta.txt 为 baseline / no_change / CHANGE,外加 + 严重级别 标题 与 - 严重级别 标题。
classify --llm 和 TUI 分诊附加功能是仅有的 completions POST(Grok /v1/chat/completions,操作者确认)。没有密钥:仅本地修复建议。密钥来自 XAI_API_KEY 或 ~/.secrets/xai.txt。绝不转储。
CLI (clap) masq
→ seat | recon | sniff | api | sit | chameleon
→ discover | proxy | sast | classify | overnight | map
→ scan | multi | pin | check | detectors | tui
→ client (HTTP / SSE / ws / unix / npipe / stdio)
→ normalize (full-schema walk, caps)
→ detectors + sniff + recon + sit findings
→ report (text / JSON / Markdown) + optional TUI
库 crate:masq(scan_from_tools_list、scan_stdio、run_seat、PostureReport)。
不要转储 ~/.secrets。recon 只统计文件。输出“路径 + loaded”。
cargo test
cargo clippy --all-targets -- -D warnings
预期退出码为 0。
固定样本:T1 描述投毒、T3 跳行、T6 参数名、T8 ANSI、T13 重复名称、pin 抽换、多列表、tests/mock_mcp_server.py 下的实时 NDJSON mock。
密钥不会进入 git(reports/、data/、.env、*.key、secrets/、.masq/)。
MIT。版权所有 2026 SamsonCyber。
| 命令 | 作用 |
|---|
seat(默认) | 完整态势:recon + sniff + api + skills + 可选 sit。 |
recon | 配置文件、监听端口、影子 URL、sudo argv、未固定的 npx/uvx。 |
sniff | 在会话日志中查找密钥、明文推理、加密 CoT 回显。 |
sniff --timeline | 按文件顺序输出 T0001 行。不解密。每文件上限 200 个事件。 |
api | 在回环上仅用 GET 请求 /v1/models(及同类端点);--lab 会加入白名单对端。 |
sit | 说 MCP:initialize、notifications/initialized、tools/list、prompts/list、resources/list。绝不主动发起 tools/call。 |
chameleon / mimic | 对实时目录或文件目录执行 sit,写出 catalog.json + aimock.json + calls.json。示例 tools/call 信封仅供 aimock 使用。 |
discover | 打印已知的智能体 MCP 配置路径。不生成进程。 |
proxy | 转发智能体的 JSON-RPC。--block 会拒绝形似密钥的 tools/call 参数/结果。默认监听 127.0.0.1:9877。 |
sast | 本地源码中的 sink。若已安装 semgrep 则使用之。 |
classify | 对实时 tools/list 做本地 IPI / 投毒审查。--llm 会询问 Grok(操作者密钥)。 |
overnight | 反复执行 seat,直到 --hours 时间过去。写报告。不修改配置。 |
map | 对保存的 posture JSON 做文本攻击路径查询。不画图。 |
scan / multi | 静态目录 lint(裸 .json 路径会重写为这条命令)。 |
pin / check | 内容哈希 pin 存储(.masq/pins.json),用于防目录抽换的 CI。 |
detectors | 打印目录规则包。 |
tui | 带边框的 seat。一直运行到 Ctrl+C。 |
| 模块 | 覆盖范围 |
|---|
| recon | MCP01 密钥路径、MCP04 未固定的 npx/uvx、MCP07/09 监听端口与影子 URL、MCP05 sudo argv |
| catalog | MCP03 模式投毒 / 遮蔽 / 抽换 |
| skills | 对 SKILL.md 应用相同的目录检测器(Hermes、Grok、Claude、Cursor、Codex、Gemini、Amp、Kiro、OpenCode、OpenClaw)。不依赖 Snyk 云。 |
| sit | MCP02 权限蔓延、MCP03 实时 tools/list、MCP07 未认证 initialize、服务器通告 sampling/elicitation、Streamable HTTP(2025-06-18)及早期 HTTP+SSE(2024-11-05)、Origin DNS 重绑定 |
| sniff | MCP01 + MCP10 + arXiv:2608.09867 加密 CoT 回显(包括 thinkingSignature) |
| api | MCP07 未认证 /v1/models、MCP09 LAN 绑定 |
| watch | 对 .masq/pins.json + skills 做 pin 差异比对。overnight 会启用它。不是代理。 |
| fleet | 将 lab 白名单汇总进一个 FLEET 区块 |
| map | 对 posture 报告做文本路径查询 |
| 限制 | 值 |
|---|
| tools/list 文件 | 8 MiB |
| sniff 文件 | 8 MiB(更大时仅采样前 2 MiB) |
| sniff 文件数 / 扫描根 | 300(优先级内取最新 mtime) |
| timeline 事件 / 文件 | 200,之后输出 timeline truncated |
| timeline T 行数 | 500(inspect 与 collapse 仍会运行) |
| schema 遍历深度 | 64 |
| 每个清单的 tools 数 | 5_000 |
| HTTP 探测 | 仅 GET,API 2s / sit 5s |
| sit 握手 | 超时 + 终止 |
| 本工具 | 本工具不会 |
|---|
| 以智能体客户端的身份 sit(initialize + list) | 对实时服务器主动发起 tools/call |
| 检测日志中的加密 CoT 回显 | 解密 CoT 或将其重放给更弱的模型 |
GET /v1/models | POST completions(可选开启的 TUI 分诊 / classify --llm 除外) |
| 对目录做 pin 哈希防抽换 | 签名 PKI / 企业级 pin 保险库 |
在 proxy --block 中转发智能体的 tools/call | 完整运行时 DLP 网关 / SaaS 控制面 |
| 本地技能树 lint | Snyk / 云端 SCA |
| 检查项 | 预期 |
|---|
masq fixtures/clean_calculator.json --trusted | exit 0 |
masq fixtures/t3_line_jump.json | exit 2 |
masq fixtures/t13_duplicate_names.json | exit 2(工具遮蔽) |
masq sniff --timeline fixtures/(非 TTY / --json) | 仅带该标志时输出 T0001 |
masq chameleon fixtures/clean_calculator.json -o <tmpdir> | catalog.json、aimock.json、calls.json |
实时运行 masq --no-color | 令牌已脱敏(…,而非完整 sk-) |