thecnical/aegis
GitHub: thecnical/aegis
一个 AI 驱动的自动化渗透测试平台,通过统一 CLI 与工作区管理,将侦察、漏洞利用与报告整合为端到端可追溯的安全工作流。
Stars: 2 | Forks: 0
```
░█████╗░███████╗░██████╗░██╗░██████╗
██╔══██╗██╔════╝██╔════╝░██║██╔════╝
███████║█████╗░░██║░░██╗░██║╚█████╗░
██╔══██║██╔══╝░░██║░░╚██╗██║░╚═══██╗
██║░░██║███████╗╚██████╔╝██║██████╔╝
╚═╝░░╚═╝╚══════╝░╚═════╝░╚═╝╚═════╝
```
### ⚔ AI驱动的自主渗透测试平台 ⚔
[](https://python.org)
[](LICENSE)
[](https://github.com/thecnical/aegis/actions)
[](https://github.com/thecnical/aegis/releases)
[](https://kali.org)
[](https://github.com/astral-sh/ruff)
[](https://mypy-lang.org)
[](https://pypi.org/project/aegis-cli/)
[](https://github.com/PyCQA/bandit)
[](https://buymeacoffee.com/chandanpandit)
```
┌─ 15+ Attack Modules · 10+ WAF Vendors · 100% Free & Open Source ─┐
│ Recon → Vuln → Exploit → Post → Report │
│ AI selects tools. AI reads output. AI decides next. │
└────────────────────────────────────────────────────────────────────────┘
```
```
# 完整自主渗透测试 — 一键式
aegis ai auto --target example.com --full --format html
```
## 资源
### 架构思维导图
📄 Whitepaper / PDF View PDF → |
📊 Slide Deck / PPTX Download Slides → |
| **自主安全白皮书** | **高管战略演示** |
|:---:|:---:|
| [](Aegis_Autonomous_Security.pdf) | [](Aegis_Autonomous_Security.pptx) |
| [📄 下载 PDF](Aegis_Autonomous_Security.pdf) | [📊 下载 PPTX](Aegis_Autonomous_Security.pptx) |
## 架构
```
┌──────────────────────────────────────────────────────────────────┐
│ CLI Layer (Click — main.py) │
│ recon · vuln · exploit · ai · burp · cve · campaign · report │
├──────────────────────────────────────────────────────────────────┤
│ Core Layer (aegis/core/) │
│ AIOrchestrator · CampaignRunner · BurpImporter │
│ CVECorrelator · SARIFExporter · TemplateManager · Notifier │
├──────────────────────────────────────────────────────────────────┤
│ Tools Layer (aegis/tools/) │
│ recon/ · vuln/ · exploit/ · post/ · report/ │
│ Each module is a Click command that writes findings to the DB │
├──────────────────────────────────────────────────────────────────┤
│ Storage Layer (SQLite per workspace) │
│ targets · hosts · ports · findings · evidence │
│ cve_correlations · scan_sessions · scope · api_tokens │
└──────────────────────────────────────────────────────────────────┘
```
**数据流:** 工具运行 → 输出解析 → `db.add_finding()` → AI 分级 → 生成报告 → 导出 SARIF → CI/CD 通知。
## 安装
### 选项 1 — 一键安装(推荐)
安装所有内容:apt 包、Go、Rust、subfinder、nuclei、trufflehog、gowitness、amass、feroxbuster、webtech 以及 Aegis 自身。
```
git clone https://github.com/thecnical/aegis.git
cd aegis
sudo bash install.sh
```
预览而不执行更改:
```
sudo bash install.sh --dry-run
```
若 Aegis 已安装,请使用内置引导命令:
```
sudo aegis bootstrap --yes
# 如果不需要,请跳过 Rust/feroxbuster
sudo aegis bootstrap --yes --skip-rust
# 仅预览
aegis bootstrap --dry-run
```
安装完成后,打开新终端:
```
aegis doctor # verify all tools are found
aegis ai auto --target example.com # run your first pentest
```
### 选项 2 — 手动安装(Kali Linux)
**1. 系统依赖**
```
sudo apt update
sudo apt install -y python3-pip python3-venv git \
libpango-1.0-0 libpangoft2-1.0-0 libpangocairo-1.0-0 \
libcairo2 libffi-dev libgdk-pixbuf-2.0-0
```
**2. 克隆并创建虚拟环境**
```
git clone https://github.com/thecnical/aegis.git
cd aegis
python3 -m venv .venv
source .venv/bin/activate
```
**3. 安装 Aegis**
```
pip install -e .
```
**4. 创建目录并验证**
```
mkdir -p data/logs
aegis doctor
```
**5. 安装外部工具**
```
aegis install-tools --yes
```
### 选项 3 — PyPI
```
pip install aegis-cli
pip install "aegis-cli[mcp]" # include MCP server support
pip install -e ".[dev]" # development dependencies
```
## 快速开始
```
# 1. 将目标添加到范围
aegis scope add example.com --kind domain
# 2. 运行侦察
aegis recon domain example.com
# 3. 扫描漏洞
aegis vuln web https://example.com
# 4. 生成报告
aegis report generate example.com --format html
# 5. 或使用一条命令完成以上所有操作
aegis ai auto --target example.com --format html --full
```
## 完整使用指南
### Hydra 暴力破解(真实凭证测试)
```
# 使用默认凭据测试 SSH(需要 --force 绕过 safe_mode)
aegis vuln net 192.168.1.1 --service ssh --force
# 同时测试所有服务
aegis vuln net 192.168.1.1 --service all --force
# 使用自定义单词表
aegis vuln net 192.168.1.1 --service ssh \
--userlist /usr/share/wordlists/users.txt \
--passlist /usr/share/wordlists/rockyou.txt --force
# 仅 WAF 检测(不进行暴力破解)
aegis vuln net 192.168.1.1 --no-brute --url http://192.168.1.1
```
### HTTP 证据捕获(每个发现均有证明)
```
# Web 扫描 — 为每个发现捕获完整的 HTTP 请求/响应
aegis vuln web https://example.com
# 认证扫描 — 传递会话 Cookie
aegis vuln web https://example.com --cookies "session=abc123; csrf=xyz"
# 使用自定义认证头(Bearer 令牌、API 密钥等)
aegis vuln web https://example.com --header "Authorization: Bearer eyJ..."
# 针对特定漏洞类型
aegis vuln web https://example.com --tags "cve,sqli,xss"
```
### WAF 检测
```
# 在运行任何利用程序之前检测 WAF
aegis vuln net 192.168.1.1 --no-brute --no-smb --url https://example.com
# WAF 检测在 ai auto 模式下自动运行
aegis ai auto --target example.com
# 如果检测到 WAF,请使用隐身式配置文件以减少噪音
aegis --profile stealth vuln web https://example.com
```
### PostgreSQL(团队/并发使用)
```
# 安装驱动
pip install psycopg2-binary
# 创建数据库
createdb aegis
psql aegis -c "CREATE USER aegis WITH PASSWORD 'yourpassword';"
psql aegis -c "GRANT ALL ON DATABASE aegis TO aegis;"
# 更新 config/config.yaml:
# db_path: "postgresql://aegis:yourpassword@localhost:5432/aegis"
```
### 认证扫描(登录后)
```
# 手动登录,获取会话 Cookie,然后进行扫描
aegis vuln web https://app.example.com/dashboard \
--cookies "sessionid=abc123def456" \
--header "X-CSRF-Token: token123"
# 使用 Bearer 令牌进行 API 扫描
aegis vuln web https://api.example.com \
--header "Authorization: Bearer eyJhbGciOiJIUzI1NiJ9..." \
--tags "api,auth"
```
### 全自动测试(端到端)
```
# 1. 设置工作区与范围
aegis workspace create client-acme
aegis workspace switch client-acme
aegis scope add acme.com --kind domain
aegis scope add 10.10.0.0/24 --kind cidr
# 2. 运行完整自主渗透测试
aegis ai auto --target acme.com --full --format html
# 3. 分级与关联
aegis ai triage --session 1
aegis cve correlate --session 1
# 4. 导出以用于 CI/CD
aegis sarif export --session 1 --output results.sarif
```
### 凭证收集(后渗透)
```
# 列出 SMB 共享
aegis post creds --target 192.168.1.10
# 深度扫描 — 下载并扫描文件中的密码/令牌
aegis post creds --target 192.168.1.10 --deep
```
### pivoting(内网)
```
# 通过受损主机使用 SOCKS5 代理
aegis post pivoting 10.0.0.0/24 --ssh user@192.168.1.10
# 通过代理扫描内部网络
aegis post pivoting 10.0.0.0/24 --ssh user@192.168.1.10 --scan
# 端口转发:通过本地端口 3390 访问内部 RDP
aegis post pivoting 10.0.0.0/24 --ssh user@192.168.1.10 \
--forward 3390:10.0.0.5:3389
```
### Metasploit 集成
```
# 自动匹配目标的所有发现到 MSF 模块
aegis exploit msf 192.168.1.1 --force
# 运行特定的 MSF 模块(仅检查 — 不进行利用)
aegis exploit msf 192.168.1.1 --module exploit/windows/smb/ms17_010_eternalblue \
--check --force
# 从特定发现 ID 运行
aegis exploit msf 192.168.1.1 --finding-id 42 --lhost 10.10.10.1 --force
# 使用 Metasploit RPC API(需要:msfrpcd -P yourpassword -S -f)
aegis exploit msf 192.168.1.1 --rpc-host 127.0.0.1 --rpc-pass yourpassword --force
```
### HTTP 请求走私
```
# 测试 CL.TE、TE.CL、TE.TE desync 漏洞
aegis vuln smuggling https://example.com
# 测试特定路径
aegis vuln smuggling https://example.com --path /api/v1/users
# 调整超时(超时越长 = 定时检测越敏感)
aegis vuln smuggling https://example.com --timeout 20
```
### 云资产发现
```
# 发现暴露的 S3、Azure Blob、GCP Storage 存储桶
aegis recon cloud example.com
# 跳过特定提供者
aegis recon cloud example.com --no-azure --no-gcp
# 使用自定义存储桶名称单词表
aegis recon cloud example.com --wordlist /path/to/buckets.txt
```
### Active Directory 枚举
```
# 匿名枚举(无需凭据)
aegis recon ad 192.168.1.10 --domain corp.local
# 使用凭据进行完整枚举
aegis recon ad 192.168.1.10 --domain corp.local \
--username administrator --password Password123
# 在 BloodHound 收集完成后,导入到 BloodHound GUI:
# bloodhound → 上传数据 → 选择 data/ad/bloodhound/ 中的 zip 文件
# 运行查询:“查找通向域管理员的最短路径”
```
### OOB SSRF/XXE 检测
```
# 使用 interactsh 自动检测
# 安装:go install github.com/projectdiscovery/interactsh/cmd/interactsh-client@latest
aegis exploit oob https://example.com --force
# 使用自定义回调域(Burp Collaborator 等)
aegis exploit oob https://example.com --callback your.burpcollaborator.net --force
# 同时测试 XXE(向端点发送 XML 有效载荷)
aegis exploit oob https://example.com --test-xxe --force
# 等待更长时间以获取异步回调
aegis exploit oob https://example.com --wait 30 --force
```
## 配置
所有设置位于 `config/config.yaml`。Aegis 从不读取环境变量中的密钥。
```
general:
db_path: data/aegis.db
safe_mode: true # abort if target is out of scope
wordlists_path: data/wordlists
api_keys:
shodan: CHANGE_ME # https://shodan.io (free tier available)
openrouter: CHANGE_ME # https://openrouter.ai (free tier available)
bytez: CHANGE_ME # https://bytez.com (free tier available)
nvd: CHANGE_ME # https://nvd.nist.gov/developers/request-an-api-key (free)
notifications:
slack_webhook: ""
discord_webhook: ""
profiles:
default:
timeout: 30
nmap_args: "-sC -sV"
nuclei_rate: 150
stealth:
timeout: 120
nmap_args: "-sS -T2 --randomize-hosts"
nuclei_rate: 20
deep:
timeout: 90
nmap_args: "-sC -sV -A -O --script=vuln"
nuclei_rate: 50
```
通过 `--profile stealth` 切换配置文件。所有 API 密钥均有免费层级 — 无需付费订阅。
**全局 CLI 标志:**
| 标志 | 默认值 | 描述 |
|---|---|---|
| `--config PATH` | `config/config.yaml` | 配置文件路径 |
| `--profile NAME` | `default` | 扫描配置文件 |
| `--workspace NAME` | 活动工作区 | 覆盖当前工作区 |
| `--json` | 关闭 | 以 JSON 格式输出 |
| `--json-output FILE` | — | 将 JSON 写入文件 |
| `--debug` | 关闭 | 启用调试日志 |
## 工作区
每次演练拥有独立的 SQLite 数据库。工作区之间无共享状态。
```
aegis workspace create client-acme # create a new workspace
aegis workspace switch client-acme # switch to it
aegis workspace list # list all workspaces
aegis workspace delete old-engagement # remove a workspace
# 在不切换的情况下覆盖单个命令
aegis --workspace client-acme recon domain acme.com
```
## 范围管理
在任何工具运行前,`ScopeManager` 检查目标是否在范围内。启用 `safe_mode: true` 时,超出范围的扫描会在发起网络请求前中止。
```
aegis scope add acme.com --kind domain
aegis scope add 10.10.0.0/16 --kind cidr
aegis scope add https://api.acme.com --kind url
aegis scope add 192.168.1.5 --kind ip
aegis scope list
aegis scope remove 3
```
## 侦察
```
# 子域名枚举、DNS、Nmap 扫描已发现主机
aegis recon domain example.com
# CIDR 范围扫描 — 主机、端口、服务
aegis recon network 192.168.1.0/24 --port-scan
# DNS 记录查询
aegis recon dns example.com --types A,MX,TXT,NS,AAAA
# OSINT — 电子邮件、GitHub 关键词、Shodan
aegis recon osint example.com --emails --github-dorks
# 秘密扫描(trufflehog)
aegis recon secrets /path/to/project
aegis recon secrets https://github.com/target/repo --mode git
# 所有 Web 服务的截图(gowitness)
aegis recon screenshot example.com
aegis recon screenshot . --from-db
```
## 漏洞扫描
```
# 通过 Nuclei 模板进行 Web 漏洞扫描
aegis vuln web https://example.com
# 通过 Nmap NSE 脚本进行网络漏洞扫描
aegis vuln net 192.168.1.1
# 通过 testssl.sh 进行 SSL/TLS 分析
aegis vuln ssl example.com --port 443
# 通过 ffuf 进行 API 模糊测试
aegis vuln api https://api.example.com --wordlist data/wordlists/api.txt
```
## 技术检测
Aegis 使用免费开源工具 — 无需付费 API 密钥。
| 工具 | 安装 | 说明 |
|---|---|---|
| **webtech** | `pip install webtech` | 通过头部、HTML、Cookie 指纹识别 |
| **whatweb** | `sudo apt install whatweb` | Kali Linux 预装 |
Aegis 优先尝试 `webtech`,若不可用则自动回退到 `whatweb`。
```
aegis recon domain example.com # tech detection runs automatically
aegis recon domain example.com --no-techdetect # skip if not needed
```
## AI 功能
### 自主模式
```
# 完整渗透测试 — 侦察、漏洞、AI 分级、报告
aegis ai auto --target example.com
# 全部 5 个阶段 + HTML 报告
aegis ai auto --target example.com --full --format html
# 试运行 — 查看将在不执行的情况下运行的内容
aegis ai auto --target example.com --dry-run
```
### AI 分级与分析
```
aegis ai triage --session 1 # triage findings from a session
aegis ai summarize --session 1 # executive summary
aegis ai suggest --target acme.com # attack surface suggestions
aegis ai report --target acme.com # generate narrative report section
aegis ai chat # interactive AI chat about findings
```
### AI 载荷生成
在 `aegis ai auto` 中,复勘完成后 AI 会自动生成针对性载荷(SQLi、XSS、LFI、SSRF、RCE),基于检测到的技术栈。载荷存储为 `medium` 严重性、类别 `ai-payload`。使用免费的 OpenRouter 或 Bytez 密钥。
## MCP 服务器 — AI 代理集成
Aegis 可作为 [MCP](https://modelcontextprotocol.io) 服务器运行,使 AI 代理(如 Claude、Cursor)能够自主驱动完整渗透测试。
```
pip install mcp
aegis-mcp
```
添加到你的 Claude / Cursor MCP 配置:
```
{
"mcpServers": {
"aegis": {
"command": "python",
"args": ["-m", "aegis.mcp_server"]
}
}
}
```
可用 MCP 工具:
| 工具 | 描述 |
|---|---|
| `aegis_recon_domain` | 子域名枚举 + 技术检测 |
| `aegis_vuln_web` | Nuclei Web 漏洞扫描 |
| `aegis_ai_auto` | 完整自动渗透测试 |
| `aegis_get_findings` | 从数据库查询发现结果 |
| `aegis_generate_report` | 生成报告 |
| `aegis_scope_add` | 将目标添加到范围 |
| `aegis_secrets_scan` | 扫描暴露的密钥 |
## 报告
```
# Markdown 报告
aegis report generate example.com --format md
# 带有 D3.js 攻击路径图的 HTML 报告
aegis report generate example.com --format html
# PDF 报告
aegis report generate example.com --format pdf
# 按最低严重性过滤
aegis report generate example.com --format html --min-severity high
```
HTML 报告包含交互式 D3.js 力导向攻击路径图 — 蓝色节点表示主机,彩色节点表示按严重性分类的发现,边表示关系。
## Burp Suite 集成
```
# 从 Burp XML 导出导入发现
aegis burp import scan.xml
# 在不导入的情况下预览
aegis burp import scan.xml --dry-run
# 列出所有 Burp 导入的发现
aegis burp list
```
## CVE 关联
```
# 在会话中关联所有发现与 NVD CVE
aegis cve correlate --session 1
# 直接搜索 NVD
aegis cve search "apache log4j" --max 10
# 列出与特定发现关联的 CVE
aegis cve list --finding 42
```
## 活动演练
并行扫描多个目标并跟踪结果。
```
# 创建活动
aegis campaign create q4-audit --domain acme.com
# 运行它
aegis campaign run q4-audit --full
# 并行运行针对目标列表的活动
aegis campaign run-parallel q4-audit --targets targets.txt --max-parallel 5
# 比较两次运行
aegis campaign diff q4-audit
# 生成活动报告
aegis campaign report q4-audit
```
## 通知
在 `config/config.yaml` 中配置 Webhook:
```
# 发送测试通知
aegis notify test --channel slack
# 从会话发送发现
aegis notify send --session 1 --min-severity high --channel discord
```
## SARIF 导出
```
# 导出所有发现为 SARIF v2.1.0
aegis sarif export
# 导出特定会话
aegis sarif export --session 1 --output results.sarif
```
通过 `github/codeql-action/upload-sarif` 操作上传到 GitHub Code Scanning,实现 PR 内联注释。
## 卸载
```
aegis uninstall --dry-run # preview only
aegis uninstall --yes # remove Aegis and tools
aegis uninstall --yes --remove-data # also delete databases and reports
aegis uninstall --yes --remove-data --remove-config # full clean
```
## 开发
```
git clone https://github.com/thecnical/aegis.git
cd aegis
python3 -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
pytest --tb=short # run tests
ruff check . # lint
mypy aegis/ # type check
```
## 路线图
**近期目标**
- Metasploit 会话管理 — 从 CLI 交互已打开的 Shell
- 云资产枚举扩展 — Route53、Azure DNS、GCP DNS 区域传输
- 被动 JS 端点提取(侦察阶段)
- OOB DNS 仅模式(无需 interactsh 依赖)
**中期目标**
- 自主漏洞利用链 — AI 选择并串联利用基于已确认漏洞的利用
- 自定义 Nuclei 模板生成 — AI 为发现的端点编写 YAML 模板
- Active Directory 攻击路径执行 — 自动运行 BloodHound 建议的攻击路径
- Kerberoasting 与 AS-REP 轮换集成
**研究级**
- 使用 `boofuzz` 进行协议级模糊测试并与发现结果关联
- WAF/IDS 绕过使用 AI 生成的混淆载荷
- CVE 到 PoC 自动映射 — 关联 NVD CVE、ExploitDB 与 GitHub PoC
- LLM 生成针对确认漏洞的定制利用代码
## 贡献
欢迎提交 Pull Request。重大变更请先打开 Issue。
提交前请确保 `ruff check .` 与 `mypy aegis/` 通过。
## 支持
如果 Aegis 为你的演练节省时间或帮助学习进攻安全,请考虑支持该项目。
[](https://buymeacoffee.com/chandanpandit)
## 许可证
MIT — 详见 [LICENSE](LICENSE)。标签:AI驱动, CI集成, Python, XML 请求, 代理智能, 免费, 安全开发, 安全测试, 开源, 开源框架, 持续集成, 攻击性安全, 无后门, 渗透测试平台, 用户模式钩子绕过, 类型检查, 结构化信息, 自主渗透测试, 自动化渗透, 请求拦截, 逆向工具