Cigilipuf/whitehathackerai
GitHub: Cigilipuf/whitehathackerai
一个由LLM驱动的自主渗透测试框架,通过ReAct决策循环协调60多种安全工具,实现自动化漏洞发现、验证和报告生成。
Stars: 0 | Forks: 0
# 🛡️ WhiteHatHacker AI
### 自主漏洞赏金猎人 — 由 Offensive Security LLM 驱动
[](https://python.org)
[](LICENSE)
[]()
[]()
[]()
[]()
**一个由 AI 驱动的自主安全评估框架,能够像专业漏洞赏金研究员一样思考、决策和狩猎。**
[快速开始](#-getting-started) · [架构设计](#-architecture) · [核心功能](#-key-features) · [文档中心](#-documentation)
## 这是什么?
WhiteHatHacker AI 不是一个扫描器 — 它是一个**自主安全研究代理**。它使用微调的 offensive security LLM(BaronLLM v2,150亿参数)作为推理大脑,通过 ReAct 决策循环协调60多种安全工具,并生成带有证据支持的漏洞报告,可直接用于负责任的披露。
机器人通过 **观察 → 思考 → 行动 → 评估 → 决策** 循环运行:它观察工具输出、推理攻击面、选择下一步行动、评估结果,并决定是深入挖掘、调整策略还是继续前进。每个发现都会经过7层误报消除管道才会进入报告。
### 与众不同之处
| | 传统扫描器 | WhiteHatHacker AI |
|---|---|---|
| **决策方式** | 固定规则,顺序执行 | LLM 驱动的 ReAct 循环,动态选择工具 |
| **误报率** | 高误报率,需要人工筛选 | 7层自动化消除(模式 → 多工具 → 上下文 → 载荷 → 贝叶斯 → 重放 → LLM 推理) |
| **适应性** | 静态扫描配置 | 从每次扫描中学习 — 记录高效工具、误报模式和技术-漏洞关联 |
| **验证** | 标记潜在问题 | 生成 PoC 脚本、重放漏洞利用、收集加密证据链 |
| **覆盖范围** | 单工具视角 | 交叉关联60+工具的发现,通过 LLM 推理发现攻击链 |
| **报告输出** | 原始工具输出 | 平台就绪报告(HackerOne/Bugcrowd),包含 CVSS 评分、重现步骤和证据包 |
## ⚡ 核心功能
### 代理式 ReAct 工作流
核心创新:不是按固定顺序运行工具,LLM 大脑根据累积的观察结果决定**下一步做什么**。它可以回到早期阶段、深入研究特定端点、制定并测试假设、自主发现多步骤攻击链。
```
while budget_remaining and not brain_says_done:
OBSERVE → Read current state from Working Memory
THINK → Brain decides next action (which tool, which target, why)
ACT → Execute selected ToolUnit(s)
EVALUATE → Brain assesses result quality and signal value
DECIDE → Continue / pivot / go deeper / change stage / stop
```
### 双脑 LLM 架构
| 模式 | 基座 | 角色 | 使用场景 |
|------|------|------|-----------|
| **Think 模式** | BaronLLM v2 (Qwen3-14B, Q8_0) | 深度分析、漏洞利用策略、误报消除、报告撰写 | 复杂推理任务 |
| **NoThink 模式** | 同模型,禁用 CoT | 快速分类、工具选择、侦察决策 | 速度关键决策 |
| **备用** | DeepHat-V1-7B (Qwen2.5-Coder-7B, Q4_K_M) | 紧急备份 | 两个主模式都不可用时 |
### OpenAI 兼容的 LLM 后端
大脑引擎连接任何 **OpenAI 兼容的 API 端点** — 无供应商锁定:
- **[LM Studio](https://lmstudio.ai/)** — 推荐用于本地推理。加载 GGUF 模型,启用服务器,将机器人指向 `http://127.0.0.1:1234/v1`
- **[llama.cpp server](https://github.com/ggerganov/llama.cpp)** — 使用您的模型运行 `llama-server`,使用 `/v1/chat/completions` 端点
- **[Ollama](https://ollama.com/)** — 使用 `ollama serve` 启动任何模型,通过 OpenAI 兼容 API 连接
- **[vLLM](https://github.com/vllm-project/vllm)** — 生产级服务,OpenAI API 兼容
- **任何 OpenAI API 兼容端点** — 包括云托管模型或自定义推理服务器
```
# config/settings.yaml
brain:
primary:
backend: remote # "local" (llama-cpp-python) or "remote" (OpenAI-compatible API)
api_url: "http://127.0.0.1:1234/v1" # Any OpenAI-compatible endpoint
model_name: "baronllm-v2-offensivesecurity"
context_length: 32768
secondary:
backend: remote
api_url: "http://127.0.0.1:1234/v1" # Same server, NoThink mode via /no_think prefix
```
机器人使用标准的 **`/v1/chat/completions`** 和 SSE 流式传输,因此它可以与任何实现 OpenAI Chat Completions API 的服务器开箱即用。
### HUNTER 模式 — LLM 驱动的漏洞研究
除了自动化扫描,HUNTER 模式将 LLM 转变为积极的研究者:
| 阶段 | 发生什么 |
|-------|-------------|
| **A — 模板生成** | 大脑根据检测到的技术栈生成针对特定端点的自定义 Nuclei YAML 模板 |
| **B — 深度探测** | 迭代假设驱动测试:分析 → 假设 → 探测 → 观察 → 适应 → 循环 |
| **C — 漏洞利用证明** | ExploitVerifier 通过4种策略确认发现(PoC 脚本、cURL、Metasploit、Nuclei),并提供加密证据链 |
### 7层误报消除
最关键的子系统 — 将真实发现与噪声区分开来:
| 层 | 方法 | 描述 |
|-------|--------|-------------|
| 0 | **历史误报反馈** | 从之前的扫描中学习每个工具的误报率 |
| 1 | **模式匹配** | 100+ 已知误报模式、工具特性、WAF/CDN/SPA 伪影 |
| 2 | **多工具验证** | 同一漏洞由 ≥2 个独立工具确认 |
| 3 | **上下文分析** | HTTP 响应差异、WAF 检测、CDN 补偿、工具特性检查 |
| 4 | **载荷确认** | 盲测重试、时间盲测、带外回调(Interactsh) |
| 5 | **贝叶斯评分** | 0-100 置信度评分,包含证据链和响应差异分析 |
| 6 | **完整 HTTP 重放** | 使用原始方法/正文重新发送请求,与对照请求对比差异 |
| 7 | **跨发现 LLM 推理** | 大脑综合分析所有发现,发现攻击链并消除关联误报 |
### 完整功能集
| 类别 | 功能 |
|----------|----------|
| **扫描** | 60+ 工具:Nmap、SQLMap、Nuclei(200+ 自定义模板)、Amass、FFuf、Dalfox、Metasploit、Commix、SSRFMap、TplMap 等 |
| **流水线** | 完整扫描、Web 应用、API、网络、快速侦察、代理式(大脑驱动)— 全部支持会话检查点/恢复 |
| **自定义检查** | 28 个专业检查器:IDOR、认证绕过、竞态条件、业务逻辑、JWT 深度、GraphQL 深度、HTTP/2 走私、CI/CD、原型污染、缓存中毒、WebSocket 等 |
| **漏洞利用验证** | 沙箱中执行 PoC 脚本、cURL 重放、Metasploit 自动利用、Nuclei 重新验证 — 附带 HAR 导出和加密证据链 |
| **报告** | Markdown、HTML、JSON、PDF。HackerOne 和 Bugcrowd 平台就绪模板。`whai submit` CLI 支持草稿模式 |
| **运维** | 持续监控(`whai monitor`)、多目标活动(`whai campaign`)、增量扫描(仅新资产/变更资产)、跨扫描去重(GlobalFindingStore) |
| **集成** | Slack、Telegram、Discord 通知。SQLite 资产数据库。崩溃恢复的会话持久化 |
| **安全** | 每次工具调用都强制执行范围验证。速率限制始终启用。载荷安全过滤器阻止破坏性命令。半自主模式下有人工审批门控 |
## 🏗️ 架构设计
```
┌──────────────────────────────────────────────────────────────┐
│ WhiteHatHacker AI v3.5 │
├────────────┬──────────────┬──────────────┬───────────────────┤
│ CLI │ GUI │ REST API │ WebSocket API │
├────────────┴──────────────┴──────────────┴───────────────────┤
│ │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ AGENTIC ORCHESTRATOR (ReAct Loop) │ │
│ │ WorkingMemory · AgentContext · ToolUnitRegistry │ │
│ │ OBSERVE → THINK → ACT → EVALUATE → DECIDE → (loop) │ │
│ └──────────────────────┬──────────────────────────────────┘ │
│ │ │
│ ┌──────────────────────▼──────────────────────────────────┐ │
│ │ DUAL BRAIN ENGINE (OpenAI-Compatible API) │ │
│ │ BaronLLM v2 Think ←→ BaronLLM v2 NoThink │ │
│ │ BrainRouter · Cache · CoT Logging · Auto-Recovery │ │
│ │ Connects to: LM Studio / llama.cpp / Ollama / vLLM │ │
│ └──────────────────────┬──────────────────────────────────┘ │
│ │ │
│ ┌──────────────────────▼──────────────────────────────────┐ │
│ │ HUNTER MODE (Template Gen · Deep Probe · PoC) │ │
│ ├──────────────────────────────────────────────────────────┤ │
│ │ SECURITY TOOL ORCHESTRATOR (60+ Tools) │ │
│ │ Recon · Scanners · Exploit · Fuzzing · Network · Crypto │ │
│ ├──────────────────────────────────────────────────────────┤ │
│ │ FALSE POSITIVE ELIMINATION (7-Layer Pipeline) │ │
│ │ Patterns · Multi-Tool · Context · Payload · Bayesian │ │
│ │ Full Replay · Cross-Finding LLM · Evidence Quality Gate │ │
│ ├──────────────────────────────────────────────────────────┤ │
│ │ EXPLOIT VERIFICATION & EVIDENCE │ │
│ │ ExploitVerifier · EvidenceAggregator · HAR · PoC │ │
│ ├──────────────────────────────────────────────────────────┤ │
│ │ REPORTING & INTEGRATION │ │
│ │ HackerOne · Bugcrowd · Slack · Telegram · HTML/PDF │ │
│ └──────────────────────────────────────────────────────────┘ │
└──────────────────────────────────────────────────────────────┘
```
## 🚀 快速开始
### 环境要求
| 组件 | 最低配置 | 推荐配置 |
|-----------|---------|-------------|
| **操作系统** | Ubuntu 22.04+ | Kali Linux 2024+ |
| **Python** | 3.11 | 3.12+ |
| **内存** | 16 GB | 32 GB+(用于150亿模型) |
| **GPU** | — | NVIDIA 16GB+ 显存或 Apple Silicon |
| **存储 | 100 GB SSD | 500 GB NVMe |
### 安装
```
# 克隆
git clone https://github.com/Cigilipuf/whitehathackerai.git
cd whitehathackerai
# Python 依赖项
pip install -r requirements.txt
# 安全工具(Kali 原生 + Go 开发)
bash scripts/setup_kali_tools.sh
bash scripts/setup_go_tools.sh
# 下载 LLM 模型(约 15.7 GB)
bash scripts/download_models.sh
# 字典文件
bash scripts/setup_wordlists.sh
```
### 配置
```
cp .env.example .env
# 编辑 .env — 添加你的 API 密钥(Shodan, HackerOne, GitHub 等)
# 将 brain 引擎指向你的 OpenAI 兼容 LLM 服务器
# 编辑 config/settings.yaml → brain.primary.api_url
# 默认值:http://127.0.0.1:1234/v1(LM Studio 默认)
# 验证设置
bash scripts/health_check.sh
```
### 使用方法
```
# 完全自主扫描
whai scan --target example.com --mode autonomous --profile balanced
# 半自主(关键步骤需人工审批)
whai scan --target example.com --mode semi-autonomous
# 仅快速侦察
whai scan --target example.com --pipeline quick_recon
# 智能体模式(brain 驱动的 ReAct 循环)
whai scan --target example.com --pipeline agentic
# 持续监控(每 2 小时重新扫描)
whai monitor example.com --interval 120
# 多目标行动
whai campaign targets.txt --profile aggressive
# 试运行(预览运行内容但不执行)
whai scan --target example.com --dry-run
# 系统健康检查
whai diagnose
```
### Docker 部署
```
# CPU
docker compose -f docker/docker-compose.yaml --profile cpu up -d
# GPU(需要 nvidia-docker)
docker compose -f docker/docker-compose.yaml --profile gpu up -d
```
## 🔄 扫描流水线
默认的10阶段流水线(或者代理式循环可以动态重新排序这些阶段):
```
1. Scope Analysis → Validate targets, define boundaries, parse scope YAML
2. Passive Recon → Subdomains, OSINT, DNS, Wayback/GAU, GitHub secrets, email security
3. Active Recon → Port scan, web crawl, tech detection, CDN/WAF fingerprint, favicon hash
4. Enumeration → Parameters, auth flows, APIs, JS analysis, VHost fuzzing, source maps
5. Attack Surface Map → Threat model, prioritize vectors, brain-generated attack narratives
6. Vulnerability Scan → SQLi, XSS, SSRF, SSTI, IDOR, BOLA, RCE, smuggling, JWT, GraphQL, 28 custom checkers
7. FP Elimination → 7-layer verification pipeline with confidence scoring
8. Reporting → CVSS scoring, PoC, reproduction steps, evidence packages, quality report
9. Platform Submit → HackerOne / Bugcrowd draft submission via whai submit
10. Knowledge Update → Record productive tools, FP patterns, tech-vuln correlations for next scan
```
## 📁 项目结构
```
src/
├── brain/ # Dual LLM engine, router, prompts, working memory, reasoning
│ ├── engine.py # BrainEngine — local (llama-cpp-python) & remote (OpenAI-compatible API)
│ ├── router.py # Task → model routing (Think/NoThink/Fallback)
│ ├── intelligence.py # IntelligenceEngine — high-level brain operations
│ ├── prompts/ # System prompts for each task type + agent prompts
│ ├── memory/ # Context manager, knowledge base, working memory
│ └── reasoning/ # Chain of thought, attack planner, risk assessor
├── workflow/ # Orchestrator, state machine, agent loop, pipelines
│ ├── agent_orchestrator.py # ReAct loop implementation
│ ├── tool_unit.py # ToolUnit abstraction for agentic execution
│ └── pipelines/ # full_scan, web_app, api_scan, network, agentic
├── tools/ # 60+ security tool wrappers
│ ├── recon/ # Subdomain, port scan, web discovery, DNS, OSINT, tech detect
│ ├── scanners/ # Nuclei, SQLMap, Dalfox, + 28 custom checkers
│ ├── exploit/ # Metasploit, SearchSploit, ExploitVerifier, PoC generator
│ ├── fuzzing/ # FFuf, Gobuster, Feroxbuster, dynamic wordlist
│ └── ... # network, api_tools, crypto, proxy
├── fp_engine/ # 7-layer false positive elimination
├── analysis/ # Vulnerability analysis, attack surface, correlation, benchmarking
├── reporting/ # Report generator, templates, evidence aggregator, platform submit
├── integrations/ # Database, cache, notifications, asset DB
└── utils/ # Logger (multi-sink loguru), rate limiter, scope validator
```
## 🧪 测试
```
# 完整测试套件(约 2690 个测试)
pytest
# 带覆盖率
pytest --cov=src --cov-config=.coveragerc
# 特定模块
pytest tests/test_fp_engine/ -v
# 针对漏洞实验室的基准测试(DVWA, Juice Shop, WebGoat 等)
whai benchmark --start-labs --scan --report
```
## ⚖️ 伦理使用
此工具**仅**用于授权的安全测试:
- ✅ 仅用于有明确书面授权的目标(漏洞赏金计划、您自己的系统)
- ✅ 遵守所有计划规则和范围定义
- ✅ 通过适当渠道负责任地报告发现
- ❌ 禁止用于未经授权的目标
- ❌ 禁止窃取、修改或删除数据
- ❌ 禁止执行 DoS/DDoS 攻击
**范围验证和速率限制在每次工具调用时都会强制执行,无法禁用。**
## 📄 许可证
MIT 许可证 — 详见 [LICENSE](LICENSE)。
## 📚 文档
| 文档 | 描述 |
|----------|-------------|
| [架构指南](docs/ARCHITECTURE.md) | 系统设计、数据流、模块交互 |
| [工具目录](docs/TOOL_CATALOG.md) | 所有60+ 集成安全工具及使用详情 |
| [工作流指南](docs/WORKFLOW_GUIDE.md) | 流水线阶段、扫描配置、参数设置 |
| [API 参考](docs/API_REFERENCE.md) | REST/WebSocket API 端点 |
| [贡献指南](docs/CONTRIBUTING.md) | 开发环境配置、编码规范、PR 流程 |标签:Agentic AI, AI代理, AI安全, AI风险缓解, Bug Bounty, Chat Copilot, CTI, DLL 劫持, False Positive, llama.cpp, LLM, LLM评估, LMStudio, Offensive Security, Ollama, OpenAI兼容API, ReAct框架, Red Team, SOC工具, Threat Hunting, Unmanaged PE, vLLM, Web安全, 人工智能安全, 可自定义解析器, 合规性, 域名收集, 大语言模型, 安全测试, 实时处理, 密码管理, 工具编排, 开源安全工具, 攻击性安全, 数据展示, 漏洞发现, 红队, 网络安全, 自主代理, 自动化渗透测试, 蓝队分析, 误报消除, 请求拦截, 负责任披露, 逆向工程平台, 隐私保护