Implementation:0xSteph Pentest ai ReconAgent run recon
| Knowledge Sources | |
|---|---|
| Domains | Security_Testing, Reconnaissance |
| Last Updated | 2026-10-23 12:00 GMT |
Overview
Concrete LLM-driven reconnaissance agent that runs network reconnaissance and OSINT against a target, with a deterministic fallback when no LLM is available.
Description
The ReconAgent class is the first phase of the engagement lifecycle. It performs reconnaissance using both built-in scanners (no dependencies) and external tools (if installed). When an LLM is configured, the agent reasons about which tools to run and adapts based on findings. Without an LLM, it falls back to a deterministic tool loop.
Depth levels:
- passive: Subdomain enumeration and OSINT only (no direct target contact)
- standard: Passive + port scanning + web tech detection
- deep: Standard + vulnerability scanning + content discovery
Per-phase finding caps prevent DB explosion (subdomain_enum: 200, port_scan: 500, vuln_scan: 1000). Caps are overridable via `PENTEST_AI_MAX_FINDINGS_<PHASE>` env vars.
Usage
Import this when you need to:
- Run the recon phase of an engagement
- Perform network reconnaissance with LLM-driven tool selection
- Enumerate subdomains, ports, services, and web technologies
Code Reference
Source Location
- Repository: pentest-ai
- File: agents/recon/recon_agent.py
Signature
class ReconAgent(BaseAgent):
agent_type = "recon"
def __init__(
self,
registry: Any,
db: Any,
llm: LLMClient | None = None,
scope: Any = None,
):
async def run_recon(
self,
target: str,
depth: str = "standard",
engagement_id: str = "",
) -> dict[str, Any]:
"""Run reconnaissance. LLM-driven or deterministic fallback."""
# Per-phase finding caps (env-overridable)
PHASE_FINDING_CAPS = {
"subdomain_enum": 200,
"osint": 200,
"port_scan": 500,
"web_tech": 100,
"vuln_scan": 1000,
"content_discovery": 500,
}
Import
from agents.recon.recon_agent import ReconAgent
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| target | str | Yes | Hostname, IP, or URL to recon |
| depth | str | No | passive / standard / deep (default: standard) |
| engagement_id | str | No | For FindingsDB persistence |
Outputs
| Name | Type | Description |
|---|---|---|
| returns | dict[str, Any] | target, depth, findings_count, status, phases_completed |
Usage Examples
Running Reconnaissance
from agents.recon.recon_agent import ReconAgent
from tools.registry import ToolRegistry
registry = ToolRegistry()
agent = ReconAgent(registry, db, llm=my_llm, scope=scope)
agent.set_rate_limiter(rate_limiter)
result = await agent.run_recon(
target="https://app.example.com",
depth="deep",
engagement_id="eng-123",
)
print(f"Recon complete: {result['findings_count']} findings")