Implementation:0xSteph Pentest ai Authenticated Scan
| Knowledge Sources | |
|---|---|
| Domains | Web_Security, Active_Scanning, Injection_Detection |
| Last Updated | 2026-10-23 00:00 GMT |
Overview
Concrete tool for authenticated active web scanning with login, crawl, and payload injection for SQLi/XSS/CMDi, provided by the pentest-ai engine.
Description
The run_authenticated_scan function logs into a target, crawls same-host pages under the authenticated session, extracts query parameters and form fields, and fires deterministic payloads for SQL injection, reflected XSS, and command injection. Each confirmed hit becomes a structured finding with evidence. It is intentionally standalone: no LLM, no external tools, just httpx + response pattern matching. It includes destructive-parameter keyword filtering to skip forms that could modify state (password changes, deletes, role grants).
Usage
Import this function when you need to run an authenticated active web scan against a target. Provide either a WebAuthenticator (to run a fresh login) or a pre-existing AuthSession (to resume a session). Pass a ScopeEnforcer to ensure crawled endpoints are within the operator's confirmed scope.
Code Reference
Source Location
- Repository: 0xSteph_Pentest_ai
- File: engine/authenticated_scan.py
- Lines: 1-479
Signature
async def run_authenticated_scan(
target: str,
authenticator: WebAuthenticator | None = None,
session: AuthSession | None = None,
max_pages: int = 40,
timeout_seconds: float = 10.0,
scope: Any = None,
) -> dict[str, Any]:
"""Authenticate (if needed), crawl, probe, return findings."""
Import
from engine.authenticated_scan import run_authenticated_scan, ScanConfig, DiscoveredEndpoint
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| target | str | Yes | Base URL to scan (e.g. http://localhost:3000)
|
| authenticator | None | No | Login flow to obtain a session (required if session is None) |
| session | None | No | Pre-existing authenticated session to reuse |
| max_pages | int | No | Maximum pages to crawl (default: 40) |
| timeout_seconds | float | No | HTTP request timeout (default: 10.0) |
| scope | Any | No | ScopeEnforcer to filter endpoints before probing |
Outputs
| Name | Type | Description |
|---|---|---|
| target | str | The scanned target URL |
| endpoints_tested | int | Number of parameterized endpoints probed |
| findings_count | int | Total findings found |
| findings | list[dict] | List of finding dicts with title, description, severity, category, evidence, poc |
Usage Examples
Basic Authenticated Scan
import asyncio
from engine.auth_session import WebAuthenticator
from engine.authenticated_scan import run_authenticated_scan
auth = WebAuthenticator(
flow="form_post",
login_url="http://localhost:3000/login",
username="admin",
password="password123",
)
result = asyncio.run(run_authenticated_scan(
target="http://localhost:3000",
authenticator=auth,
max_pages=20,
))
print(f"Tested {result['endpoints_tested']} endpoints")
print(f"Found {result['findings_count']} findings")
for f in result["findings"]:
print(f" [{f['severity']}] {f['title']}")
With Scope Enforcement
import asyncio
from engine.auth_session import WebAuthenticator
from engine.authenticated_scan import run_authenticated_scan
from engine.scope import build_enforcer
scope = build_enforcer(["localhost:3000"], exclusions=["/admin/*"])
auth = WebAuthenticator(
flow="form_post",
login_url="http://localhost:3000/login",
username="admin",
password="password123",
)
result = asyncio.run(run_authenticated_scan(
target="http://localhost:3000",
authenticator=auth,
scope=scope, # out-of-scope endpoints dropped before probing
))