PTES Phase 2 - Intelligence gathering for AWS security assessments
Installation
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
3. Workflow de Enumeração (WorstAssume Adaptive Enumeration)
Fast Path vs Slow Path (worstassume/modules/iam.py)
FAST PATH (iam:GetAccountAuthorizationDetails):
- 1 chamada API = todos usuários, grupos, roles, políticas
- ~2-5 segundos para conta completa
- Requer: iam:GetAccountAuthorizationDetails
SLOW PATH (fallback quando fast path não disponível):
- 50-200+ chamadas API individuais
- ~30-120 segundos dependendo do tamanho da conta
- Requer: iam:ListUsers, iam:ListRoles, iam:ListGroups, etc.
CAPABILITY PROBING (worstassume/core/capability.py):
Antes de enumerar, WorstAssume detecta automaticamente:
- iam_full_dump: Pode usar fast path?
- iam_list_users: Pode listar usuários?
- iam_list_roles: Pode listar roles?
- iam_list_policies: Pode listar políticas?
- ec2_full, s3_full, lambda_full, etc.
Módulos de Enumeração (executados em sequência)
# Cada módulo é executado com jitter (se --stealth)# Ordem de execução no worstassume/cli.py:
1. Identity (identity_mod.get_caller_identity)
→ Retorna: ARN, Account ID, Principal Type
2. IAM (iam.enumerate)
→ Usuários, Groups, Roles, Policies, Memberships
3. EC2 (ec2.enumerate)
→ Instances, Instance Profiles, Metadata Options
4. S3 (s3.enumerate)
→ Buckets, Bucket Policies
5. Lambda (lambda_.enumerate)
→ Functions, Execution Roles
6. ECS (ecs.enumerate)
→ Clusters, Task Definitions, Task Roles
7. VPC (vpc.enumerate)
→ VPCs, Subnets, Security Groups
# Após enumerar múltiplas contas, WorstAssume detecta automaticamente:
worst accounts list # Mostra contas enumeradas# Cross-account links são inferidos sem chamadas API adicionais# Analisando trust policies das roles no banco de dados
# Detecção automática durante análise de trust policies:if principal_block == "*":
is_wildcard = True# Qualquer principal pode assumir
severity = "CRITICAL"elif"aws:PrincipalOrgID"in condition:
is_wildcard = True# Todo o organization pode assumir
severity = "HIGH"
5. Mapeamento de Superfície de Ataque (PTES 2.5.4 - Active Footprinting)
# Listar contas enumeradas
worst accounts list
# Output:# Account ID Name Principals Resources Last Enumerated# 123456789012 DEV-Prod 142 89 2026-04-24 15:30# 222222222222 STG-Data 67 34 2026-04-24 16:45# Deletar conta e todos os dados
worst accounts delete 123456789012
# Exportar grafo para análise externa
worst graph-export --output graph.json
7. Análise Preliminar de Riscos (PTES 3.3 - Attack Avenues)
Red Flags Imediatas
Trust policies com Principal: "*"
Políticas com Action: "*" e Resource: "*"
IAM Users com console access sem MFA
Access keys antigas (> 90 dias)
EC2 instances com IMDSv1 habilitado
Lambda functions com permissões administrativas
PTES 2.3.7 - Metadata Leakage
S3 buckets com listagem pública
EC2 metadata endpoint exposto (IMDSv1)
Lambda environment variables com secrets
8. Ferramentas de Inteligência (PTES Tools Required)
WorstAssume Commands
# Listar contas enumeradas
worst accounts list
# Exportar grafo para análise externa (PTES 6.2 - Technical Reporting)
worst graph-export --output graph.json
# Visualizar dashboard
worst viz
AWS CLI Commands Úteis
# Identidade (PTES 2.5.4.7 - Banner Grabbing)
aws sts get-caller-identity
# Região atual
aws configure get region
# Listar todas as regiões
aws ec2 describe-regions --query 'Regions[].RegionName'# Descrever ranges de IP (PTES 2.5.1 - IP Ranges)
aws ec2 describe-prefix-lists --query 'PrefixLists[?PrefixListName*`com.amazonaws']'
Ver /root/.pcode/skills/pentest-network-scanning/SKILL.md para documentação completa do Naabu.
Quando usar hping3 (Complementar)
Use hping3 como ferramenta complementar quando:
Host Discovery (PTES 2.5.4.1 - Ping Sweeps)
# SYN scan na porta 80 para descobrir hosts vivos
hping3 -S -p 80 --scan 1-254 192.168.1.1
# ICMP scan para host discovery
hping3 -1 -c 5 192.168.1.1
# TCP ACK scan (bypass de firewalls stateless)
hping3 -A -p 80 192.168.1.1
# UDP scan para discovery
hping3 -2 -p 53 192.168.1.1
Port Scanning (PTES 2.5.4.8 - Port Scanning)
# SYN scan em range de portas (stealth scan)
hping3 -S -p 1-1000 --scan target.com
# Scan em portas específicas
hping3 -S -p 22,80,443,8080 --scan target.com
# XMAS scan (difícil de detectar por IDS)
hping3 -F -P -U -p 1-1000 --scan target.com
# NULL scan (sem flags)
hping3 -O -p 1-1000 --scan target.com
Firewall Ruleset Mapping (PTES 2.5.4 - Active Footprinting)
# Testar se firewall permite SYN
hping3 -S -p 80 target.com
# SYN-ACK = porta aberta# RST = porta fechada# Sem resposta = filtrada# Testar se firewall é stateful (ACK scan)
hping3 -A -p 80 target.com
# RST = porta não filtrada (firewall stateless)# Sem resposta = firewall stateful ou drop# Mapear regras com TTL customizado
hping3 -S -p 80 -t 64 target.com
hping3 -S -p 80 -t 128 target.com
Template de Finding - Network Discovery com hping3
FINDING: NETWORK-DISCOVERY-HPING3
CATEGORY: RECONNAISSANCE
SEVERITY: INFO
PTES: 2.5.4 - Active Footprinting
TARGET:
- IP/Hostname: [target]
- Portas descobertas: [lista]
- Hosts ativos: [lista]
DESCRIPTION:
Host discovery e port scanning via hping3 identificou [X] hosts ativos
e [Y] portas abertas na rede alvo. hping3 permitiu bypass de filtros
que bloqueavam scans tradicionais do nmap.
EVIDENCE:
hping3 -S -p 1-1000 --scan [target]
[Output do scan]
TECHNIQUE:
- SYN scan (-S): Identifica portas abertas via SYN-ACK
- ACK scan (-A): Mapeia firewalls stateless
- XMAS scan (-FPU): Evasão de IDS básico
PTES REFERENCE: Section 2.5.4 (Active Footprinting)
Advanced: Packet Crafting para Evasão (PTES 4.1.1 - Countermeasure Bypass)
# Random source IP (spoofing para testes de IDS/IPS)
hping3 -S -p 80 --rand-source target.com
# Fragmented packets (bypass de ACLs fracas)
hping3 -S -p 80 -f target.com
# Don't fragment flag
hping3 -S -p 80 -y target.com
# Custom TTL para OS fingerprinting
hping3 -S -p 80 -t 64 target.com # Windows típico
hping3 -S -p 80 -t 128 target.com # Linux típico# Source address spoofing
hping3 -S -p 80 -a 10.0.0.1 target.com
NOTE: Nettacker complementa Naabu e hping3 com detecção automática de tecnologias, subdomain enumeration, e WAF detection em uma única ferramenta.
9.1 Subdomain Enumeration com Nettacker
# Enumeração passiva de subdomínios (sem scan ativo)
docker run --rm owasp/nettacker -i target.com -m subdomain_scan
# Subdomínios + detecção de tecnologias
docker run --rm owasp/nettacker -i target.com -m subdomain_scan,web_technologies_scan
# Output JSON para integração
docker run --rm -v $(pwd):/tmp owasp/nettacker \
-i target.com -m subdomain_scan \
--json-output /tmp/subdomains.json
# API integration
API_KEY=$(docker logs nettacker 2>&1 | grep "API Key" | awk '{print $4}')
curl -k -X POST "https://localhost:5000/new/scan" \
-d "key=${API_KEY}&targets=target.com&selected_modules=subdomain_scan"
Template de Finding - Subdomain Discovery:
FINDING: SUBDOMAIN-DISCOVERY-NETTACKER
CATEGORY: RECONNAISSANCE
SEVERITY: INFO
PTES: 2.5.2 - Active Reconnaissance
TARGET: target.com
SUBDOMAINS FOUND: [X]
- api.target.com (203.0.113.10)
- admin.target.com (203.0.113.11)
- dev.target.com (203.0.113.12)
DESCRIPTION:
Nettacker subdomain enumeration identified [X] subdomains through passive
OSINT sources and DNS brute-forcing. Several subdomains expose administrative
interfaces and development environments.
EVIDENCE:
docker run --rm owasp/nettacker -i target.com -m subdomain_scan
REMEDIATION:
- Implement DNS zone transfer restrictions
- Remove unused subdomains from DNS
- Apply WAF to exposed administrative subdomains
- Consider DNS wildcard records for unused prefixes
PTES REFERENCE: Section 2.5.2 (Active Reconnaissance)
9.2 Web Technology Detection (PTES 2.5.4.7 - Banner Grabbing)
# Detecção de tecnologias web (CMS, frameworks, servidores)
docker run --rm owasp/nettacker -i target.com -m web_technologies_scan
# CMS-specific detection
docker run --rm owasp/nettacker -i target.com \
-m wordpress_scan,joomla_scan,drupal_scan
# Output detalhado com versões
docker run --rm owasp/nettacker -i target.com -m web_technologies_scan \
--graph-output /tmp/report.html
9.6 Reverse IP Lookup (PTES 2.5.1 - Identifying IP Ranges)
# ViewDNS reverse IP lookup (shared hosting detection)
docker run --rm owasp/nettacker -i target.com -m viewdns_reverse_iplookup_scan
# Identificar outros domínios no mesmo IP# Útil para descobrir siblings em shared hosting
9.7 Full Recon Workflow (Nettacker + Existing Tools)
# Step 1: Subdomain enumeration (Nettacker)
docker run --rm owasp/nettacker -i target.com -m subdomain_scan \
--json-output /tmp/subdomains.json
# Step 2: Extract live domains
jq -r '.[] | select(.result.subdomain_found == true) | .result.subdomain_found' \
/tmp/subdomains.json | tee live_subdomains.txt
# Step 3: Port scanning (Naabu - mais rápido para grandes ranges)
naabu -l live_subdomains.txt -o ports.json -j
# Step 4: Web tech detection (Nettacker)for domain in $(cat live_subdomains.txt); do
docker run --rm owasp/nettacker -i $domain -m web_technologies_scan \
--json-output /tmp/tech_${domain}.json &
donewait# Step 5: WAF detection (Nettacker)for domain in $(cat live_subdomains.txt); do
docker run --rm owasp/nettacker -i $domain -m waf_scan \
--json-output /tmp/waf_${domain}.json &
donewait# Step 6: Consolidate resultscat /tmp/tech_*.json | jq -s '.' > /tmp/tech_consolidated.json
cat /tmp/waf_*.json | jq -s '.' > /tmp/waf_consolidated.json
9.9 Comparison: Nettacker vs Subfinder for Subdomain Enum
Feature
Nettacker
Subfinder
Sources
Built-in OSINT + DNS brute
40+ passive sources
Speed
Moderate
Very fast
Integration
Part of full scan workflow
Standalone + httpx pipeline
Output
JSON, HTML, CSV
TXT, JSON
Best For
Combined recon + vuln scan
Fast subdomain-only enum
Recommended Workflow:
# Use Subfinder for initial fast enumeration
subfinder -d target.com -o subs_fast.txt
# Use Nettacker for deep scan with DNS brute-forcing
docker run --rm owasp/nettacker -i target.com -m subdomain_scan
# Combine resultscat subs_fast.txt nettacker_subs.txt | sort -u > all_subs.txt
# Proceed with Naabu + httpx + nucleicat all_subs.txt | naabu -silent | httpx -silent | nuclei
10. Username Enumeration com security-usernames
Recursos Disponíveis (security-usernames plugin)
Local: `seclists-categories usernames/usernames/references/`
Wordlists Disponíveis:
- `Names/names.txt` - Nomes comuns para enumeration
- `top-usernames-shortlist.txt` - Top usernames para teste rápido
- `cirt-default-usernames.txt` - Default accounts de serviços
Técnicas de Username Enumeration
# Usar wordlists com ffuf
ffuf -w seclists-categories/usernames/top-usernames-shortlist.txt \
-u https://target.com/users/FUZZ \
-mc 200
# Usar com curl para teste de existênciafor user in $(cat seclists-categories/usernames/cirt-default-usernames.txt); do
curl -s -o /dev/null -w "%{http_code}""https://target.com/api/users/$user"done# Integrar com ferramentas OSINT
theHarvester -d target.com -b google,linkedin
subfinder -d target.com -o domains.txt
Default Accounts para Testar (cirt-default-usernames.txt)
Após completar esta fase, prossiga para pentest-threat-modeling (PTES Phase 3)
🤖 AIRecon Integration for Intelligence Gathering
AIRecon é um agente autônomo de penetration testing (v0.1.7-beta) que pode ser invocado como ferramenta incremental durante intelligence gathering para automatizar OSINT, network scanning, e descoberta de credenciais.
Invocando AIRecon para Intelligence Gathering
# AIRecon com keywords de OSINT e network discovery
airecon "pentest intelligence gathering osint network scan target.com"# AIRecon detectará keywords e carregará:# - pentest-intelligence-gathering.md (skill primária)# - pentest-network-scanning.md (para network scan)# - MCP tools: hexstrike (nmap, naabu), cve-mcp, pentestswarm# Para pfSense-specific OSINT:
airecon "pfsense osint shodan censys reconnaissance"# Para API key discovery:
airecon "api key discovery github secrets scan target"
AIRecon Slash Commands Úteis para Intelligence Gathering
# Network scanning com Naabu integrado
/naabu-scan --target target.com -p 443,8443,22,80
/naabu-scan --target 192.168.1.0/24 -p - -silent
# API key discovery em repositórios e código
/api-keys --target ./src --recursive
/api-keys --target https://github.com/org/repo --scan-type github
# Wordlist generation para brute-force
/wordlist --type usernames --length 6
/wordlist --type passwords --length 8 --include-symbols
MCP Tool Integration via AIRecon
Durante intelligence gathering, AIRecon pode invocar MCP tools automaticamente:
# hexstrike-local: nmap, naabu, nuclei scans
airecon "scan target.com with nmap version detection"# → Usará mcp__hexstrike-local__nmap_scan
airecon "run naabu port scan on 192.168.1.0/24"# → Usará mcp__hexstrike-local__rustscan_fast_scan ou naabu_scan
airecon "run nuclei vulnerability scan on target.com"# → Usará mcp__hexstrike-local__nuclei_scan# pentestswarm-remote: Automated reconnaissance campaigns
airecon "start reconnaissance campaign for example.com"# → Usará mcp__pentestswarm-remote__start_campaign# → Retornará campaign_id para monitoramento# cve-mcp: CVE lookup para tecnologias detectadas
airecon "check CVEs for Apache 2.4.57"# → Usará mcp__cve-mcp__search_cves# virustotal: Domain e IP reputation
airecon "check domain reputation for suspicious-domain.com"# → Usará mcp__virustotal__get_domain_report# osint-remote: Username e email OSINT
airecon "search username john.doe across social networks"# → Usará mcp__osint-remote__maigret_search
Workflow Example: Intelligence Gathering com AIRecon + Naabu + Nettacker
# 1. Usar AIRecon para OSINT inicial
airecon "osint reconnaissance target.com subdomain enumeration"# 2. AIRecon auto-carrega pentest-intelligence-gathering.md# 3. Invocar Naabu via AIRecon para port scanning
airecon "/naabu-scan --target target.com -p - -silent"# 4. Invocar Nettacker via AIRecon para tech detection
airecon "docker run --rm owasp/nettacker -i target.com -m web_technologies_scan"# 5. AIRecon processa output e consolida findings# 6. Exportar para relatório de intelligence gathering
airecon "export findings to JSON for stakeholder review"
Workflow Example: pfSense-Specific Intelligence
# 1. Passive OSINT com Shodan/Censys via AIRecon
airecon "shodan search product:pfsense org:target"# 2. AIRecon detecta pfSense e ativa pentest-pfsense skill# 3. Version detection via AIRecon
airecon "censys search services.http.title:pfSense"# 4. CVE mapping automático
airecon "check CVEs for pfSense 2.7.0"# → Usará mcp__cve-mcp__search_cves com filtro de severidade# 5. Exportar findings
airecon "export pfsense intelligence report"
AIRecon Auto-Skill Loading para Intelligence
Keywords Detectadas
Skills Carregadas
MCP Tools Ativados
osintsubdomain
pentest-intelligence-gathering
osint-remote, hexstrike
network scannaabu
pentest-network-scanning
hexstrike (nmap, rustscan)
api keysecret
pentest-intelligence-gathering
hexstrike (scan_repo_secrets)
pfsensefirewall
pentest-pfsense
shodan, cve-mcp
cpanelwhm
pentest-exploitation
cve-mcp (CVE-2026-41940)
username enum
pentest-intelligence-gathering
hexstrike (hydra, http_intruder)
AIRecon + PentestSwarm Campaign Integration
# Iniciar campanha de reconnaissance automatizada
airecon "start pentestswarm campaign for target.com"# PentestSwarm retornará campaign_id:# campaign_abc123# Monitorar progresso da campanha
airecon "get campaign status campaign_abc123"# Buscar findings da campanha
airecon "get campaign findings campaign_abc123"# Exportar resultados consolidados
airecon "export campaign report campaign_abc123"
AIRecon Error Handling e Retry Logic
AIRecon implementa error handling inteligente para ferramentas de intelligence:
# Se Naabu falhar (rate limiting), AIRecon automaticamente:# 1. Aguarda backoff exponencial (2s, 4s, 8s...)# 2. Tenta alternativa (rustscan, masscan)# 3. Reporta falha após 3 retries# Se Shodan API rate-limited:# 1. Switch para Censys API# 2. Fallback para OSINT passivo (Wayback Machine)# 3. Notifica usuário sobre limitação
🤖 Watchtower Integration for Intelligence Gathering
Watchtower é um framework de penetration testing baseado em LangGraph com arquitetura multi-agente (Planner, Worker, Analyst) que automatiza reconnaissance, vulnerability analysis, e report generation.
Go deep on one program rather than spread across many — learn the application thoroughly
Build a profile of the company — tech stack, developers, processes
Look where others don't — check error pages, admin paths, old versions, mobile API
Follow the filter — if input is filtered somewhere, that functionality exists and may be bypassed
Testing Sequence (One Page / Feature)
For each input point:
1. Non-malicious HTML tags (<h2>, <img>) → are they reflected?
2. Incomplete tags → what happens? (<iframe src=//evil.com )
3. Encoding tests → %0d, %0a, %09, <%00
4. Observe the OUTPUT too (not just response) — where does your input appear?
5. Test same input in ALL similarly-structured pages (shared code → shared vuln)
6. Check if the same parameter exists in mobile/API endpoint (less protected)
Parameter Insights
- Each parameter tells a story: "what does this do server-side?"
- Filename → OS interaction → Path Traversal / CMDi
- URL/location → HTTP fetch → SSRF
- Template/HTML parameter → render function → SSTI
- XML field → parser → XXE
- SQL filter → query → SQLi
- User-content → storage → Stored XSS
13.25 Bug Bounty Program Triage (Where to Spend Time)
High-Value Target Selection
✓ Programs with large scope (*.target.com)
✓ Programs that pay for P2/P3 (not just RCE)
✓ Programs with recent tech changes (migrations = new bugs)
✓ Programs with active development (new features = new attack surface)
× Avoid: frozen/old codebases with well-known CVEs (already claimed)
× Avoid: strict programs with narrow scope (less surface)
16. AI Agent Intelligence Gathering (CLAUDE-SEC Integration)
NOTE: AI agents (Claude Desktop, Claude Code) represent a new attack surface. This section covers OSINT and reconnaissance specific to AI agent installations, MCP servers, and autonomous execution capabilities.
16.1 AI Agent Detection (Passive)
# Process detection (local machine)
pgrep -i "Claude"
pgrep -i "claude-code"# Check for configuration directoriesls -la ~/Library/Application\ Support/Claude/ 2>/dev/null # macOSls -la ~/.claude/ 2>/dev/null # Claude Code# Windows equivalentsdir"$env:APPDATA\Claude" 2>$nulldir"$env:USERPROFILE\.claude" 2>$null# Network indicators (remote assessment)# MCP servers often expose HTTP endpoints
nmap -p 8897,8080,3000 target -sV --open
# Detect AI agents on target machine
airecon "detect Claude Desktop or Claude Code installation"# Enumerate MCP servers
airecon "enumerate MCP servers and analyze configurations"# Check autonomous execution
airecon "check for AI autonomous scheduled tasks"# Plugin risk assessment
airecon "assess AI plugin security including hooks"
16.8 Integration with claudit-sec
# Run full AI agent audit
./claude_audit.sh --json > ai_agent_audit.json
# Extract high-risk findings
jq '.findings[] | select(.severity == "WARN" or .severity == "CRITICAL")' \
ai_agent_audit.json
# HTML report for stakeholders
./claude_audit.sh --html ai_agent_report.html