内容
# 脚手架 - 漏洞赏金与CTF挑战平台
## 代理无关的进攻性编排
脚手架(The Scaffolding)是一个用于自主解决CTF挑战和进行漏洞赏金研究的开源框架。它通过将模型上下文协议(MCP)与持久的、自我改进的代理知识库相结合,实现了高级安全推理与确定性执行的桥梁。
**插入任何AI代理:Claude Code、GitHub Copilot、Codex、Gemini、OpenCode等,只需最小配置。**
## 功能概述
大多数AI代理在进攻性安全任务中表现不佳,因为它们缺乏结构化的信息收集、被噪音淹没、并且在长时间会话中丢失上下文。脚手架通过提供以下功能解决了这个问题:
- **结构化技能加载**:代理仅加载与当前挑战类型(web、pwn、crypto等)相关的技能,保持上下文清洁
- **LatticeMind集成**:自动扫描具有置信度评分的发现结果,以便代理在信号而非噪音上进行推理
- **Kali MCP集成**:直接访问标准安全工具,无需手动设置
- **持久笔记**:会话状态被外部化,防止长时间解决过程中的上下文丢失
- **自我改进文档**:解决结果反馈到技能文件中,使平台随着时间推移变得更好
## 演示
以下是一个代理使用脚手架解决一个困难的web挑战的演示。
https://github.com/user-attachments/assets/5774267e-0e5c-414b-99d3-1b9de2bc0444
## 架构
<img width="865" height="873" alt="Screenshot 2026-04-11 021928" src="https://github.com/user-attachments/assets/03f7bd4d-addc-467b-abda-a074f03db30c" />
代理位于三个工具层的中心:
- **LatticeMind** — 运行有针对性的扫描,根据置信度评分发现结果,为代理提供推理依据
- **Kali MCP** — 按需执行标准安全工具
- **GitHub MCP** — 搜索漏洞利用、PoCs和参考实现
启动会话时,引导技能加载特定领域的知识。笔记持久化会话状态,并在每次解决后反馈到技能中。
## 入门指南
**前提条件**
- Docker
- 支持MCP的AI代理
**设置**
1. 克隆此仓库
2. 将`.env.example`复制到`.env`并填写您的API密钥/路径
3. 设置MCP并使用脚手架脚本启动您喜欢的代理:
```bash
pip install -r scaffold/requirements.txt
python scaffold.py
```
*交互式TUI将让您配置MCP、初始化项目和启动代理(Gemini、Cursor、OpenCode、Codex、Copilot、Claude、Antigravity)。*
## 项目结构
```
(root)/
├── .agents/ # 代理技能定义
├── .cursor/ # Cursor IDE配置
├── .gemini/ # Gemini CLI配置
├── .github/ # GitHub集成
├── .opencode/ # OpenCode代理配置
├── ctf-benchmarking/ # 5挑战困难CTF基准测试清单/模板
├── kali-mcp/ # Kali Linux MCP服务器集成
├── AGENTS.md # 共享代理说明
├── HUMAN.md # 面向人类的文档
└── README.md
```
## 技能
特定领域的技能文件由代理根据挑战类型加载。每个技能都编码了侦察模式、攻击链和过去解决经验的教训。
| 技能 | 覆盖范围 |
|---|---|
| `agent-setup` | 工具准备和依赖检查 |
| `agent-calibration` | 工作流优化和反馈 |
| `crypto` | 编码、RSA、椭圆曲线、哈希攻击 |
| `forensics` | 文件、内存、网络和多媒体分析 |
| `mobile` | 移动应用安全测试 |
| `network` | 侦察和网络评估 |
| `pwn` | 栈、堆和格式化字符串利用 |
| `recon` | 目标发现和侦察 |
| `reverse-engineering` | 二进制分析和逆向工程 |
| `web` | Web应用安全测试 |
## 技能合约和基准指标
为了保持跨代理的技能质量一致,该仓库包括:
- 规范合约:`.agents/standards/skill-contract.yaml`
- 机器可读合约:`.agents/standards/skill-contract.json`
- 质量门控配置:`.agents/standards/quality-gate.json`
- 路由器单一事实来源:`.agents/standards/router-spec.json`
- 可复制的基准生成器:`tools/skills/baseline_metrics.py`
- 验证器:`tools/skills/validate_skills.py`
- 标准化工具:`tools/skills/normalize_skills.py`
- 路由器生成器:`tools/skills/generate_router_wrappers.py`
- 烟雾评估门控:`tools/skills/smoke_eval.py`
- 当前基准快照:`reports/skill-baseline.json`
常用命令:
```bash
# 生成基准
python tools/skills/baseline_metrics.py --output reports/skill-baseline.json
# 标准化已知markdown问题
python tools/skills/normalize_skills.py --write --fix-footnotes
# 检查标准化偏移(CI安全)
python tools/skills/normalize_skills.py --check --fix-footnotes
# 验证合约
python tools/skills/validate_skills.py --report reports/skill-validation.json
# 从一个规范重新生成所有路由器包装器
python tools/skills/generate_router_wrappers.py
# 运行端到端质量门控
python tools/skills/smoke_eval.py --output reports/skill-smoke-eval.json
```
CI强制执行位于`.github/workflows/skills-quality.yml`。
### 低成本Cursor自动基准测试(<=15任务)
使用阶段路由基准测试以低成本检查实际代理行为:
所有基准测试运行器默认为`--model composer-2`以进行一致的A/B比较。
```bash
python tools/benchmarks/run_cursor_phase_benchmark.py ^
--tasks tools/benchmarks/cursor_phase_tasks.json ^
--max-tasks 10 ^
--timeout-sec 20 ^
--output reports/benchmarks/cursor-auto-phase-benchmark.json
```
任务集文件:`tools/benchmarks/cursor_phase_tasks.json`(默认为10任务;最大15任务)。
### 安全基准测试(仅限技能,目前,后续将比较MCP)
首先使用仅限技能的配置文件运行更丰富的安全基准测试:
```bash
python tools/benchmarks/run_cursor_security_benchmark.py ^
--profile skills-only ^
--tasks tools/benchmarks/cursor_security_tasks.json ^
--max-tasks 12 ^
--timeout-sec 20 ^
--output reports/benchmarks/cursor-security-skills-only.json
```
稍后,在启用Kali/Lattice MCP后,运行:
```bash
python tools/benchmarks/run_cursor_security_benchmark.py ^
--profile mcp-enabled ^
--tasks tools/benchmarks/cursor_security_tasks.json ^
--max-tasks 12 ^
--timeout-sec 20 ^
--output reports/benchmarks/cursor-security-mcp-enabled.json
```
然后比较:
```bash
python tools/benchmarks/compare_cursor_benchmarks.py ^
--baseline reports/benchmarks/cursor-security-skills-only.json ^
--candidate reports/benchmarks/cursor-security-mcp-enabled.json ^
--output reports/benchmarks/cursor-security-comparison.json
```
### 漏洞发现基准测试(真实质量)
运行具有严格JSON发现结果和TP/FP/FN评分的困难但低成本的漏洞发现基准测试(最多20任务):
```bash
python tools/benchmarks/run_cursor_vuln_benchmark.py ^
--profile control ^
--model composer-2 ^
--tasks tools/benchmarks/cursor_vuln_tasks.json ^
--max-tasks 20 ^
--timeout-sec 120 ^
--store-raw-output ^
--output reports/benchmarks/cursor-vuln-control.json
python tools/benchmarks/run_cursor_vuln_benchmark.py ^
--profile skills-only ^
--model composer-2 ^
--tasks tools/benchmarks/cursor_vuln_tasks.json ^
--max-tasks 20 ^
--timeout-sec 120 ^
--store-raw-output ^
--output reports/benchmarks/cursor-vuln-skills-only.json
```
自适应和轻量级脚手架配置文件也支持:
```bash
python tools/benchmarks/run_cursor_vuln_benchmark.py ^
--profile adaptive ^
--model gpt-5.4-mini-high ^
--tasks tools/benchmarks/cursor_vuln_tasks.json ^
--max-tasks 20 ^
--timeout-sec 120 ^
--output reports/benchmarks/cursor-vuln-adaptive.json
python tools/benchmarks/run_cursor_vuln_benchmark.py ^
--profile skills-lite ^
--model gemini-3-flash ^
--tasks tools/benchmarks/cursor_vuln_tasks.json ^
--max-tasks 20 ^
--timeout-sec 120 ^
--verify-findings ^
--output reports/benchmarks/cursor-vuln-skills-lite.json
```
稍后(启用MCP后):
```bash
python tools/benchmarks/run_cursor_vuln_benchmark.py ^
--profile mcp-enabled ^
--model composer-2 ^
--tasks tools/benchmarks/cursor_vuln_tasks.json ^
--max-tasks 20 ^
--timeout-sec 120 ^
--store-raw-output ^
--output reports/benchmarks/cursor-vuln-mcp-enabled.json
```
比较两次漏洞运行:
```bash
python tools/benchmarks/compare_cursor_vuln_benchmarks.py ^
--baseline reports/benchmarks/cursor-vuln-control.json ^
--candidate reports/benchmarks/cursor-vuln-skills-only.json ^
--output reports/benchmarks/cursor-vuln-control-vs-skills.json
```
运行2次实验(对照组与技能组)并聚合:
```bash
python tools/benchmarks/run_cursor_vuln_experiment.py ^
--profiles control skills-only ^
--runs 2 ^
--model composer-2 ^
--tasks tools/benchmarks/cursor_vuln_tasks.json ^
--max-tasks 20 ^
--timeout-sec 120 ^
--store-raw-output ^
--output reports/benchmarks/cursor-vuln-experiment-runs2.json
```
从所有运行响应中生成客观和主观评分:
```bash
python tools/benchmarks/grade_cursor_vuln_responses.py ^
--experiment reports/benchmarks/cursor-vuln-experiment-runs2.json ^
--output reports/benchmarks/cursor-vuln-manual-grade.json
```
生成一个整合的排行榜(JSON + Markdown):
```bash
python tools/benchmarks/generate_vuln_leaderboard.py ^
--input-root reports/benchmarks/model-sweep ^
--output-json reports/benchmarks/model-sweep-leaderboard.json ^
--output-md reports/benchmarks/model-sweep-leaderboard.md
```
默认情况下,漏洞比较关注效率指标;仅当您明确想要延迟/令牌差异时,请添加`--include-cost`。
---
### Dockerized困难CTF基准测试(5挑战测试台)
该仓库还包含一个dockerized基准测试套件,每个类别都有一个困难的挑战(`web`、`pwn`、`crypto`、`forensics`、`reverse-engineering`)和手动评分所需的期末报告。
获取源码:
```bash
python tools/benchmarks/fetch_ctf_sources.py ^
--manifest ctf-benchmarking/manifest.json ^
--source-root ctf-benchmarking/sources
```
运行基准测试:
```bash
python tools/benchmarks/run_cursor_ctf_benchmark.py ^
--manifest ctf-benchmarking/manifest.json ^
--source-root ctf-benchmarking/sources ^
--model composer-2 ^
--output-dir reports/benchmarks/ctf-run-01
```
生成评分工作表:
```bash
python tools/benchmarks/grade_cursor_ctf_writeups.py ^
--run-report reports/benchmarks/ctf-run-01/run-report.json ^
--rubric ctf-benchmarking/grading/rubric.json ^
--output reports/benchmarks/ctf-run-01/manual-grade.json ^
--worksheet-md reports/benchmarks/ctf-run-01/manual-grade.md
```
---
## 设计理念
脚手架的设计注重token效率。技能选择性加载,笔记外部化状态而不是消耗上下文,LatticeMind的置信度评分防止代理在无关发现上进行推理。它根据您的设置完全在本地或云基础设施上运行。
## 责任使用
该项目旨在用于安全研究和教育。仅在您授权测试的系统上使用它。
### 致谢
- [k3nn3dy-ai](https://github.com/k3nn3dy-ai) 为 [Kali MCP](https://github.com/k3nn3dy-ai/kali-mcp) —
该平台的重要组成部分,通过模型上下文协议提供对Kali Linux安全工具的直接访问。