A run is a sequence of small, recorded decisions: move a phase, check the tool and the scope, execute, turn output into facts, and leave the phase closed with a reason. The engine enforces the order; you enforce the judgement.
The nine phases
The phase order is fixed. Each phase has a status (pending, running, done, blocked or skipped), a start and end time, a note, and the tools and workers recorded against it.
| # | Phase | What you are establishing | Typical catalogue tools |
|---|---|---|---|
| 1 | Pre-engagement | Authorization, scope, success criteria | No execution; scope and RoE |
| 2 | Recon | Reachable hosts, names, certificates, exposure | nmap, subfinder, httpx, amass, dnsx |
| 3 | Enumeration | Services, paths, parameters, identities | gobuster, ffuf, katana, enum4linux-ng |
| 4 | Vulnerability analysis | Candidate weaknesses with evidence | nikto, nuclei, whatweb, web/API tools |
| 5 | Exploitation | Controlled proof that a weakness is real | sqlmap, metasploit-framework (gated in SAFE) |
| 6 | Privilege escalation | Proof of a higher-privilege path | Host and AD tooling (gated in SAFE) |
| 7 | Lateral movement | Proof of reach into another system | impacket, evil-winrm, chisel (gated) |
| 8 | Post-exploitation | Minimal-impact collection and detection notes | Scoped utilities; no persistence |
| 9 | Reporting | Verified findings, evidence and deliverables | pentest_report, pentest_complete_engagement |
Phase gating and backtracking
Forward movement is limited to one phase beyond the furthest phase reached; backward movement is always allowed, because a new fact can invalidate a conclusion. A call with only phase starts a pending phase or closes a running one. running and done require an accepted RoE. skipped and blocked require a written note — the reason becomes part of the report, so a gap is documented rather than hidden. Moving forward closes the previous running phase as done.
pentest_set_phase({ phase: "recon" })
pentest_set_phase({ phase: "enumeration", status: "running" })
pentest_set_phase({ phase: "exploitation", status: "skipped",
note: "Client deferred exploitation to a second engagement." })
Skipping is not a shortcut for "we ran out of time" on a phase that was never attempted; use blocked when a real obstacle stopped you, and state the obstacle. The completion checklist accepts both, but a reader can tell the difference.
Planning and the team board
pentest_plan keeps a deterministic plan beside the engagement: an objective and steps, per-step status, owner, phase, tools, deliverable and budget, plus consumed usage in tools, tokens and minutes. Actions are create, status, update, consume, critic and close. The critic returns a verdict and a score against the stored plan; it does not invent work.
pentest_plan({ action: "create", objective: "Validate the checkout flow",
steps: [
{ phase: "recon", objective: "Map the storefront and auth endpoints" },
{ phase: "vulnerability-analysis", objective: "Test idempotency and coupon reuse" }
] })
pentest_team keeps a role and task board: plan, status, add, update, focus, reassign, handoff, prompt and close. Tasks carry dependencies, owner, priority, write scopes and a deliverable; prompt builds a delegation prompt for one task. With publish: true on plan or prompt, the tool creates matching native Agent Teams tasks in dependency order when Team mode is enabled; otherwise it returns a warning and the local board still stands.
The Team tab renders the same board and task counts. The plan is operational scaffolding, not a second source of findings: close the plan when the work is done, and let the graph carry the evidence.
The pentest_exec contract
Every command goes through one executor, whether it runs in the Kali container or in degraded host mode. The contract is deliberately narrow:
| Parameter | Required | Behaviour |
|---|---|---|
tool | yes | Catalogue name, apt package or binary; aliases resolve before spawning |
args | yes | argv array, never a shell string; no interpolation |
target | no | Checked against scope before an approval exists; out-of-scope is refused |
category | no | May raise the catalogue category, never lower it; the more severe wins |
timeoutMs | no | Per-call budget, capped at one hour; default 15 minutes |
rationale, impact | no | Shown on the approval card in SAFE mode |
pentest_exec({
tool: "nmap",
args: ["-sV", "-Pn", "-p", "443,8443", "shop.example.com"],
target: "shop.example.com",
category: "recon",
rationale: "Fingerprint the TLS endpoints named in the scope.",
impact: "Service probes only; no authentication attempts."
})
stdout and stderr are captured up to 200 KB each, with exit code, duration and the runtime actually used. The capture becomes hashed evidence automatically, so an attempt is visible in the report even when it fails. Exit 126 or 127 means the binary is missing or not executable in the active runtime; check pentest_tool_inventory before retrying.
Approvals in the middle of a run
In SAFE mode, a call whose effective category is exploitation, privesc, lateral, exfiltration, credential or credential_dump creates an approval request after the target has passed the scope check. The card records the tool, exact command, target, phase, category, worker, rationale and expected impact.
| Decision | Effect | Recorded status |
|---|---|---|
| Approve once | This call runs; a later call asks again | approved_once |
| Approve for phase | Grants that category for that phase; later calls in the same phase and category skip the card | approved_phase |
| Deny | The call returns a denial result; nothing executes | denied |
| No answer | Expires after approvalTimeoutMs (default five minutes); the call returns a denial | expired |
Approvals are never granted automatically, never persist across engagements, and are not a queue the agent can clear. A phase grant is the only decision with memory, and it is scoped to one category in one phase.
When a call blocks
A blocked call is a normal result, not an error to route around. Read the queue with pentest_approvals (it lists pending requests for this engagement), then decide in the Approvals drawer.
Repeating a blocked call does not create consent and does not clear the card. If the approval expired, approve and then repeat the call so a fresh request is created; if it was denied, stop and change the plan. The audit trail records every attempt, including the ones that went nowhere.
pentest_approvals()
pentest_state() // phase, pending approvals, next gate reason
If the card vanished and the tool never ran, it expired. Expiry is not a denial: the run stays blocked, the record becomes expired, and nothing executed. Approve, then repeat the call so a fresh approval is created. If a run is already executing and will not finish, the Activity tab's kill control terminates it; the run keeps its partial output, exit status and audit record. Killing does not delete evidence.
Stopping and restarting
Not every engagement ends with a report. 1.3 adds an explicit lifecycle so an engagement can be halted or reset without losing the record or the authorisation. Both actions live in Scope & RoE, ask for confirmation and are operator-only — there is no agent tool for either.
| Action | What it does | What it keeps |
|---|---|---|
| Stop | Kills active tool runs, interrupts tracked native agents, marks the running phase blocked, denies pending approvals and sets the engagement to stopped | Findings, evidence, reports, the plan and the full audit trail |
| Restart from scratch | Archives the old state and artifacts, then starts a new engagement id from pre-engagement with the same name, client, scope, accepted RoE and mode | Scope, client, RoE and mode; the archive on disk |
Stop is refused for a completed engagement — the final report set is already the end of that lifecycle. Restart accepts a stopped, completed or active engagement; an active one is stopped first, and any agent that could not be interrupted is reported as a warning rather than silently ignored.
The archive is written under $DSH_HOME/redteam/archives/<session>/<engagement>-<timestamp>/, containing state.json and the moved artifact directories. The new engagement starts with no findings, tool runs, reports, plan or team board; the old ones are in the archive, not deleted. Edit the scope while stopped, then restart to begin again from pre-engagement.
# examples of the lifecycle records you will see in the audit trail
engagement_stopped
engagement_restarted
Restart is destructive by intent: it is a new engagement with the same authorization, not a rollback. If you need to preserve a final set, complete and export it before restarting.
Progress and completion
Progress is a simple function of phase state: done and skipped phases count one, a running phase counts half, and the total is nine. That is why a phase you never started shows as zero even if the graph is busy.
pentest_complete_engagement is the only action that produces a final set. It refuses while any non-reporting phase is neither done nor skipped with a reason, and refuses if reporting is blocked. On success it marks reporting done, sets the engagement completed, and generates the requested formats (default md, pdf, json). Any report generated before that point is stamped as a draft.
pentest_complete_engagement({
formats: ["md", "html", "pdf", "docx"],
lang: "en",
note: "All agreed phases closed; exploitation deferred in writing."
})
The returned checklist names open phases, verified findings, evidence count and the report paths. If it refuses, fix the named phase rather than generating another draft.
Next: the toolbox, wordlists and OSINT. Reference: TOOLS.md and USER-GUIDE.md.
What good looks like
- Phases advance one step at a time and can always move back; skipped and blocked phases need a written reason.
- pentest_exec takes an argv array and validates the target against scope before any approval request exists.
- Category can be raised by the caller but never lowered, so an exploitation use of a recon tool still hits the SAFE gate.
- Approve once, approve for the phase, deny or let it expire — and never retry a blocked call in a loop.
- Completion needs every non-reporting phase closed and produces the only final report set; earlier reports are drafts.
- Stop and Restart are operator-only, audited and archive the record — restart begins a new engagement, it does not roll back.