Share
## https://sploitus.com/exploit?id=6FADC1BD-A6C3-5FCE-A691-AF32D31E8B3A
# AI Pentest Agent ๐Ÿ›ก๏ธ๐Ÿค–

**The first open-source autonomous AI penetration testing agent skill.**

[![Tests](https://github.com/Erfix404/ai-pentest-agent/actions/workflows/ci.yml/badge.svg)](https://github.com/Erfix404/ai-pentest-agent/actions)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
[![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](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