Implementation:0xSteph Pentest ai agents Handoff Report Generator
| Knowledge Sources | |
|---|---|
| Domains | Security, Reporting, CLI |
| Last Updated | 2026-10-22 12:00 GMT |
Overview
Concrete script for generating cross-session Markdown handoff reports from SQLite engagement data provided by the pentest-ai-agents toolkit.
Description
The handoff.sh script produces a structured Markdown summary of the current engagement state, designed for cross-session continuity. When an operator closes one session and another picks up the engagement, this report gives a complete snapshot: engagement summary, hosts, services, vulnerabilities grouped by severity, credentials, attack chains, recent activity log, and auto-generated suggested next steps.
It sources `db/lib/common.sh` for database access and uses `require_engagement()` to identify the active engagement from the `PENTEST_AI_ENGAGEMENT` environment variable. The script takes no CLI arguments and writes all output to stdout.
Usage
- End of session: Run `handoff.sh` at the end of a testing session to generate a handoff report for the next operator or session.
- Progress check: Run mid-engagement to get a structured summary of current findings.
- Report scaffolding: Use the output as a starting point for the final engagement report.
Code Reference
Source Location
- Repository: pentest-ai-agents
- File: db/handoff.sh
Signature
#!/usr/bin/env bash
# Standalone script - no arguments
# Uses PENTEST_AI_ENGAGEMENT env var for active engagement
# Internal helpers:
section(title: str) # Prints "## {title}" header
row(text: str) # Prints a row (used in tables)
# Output sections (all to stdout):
# 1. Engagement Summary (client, type, status, scope, started)
# 2. Hosts (IP, hostname, OS, role, status)
# 3. Services (host, port, protocol, service, version)
# 4. Vulnerabilities (grouped by severity: critical, high, medium, low, info)
# 5. Credentials (username, domain, type, access, source, host)
# 6. Attack Chains (name, score, status, steps, MITRE IDs)
# 7. Recent Activity (last 30 session log entries)
# 8. Suggested Next Steps (auto-generated from unconfirmed vulns, untested creds, incomplete chains)
Import
# Invoke directly (no arguments needed):
handoff.sh > handoff_report.md
# Or pipe to file:
handoff.sh | tee handoff_$(date +%Y%m%d).md
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| PENTEST_AI_ENGAGEMENT | env var | Yes | Active engagement ID |
| PENTEST_AI_DB | env var | No | Database path override |
Outputs
| Name | Type | Description |
|---|---|---|
| Markdown report | stdout | Full engagement handoff report in Markdown format |
Usage Examples
Generate a Handoff Report
# Set active engagement
export PENTEST_AI_ENGAGEMENT="acme-2026-q4"
# Generate and save the handoff report
handoff.sh > handoff_acme_2026q4.md
# Display in terminal
handoff.sh
Auto-Generated Next Steps
# The script automatically generates suggested next steps based on engagement state:
# - Unconfirmed vulnerabilities → "Validate N unconfirmed vulnerabilities (use poc-validator)"
# - Untested credentials → "Test N untested credentials (use credential-tester)"
# - Incomplete chains → "Complete N attack chains (use exploit-chainer)"
# - All clean → "All findings validated. Ready for report generation."
Related Pages
Implements Principles
- Principle:0xSteph_Pentest_ai_agents_Persistent_Engagement_Storage
- Principle:0xSteph_Pentest_ai_agents_Pentest_Reporting
Requires Environment
Related Implementations
- Implementation:0xSteph_Pentest_ai_agents_Findings_CLI populates the database that handoff.sh reads from
- Implementation:0xSteph_Pentest_ai_agents_Db_Common_Library provides require_engagement, db_exec used by this script