
# pentest-ai
**将 Claude Code 转变为您的进攻性安全研究助手。**
28 个专业 AI 子代理,涵盖授权渗透测试的各个阶段,从范围界定到报告生成。6 个 Tier 2 代理可直接执行工具(需经您批准)。自主漏洞利用链。经 PoC 验证的发现。代理集群编排。业务逻辑缺陷检测。CI/CD 流水线集成。映射 MITRE ATT&CK。每个响应均包含攻防双重视角。
[](LICENSE)
[](https://docs.anthropic.com/en/docs/claude-code)
[](https://attack.mitre.org/)
[]()
[](CHANGELOG.md)
[]()
[]()
[]()
[](https://github.com/0xSteph/pentest-ai/stargazers)
[](https://github.com/0xSteph/pentest-ai/network/members)
[](https://github.com/0xSteph/pentest-ai/commits/main)
[](https://github.com/0xSteph/pentest-ai/issues)
[入门指南](#quick-start) | [代理](#agents) | [示例](#examples) | [文档](#documentation) | [更新日志](CHANGELOG.md) | [主页](https://0xsteph.github.io/pentest-ai/)
## 目录
- [这是什么?](#what-is-this)
- [代理](#agents)
- [工作流程](#workflow)
- [pentest-ai 与手动研究对比](#pentest-ai-vs-manual-research)
- [pentest-ai 的独特之处](#how-pentest-ai-is-different)
- [使用场景](#use-cases)
- [快速开始](#quick-start)
- [在容器中运行工具](#running-tools-in-a-container)
- [代理路由原理](#how-agent-routing-works)
- [示例](#examples)
- [前置条件](#prerequisites)
- [常见问题](#faq)
- [文档](#documentation)
- [贡献](#contributing)
- [法律声明](#legal)
- [许可证](#license)
## 这是什么?
pentest-ai 是一个包含 28 个 Claude Code 子代理的集合:这些专业的 AI 助手会根据您正在进行的任务自动激活。让 Claude 规划一次渗透测试,任务规划代理(Engagement Planner)就会接管。粘贴 Nmap 输出,侦察顾问(Recon Advisor)会对其进行分析。需要对 AD 环境进行 Kerberoasting?AD 攻击代理会为您构建并运行 Impacket 命令。每个代理都具备进攻性安全方法论、MITRE ATT&CK 映射以及行业标准框架方面的深厚领域知识。
您无需成为专家即可使用这些代理。它们可以根据您的需求以任何级别进行交流,从解释什么是 Kerberoasting 到为高级操作员提供精确的 Impacket 命令语法。
### 工作原理
1. **安装**代理文件到您的 Claude Code 代理目录
2. **打开 Claude Code** 并自然地描述您的任务
3. **Claude 自动路由**到相应的专业代理
无需配置,无需记忆命令。只需描述您的需求即可。
### 快速演示:咨询模式(Tier 1)
```
$ claude
You: Analyze this Nmap scan and prioritize targets for our internal pentest
▸ Routing to recon-advisor agent...
## 优先目标摘要
### 关键优先级 (立即利用)
| Host | Port | Service | Finding |
|------------|------|---------|--------------------------|
| 10.10.1.5 | 445 | SMB | SMBv1 enabled, MS17-010 |
| 10.10.1.20 | 3389 | RDP | BlueKeep (CVE-2019-0708) |
### 建议的后续步骤
1. nmap -sV --script smb-vuln* 10.10.1.5
2. crackmapexec smb 10.10.1.0/24
3. bloodhound-python -d corp.local
```
### 快速演示:执行模式(Tier 2)
```
$ claude
You: My authorized scope is 10.10.1.0/24. Internal network pentest.
Run a service scan on the subnet.
▸ Routing to recon-advisor agent...
Scope recorded: 10.10.1.0/24 (internal)
I'll start with host discovery, then do targeted service detection
on live hosts.
[MODERATE] Host discovery scan:
nmap -sn 10.10.1.0/24 -oN nmap_10.10.1.0_discovery_20260330_140000.txt
▸ Allow Bash command? [y/n]
Found 47 live hosts. Running service detection on the top ports...
[MODERATE] Service scan on live hosts:
nmap -sT -sV -sC --top-ports 1000 --min-rate 100 --max-rate 1000
--host-timeout 300s -iL live_hosts.txt
-oN nmap_10.10.1.0_services_20260330_140215.txt
▸ Allow Bash command? [y/n]
## 优先目标摘要
| Priority | Host | Port | Service | Finding |
|----------|------------|------|----------------|-----------------------|
| Critical | 10.10.1.5 | 445 | SMB 1.0 | MS17-010 likely |
| Critical | 10.10.1.20 | 3389 | RDP 10.0.17763 | BlueKeep candidate |
| High | 10.10.1.12 | 8080 | Jenkins 2.289 | Pre-auth RCE range |
Evidence saved. Want me to run SMB vulnerability scripts on 10.10.1.5 next?
```
## 代理
### 进攻性操作
| 代理 | 功能 | 示例提示词 |
|-------|-------------|----------------|
| **Engagement Planner(任务规划)** | 采用分阶段方法论规划渗透测试,包含 MITRE ATT&CK 技术映射、时间估算和交战规则模板 | *"Plan an internal network pentest for a 500-endpoint Active Directory environment with a 2-week window"* |
| **Recon Advisor(侦察顾问)** | 解析 Nmap、Nessus、BloodHound 等 20 多种工具的输出。优先排序目标,映射 CVE,并推荐具体的后续命令。**Tier 2:可在您批准后直接执行侦察工具。** | *"Scan 10.10.1.0/24 and tell me what to hit first"* |
| **OSINT Collector(OSINT 收集)** | 开源情报收集:域名侦察、邮箱收集、社交媒体画像、泄露数据分析以及基础设施映射 | *"Build an OSINT profile on this target domain before our external engagement"* |
| **Exploit Guide(漏洞利用指南)** | 详细的漏洞利用方法论,涵盖 AD 攻击、Web 应用、云环境和后渗透。每种技术都包含防御视角 | *"Walk me through AS-REP Roasting and how defenders detect it"* |
| **Privilege Escalation(权限提升)** | 系统化的 Linux 和 Windows 权限提升方法论。SUID 滥用、令牌模拟、服务利用、内核漏洞利用以及容器逃逸 | *"Here's my linpeas output, what's the fastest path to root?"* |
| **Cloud Security(云安全)** | AWS、Azure 和 GCP 渗透测试方法论。IAM 权限提升、容器逃逸、无服务器利用以及云原生攻击路径 | *"I have read-only AWS access with this IAM policy. Find privilege escalation paths"* |
| **API Security(API 安全)** | REST、GraphQL 和 WebSocket 安全测试。OWASP API Top 10、JWT 攻击、OAuth 利用、BOLA/BFLA 测试以及 API 发现 | *"Test this API for BOLA. Here's the Swagger doc and a valid JWT"* |
| **Mobile Pentester(移动端渗透测试)** | Android 和 iOS 应用程序安全测试。APK/IPA 分析、Frida hooking、SSL pinning 绕过、OWASP MASTG/MASVS 方法论 | *"Decompile this APK and check for hardcoded secrets and certificate pinning"* |
| **Wireless Pentester(无线渗透测试)** | WiFi 和蓝牙渗透测试。WPA/WPA2/WPA3 攻击、邪恶双子、恶意 AP、企业无线网络和蓝牙安全 | *"Capture a WPA2 handshake and set up an evil twin for this corporate network"* |
| **Social Engineer(社会工程)** | 针对授权红队交战的钓鱼活动、预设场景、语音钓鱼、物理社会工程以及安全意识评估 | *"Design a phishing campaign for this engagement using GoPhish"* |
| **Vuln Scanner(漏洞扫描)** | 使用 Nuclei、Nikto 和 Nmap NSE 脚本运行漏洞扫描。解析 Nessus 和 OpenVAS 结果。按 CVSS 和漏洞利用可用性进行优先排序。**Tier 2:可在您批准后直接执行扫描。** | *"Run a Nuclei scan on 10.10.1.0/24 for critical and high severity CVEs"* |
| **Web Hunter(Web 猎手)** | 使用 ffuf、gobuster、feroxbuster、sqlmap 和 dalfox 进行 Web 应用程序测试。内容发现、参数模糊测试、虚拟主机枚举和 WAF 检测。**Tier 2:可直接执行 Web 测试工具。** | *"Fuzz directories on https://target.com and check for SQL injection on the login form"* |
| **Credential Tester(凭证测试)** | 密码攻击方法论,涵盖 Hydra、Hashcat、John the Ripper、CrackMapExec 喷洒、Kerbrute 以及自定义字典生成。哈希识别和破解策略 | *"I have these NTLM hashes from a SAM dump. What's the fastest cracking approach?"* |
| **Attack Planner(攻击规划)** | 将所有其他代理的发现关联为多步骤攻击链。按概率、隐蔽性和业务影响对路径进行评分。构建横向移动图谱和攻击链比较矩阵 | *"I have Nmap results, BloodHound data, and some cracked hashes. Build me the best attack chain to DA"* |
| **Bug Bounty Hunter(漏洞赏金猎手)** | 针对 HackerOne、Bugcrowd 和 Intigriti 的漏洞赏金方法论。目标选择、侦察自动化、重复发现避免策略以及能获得赏金的专业报告撰写 | *"Help me write a P1 report for this IDOR I found on HackerOne"* |
| **AD Attacker(AD 攻击)** | 使用 BloodHound、Impacket、CrackMapExec、Certipy 和 Kerbrute 执行 Active Directory 攻击。Kerberos 攻击、委派滥用、ACL 利用和证书滥用。**Tier 2:可在您批准后直接执行 AD 工具。** | *"Kerberoast all service accounts in corp.local and crack the hashes"* |
| **Exploit Chainer(漏洞利用链接器)** | 自主漏洞利用链接,将孤立的低严重性发现转化为完整的系统入侵。每一步都需经您批准执行,并在路径受阻时进行调整。找到信息泄露,将其与弱权限链接,并指导您获取管理员权限。**Tier 2:逐步执行漏洞利用链并需经您批准。** | *"I have these 15 findings from the scan. Chain them into the shortest path to Domain Admin"* |
| **PoC Validator(PoC 验证)** | 自动生成并安全执行概念验证脚本以验证发现。在误报浪费任何人时间之前将其消除。每个确认的漏洞都附带可重现的证据。**Tier 2:可在您批准后执行安全的、非破坏性的 PoC。** | *"Validate these 47 Nuclei findings and tell me which ones are real"* |
| **Swarm Orchestrator(集群编排)** | 作为红队集群协调所有其他代理的管理代理。将侦察、扫描、利用和报告分配给专家。运行并行工作流,跟踪进度,并将结果汇编成统一的任务全景。模拟真实人类红队的运作方式。 | *"Run a full automated red team assessment against my staging environment"* |
| **Business Logic Hunter(业务逻辑猎手)** | 发现标准扫描器遗漏的漏洞:价格篡改、工作流绕过、竞态条件、授权逻辑缺陷和功能滥用。理解预期的应用程序工作流,并积极寻找破坏业务规则的方法。**Tier 2:可在您批准后执行业务逻辑测试。** | *"Test this e-commerce checkout flow for price manipulation and race conditions"* |
| **CI/CD Red Team(CI/CD 红队)** | 将红队测试直接集成到 CI/CD 流水线中。为 GitHub Actions、GitLab CI 和 Jenkins 生成即用型配置。在每次代码推送时自动运行安全扫描,并配置安全门控,在发现关键问题时阻止部署。 | *"Generate a GitHub Actions workflow that runs security scans on every PR"* |
### 防御与分析
| 代理 | 功能 | 示例提示词 |
|-------|-------------|----------------|
| **Detection Engineer(检测工程师)** | 生成可部署的检测规则,支持 Sigma、Splunk SPL、Elastic KQL 和 Sentinel KQL,并提供误报调优指导 | *"Create a detection rule for DCSync with Sigma and Splunk SPL"* |
| **Threat Modeler(威胁建模)** | STRIDE/DREAD 威胁建模、攻击树构建、数据流分析以及针对特定架构的威胁枚举 | *"Build a STRIDE threat model for our microservices API gateway"* |
| **Forensics Analyst(取证分析师)** | 数字取证和事件响应。证据获取、内存取证、磁盘分析、时间线构建和证据保管链 | *"Walk me through a Volatility 3 workflow for this memory dump"* |
| **Malware Analyst(恶意软件分析师)** | 二进制分析、逆向工程、沙箱方法论、YARA 规则编写和 IOC 提取 | *"Analyze this suspicious PE file. Start with static analysis then walk me through Ghidra"* |
| **STIG Analyst(STIG 分析师)** | DISA STIG 合规性分析,包含 GPO 修复路径、风险评分、验证命令和保留例外(keep-open)理由模板 | *"Analyze V-220768, what breaks if I apply it, and write a keep-open justification"* |
### 报告与学习
| 代理 | 功能 | 示例提示词 |
|-------|-------------|----------------|
| **Report Generator(报告生成)** | 将原始发现转化为专业的渗透测试报告,包含执行摘要、CVSS 评分、证据格式化和修复路线图 | *"Compile these 12 findings into a professional report with an executive summary"* |
| **CTF Solver(CTF 解题)** | 针对 HackTheBox、TryHackMe 和竞技 CTF 的系统性挑战解题伙伴。涵盖 Web 利用、二进制利用、逆向工程、密码学、取证和 OSINT | *"I'm stuck on this HackTheBox machine. I have a low-priv shell. Help me enumerate for privesc"* |
代理功能一览
```
OFFENSIVE OPERATIONS
engagement-planner ── PTES, OWASP, NIST 800-115, MITRE ATT&CK
Rules of engagement templates
Phased methodology with time estimates
recon-advisor ─────── Nmap, Nessus, BloodHound, masscan, Shodan + 20 more
CVE mapping and attack surface prioritization
Specific follow-up commands for each finding
osint-collector ───── Subfinder, Amass, theHarvester, Sherlock, Shodan
Domain, email, identity, and organization intelligence
Passive vs active classification with OPSEC notes
exploit-guide ─────── Active Directory (Kerberoasting, DCSync, delegation attacks)
Web apps (OWASP Top 10, API security, deserialization)
Cloud (AWS, Azure, GCP privilege escalation)
MANDATORY defensive perspective for every technique
privesc-advisor ───── Linux (SUID, capabilities, cron, kernel exploits)
Windows (tokens, services, UAC bypass, DLL hijacking)
GTFOBins and LOLBAS reference for every binary
cloud-security ────── AWS (Pacu, ScoutSuite), Azure (ROADtools, AzureHound), GCP
IAM privilege escalation and role chaining
Container escape and Kubernetes attacks
api-security ──────── OWASP API Top 10 (2023) full coverage
JWT, OAuth 2.0, GraphQL, WebSocket testing
BOLA/BFLA methodology with HTTP request examples
mobile-pentester ──── Android (jadx, Frida, Drozer, apktool)
iOS (class-dump, Objection, Cycript, lldb)
OWASP MASTG/MASVS compliance mapping
wireless-pentester ── WPA/WPA2/WPA3, WPS, PMKID, KRACK
Evil twin, rogue AP, enterprise 802.1X attacks
Bluetooth Classic and BLE security testing
social-engineer ───── GoPhish, King Phisher, Evilginx2
Phishing, vishing, SMiShing, physical SE
Pretexting frameworks and campaign metrics
vuln-scanner ──────── Nuclei, Nikto, Nmap NSE, Nessus/OpenVAS parsing
CVE mapping with exploit availability assessment
False positive filtering and chain identification
[Tier 2: executes scans with user approval]
web-hunter ────────── ffuf, gobuster, feroxbuster, sqlmap, dalfox
Content discovery, parameter fuzzing, vhost enum
WAF detection and bypass, technology fingerprinting
[Tier 2: executes web tools with user approval]
credential-tester ─── Hydra, Hashcat, John, CrackMapExec, Kerbrute
Password spraying with lockout awareness
Hash identification, wordlist generation, rule attacks
attack-planner ────── Multi-step attack chain correlation
Path scoring: probability x stealth x impact
Lateral movement mapping and chain comparison
Correlates findings from all other agents
bug-bounty ────────── HackerOne, Bugcrowd, Intigriti methodology
Report writing for maximum payout
Duplicate avoidance and recon automation
Business logic flaw hunting methodology
ad-attacker ───────── BloodHound, Impacket, CrackMapExec, Certipy
Kerberoasting, DCSync, delegation abuse, RBCD
ACL exploitation and certificate abuse (ESC1-ESC8)
[Tier 2: executes AD tools with user approval]
exploit-chainer ───── Autonomous multi-step exploit chain execution
Chains low-severity findings into full compromise
Step-by-step pivoting with approval at each gate
Chain scoring: reach x reliability x stealth x speed
[Tier 2: executes chain steps with user approval]
poc-validator ─────── Automatic PoC generation and safe execution
False positive elimination via verified exploitation
Batch validation of scanner output (Critical first)
Non-destructive canary-based proof of concept
[Tier 2: executes safe PoCs with user approval]
swarm-orchestrator ── Red team swarm coordination and task delegation
Parallel agent workstreams with progress tracking
7-phase engagement lifecycle management
Agent conflict resolution and handoff orchestration
bizlogic-hunter ───── Price manipulation and payment tampering detection
Workflow bypass and state machine abuse
Race condition testing (double-spend, concurrent claims)
Authorization logic and multi-tenant isolation testing
[Tier 2: executes logic tests with user approval]
cicd-redteam ──────── GitHub Actions, GitLab CI, Jenkins pipeline configs
3-tier scanning: per-push, per-PR, scheduled
Security gates with configurable thresholds
Trend tracking across pipeline runs
DEFENSE & ANALYSIS
detection-engineer ── Sigma, Splunk SPL, Elastic KQL, Sentinel KQL, YARA
False positive analysis and tuning guidance
Threat hunting hypotheses and queries
threat-modeler ────── STRIDE and DREAD analysis frameworks
Attack tree construction and data flow diagrams
Architecture-specific threat enumeration
forensics-analyst ─── Volatility 2/3, Autopsy, Sleuth Kit, Plaso
Memory, disk, network, and cloud forensics
Timeline analysis and chain of custody
malware-analyst ───── IDA Pro, Ghidra, x64dbg, Radare2
Static/dynamic analysis and sandbox methodology
YARA rule writing and IOC extraction
stig-analyst ──────── Windows, Linux, AD, Network, VMware, Application STIGs
GPO remediation with exact registry paths
Keep-open justification templates for auditors
REPORTING & LEARNING
report-generator ──── PTES/OWASP/SANS report format
Executive summaries for non-technical leadership
CVSS v3.1 scoring and CWE mapping
Remediation roadmaps with priority timelines
ctf-solver ────────── HackTheBox, TryHackMe, PicoCTF, OverTheWire
Web, Pwn, Rev, Crypto, Forensics, OSINT
Methodology-first guidance with learning focus
```
## 工作流程
将代理链接起来形成完整的任务工作流:
```
graph LR
A[OSINT] -->|osint-collector| B[Scope & Plan]
B -->|engagement-planner| C[Reconnaissance]
C -->|recon-advisor| D[Vuln Scanning]
D -->|vuln-scanner| D2[PoC Validation]
D2 -->|poc-validator| E[Web Testing]
E -->|web-hunter| E2[Business Logic]
E2 -->|bizlogic-hunter| F[Attack Chains]
F -->|exploit-chainer| G[Exploitation]
G -->|exploit-guide / ad-attacker| H[Credential Attacks]
H -->|credential-tester| I[Escalation]
I -->|privesc-advisor| J[Detection Rules]
J -->|detection-engineer| K[Final Report]
I -->|report-generator| K
L[CI/CD Pipeline] -->|cicd-redteam| D
M[Swarm Manager] -->|swarm-orchestrator| C
style A fill:#1a1a2e,stroke:#e94560,color:#fff
style B fill:#1a1a2e,stroke:#e94560,color:#fff
style C fill:#1a1a2e,stroke:#e94560,color:#fff
style D fill:#1a1a2e,stroke:#e94560,color:#fff
style E fill:#1a1a2e,stroke:#e94560,color:#fff
style F fill:#1a1a2e,stroke:#e94560,color:#fff
style G fill:#1a1a2e,stroke:#e94560,color:#fff
style H fill:#1a1a2e,stroke:#e94560,color:#fff
style I fill:#1a1a2e,stroke:#e94560,color:#fff
style J fill:#1a1a2e,stroke:#e94560,color:#fff
style K fill:#1a1a2e,stroke:#e94560,color:#fff
```
### 架构
```
graph TD
User[You] --> Claude[Claude Code]
Claude -->|"Gather OSINT"| OC[OSINT Collector]
Claude -->|"Plan a pentest"| EP[Engagement Planner]
Claude -->|"Analyze this scan"| RA[Recon Advisor]
Claude -->|"How do I exploit X?"| EG[Exploit Guide]
Claude -->|"Escalate privileges"| PE[Privesc Advisor]
Claude -->|"Test this cloud env"| CL[Cloud Security]
Claude -->|"Test this API"| AP[API Security]
Claude -->|"Test this app"| MP[Mobile Pentester]
Claude -->|"Test WiFi security"| WP[Wireless Pentester]
Claude -->|"Plan phishing campaign"| SE[Social Engineer]
Claude -->|"Scan for vulns"| VS[Vuln Scanner]
Claude -->|"Fuzz this webapp"| WH[Web Hunter]
Claude -->|"Crack these hashes"| CT[Credential Tester]
Claude -->|"Build attack chain"| AP2[Attack Planner]
Claude -->|"Bug bounty report"| BB[Bug Bounty Hunter]
Claude -->|"Attack this AD"| AD[AD Attacker]
Claude -->|"Chain exploits"| EC[Exploit Chainer]
Claude -->|"Validate findings"| PV[PoC Validator]
Claude -->|"Run full red team"| SO[Swarm Orchestrator]
Claude -->|"Test business logic"| BH[BizLogic Hunter]
Claude -->|"CI/CD security"| CR[CI/CD Red Team]
Claude -->|"Model threats"| TM[Threat Modeler]
Claude -->|"Build a detection rule"| DE[Detection Engineer]
Claude -->|"Analyze this binary"| MA[Malware Analyst]
Claude -->|"Forensic analysis"| FA[Forensics Analyst]
Claude -->|"Check this STIG"| SA[STIG Analyst]
Claude -->|"Write the report"| RG[Report Generator]
Claude -->|"Solve this CTF"| CS[CTF Solver]
OC --> KB[Knowledge Base]
EP --> KB
RA --> KB
EG --> KB
PE --> KB
CL --> KB
AP --> KB
MP --> KB
WP --> KB
SE --> KB
VS --> KB
WH --> KB
CT --> KB
AP2 --> KB
BB --> KB
AD --> KB
EC --> KB
PV --> KB
SO --> KB
BH --> KB
CR --> KB
TM --> KB
DE --> KB
MA --> KB
FA --> KB
SA --> KB
RG --> KB
CS --> KB
style User fill:#e94560,stroke:#e94560,color:#fff
style Claude fill:#0f3460,stroke:#e94560,color:#fff
style KB fill:#533483,stroke:#e94560,color:#fff
style OC fill:#1a1a2e,stroke:#e94560,color:#fff
style EP fill:#1a1a2e,stroke:#e94560,color:#fff
style RA fill:#1a1a2e,stroke:#e94560,color:#fff
style EG fill:#1a1a2e,stroke:#e94560,color:#fff
style PE fill:#1a1a2e,stroke:#e94560,color:#fff
style CL fill:#1a1a2e,stroke:#e94560,color:#fff
style AP fill:#1a1a2e,stroke:#e94560,color:#fff
style MP fill:#1a1a2e,stroke:#e94560,color:#fff
style WP fill:#1a1a2e,stroke:#e94560,color:#fff
style SE fill:#1a1a2e,stroke:#e94560,color:#fff
style VS fill:#1a1a2e,stroke:#e94560,color:#fff
style WH fill:#1a1a2e,stroke:#e94560,color:#fff
style CT fill:#1a1a2e,stroke:#e94560,color:#fff
style AP2 fill:#1a1a2e,stroke:#e94560,color:#fff
style BB fill:#1a1a2e,stroke:#e94560,color:#fff
style AD fill:#1a1a2e,stroke:#e94560,color:#fff
style EC fill:#1a1a2e,stroke:#e94560,color:#fff
style PV fill:#1a1a2e,stroke:#e94560,color:#fff
style SO fill:#1a1a2e,stroke:#e94560,color:#fff
style BH fill:#1a1a2e,stroke:#e94560,color:#fff
style CR fill:#1a1a2e,stroke:#e94560,color:#fff
style TM fill:#1a1a2e,stroke:#e94560,color:#fff
style DE fill:#1a1a2e,stroke:#e94560,color:#fff
style MA fill:#1a1a2e,stroke:#e94560,color:#fff
style FA fill:#1a1a2e,stroke:#e94560,color:#fff
style SA fill:#1a1a2e,stroke:#e94560,color:#fff
style RG fill:#1a1a2e,stroke:#e94560,color:#fff
style CS fill:#1a1a2e,stroke:#e94560,color:#fff
```
## pentest-ai 与手动研究对比
| 任务 | 无 pentest-ai | 有 pentest-ai |
|------|-------------------|-----------------|
| **规划任务** | 花数小时查看 PTES/NIST 文档,手动构建电子表格 | 数分钟内生成带有 MITRE 映射的结构化计划 |
| **收集 OSINT** | 手动运行数十种工具,人工交叉引用结果 | 带有被动/主动分类的自动化方法论 |
| **分析 Nmap 输出** | 手动 grep 结果,逐个交叉引用 CVE | 优先排序的攻击向量和具体的后续命令 |
| **研究 AD 攻击** | 阅读 10 多篇博客文章,从多个来源拼凑方法论 | 完整的方法论,包含精确命令、OPSEC 注意事项和检测视角 |
| **威胁建模** | 数周的 STRIDE/DREAD 分析和电子表格处理 | 带有攻击树和风险矩阵的结构化威胁模型 |
| **编写检测规则** | 手动将 ATT&CK 技术翻译成 Sigma/SPL,测试误报 | 多种格式的可部署规则,附带调优指导 |
| **分析恶意软件** | 设置隔离实验室,使用多种工具手动分类 | 引导式的静态/动态分析工作流,含 IOC 提取 |
| **STIG 合规** | 搜索 DISA PDF,手动映射控制项,从头编写理由 | 完整分析,含 GPO 路径、验证命令和保留例外模板 |
| **撰写报告** | 花数天格式化发现、编写执行摘要、计算 CVSS | 数分钟内生成格式一致的专业报告结构 |
## pentest-ai 的独特之处
市面上还有其他 AI 安全工具(如 HexStrike AI、CAI 和各种商业平台)。以下是 pentest-ai 的定位:
**方法论优先,按需执行。** 大多数 AI 渗透测试框架只是将 150 多种工具封装在 AI 执行层之后便草草了事。pentest-ai 从方法论入手:做什么、为什么有效、防御者如何发现。特定代理(Tier 2)也可以直接执行侦察和枚举命令,但每条命令都需经您批准。您始终掌握控制权,同时学习相关技术。
**零基础设施。** 无需 Python 环境、Docker 容器或 Claude 订阅之外的 API 密钥。复制一些 Markdown 文件即可开始工作。其他框架需要专用基础设施、依赖管理和设置时间才能开始。
**原生为 Claude Code 构建。** 这些代理使用 Claude Code 内置的子代理路由和权限系统。没有中间件,没有自定义框架,没有需要维护的编排层。当 Claude Code 改进时,您的代理也会随之改进。
**默认双重视角。** 每项进攻技术都附带防御视角:如何被检测、生成什么日志、哪些 Sigma 规则能捕获它。这不是一个单独的模式或附加组件。它内置于每个代理响应中。
**适合所有技能水平。** 您无需成为高级操作员。提出基础问题可获得清晰解释。提出高级问题可获得精确的命令语法和 OPSEC 注意事项。代理会适应您的水平。
| | pentest-ai v3.0 | 工具重型框架 |
|---|---|---|
| **设置** | `./install.sh --global`,完成 | Python 环境、Docker、API 密钥、依赖项 |
| **代理** | 28 个专家,6 个具备执行能力 | 单体代码库,150+ 工具封装 |
| **方法** | 方法论 + 执行,逐命令批准 | AI 直接执行工具,通常缺乏上下文 |
| **漏洞利用链** | 从低严重性到完全入侵的自主多步骤链 | 手动关联或不包含 |
| **误报** | 仅限 PoC 验证的发现 | 带有噪声的扫描器输出 |
| **集群模式** | 管理代理协调并行专家团队 | 单个代理处理所有事情 |
| **业务逻辑** | 专用代理处理扫描器遗漏的逻辑缺陷 | 未覆盖 |
| **CI/CD 集成** | 即用型流水线配置,带安全门控 | 需要外部工具集成 |
| **攻击链** | 专用攻击规划器 + 漏洞利用链接器执行 | 手动关联或不包含 |
| **学习** | 边用边学技术 | 没有上下文的工具输出 |
| **安全模型** | 双层:范围强制执行 + Claude Code 权限门控 | 各异,通常是自主的 |
| **依赖项** | 仅 Claude Code | 自定义框架、编排层、工具安装 |
| **防御视角** | 内置于每个响应中 | 单独模块或不包含 |
| **维护** | 更新代理文件,语义化版本控制 | 跟踪框架更新、工具兼容性、API 变更 |
## 使用场景
### 安全新手 / SCA 代表
如果您刚开始从事安全评估或合规(SCA、IA 分析师、安全审计员)的新角色,pentest-ai 能助您快速上手。使用 **STIG analyst** 了解合规控制如何工作以及应用它们时会破坏什么。使用 **engagement planner** 了解专业评估是如何构建的。使用 **threat modeler** 学习如何系统地思考风险。这些代理会根据您需要的深度解释概念,让您比单纯研究文档更快地适应角色。
### 内部网络渗透测试
从 **OSINT collector** 开始进行交战前侦察。使用 **engagement planner** 构建带有 ATT&CK 映射的分阶段计划。运行扫描并将输出提供给 **recon advisor** 以获取优先排序的攻击向量。使用 **exploit guide** 获取 AD 攻击方法论,使用 **privilege escalation advisor** 进行本地提权。使用 **detection engineer** 生成检测规则,以便客户可以监控您使用的技术。最后使用 **report generator** 汇编所有内容。
### 云安全评估
使用 **cloud security** 代理枚举 IAM 策略,并在 AWS、Azure 或 GCP 中查找权限提升路径。结合 **API security** 代理测试云托管 API 和无服务器函数。将发现反馈给 **detection engineer** 以生成 CloudTrail/Activity Log 检测规则。使用 **report generator** 记录所有内容,包括云特定的修复指导。
### 红队交战
从 **OSINT** 和 **threat modeling** 开始,识别最现实的攻击路径。使用 **social engineer** 规划钓鱼活动。部署 **wireless pentester** 进行物理位置评估。在横向移动时链接 **exploit guide**、**privilege escalation** 和 **cloud security**。使用 **forensics analyst** 了解您留下了哪些痕迹。**detection engineer** 构建蓝队日后可用的规则。
### 移动应用程序评估
使用 **mobile pentester** 通过 Frida 和 Objection 进行 Android/iOS 应用分析。结合 **API security** 代理测试后端 API。将发现反馈给 **report generator** 生成符合 OWASP MASVS 的报告。
### 事件响应
部署 **forensics analyst** 进行证据获取和时间线构建。使用 **malware analyst** 进行可疑二进制文件分类。**detection engineer** 构建规则以捕获已识别的 TTP。使用 **report generator** 记录事件。
### CTF 竞赛
加载 **CTF solver** 获取跨所有类别的系统性挑战指导。使用 **recon advisor** 进行网络挑战枚举,使用 **exploit guide** 处理复杂的利用链,当您拥有低权限 shell 并需要提权时使用 **privilege escalation advisor**。
### 合规审计
使用 **STIG analyst** 根据 DISA STIG 基线评估系统,生成 GPO 修复路径,并编写保留例外理由。将识别的差距反馈给 **detection engineer** 以构建未缓解发现的监控规则。使用 **report generator** 生成合规报告。
### 紫队演练
通过 **exploit guide**(为每项技术提供防御视角)运行进攻技术,然后使用 **detection engineer** 为使用的每项技术构建检测规则。根据 MITRE ATT&CK 矩阵验证检测覆盖范围。此工作流既验证了红队的方法论,也验证了蓝队的检测能力。
## 快速开始
```
# 使用一条命令克隆并安装
git clone https://github.com/0xSteph/pentest-ai.git && cd pentest-ai && ./install.sh --global
# 或使用交互式安装程序
./install.sh
# 或手动安装
cp agents/*.md ~/.claude/agents/
```
安装脚本支持 `--global`、`--project`、`--uninstall`、`--update`、`--status` 和 `--lite` 选项。运行 `./install.sh --help` 了解详情。
**在意 Token 消耗?** 使用精简模式在 Haiku 上运行咨询代理(成本更低,方法论相同):
```
./install.sh --global --lite
```
有关减少 token 消耗的完整指南,请参阅 [TOKEN-OPTIMIZATION.md](docs/TOKEN-OPTIMIZATION.md)。
然后打开 Claude Code 并尝试:
```
"I need to plan an internal penetration test for a mid-size company
with Active Directory, 3 VLANs, and about 500 endpoints.
The engagement window is 2 weeks."
```
Claude 会自动路由到任务规划代理并生成完整的分阶段计划。
**Claude 新手?** 请参阅 INSTALL.md 中的 [分步设置指南](INSTALL.md#new-to-claude-start-here)。它将引导您完成创建账户、安装 CLI 以及获取第一个代理响应。
有关所有安装方法和故障排除,请参阅 [INSTALL.md](INSTALL.md)。
## 在容器中运行工具
社区建议:在装有 Kali Linux 的 Docker 容器中运行实际的安全工具,而不是安装在主机上。这可以保持工作站的整洁,并避免端点防护标记您的工具集。
```
# 拉取 Kali Linux Docker 镜像
docker pull kalilinux/kali-rolling
# 启动一个具有网络访问权限的交互式 Kali 容器
docker run -it --name pentest-lab kalilinux/kali-rolling /bin/bash
# 在容器内,安装你需要的工具
apt update && apt install -y nmap nikto sqlmap metasploit-framework bloodhound
# 稍后重新连接
docker start -ai pentest-lab
```
**工作流程:** 在主机上的 Claude Code 中使用 pentest-ai 代理获取方法论指导、分析输出并规划您的方法。在 Kali 容器内运行实际工具。将工具输出复制回 Claude Code 进行分析。
```
Host (Claude Code + pentest-ai agents)
├── Get methodology from agents
├── Paste tool output for analysis
└── Generate reports and detection rules
Docker Container (Kali + security tools)
├── Run Nmap, Nessus, BloodHound, etc.
├── Execute authorized testing
└── Capture output for agent analysis
```
这种分离意味着您的主机保持干净,您的 EDR 不会标记您的开发机,您的工具位于一个可随时重建的一次性环境中。
## 代理路由原理
Claude Code 读取每个代理 YAML 前言中的 `description` 字段来决定何时委托。您无需指定使用哪个代理。只需自然地描述您的任务。
```
---
name: recon-advisor
description: Delegates to this agent when the user pastes scan output
(Nmap, Nessus, Nikto, masscan, etc.)... Can execute
reconnaissance commands directly with user approval.
tools: [Bash, Read, Write, Edit, Grep, Glob]
model: sonnet
---
```
Claude 将您的意图与代理描述匹配并自动路由。如果您喜欢直接控制,也可以显式调用代理。
## Tier 1 与 Tier 2 代理
代理在两个层级之一运行:
### Tier 1:咨询(所有代理)
每个代理都在咨询模式下工作。您粘贴工具输出、询问方法论问题或请求文档。代理进行分析、建议并生成产物。您自己运行工具。
### Tier 2:执行(特定代理)
一些代理还可以直接组合和执行命令。当您要求侦察顾问 "scan 10.10.1.0/24" 时,它会构建 nmap 命令,解释其功能,标记噪声级别,并在您批准后运行。然后它解析输出并建议后续步骤。
**工作原理:**
1. 您声明您的授权范围(IP 范围、域名、URL)
2. 代理在组合命令之前针对您的范围验证每个目标
3. Claude Code 向您显示完整命令并请求批准
4. 代理执行、保存证据、分析结果并建议下一步
**安全模型:** 代理在提示级别强制执行范围(拒绝超出范围的目标)。Claude Code 在系统级别强制执行批准(您看到并批准每条命令)。在运行任何内容之前,两层必须都通过。
**Tier 2 代理:**
| 代理 | 执行内容 | 风险等级 |
|-------|-----------------|------------|
| **Recon Advisor** | nmap, dig, whois, curl, netcat, traceroute, whatweb, nikto | 低(只读扫描) |
| **Vuln Scanner** | nuclei, nikto, nmap NSE scripts | 低-中(漏洞检测) |
| **Web Hunter** | ffuf, gobuster, feroxbuster, sqlmap, dalfox, whatweb | 中(主动 Web 测试) |
| **AD Attacker** | BloodHound, Impacket (GetUserSPNs, secretsdump, psexec), CrackMapExec, Certipy, ldapsearch, enum4linux | 中-高(AD 枚举和攻击) |
有关完整的安全模型和转换指南,请参阅 [docs/TIER2-EXECUTION.md](docs/TIER2-EXECUTION.md)。
**仅 Tier 1(咨询,无执行):**
| 代理 | 原因 |
|-------|-----|
| Exploit Guide | 漏洞利用工具风险较高。保持咨询模式。 |
| Social Engineer | 钓鱼执行不应由 AI 自动化。 |
| Wireless Pentester | 需要硬件交互(WiFi 适配器)。 |
| Mobile Pentester | 需要设备连接。 |
| Engagement Planner | 生成计划,而非命令。 |
| Threat Modeler | 生成分析,而非命令。 |
| Report Generator | 生成文档,而非命令。 |
| Credential Tester | 密码攻击需要谨慎的人工监督以应对锁定风险。 |
| Attack Planner | 生成策略,而非命令。协调其他代理的发现。 |
| Bug Bounty Hunter | 方法论和报告撰写。侦察工具由其他 Tier 2 代理覆盖。 |
## 示例
在 [examples/](examples/) 目录中查看真实的代理输出:
| 示例 | 代理 | 展示内容 |
|---------|-------|---------------|
| [任务计划](examples/example-engagement-plan.md) | engagementanner | 内部网络渗透测试的完整分阶段计划,含 MITRE ATT&CK 映射 |
| [Nmap 分析](examples/example-nmap-analysis.md) | recon-advisor | 扫描分析,含优先排序的攻击向量和后续命令 |
| [检测规则](examples/example-detection-rule.md) | detection-engineer | Sigma、Splunk SPL 和 Elastic KQL 中的 Kerberoasting 检测 |
| [STIG 发现](examples/example-stig-finding.md) | stig-analyst | V-220768 分析,含 GPO 路径、验证和保留例外模板 |
| [报告摘录](examples/example-report-excerpt.md) | report-generator | 为专业渗透测试报告格式化的 SQL 注入发现 |
## 发现数据库
持久化 SQLite 存储,可在 Claude Code 会话之间保留任务数据。存储和检索零 token 成本。
```
# 初始化并开始记录
findings.sh init acme-2024 --client "ACME Corp" --type internal --scope "10.0.0.0/24"
export PENTEST_AI_ENGAGEMENT="acme-2024"
# Agent 在扫描期间自动写入数据库
findings.sh stats # Check progress: hosts, vulns, creds, chains
findings.sh list vulns # See all findings
findings.sh export # Full JSON export
bash handoff.sh # Generate a Markdown handoff report for the next session
```
当 `findings.sh` 在 PATH 中时,所有 Tier 2 代理都会写入数据库。使用 `--no-db` 标志跳过安装。完整文档:[docs/FINDINGS-DB.md](docs/FINDINGS-DB.md)。
## 前置条件
- 已安装并配置 [Claude Code](https://docs.anthropic.com/en/docs/claude-code)
- Claude Pro 或 Max 订阅
- 用于授权安全测试:签署的交战规则和明确的范围
- 推荐认证:OSCP、GPEN、PenTest+、CEH、CPTS(或同等经验)
## 常见问题
### 使用此工具会导致 Anthropic 封禁我的账户吗?
不会。这些代理提供方法论指导、分析和文档。Tier 2 代理可以执行侦察命令,但每条命令都通过 Claude Code 内置的权限提示,这是 Anthropic 自身的安全机制。代理不会绕过它。Anthropic 的准则允许安全研究、授权渗透测试和防御性安全工作。如果您在拥有适当书面授权的授权交战中使用这些代理,就没有问题。
Claude 的安全护栏仍然适用。如果您要求它编写实际的恶意软件或攻击未经授权的系统,它会拒绝,无论是否安装了这些代理。Tier 2 执行仅限于侦察和枚举工具,不包括漏洞利用。
### 我的数据会发送给第三方吗?
当您使用 Claude Code 时,您的提示词会发送给 Anthropic 进行处理。pentest-ai 代理不会添加任何额外的数据传输。数据流与不安装代理使用 Claude Code 完全相同。
对于敏感任务:
- 使用 Anthropic 的 API 和您自己的密钥(默认情况下 API 输入不用于训练)
- 在粘贴工具输出之前编辑掉客户特定数据
- 检查您的 ROE 和客户 NDA 对 AI 数据处理的限制
- 有关详细指导和客户沟通模板,请参阅 [DATA-PRIVACY.md](docs/DATA-PRIVACY.md)
### 这与 HexStrike AI 或 CAI 有何不同?
请参阅上方 [pentest-ai 的独特之处](#how-pentest-ai-is-different)。简短版本:这些工具将 150 多种安全工具封装在带有自主操作的 AI 执行层之后。pentest-ai 以方法论为主导,并添加带有逐命令用户批准的可选执行。您在每一步都理解正在发生什么。不同的理念,不同的用例。它们可以互补。
### 我是安全新手。这对我有用吗?
是的。代理会根据您需要的级别解释概念。问 "what is Kerberoasting?" 您会得到清晰的解释。问 "walk me through AS-REP Roasting against this specific AD configuration" 您会得到精确的命令和 OPSEC 注意事项。如果您刚开始从事安全评估或合规工作,请参阅上方的 [安全新手用例](#new-to-security--sca-representatives)。
### 代理使用了太多 token。如何降低成本?
使用 `--lite` 模式安装:`./install.sh --global --lite`。这将仅咨询的代理切换到 Haiku(大约是 Sonnet 能力的 90%,成本却只有一小部分),同时在准确性重要的执行代理上保留 Sonnet。您也可以通过将单个代理前言中的 `model: sonnet` 更改为 `model: haiku` 来切换。保持对话专注,并在任务阶段之间开始新会话。有关完整细分,请参阅 [TOKEN-OPTIMIZATION.md](docs/TOKEN-OPTIMIZATION.md)。
### 我可以使用本地模型代替 Claude 吗?
可以。代理是纯 Markdown 系统提示词。唯一特定于 Claude 的部分是 YAML 前言头。运行 `./opencode-setup.sh --full` 将所有 23 个代理转换为 [OpenCode/Crush](https://github.com/charmbracelet/crush) 自定义命令,可与 Ollama、LM Studio、vLLM 或任何本地模型配合使用。无需云 API,无需关键词过滤,数据不离开您的机器。
有关完整的设置说明、硬件要求和建议,请参阅 [docs/LOCAL-SETUP.md](docs/LOCAL-SETUP.md)。
### 如果 Anthropic 或 OpenAI 更改条款怎么办?
pentest-ai 不锁定于任何提供商。代理文件是纯 Markdown,其方法论内容适用于任何 LLM。`opencode-setup.sh` 适配器剥离 Claude Code 前言并生成与 OpenCode/Crush 兼容的文件,后者支持 Ollama(本地)、OpenAI、Google Gemini、Groq、OpenRouter、AWS Bedrock、Azure 等。如果任何提供商限制或限制安全内容,切换到另一个提供商或完全在本地运行。您的代理和方法论属于您。
## 文档
| 文档 | 描述 |
|----------|-------------|
| [INSTALL.md](INSTALL.md) | 分步安装指南,包含安装脚本和故障排除 |
| [Agent Guide](docs/AGENT-GUIDE.md) | 每个代理的工作原理、使用时机和示例提示词 |
| [Tier 2 Execution](docs/TIER2-EXECUTION.md) | 执行模式的工作原理、安全模型和代理转换指南 |
| [Local Setup](docs/LOCAL-SETUP.md) | 使用 Ollama、OpenCode/Crush 和本地 GPU 完全离线运行 |
| [Customization](docs/CUSTOMIZATION.md) | 修改代理、更改模型、添加工具、创建新代理 |
| [Contributing](docs/CONTRIBUTING.md) | 如何提交改进和代理质量标准 |
| [Token Optimization](docs/TOKEN-OPTIMIZATION.md) | 通过精简模式、模型路由和使用技巧减少 token 消耗 |
| [Findings Database](docs/FINDINGS-DB.md) | 跨会话任务数据的持久化 SQLite 存储 |
| [Data Privacy](docs/DATA-PRIVACY.md) | LLM 数据处理、敏感任务、本地模型选项 |
| [Changelog](CHANGELOG.md) | 版本历史和发布说明 |
| [Disclaimer](DISCLAIMER.md) | 法律和道德使用条款 |
## 贡献
欢迎贡献。有关指南,请参阅 [docs/CONTRIBUTING.md](docs/CONTRIBUTING.md)。
代理提交必须包含 MITRE ATT&CK 映射,并考虑进攻和防御两个视角。
## 法律声明
此工具包仅用于**授权安全测试**。用户在任何任务中使用这些代理之前必须拥有适当的书面授权。有关完整条款,请参阅 [DISCLAIMER.md](DISCLAIMER.md)。
Tier 1 代理提供方法论指导和分析。Tier 2 代理可以在您批准后执行侦察命令。没有代理执行攻击、生成功能性漏洞利用代码或绕过 Claude Code 的权限系统。
## 许可证
[MIT License](LICENSE)
由 [0xSteph](https://github.com/0xSteph) 构建
如果此项目对您的安全工作有帮助,请考虑给一个 star。