Field manual · 04

Running the engagement

The nine phases, the plan, tool execution, approvals in the middle of a run and how to recover.

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.

#PhaseWhat you are establishingTypical catalogue tools
1Pre-engagementAuthorization, scope, success criteriaNo execution; scope and RoE
2ReconReachable hosts, names, certificates, exposurenmap, subfinder, httpx, amass, dnsx
3EnumerationServices, paths, parameters, identitiesgobuster, ffuf, katana, enum4linux-ng
4Vulnerability analysisCandidate weaknesses with evidencenikto, nuclei, whatweb, web/API tools
5ExploitationControlled proof that a weakness is realsqlmap, metasploit-framework (gated in SAFE)
6Privilege escalationProof of a higher-privilege pathHost and AD tooling (gated in SAFE)
7Lateral movementProof of reach into another systemimpacket, evil-winrm, chisel (gated)
8Post-exploitationMinimal-impact collection and detection notesScoped utilities; no persistence
9ReportingVerified findings, evidence and deliverablespentest_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.

One-step-forward phase movement with backtracking Nine phases in order. From the furthest reached phase you may start the next one or move back; jumping two phases ahead is refused with a phase-order error. A skipped or blocked phase needs a reason and stays visible in the report. Reporting is closed by completion. FIXED ORDER pre recon enum vuln exploit privesc lateral post report +1 only backtracking is allowed when facts change skipped / blocked requires a note; stays in the report running / done requires an accepted RoE completion all non-reporting phases closed
Figure 2. The phase engine is a ratchet with a reverse gear: one step forward, any number back, and every exception carries a reason.

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:

ParameterRequiredBehaviour
toolyesCatalogue name, apt package or binary; aliases resolve before spawning
argsyesargv array, never a shell string; no interpolation
targetnoChecked against scope before an approval exists; out-of-scope is refused
categorynoMay raise the catalogue category, never lower it; the more severe wins
timeoutMsnoPer-call budget, capped at one hour; default 15 minutes
rationale, impactnoShown 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.

DecisionEffectRecorded status
Approve onceThis call runs; a later call asks againapproved_once
Approve for phaseGrants that category for that phase; later calls in the same phase and category skip the cardapproved_phase
DenyThe call returns a denial result; nothing executesdenied
No answerExpires after approvalTimeoutMs (default five minutes); the call returns a denialexpired
Approval required modal showing a Metasploit command, target, in-scope result, phase, worker, rationale, expected impact and three decision buttons
Figure 1. What the operator sees before a gated call runs. The scope result is shown because it was checked first: an out-of-scope target never reaches this card. Deny, approve for the phase, or approve once. The agent waits; it cannot resolve the card itself.

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.

Retry is not approval

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.

ActionWhat it doesWhat it keeps
StopKills active tool runs, interrupts tracked native agents, marks the running phase blocked, denies pending approvals and sets the engagement to stoppedFindings, evidence, reports, the plan and the full audit trail
Restart from scratchArchives the old state and artifacts, then starts a new engagement id from pre-engagement with the same name, client, scope, accepted RoE and modeScope, 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.