How greydgl/pentestgpt works
PentestGPT offers two workflows: an autonomous staged pipeline for CTF and penetration-test runs, and an interactive legacy mode that maintains a Pentesting Task Tree (PTT). The newer agent package separates LLM decisions, planning, execution, and durable run state; unified_agent supplies interchangeable Claude Code and Codex backends. The README documents the autonomous stages and session persistence, but the sampled excerpts do not establish all orchestration links. The legacy orchestrator and provider client wiring are more directly evidenced by the sampled source.
Main entry points: loop.py Run Loop · pentest_gpt.py PTT Orchestrator · agent.py Unified Agent · client.py Session Client
Components 26
Autonomous Pipeline
- Run Loop
pentestgpt_agent/src/pentestgpt_agent/loop.py - Decision Agents
pentestgpt_agent/src/pentestgpt_agent/agents.py - Task Planning
pentestgpt_agent/src/pentestgpt_agent/plan.py - Session State
pentestgpt_agent/src/pentestgpt_agent/memory.py - Task Execution
pentestgpt_agent/src/pentestgpt_agent/execution.py - Run Trial
pentestgpt_agent/src/pentestgpt_agent/trial.py - Audit Trail
pentestgpt_agent/src/pentestgpt_agent/audit.py - Run Trace
pentestgpt_agent/src/pentestgpt_agent/trace.py - Asset Discovery → Vulnerabilities → Report
pentestgpt_agent/src/pentestgpt_agent - Recon → Exploit → Walkthrough
pentestgpt_agent/src/pentestgpt_agent
Agent Runtime
- Unified Agent
unified_agent/agent.py - Claude / Codex
unified_agent/backends/base.py - Tool Registry
unified_agent/tools.py - MCP Tool Server
unified_agent/tool_server.py
Interactive Legacy
- Legacy CLI
pentestgpt_legacy/main.py - PTT Orchestrator
pentestgpt_legacy/utils/pentest_gpt.py - Task Commands
pentestgpt_legacy/utils/task_handler.py - Role Prompts
pentestgpt_legacy/prompts/prompt_class.py
LLM Providers
- Session Client
pentestgpt_legacy/llm/client.py - Provider Factory
pentestgpt_legacy/llm/factory.py - Model Registry
pentestgpt_legacy/llm/registry.py - OpenAI-Compatible
pentestgpt_legacy/llm/providers/openai_compatible.py
Other components
- Operator
- Pentest Target
- LLM Provider
- Agent CLI
Connections 24
- Operator → Run Loop: starts run
- Pentest Target → Run Loop: sets target
- Run Loop → Decision Agents: requests decisions
- Run Loop → Session State: persists state
- Decision Agents → Task Planning: proposes tasks
- Run Loop → Task Execution: dispatches work
- Task Execution → Unified Agent: runs agent
- Unified Agent → Claude / Codex: selects backend
- Claude / Codex → Agent CLI: drives CLI
- Unified Agent → Tool Registry: configures tools
- Tool Registry → MCP Tool Server: serves tools
- Run Loop → Run Trial: records trial
- Run Loop → Audit Trail: audits run
- Run Loop → Run Trace: traces run
- Legacy CLI → PTT Orchestrator: starts session
- PTT Orchestrator → Task Commands: accepts commands
- PTT Orchestrator → Role Prompts: uses prompts
- PTT Orchestrator → Session Client: sends role prompts
- Session Client → Provider Factory: uses provider
- Provider Factory → Model Registry: resolves model
- Session Client → LLM Provider: requests completions
- LLM Provider → OpenAI-Compatible: uses compatible API
- Run Loop → Asset Discovery → Vulnerabilities → Report: runs pentest stages
- Run Loop → Recon → Exploit → Walkthrough: runs CTF stages