An agentic pentesting MCP server that automates web application penetration testing using the full OWASP Web Security Testing Guide and PortSwigger Web Security Academy technique references.
Point it at a target — it crawls your app, maps every endpoint, then spawns role-specialized agents (Scout, Analyzer, Exploiter, Reporter) to test for XSS, SQLi, SSRF, SSTI, IDOR and more. No false positives — every finding is backed by real, reproducible evidence with quality gates enforcing proof at every phase. Includes 31 PortSwigger technique guides, adaptive WAF evasion for 12 vendors, cross-phase vulnerability chaining, and risk-weighted endpoint prioritization. Run it with Claude Code, the API, or go fully offline using Ollama models.
Agentic Pentesting MCP server that discovers, exploits, and reports web application vulnerabilities.
星數
244
工具
—
可用率
—
Think of it as: A senior pentester's methodology encoded into an MCP server — 109 OWASP tests, 31 PortSwigger attack technique guides, 68+ MCP tools, 27 security tools, 4 specialized agent roles, 7 structured phases, automated quality assurance, and a zero-context final review.
When a tool produces empty or suspicious output, the validator suggests fixes (e.g., add -Pn for nmap, remove proxy env vars, try different flags)
Integrated into the tool execution workflow — agents call verify_tool_result() after every CLI tool run
Progressive Context Compression
Phase summaries (~500-800 words) auto-generated when phase gates pass — capturing findings, coverage, tool results, and attack surface in compressed form
Prevents context degradation in long-running engagements by replacing raw historical data with structured summaries
get_engagement_summary() combines all phase summaries into a single overview for injecting into new subagent prompts
Summaries stored as deliverables — accessible by any downstream agent without requiring full engagement history
Counterfactual Analysis (Second-Pass Discovery)
After an Analyzer completes with vulnerabilities found, a second Analyzer is spawned with instructions to "assume those vulns are patched"
The counterfactual Analyzer searches for additional vulnerabilities: different endpoints, different parameters, different injection contexts, logic flaws
Results are appended to the existing exploitation queue (automatic merge with deduplication by endpoint+parameter and auto-incrementing IDs)
Based on PenHeal ablation research showing +71% vulnerability coverage with counterfactual prompting
Multi-Domain Support
Automatic SSO/OAuth/OIDC/SAML detection and handling
Per-domain scope registration, crawling, and testing
Cookie jar management for cross-domain session persistence
Append-only findings.md and progress.log survive crashes
Git workspace checkpointing with rollback capability
Auto-resume on interruption — resume-prompt.md auto-generated at every checkpoint with full context (target, credentials, current phase, remaining tests, scope). Paste into a new session to continue exactly where you left off
Mid-phase checkpoint granularity — tracks which tests within a phase are completed, not just phase-level state
Full audit trail of every MCP tool call with timestamps
Professional Reporting
Markdown reports with executive summary, findings by severity, test coverage matrix, and tool coverage
Per-category coverage percentages and gap analysis
Vulnerability chaining analysis documented
Final Judge observations and quality notes included
Agent Role System
AutoPentest uses 4 specialized agent roles instead of generic subagents. Each role has a dedicated prompt template with focused tool guidance, input/output contracts, and anti-patterns.
Role
Template
Purpose
Phases
Scout
templates/agent-roles/scout.md
Reconnaissance and attack surface mapping
Phase 0-1, source code discovery
Analyzer
templates/agent-roles/analyzer.md
Vulnerability discovery with canary/witness payloads
Phase 2-5 analysis
Exploiter
templates/agent-roles/exploiter.md
Exploitation proof with evidence
Phase 4 exploitation
Reporter
templates/agent-roles/reporter.md
Quality review and Final Judge
Phase transitions, post-report
How the Pipeline Works
Phase 4 (highest-impact testing) uses a two-stage pipeline per vulnerability class:
Three pipelines (XSS, Injection, SSRF/SSTI) run in parallel. The validation checkpoint between Analyzer and Exploiter ensures only well-formed exploitation queues proceed.
Role Boundaries
Each role has explicit tool restrictions enforced through prompts:
Scouts cannot call log_finding() or send attack payloads
Analyzers can log configuration findings (missing headers, weak cookies) but not injection-class findings
Exploiters cannot create new queues — they consume what the Analyzer produced
Reporters cannot send HTTP requests to the target — they review data only
For CTF challenges and small apps (<3 input endpoints), a legacy monolithic pipeline is available as a fallback.
Quick Start
Prerequisites
Docker (Docker Desktop on macOS/Windows, Docker Engine on Linux)
# 1. Clone the repository
git clone https://github.com/bhavsec/autopentest-ai.git
cd autopentest-ai
# 2. Install Python dependencies for the MCP server
cd server && uv sync && cd ..
# 3. Build Docker image and start the tools container
make setup
That's it. All 27 security tools are now installed and ready inside the Docker container.
Verify Installation
# Check all tools are installed
make verify-tools
# Expected output:
# [+] nuclei: installed
# [+] httpx: installed
# [+] katana: installed
# ... (27 tools total)
Start Testing
# Launch Claude Code in the project directory
claude
Then tell Claude what to test:
Run a full WSTG assessment against https://target.example.com
Usage
Option A: Interactive Mode
Launch Claude Code and provide the target:
Run a full pentest against https://app.example.com
Credentials: admin / P@ssw0rd123
Claude will ask for any missing information (like credentials) and begin the 7-phase workflow.
Option B: Config-Driven Mode (Recommended)
Create a YAML config file for repeatable, consistent assessments:
# configs/my-target.yaml
target:
url: https://app.example.com
scope:
- app.example.com
- api.example.com
exclude:
- cdn.example.com
authentication:
login_type: form
login_url: https://app.example.com/login
credentials:
username: [email protected]
password: secret123
login_flow:
- "Type $username into the email field"
- "Type $password into the password field"
- "Click the 'Sign In' button"
success_condition:
type: url_contains
value: "/dashboard"
rules:
avoid:
- description: "Do not test logout"
type: path
url_path: "/logout"
focus:
- description: "Prioritize API endpoints"
type: path
url_path: "/api"
reporting:
tester_name: "Security Team"
Then in Claude Code:
Load the config from configs/my-target.yaml and run the pentest
Option C: Targeted Testing
Run specific WSTG tests against specific endpoints:
Run WSTG-INPV-05 (SQL Injection) against https://app.example.com/search?q=
Test https://app.example.com for CORS misconfiguration (WSTG-CONF-13)
Run all authentication tests (WSTG-ATHN) against https://app.example.com
Option D: Resume an Interrupted Engagement
Resume engagement pentest-2026-02-11-myapp
Testing Phases
Phase 0: Application Discovery & Mapping
The critical foundation phase. Claude autonomously:
Payloads organized by bypass level (basic, intermediate, advanced)
Detection criteria with severity assessment rubrics
Remediation guidance with references
PortSwigger Technique Guides
31 attack technique reference guides sourced from PortSwigger Web Security Academy, organized by vulnerability class for direct use during real pentesting engagements.
AutoPentest has a multi-layered QA system that prevents shallow testing:
1. Phase Gates (Automated)
After each phase, phase_gate_check() validates:
All MUST-priority tests were executed
Minimum coverage thresholds are met
Tool coverage is adequate
No critical gaps exist
Blocked phases cannot proceed until all issues are resolved.
2. Quality Reviewer (Per-Phase)
A subagent spawned at every phase transition that:
Checks for 16 known anti-patterns (rubber-stamping, N/A cascades, finding inflation)
Identifies untested endpoints and parameters
Suggests vulnerability chaining opportunities
Recommends alternative approaches for blocked tests
3. Final Judge (Post-Report)
A zero-context agent that reviews the completed engagement with fresh eyes:
Analyzes coverage integrity across all domains
Detects N/A cascades and their root causes
Validates finding quality and evidence completeness
Identifies missed attack surface
Issues a verdict: PASS, CONDITIONAL_PASS, or FAIL
4. Exhaustion Gates
Marking a vulnerability as "not exploitable" requires proof of effort:
Vuln Class
Min Techniques
Min Bypass Attempts
XSS
3
5
SQL Injection
3
5
Command Injection
3
5
SSTI
2
3
SSRF
3
5
Path Traversal
3
5
5. Evidence Checklists
Before logging any finding, evidence requirements are verified:
Reproducible curl command
Full HTTP request and response
Proof of actual exploitation (not theoretical impact)
Correct classification tier (EXPLOITED vs POTENTIAL)
6. Live Engagement Logging
Every MCP tool call is automatically logged to engagements/<eid>/logs.txt with full arguments, results, and execution duration. Run tail -f logs.txt in a separate terminal to watch all agent activity in real time. 100% coverage via automatic tool wrapper — no manual instrumentation needed.
7. Phase Gate Timing
Phase gates enforce minimum 60-second intervals between calls (15s in CTF mode), preventing premature phase completion. Inter-gate work verification warns if fewer than 3 work events occur between consecutive gates.
Benchmarking
AutoPentest includes integration with the XBOW Validation Benchmarks — 104 CTF-style Docker challenges used as the industry standard for benchmarking AI pentest agents.
Benchmark Scores (Reference)
Agent
Score
Source
Shannon
96.2%
KeygraphHQ (2024)
PentestGPT
86.5%
USENIX Sec 2024
Usage
# Setup (one-time)
cd benchmarks/xbow && make setup
# Solve with AutoPentest (MCP server + CLAUDE.md + CTF mode)
make solve ID=XBEN-001-24
# Solve with raw Claude (baseline — no MCP, no methodology)
make solve ID=XBEN-001-24 RAW=1
# Solve by vulnerability tag
make solve-tag TAG=sqli
# Solve all 104 challenges
make solve-all
# Full baseline run for comparison
make solve-all RAW=1
# Score the latest run
make score
# Compare autopentest vs raw runs side-by-side
make compare
The solver has two modes:
autopentest (default): Runs Claude Code from the project root, loading .mcp.json (MCP server with 68+ tools) and CLAUDE.md (pentest methodology). Measures AutoPentest's full capability.
raw (RAW=1): Runs bare Claude Code with no MCP server or methodology. Baseline for measuring AutoPentest's value-add over raw LLM capability.
Each challenge is a Docker Compose app with a flag injected at build time. Flag extraction from Claude's output determines pass/fail. Results are scored per-challenge, per-tag, and per-difficulty-level.
CTF Mode
For CTF challenges and small apps, enable CTF mode for relaxed quality gates:
mode: ctf
target:
url: https://target.com
CTF mode reduces phase gate timing (15s vs 60s), skips QA Reviewer requirements, and halves completion thresholds — while maintaining finding quality and evidence standards.
Example Report
A complete example report from a pentest against PortSwigger's Gin & Juice Shop (a deliberately vulnerable application) is included in the repository:
Consolidated duplicates and secondary evidence for primary findings
Report Structure
1. Executive Summary — Target scope, finding summary, domain architecture
2. Detailed Findings — Each finding with description, evidence (curl commands), and remediation
3. Vulnerability Chaining — Cross-finding analysis (e.g., XSS + no CSP = severity upgrade)
4. Test Coverage Matrix — Per-category WSTG coverage (100% across 12 categories)
5. Tool Coverage Matrix — 27/27 tools tracked, 8 actively run
Sample Finding (SQL Injection)
From the report — a Critical SQL injection finding with full exploitation evidence:
FINDING-017: SQL Injection in /catalog category parameter — Full Data Extraction
Severity: Critical
WSTG Reference: WSTG-INPV-05
The category parameter is vulnerable to UNION-based SQL injection.
The attacker can:
1. Inject a single quote to cause a 500 error (confirming injection)
2. Use UNION SELECT with 8 columns to extract arbitrary data
3. Enumerate tables: PRODUCTS, TRACKING, USERS
4. Extract credentials from the USERS table
Evidence (reproducible curl command):
curl -sk "https://ginandjuice.shop/catalog?category='+UNION+SELECT+1,USERNAME,PASSWORD,
1,1,USERNAME,1,USERNAME+FROM+USERS+LIMIT+10--"
Every finding includes reproducible curl commands, full request/response evidence, and actionable remediation guidance.
Configuration
Engagement Config (YAML)
Config-driven pentests skip interactive questions and ensure consistency:
Every checkpoint and phase gate automatically generates engagements/<eid>/resume-prompt.md — a complete, self-contained prompt with everything a fresh session needs:
Target URL, authentication credentials, and scope domains
Current phase and which specific tests remain (mid-phase precision)
Cookie jar status and re-authentication instructions
Avoid/focus rules and endpoint map references
To resume after an interruption:
Open a new Claude Code session
Paste the contents of engagements/<eid>/resume-prompt.md
Claude picks up exactly where it left off — no manual context needed
Resume from Checkpoint (Alternative)
Resume engagement pentest-2026-02-11-myapp
This restores:
All findings and test tracking data
Coverage statistics and phase gate results
Scope registrations and deliverables
Mid-phase remaining tests (not just phase-level state)
Instructions for what to do next
Manual Checkpoints
Save at any time:
Save a checkpoint before starting Phase 4 exploitation
Rollback on Failure
If a phase produces bad results, roll back to the previous checkpoint:
No. AutoPentest automates the systematic, methodology-driven parts of a pentest. It excels at coverage (ensuring nothing is missed) and consistency (every test follows the same procedure). However, complex business logic, creative exploitation chains, and context-dependent risk assessment still benefit from human expertise. Think of it as a force multiplier.
Q: How long does a full assessment take?
It depends on the application's size and complexity. A typical medium-sized web app (50-100 endpoints) takes a few hours. Multi-domain applications with SSO take longer. The pipelined Phase 4 architecture parallelizes the most time-intensive testing.
Q: Can I run this without Burp Suite?
Yes. Burp Suite is optional and used only for passive traffic monitoring. All HTTP requests go through docker exec curl and all security tools run inside the Docker container. Without Burp, you lose the ability to review traffic in Burp's proxy history, but all testing functionality works.
Q: What are the PortSwigger technique guides?
31 attack reference guides covering detection, exploitation techniques, payloads, cheat sheets, and WAF bypass patterns — sourced from PortSwigger Web Security Academy. During testing, agents automatically load the relevant guide (e.g., the SQLi guide when testing for SQL injection) for comprehensive technique and payload reference. See docs/adding-knowledge-base-resources.md to add your own guides.
Q: How do I add custom wordlists or payloads?
Place wordlists in templates/wordlists/ and they'll be available inside the Docker container via the volume mount. The WSTG test files in knowledge-base/ can also be customized with additional payloads. To add new attack technique guides, follow the instructions in docs/adding-knowledge-base-resources.md.
Q: Can I test applications behind a VPN?
Yes. The Docker container inherits your host's network (on Linux with --network host) or reaches the host via host.docker.internal (on macOS/Windows). If your VPN is running on the host, the container can reach VPN-protected targets.
Q: What happens if a pentest is interrupted (crash, usage limit, timeout)?
AutoPentest automatically generates a resume-prompt.md file at every checkpoint with everything needed to continue. Open a new Claude Code session, paste the contents of engagements/<eid>/resume-prompt.md, and testing resumes exactly where it left off — including mid-phase progress, credentials, scope, and remaining tests.
Q: What about rate limiting?
AutoPentest includes three-tier error classification (Transient/Rate Limit/Permanent) with automatic backoff. If the target rate-limits requests, tools automatically slow down. You can also set avoid rules in the config to skip specific endpoints.
Q: What are the agent roles?
AutoPentest uses 4 specialized roles (Scout, Analyzer, Exploiter, Reporter) instead of generic subagents. Each role has a dedicated prompt template with focused tool guidance, restricted tool lists, and anti-patterns. This prevents agents from conflating reconnaissance, analysis, exploitation, and reporting — improving focus and failure isolation. See templates/agent-roles/README.md for the full role index.
Q: How does WAF evasion work?
When a payload gets blocked (403, block page), AutoPentest automatically fingerprints the WAF vendor from response characteristics, then loads vendor-specific bypass payloads organized by complexity level. 12 WAF vendors are supported (Cloudflare, AWS WAF, Akamai, Imperva, ModSecurity, F5, and more). WAF intelligence is shared across all agents via the deliverable system.
Q: What is counterfactual analysis?
After the first analysis pass finds vulnerabilities, AutoPentest can spawn a second Analyzer that assumes all known vulnerabilities are patched. This forces the agent to look for different attack vectors — different endpoints, parameters, injection contexts, and logic flaws. The results are merged into the existing exploitation queue with automatic deduplication. This technique is based on academic research (PenHeal ablation study) showing +71% vulnerability coverage improvement.
Q: How does results verification work?
When CLI tools (nmap, nuclei, sqlmap, etc.) produce empty or suspicious output, the verify_tool_result() tool detects common issues (proxy errors, permission denied, wrong flags) and suggests corrected commands. This prevents agents from silently counting broken tool runs as "completed" — a common failure mode in automated pentesting.
Q: How does vulnerability chaining work?
The knowledge graph tracks entities (endpoints, parameters, findings, cookies, domains) and relationships discovered during testing. After Phase 4, find_chains() uses BFS to discover multi-hop attack paths and checks 7 predefined chain patterns (e.g., XSS + missing CSP, SSRF + cloud metadata, IDOR + admin role). Chains that increase impact trigger automatic severity upgrades.
Disclaimer
This tool is intended for authorized security testing only. Only use AutoPentest against applications you have explicit permission to test. Unauthorized access to computer systems is illegal. The authors are not responsible for any misuse of this tool.
Always ensure you have:
Written authorization from the application owner
A clearly defined scope of what can and cannot be tested
An understanding of the testing environment (production vs staging)
Appropriate avoid rules configured for destructive or sensitive endpoints
A
Autopentest Ai
bhavsec·244 顆星·
Agentic Pentesting MCP server that discovers, exploits, and reports web application vulnerabilities.