0xenkil/GhostWire-V2
GitHub: 0xenkil/GhostWire-V2
一个由多 Agent AI 驱动的自主红队与渗透测试引擎,旨在通过自适应推理和动态规避技术替代传统静态安全扫描。
Stars: 1 | Forks: 0
# ⚡ GHOSTWIRE V7 — 自主 AI 红队引擎 ⚡
[](https://www.python.org/)
[](LICENSE)
[](https://ubuntu.com/)
[](https://github.com/)
[]()
*下一代自主安全评估框架,由自适应 LLM 推理、持久化交战记忆和动态规避技术驱动。*
## 📌 执行摘要
**GHOSTWIRE V7** 是一个先进的、完全自主的 AI 驱动的渗透测试和红队对抗平台。它从头开始构建,旨在替代基于静态规则的扫描器。Ghostwire 利用**多 Agent AI pipeline**、**动态攻击图推理**和**零硬编码决策引擎**。
Ghostwire 不依赖静态脚本,而是从每次扫描中学习:跟踪工具成功率、观察技术栈、识别 WAF 指纹、实时变异 payload,并在多次交战中保持战略记忆。
## 🔥 核心功能
### 🤖 1. 零硬编码 AI 决策引擎
- **战略顾问 (`intelligence/strategic_advisor.py`)**:持久化知识库,跟踪工具有效性、成功概率、平均执行时间和最佳发现路径。
- **自我认知引擎 (`intelligence/self_awareness_module.py`)**:持续监控 agent 的置信度水平,验证假设,跟踪知识盲区,并防止过度自信的执行。
- **推理引擎 (`intelligence/reasoning_engine.py`)**:在执行 payload 之前评估攻击前提条件、风险因素和漏洞利用链。
### 🛡️ 2. 自学习 WAF 幽灵引擎与规避
- **WAF 指纹识别与学习器 (`waf_fingerprinter.py`, `waf_learner.py`)**:识别 Cloudflare、AWS WAF、Akamai、Imperva、ModSecurity 以及自定义 Web 应用防火墙。
- **自适应 Payload 变异**:遇到 WAF 拦截时,自动尝试 header 篡改、速率限制绕过、字符编码、分块传输编码(chunked transfer encoding)和 HTTP 参数污染。
- **历史规避记忆**:记录针对目标技术栈验证有效的规避策略,以便在未来的运行中绕过安全控制。
### 👥 3. 多 Agent 自主编排
- **侦察 Agent**:子域名枚举、服务指纹识别、端口扫描和 OSINT 聚合。
- **漏洞利用 Agent**:动态 CVE 查找、漏洞利用路由和漏洞验证。
- **武器化 Agent**:自定义 payload 生成、沙箱语法验证和混淆。
- **目标与持久化 Agent**:后渗透验证、目标图扩展和提权路径映射。
- **报告 Agent**:生成全面的执行摘要、技术漏洞详情、CVSS 评分和可操作的修复步骤。
### 🌐 4. 灵活的执行环境
- **WSL2 与原生 Linux 执行**:通过原生 Linux shell 或 WSL 集成无缝执行安全工具(例如 `nmap`、`nuclei`、`sqlmap`、`ffuf`、`subfinder`、`httpx`、`amass`)。
- **VPS 与远程执行**:支持远程 SSH 执行和 VPS 资源池管理,用于分布式评估。
- **IP 轮换与隐秘代理**:集成的代理链能力和 TOR/VPS 路由,以防止 IP 被封禁。
## 🏗️ 架构
```
┌───────────────────────────────┐
│ Target Objective & Scope │
└───────────────┬───────────────┘
│
┌───────────────▼───────────────┐
│ Strategic AI Advisor │
│ (Persistent Knowledge Base) │
└───────────────┬───────────────┘
│
┌────────────────────────────────────────┼────────────────────────────────────────┐
│ │ │
┌──────▼────────────────┐ ┌──────────▼───────────┐ ┌───────────────▼────────┐
│ Reconnaissance Agent │ │ Self-Awareness Module│ │ WAF Evasion Engine │
│ (Subdomain/Ports/Web) │ │ (Knowledge & Gaps) │ │ (Fingerprint & Bypass) │
└──────┬────────────────┘ └──────────┬───────────┘ └───────────────┬────────┘
│ │ │
└────────────────────────────────────────┼────────────────────────────────────────┘
│
┌───────────────▼───────────────┐
│ Attack Graph Engine │
│ (Finding Scorer & CVEs) │
└───────────────┬───────────────┘
│
┌────────────────────────────────────────┴────────────────────────────────────────┐
│ │
┌──────▼────────────────┐ ┌────────▼───────────────┐
│ Exploitation Agent │ │ Reporting & Analytics │
│ (PoC & Verification) │ │ (HTML/JSON/MD Reports) │
└───────────────────────┘ └────────────────────────┘
```
## 📁 代码库结构
```
ghostwire-v7/
├── agents/ # Autonomous Specialized Agents
│ ├── base_agent.py # Core Agent base class & LLM interaction loop
│ ├── recon_agent.py # Passive & Active Reconnaissance logic
│ ├── exploitation_agent.py # Target exploitation & vulnerability validation
│ ├── weaponization_agent.py # Payload sandboxing & obfuscation
│ ├── persistence_agent.py # Attack path expansion & post-exploitation
│ ├── objectives_agent.py # Goal tracking & target state analysis
│ └── reporting_agent.py # Technical & Executive report generation
├── core/ # Engine Core & Execution Handlers
│ ├── orchestrator.py # Central engine controller & state manager
│ ├── ai_backend.py # Multi-provider LLM API client wrapper
│ ├── capability_registry.py # Tool capability definitions & execution wrappers
│ ├── wsl_executor.py # WSL2 Linux bridge for Windows host
│ ├── ip_rotator.py # Dynamic proxy & IP rotation controller
│ ├── target_graph.py # Attack surface node-link graph
│ └── waf_ghost_engine.py # Core WAF detection & payload mutation pipeline
├── intelligence/ # AI Intelligence & Learning Modules
│ ├── strategic_advisor.py # Historical learning & tool recommendations
│ ├── self_awareness_module.py # Confidence tracking & knowledge gap analysis
│ ├── reasoning_engine.py # Multi-step strategic attack planner
│ ├── cve_database.py # Technology-to-CVE mapper
│ ├── finding_scorer.py # Severity, confidence & priority calculator
│ └── waf_evasion_engine.py # WAF tactic strategy selector
├── tools/ # Tool Integration & Execution Wrappers
│ ├── tool_manager.py # Native CLI tool execution & timeout handlers
│ └── output_parser.py # Standardized JSON parser for security tool output
├── config.py # Global system configuration & safety thresholds
├── main.py # CLI entrypoint & interactive shell
└── requirements.txt # Python dependencies
```
## 🚀 安装与设置
### 前置条件
- **操作系统**:Linux(推荐 Ubuntu 22.04+)或安装了 **WSL2** 的 Windows 10/11。
- **Python**:Python 3.10 或更高版本。
- **安全工具**(安装在 Linux/WSL 上):`nmap`、`nuclei`、`sqlmap`、`subfinder`、`httpx`、`ffuf`、`amass`。
### 步骤 1:克隆代码库
```
git clone https://github.com/0xeni0l/red-team-V2.git
cd red-team-V2
```
### 步骤 2:设置虚拟环境与依赖
```
python3 -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
pip install -r requirements.txt
```
### 步骤 3:配置环境 (.env)
在根目录下创建一个 `.env` 文件:
```
# LLM API Provider Keys
GEMINI_API_KEY=your_gemini_api_key_here
OPENAI_API_KEY=your_openai_api_key_here
ANTHROPIC_API_KEY=your_anthropic_api_key_here
# OSINT API Keys(可选但推荐)
SHODAN_API_KEY=your_shodan_key
SECURITYTRAILS_API_KEY=your_securitytrails_key
VIRUSTOTAL_API_KEY=your_virustotal_key
# WSL Configuration(如果在 Windows 主机上运行)
USE_WSL=true
WSL_DISTRO=Ubuntu
```
## 💻 用法
### 1. 交互模式
运行 Ghostwire 的 CLI shell 以启动引导式交战:
```
python main.py
```
### 2. 自主目标评估
针对目标域名启动自动化的全面范围评估:
```
python main.py --target example.com --mode full --output ./reports/example_scan
```
### 3. 仅侦察模式
```
python main.py --target example.com --mode recon
```
## 🔒 安全与法律免责声明
Ghostwire V7 包含强制性的安全约束和范围执行保障措施:
- **书面授权保障**:内置确认标志,在执行主动扫描之前验证授权。
- **严格的范围外拦截**:自动丢弃超出明确授权列表的任何目标 IP/域名。
- **熔断系统**:通过强制执行速率限制和监控服务器响应健康状况,防止意外的 DoS 状况。
## 📜 许可证
在 **MIT License** 下分发。有关更多信息,请参阅 `LICENSE`。标签:CISA项目, PyRIT, Web报告查看器, XXE攻击, 人工智能, 多智能体系统, 用户模式Hook绕过, 运行时操纵, 逆向工具