Share
## https://sploitus.com/exploit?id=6FADC1BD-A6C3-5FCE-A691-AF32D31E8B3A
# AI Pentest Agent ๐ก๏ธ๐ค
**The first open-source autonomous AI penetration testing agent skill.**
[](https://github.com/Erfix404/ai-pentest-agent/actions)
[](LICENSE)
[](https://www.python.org/downloads/)
> Takes target โ plans attack path โ executes multi-phase pentest โ generates CVSS-scored report. Pure Python stdlib, zero extra dependencies.
## Problem
Existing pentest skills are **manual tool catalogs** โ they list tools but don't plan or execute. Existing autonomous frameworks (PentaGI โญ21K, HexStrike โญ10.5K) are monolithic Go/Rust programs. There's nothing that tells an AI agent *how to think* about pentesting while orchestrating existing tools.
## Solution
**AI Pentest Agent** is an agent-native skill that:
1. **Plans** an adaptive attack path based on target type and discovered services
2. **Executes** 5 phases: recon โ scan โ exploit โ post-exploit โ report
3. **Scores** every finding with CVSS 3.1 (pure Python, zero deps)
4. **Gathers evidence** โ every command output saved as structured JSON
5. **Reports** in markdown (human) + JSON (machine) formats
## Quick Start
```bash
# Clone and run tests
git clone https://github.com/Erfix404/ai-pentest-agent
cd ai-pentest-agent
python3 tests/run_tests.py
# Full autonomous pentest
python3 scripts/ai-pentest.py --target example.com --full --output ./results
# Attack plan (dry-run)
python3 scripts/ai-pentest.py --target example.com --plan-only
# Single phase
python3 scripts/ai-pentest.py --target https://api.example.com --phase recon
```
## Architecture
```
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ PHASE 1: RECONNAISSANCE โ
โ subfinder โ httpx โ katana โ gau โ
โ โ waybackurls โ naabu โ dnsx โ
โ Output: targets.txt, surface.json โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ PHASE 2: SCANNING โ
โ nuclei โ nmap โ tlsx โ uncover โ
โ โ gf secrets โ searchsploit โ
โ Output: vulns.json, findings.json โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ PHASE 3: EXPLOITATION โ
โ ffuf โ sqlmap โ xsstrike โ hydra โ
โ โ pwntools โ custom exploits โ
โ Output: evidence/*, exploits.log โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ PHASE 4: POST-EXPLOITATION โ
โ pivoting โ persistence โ data โ
โ exfiltration (proof only) โ
โ Output: postex.json โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ PHASE 5: REPORTING โ
โ CVSS scoring โ finding grouping โ โ
โ markdown report โ JSON evidence โ
โ Output: report.md, report.json โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
```
## Features
### ๐ง Autonomous Attack Path Planning
Builds adaptive attack plans based on target characteristics:
- **Target type auto-detection**: web / API / network / cloud
- **Technology-aware**: WordPress โ wpscan, Laravel โ .env leak, Apache โ version exploit
- **Adaptive decision tree**: plan changes based on what each phase discovers
### ๐ CVSS 3.1 Scoring Engine
Pure Python, zero dependencies. Validates all metric combinations:
```python
from cvss31 import cvss31_score, cvss31_vector_to_score
score, vector = cvss31_score("N", "L", "N", "N", "U", "H", "H", "H")
# โ 9.8, "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"
```
### ๐ง Tool Auto-Detection
Auto-detects available tools with graceful fallbacks:
| Wanted | Detection | Fallback |
|--------|-----------|----------|
| subfinder | `which subfinder` | dig + curl |
| httpx | `which httpx` | curl -I |
| naabu | `which naabu` | nmap -T4 |
| nuclei | `which nuclei` | nmap NSE |
| ffuf | `which ffuf` | gobuster |
| sqlmap | `which sqlmap` | manual injection |
### ๐ Evidence-First Methodology
Every command output is saved as structured JSON evidence. Reproducible โ full command + output captured.
## Installation
### As an Agent Skill (Hermes / Claude Code / Codex)
Copy `SKILL.md` to your skills directory:
```bash
mkdir -p ~/skills/security/ai-pentest-agent
cp SKILL.md ~/skills/security/ai-pentest-agent/
cp -r scripts/ ~/skills/security/ai-pentest-agent/
cp -r references/ ~/skills/security/ai-pentest-agent/
```
### Standalone Python
```bash
git clone https://github.com/Erfix404/ai-pentest-agent
cd ai-pentest-agent
python3 scripts/ai-pentest.py --help
```
No `pip install` needed. Pure Python stdlib.
## Usage Examples
### Full Autonomous Pentest
```bash
python3 scripts/ai-pentest.py --target example.com --full --output ./results
```
### Web Application Focus
```bash
python3 scripts/ai-pentest.py --target https://app.example.com \
--type web --output ./web-results
```
### API Security Assessment
```bash
python3 scripts/ai-pentest.py --target https://api.example.com \
--type api --output ./api-results
```
### Network Pentest
```bash
python3 scripts/ai-pentest.py --target 10.0.0.0/24 \
--type network --output ./net-results
```
### Validate a Specific Finding
```bash
python3 scripts/ai-pentest.py --validate \
--finding "SQL injection at /api/users?id=1"
```
## Project Structure
```
ai-pentest-agent/
โโโ SKILL.md # Agent skill definition
โโโ SKILL.yaml # Skill metadata for marketplaces
โโโ README.md # This file
โโโ LICENSE # MIT
โโโ scripts/
โ โโโ ai-pentest.py # Main autonomous engine (950+ lines)
โ โโโ cvss31.py # Pure Python CVSS 3.1 calculator
โโโ tests/
โ โโโ run_tests.py # Test runner (system pytest not needed)
โ โโโ test_cvss31.py # 8 tests โ CVSS scoring + validation
โ โโโ test_planner.py # 10 tests โ attack path planning
โ โโโ test_evidence.py # 6 tests โ evidence capture
โโโ references/
โ โโโ attack-paths.md # Reference attack trees
โโโ .github/workflows/
โโโ ci.yml # CI pipeline
```
## Tests
```bash
# Run all tests (no pytest needed)
python3 tests/run_tests.py
# Or with pytest
python3 -m pytest tests/ -v
```
## Safety & Ethics
- **Authorization required.** Every pipeline asks for target ownership confirmation
- **Destructive OFF by default.** No password spraying, DoS, or data-write exploits without `--aggressive`
- **Scope enforcement.** Tools limited to declared scope
- **Rate limiting.** Default 50 req/s
- **Evidence only.** No actual data exfiltration
## Research Foundation
| Paper | Key Insight | Applied In |
|---|---|---|
| Automated Pentesting Using LLMs (Happe, 2024) | LLMs need structured feedback loops | Phase-gated architecture |
| PentaGI (VXControl, 2025) | Prompt-guided tool execution | Adaptive attack planner |
| PentestAgent (GH05TCREW, 2025) | Black-box AI-driven testing | Evidence-first methodology |
| Repo | Stars | Idea |
|---|---|---|
| [vxcontrol/pentagi](https://github.com/vxcontrol/pentagi) | โญ21K | Tool orchestration |
| [0x4m4/hexstrike-ai](https://github.com/0x4m4/hexstrike-ai) | โญ10.5K | Tool integration |
| [Armur-Ai/Pentest-Swarm-AI](https://github.com/Armur-Ai/Pentest-Swarm-AI) | โญ2.1K | Phase parallelism |
| [0xSteph/pentest-ai-agents](https://github.com/0xSteph/pentest-ai-agents) | โญ2K | Security research pattern |
## License
MIT โ free to use, modify, distribute. Attribution appreciated.
## ๐ Ecosystem Gap Filled
**skills.sh**: 0 skills, 0 installs for "ai-pentesting" keyword
**GitHub demand**: โญ21K+ repos exist but **no agent skill** standard
**Hermes coverage**: 0 skills before this one