test-center-ai/super-rag
GitHub: test-center-ai/super-rag
一款完全离线的渗透测试 Agentic AI 工具,基于 6 万+安全知识块的混合 RAG 和本地 LLM,为进攻性安全测试提供从侦察到漏洞利用的推理与检索能力。
Stars: 0 | Forks: 0
# 🛡️ Super RAG
### 一款用于渗透测试的离线、Agentic AI —— 你的私人网络安全大脑。
*提出渗透测试问题,运行侦察,并在超过 **61,000+ 个**精选安全知识块上进行 exploit-chain —— 完全在你自己的机器上运行。无需云。无遥测。数据绝不外泄。*
[](https://www.python.org/)
[](#)
[](https://qdrant.tech/)
[](https://lmstudio.ai/)
[](https://modelcontextprotocol.io/)
[](LICENSE)
[](#-contributing)
## 💡 为什么选择 Super RAG?
企业安全 Copilot(如 Microsoft Security Copilot、CrowdStrike Charlotte)部署在云端、成本高昂,且专为**防御者**打造。Super RAG 改变了这一点:
- 🔒 **完全离线** —— 在 [LM Studio](https://lmstudio.ai/) 中针对本地 LLM 运行。非常适合物理隔离的实验环境、敏感的测试任务以及云访问受限的地区。
- ⚔️ **专为进攻性推理设计** —— 不仅仅是“总结此告警”,而是能够回答“*我看到 Apache 2.4.49 —— 我的下一步行动是什么?*”,并将侦察 → 漏洞识别 → 漏洞利用串联起来。
- 📚 **基于真实知识** —— 索引了 1,110 篇精心整理的笔记,**外加** HackTricks、PayloadsAllTheThings、OWASP 备忘录以及数百篇 CTF write-up。每个答案都能**追溯**到其源文件。
- 🧩 **接入你的 Agent** —— 作为 MCP server 暴露,因此 Hermes、OpenClaw、Claude Desktop 或任何 MCP client 都能立即获得 `cybersec_search` 工具。
## ✨ 功能特性
| | |
|---|---|
| 🔎 **13 策略混合检索** | Dense vectors + 全文 BM25,通过 RRF 融合,随后进行多跳(Multi-Hop)、纠正(Corrective)、上下文感知(Context-Aware)和重排序(Re-ranking)过程 —— 根据渗透测试的各个阶段进行调优。 |
| 🤖 **Agentic 渗透测试循环** | `推理(reason) → 行动(act) → 观察(observe) → 反思(reflect)`,具备卡死循环检测和混合模式(自动侦察,漏洞利用前需人工批准)。 |
| 🍯 **绕过检测意识** | 内置 honeypot、WAF(8 家厂商)和防火墙检测 —— 这样 Agent 就不会在 tarpit 上浪费步骤。 |
| 🛡️ **幻觉防护** | 命令注册表会在任何操作运行前,根据已知正确的 flags 验证每次工具调用。 |
| 📝 **报告生成** | 一条命令即可将发现转化为专业的渗透测试报告**或** HackerOne 风格的 bug-bounty 提交,附带 CVSS 和证据。 |
| 🔌 **MCP 集成** | 一个共享 server,服务多个 Agent —— `cybersec_search`、`cybersec_answer`、`cybersec_status`。 |
| 🎓 **Fine-tune 准备就绪** | 将 HTB/VulnHub write-up 中的*真实*推理过程提取为 JSONL(绝不捏造场景)。 |
## 🏗️ 架构
```
flowchart LR
subgraph Knowledge["📚 Knowledge (61,552 chunks)"]
V["1,110 curated notes"]
D["HackTricks · PayloadsAllTheThings · OWASP"]
W["CTF / HTB write-ups"]
end
subgraph Engine["🧠 Super RAG"]
I["ingest.pychunk + embed (parallel)"] Q[("Qdrant
hybrid index")] R["rag_engine.py
13 RAG strategies"] end subgraph Local["💻 LM Studio (localhost:1234)"] E["nomic-embed-text"] L["gpt-oss-20b"] end A["agent.py
pentest loop"] M["rag_mcp.py
MCP server :8765"] V & D & W --> I --> Q I -.embeddings.-> E Q --> R --> L R --> A R --> M M --> Hermes & OpenClaw & Claude["Claude Desktop"] ``` 三层结构,重深度而非规模:**内嵌式 Qdrant**(无需 Docker)用于混合搜索 → **13 种组合 RAG 策略**用于上下文组装 → **本地 LLM** 用于生成。 ## 🔬 13 种 RAG 策略(每次查询时组合使用) 大多数项目只使用 #1,然后纳闷为什么检索效果平庸。Super RAG 叠加了 13 种策略,每种都在渗透测试工作流中发挥着不可替代的作用: | # | 策略 | 为你带来的优势 | |--:|----------|------------------| | 4 | **Hybrid**(向量 + BM25,RRF 融合) | 针对 `CVE-2024-1086`、`--no-preauth`、`SeDebugPrivilege` 提供语义召回率*和*精确字符串召回率 | | 17 | **Multi-Hop** | 端口 389 → LDAP enum → 用户列表 → AS-REP roast → hash → crack,每一步都参考上一步的信息 | | 9 | **Agentic** | Agent 在测试过程中决定*何时*以及*检索什么* | | 6 | **Memory-Augmented** | 记住几小时前尝试过的内容,因此绝不会重复尝试死胡同 | | 3 | **Corrective** | 检测微弱的检索结果,并使用重新表述的词进行重新查询 | | 8 | **Context-Aware** | 根据目标环境(Windows/AD vs Web vs 云)进行过滤 | | 18 | **Reasoning re-rank** | Keyword-overlap 权重提升,让*最有用*的块浮出水面,而不仅仅是相似度最高的 | | 13 | **Adaptive** | 在侦察阶段范围宽广,在漏洞利用阶段则狭窄且精准 | | 21 | **Hierarchical** | 从一般到特定的深入挖掘,映射 ATT&CK 结构 | | 5 | **Speculative** | 在后台预取可能的后续内容以减少延迟 | | 11 | **Self-RAG** | 在整个会话中基于自己之前的答案进行构建 | | 24 | **Few-Shot** | 提取某人利用相同服务/版本的真实 write-up | | 14 | **Citation-Aware** | 每个事实都带有其源路径 —— 对 bug-bounty 报告至关重要 | ## 🏆 模型基准测试(16 个本地模型,真实渗透测试场景) 我们在 LM Studio 中通过一个 2 轮渗透测试工具使用场景(侦察 → exploit chain)对每个模型进行了基准测试,测量了**速度、准确率和有效工具循环** —— 在运行之间清退每个模型以获取纯净的数据。 | 排名 | 模型 | tok/s | 工具循环 | 评价 | |-----:|-------|------:|:----------:|---------| | 🥇 | **openai/gpt-oss-20b** | **165** | **2/2** ✅ | 唯一一个快速、准确**且**能输出干净工具调用的模型。12 GB。 | | 🥈 | qwen3.6-35b reasoning-distilled | 139 | 2/2 ✅ | 链条正确,需要剥离字符围栏 | | — | gemma-4-26b / glm-4.7-flash | 156 / 125 | 0/2 ❌ | 快速且准确,但只*思考*而不输出可用的工具调用 | ## 🚀 快速开始 ### 前置条件 - 运行在 `localhost:1234` 的 [**LM Studio**](https://lmstudio.ai/)(已启用本地服务器),配置了 **`nomic-embed-text-v1.5`**(embeddings)+ 加载了任何聊天模型 —— 自带本地模型 - **Python 3.10+**(已在 3.14.5 上测试) - 推荐使用 GPU(基于 RTX 5090 构建;embedder + 12 GB 聊天模型可容纳在 24 GB VRAM 中 —— 但较小的模型同样可用) ``` # 1. Clone git clone https://github.com/test-center-ai/super-rag.git cd super-rag # 2. Install(无需 torch、Docker 和 HuggingFace) pip install -r requirements.txt # 3. Bootstrap — clone 公开文档仓库 + 检查 LM Studio python setup.py # or: python setup.py --minimal (bundled notes only) # 4. Build 索引(可恢复;使用并行 embedding 仅需几分钟) python main.py ingest # 5. 提问任意问题 python main.py query "how do I exploit Apache 2.4.49 path traversal" python main.py query "AS-REP roasting — what tool and command?" # 6. 运行 agentic pentest 循环(混合模式:自动 recon,手动审批 exploit) python main.py pentest 10.10.10.5 --scope 10.10.10.0/24 # 7. 生成报告,或检查健康状态 python main.py report python main.py status ``` ## 🤝 从你的 AI Agent 中使用它 (MCP) Super RAG 作为**一个共享的 MCP server** 运行(`rag_mcp.py`,HTTP @ `127.0.0.1:8765/mcp`),因此多个 Agent 可以同时查询它: ``` python rag_mcp.py # or let Startup\SuperRAG-MCP.cmd auto-start it ``` **暴露的工具:** `cybersec_search(query, phase)` · `cybersec_answer(question)` · `cybersec_status()` 在任何 MCP client 中注册它: ``` // Claude Desktop / OpenClaw style "mcp": { "servers": { "cybersec-rag": { "url": "http://127.0.0.1:8765/mcp", "transport": "streamable-http" }}} ``` ``` # Hermes 风格(config.yaml) mcp_servers: cybersec-rag: { url: http://127.0.0.1:8765/mcp, enabled: true } ``` 有关完整的 Hermes + OpenClaw 演练,请参见 **[INTEGRATION.md](INTEGRATION.md)**。 ## 🎬 效果展示 —— 真实的 Agent 输出 ``` STEP 1 recon → nmap -sS -A 10.10.10.5 ✓ correct first move (2.9s) STEP 2 enumerate → gobuster on :80 (Apache live) ✓ methodical (3.3s) STEP 3 exploit → curl --path-as-is "…/cgi-bin/.%2e/…/bin/bash" -d 'reverse shell' ✓ textbook CVE-2021-41773 mod_cgi RCE (4.9s) sources: htb-cpts/initial-access-exploitation.md, oswe/file-inclusion-upload.md, HackTricks ``` 模型遵循了正确的方法论,每一步都以知识库为基础,并生成了可运行的 exploit chain —— 完全离线。 ## 📁 项目布局 ``` super-rag/ ├── main.py # CLI: ingest · query · pentest · report · extract · status ├── config.py # paths, model IDs, chunking, timeouts, tool registry ├── ingest.py # vault → chunks → parallel embed → Qdrant (~14× faster pipeline) ├── rag_engine.py # the 13 RAG strategies + RRF fusion ├── agent.py # ReAct+Reflect pentest loop, scope + approval gates ├── detector.py # honeypot / WAF / firewall detection ├── memory.py # attack-surface graph, findings, stuck-loop tracking ├── report.py # pentest report + bug-bounty submission generators ├── llm.py # one streaming chat helper (works for every model) ├── rag_mcp.py # MCP server for agent integration ├── model_benchmark.py # the 16-model benchmark harness ├── extract_training.py # real write-ups → fine-tuning JSONL └── tools/ # registry + nmap/gobuster/ffuf parsers ``` ## 🧰 技术栈 `Python 3.14` · `Qdrant`(内嵌式)· `LM Studio`(兼容 OpenAI 的本地 API)· `nomic-embed-text-v1.5` · `gpt-oss-20b` · `MCP / FastMCP` —— **零云依赖。** ## 🔐 负责任地使用 - **仅限授权目标。** Super RAG 不强制执行授权 —— 这是*你的*法律责任。请在你拥有或获得明确书面许可(测试任务、CTF、实验环境)的系统上使用它。 - **混合模式在漏洞利用前设置人工 `[y/N]` 批准关卡。** 请勿绕过它。 - **索引的外部仓库仅供参考且不受信任** —— 切勿执行从其中提取的代码。 - 本项目用于**防御性学习、授权测试以及 CTF/教育**。请勿用于非法用途。 ## 🛣️ 路线图 - [ ] Qdrant 服务器模式 (Docker),实现完全并发的多 Agent 访问 - [ ] GRPO 对 7–14B 专家模型进行 fine-tune,基于提取的真实 write-up - [ ] Web UI(目前 CLI 可用) - [ ] 根据交战规则文件进行自动范围界定 ## 🤝 贡献 欢迎提交 Issues 和 PR —— 特别是新的工具解析器、RAG 策略和探测器特征。保持防御初衷,保持引用来源。 ## 📄 许可证 MIT —— 见 [LICENSE](LICENSE)。
为离线者、物理隔离者及求知者而构建。⭐ 如果对你有帮助,请点个 Star。
标签:AI智能体, DLL 劫持, 域名收集, 大语言模型, 密码管理, 本地部署, 检索增强生成, 逆向工具