Skip to content

Web and API Testing

sm0k3net edited this page Nov 28, 2026 · 4 revisions

Web and API testing

Two drawers cover web and API work across three fidelity levels: a bounded HTTP assessment, a real isolated Chromium session, and an API inventory with single requests and controlled fuzzing. All three require an accepted RoE and validate the target against scope before the first byte is sent.

On this page: web assessment · browser sessions · API discovery · single requests · fuzzing · Nuclei · OOB canaries · retest replay.

Web assessment

pentest_web_assess is the cheap first pass: one in-scope URL (up to 5 redirects, 2 MiB body).

Area What is checked
Transport HTTPS versus plaintext HTTP, final URL after redirects
Security headers CSP, HSTS (including max-age and includeSubDomains), X-Content-Type-Options, X-Frame-Options, referrer and permissions policies
Cookies Secure, HttpOnly, SameSite, scope and expiry, with values never echoed
Forms and CSRF Forms, inputs, method, action, and CSRF-token heuristics (hidden token names, meta tags)
Technology Server, framework and library hints from headers, markup and script URLs
Endpoints Inline and external scripts, links and API-shaped paths, capped at 20
Exposure probes HEAD /.git/HEAD, HEAD /.env, HEAD /server-status, with soft-404 detection against the baseline page
Presence checks robots.txt, sitemap.xml, /.well-known/security.txt — informational, never a finding on their own

Findings are capped at 40 and checks at 80; each finding carries severity, WSTG id, OWASP category, the exact excerpt as evidence and a recommendation. The engine records a fact and evidence.

Web test drawer: a live browser session with screenshot and counters

Browser sessions

pentest_browser drives an isolated Chromium instance over the DevTools protocol: a separate process per session, a temporary profile, a viewport (1440×900 default), a 10-minute idle timeout and a cap of 3 concurrent sessions (config clamps to 1–5).

Action Parameters Effect
launch url, width, height Starts a session and navigates; returns browserId
goto browserId, url Navigates within scope
snapshot browserId Returns URL, title, DOM summary, forms, inputs, links, buttons, scripts and meta
click browserId, selector or text, index Clicks the matching element
fill browserId, selector or text, value, submit, index Types into a field, optionally pressing Enter
press browserId, key Sends a key such as Enter, Escape, Tab
eval browserId, expression Evaluates JavaScript in the page and returns JSON-safe output
screenshot browserId, fullPage Captures PNG under the session artifact directory; becomes evidence
cookies browserId Lists cookies with values redacted
storage browserId Local and session storage summary
network browserId, clear Requests observed since the last read
console browserId, clear Console entries since the last read
close browserId Ends the session and removes the temporary profile

A new session needs action:"launch" with a URL; every later call takes browserId.

Scope interception

Launch and navigation accept only http:/https: URLs inside scope; exclusions win, metadata addresses and non-HTTP schemes are refused, and an empty scope means no active testing. Top-level Document requests are intercepted through Fetch.requestPaused, so a server-side redirect cannot escape scope while subresources still load; blocked attempts are logged and counted. The full rule set is in Scope and safety.

Blocking JavaScript dialogs (alert, confirm, prompt, beforeunload) are dismissed automatically so they cannot wedge snapshot or eval; a timed-out snapshot is retried once after the dismissal. Set browser.autoDismissDialogs: false to inspect a dialog manually.

A browser-driven check looks like this:

pentest_browser { action: "launch", url: "https://app.example/login" }
pentest_browser { action: "fill", browserId: "br_…", selector: "#email", value: "tester@example" }
pentest_browser { action: "fill", browserId: "br_…", selector: "#password", value: "…", submit: true }
pentest_browser { action: "screenshot", browserId: "br_…", fullPage: true }
pentest_browser { action: "network", browserId: "br_…", clear: true }

The screenshot lands in $DSH_HOME/redteam/artifacts/<session>/browser/ and becomes evidence; the network read shows the flow's endpoints.

API discovery

pentest_api_discover builds an endpoint inventory for one in-scope base URL from five sources:

  1. OpenAPI/Swagger JSON or YAML at common paths (/openapi.json, /swagger.json, /swagger/v1/swagger.json, /api/openapi.json, /openapi.yaml, /swagger.yaml);
  2. GraphQL introspection at /graphql and /api/graphql — types, queries, mutations;
  3. Browser-observed traffic when you pass browserId: XHR and fetch requests from a live session;
  4. JavaScript bundles mined for API calls and paths, same-origin only;
  5. Bounded path probing of common paths, default 60, probeLimit 0–100.

The row carries method, path, source (openapi, swagger, graphql, observed, js, probe), status, parameters and whether auth appears required; spec title/version and GraphQL counts sit above it. Endpoints become api-endpoint assets plus a fact, and the result is captured as evidence. maxRequests bounds the budget (default 120).

Single scoped requests

pentest_api_request sends one request for authenticated testing: method, URL, headers, body, content type and allowRedirects (up to 5 same-origin). It returns status, headers, a 2 MiB body, timing and redirects. Authorization, Proxy-Authorization, Cookie, Set-Cookie and X-Api-Key values are redacted; the exchange is stored as http evidence with the same redaction.

Fuzzing

pentest_api_fuzz sends one parameter through a payload set, with a benign baseline (dsh-baseline) first. Nine categories ship: sqli, xss, lfi, ssrf, nosql, redirect, traversal, idor, format; payloads overrides with your own list (up to 200 entries).

Control Default Range
location required query, path, body, header
method GET any; body location promotes GET/HEAD to POST
concurrency 3 1–8
ratePerSecond 10 1–50
maxRequests 100 1–200
timeout 15 s fixed ceiling
body cap 2 MiB fixed

Path location needs {parameter} or FUZZ in the URL; body location needs a JSON or form body and a matching content type. An anomaly is any of:

  • status change — a different HTTP status;
  • length delta — more than max(50 bytes, 10%) from the baseline body size;
  • duration spike — more than twice the baseline and at least 100 ms above it (time-based injection);
  • reflection — the payload appears in the response (first 128 KiB inspected);
  • error signature — a database, stack-trace or framework error marker appears.

The run stops after five consecutive network errors, caps anomalies at 100 and results at 200, and reports requests, anomalies, errors, duration and truncation. You choose the rate and volume.

Nuclei template scans

pentest_nuclei runs Nuclei against one in-scope URL with a fixed request budget: JSONL output, no color, update checks disabled, one retry, 10 s timeout and a rate limit of 5–150 requests per second (default 50). severity and tags narrow the template set; templates points at a template file or directory inside the container. Matches are parsed into a fact plus structured rows (template id, name, severity, matched URL, matcher, extracted values); invalid filters are rejected before the process starts.

The apt package ships no templates. Install them once with pentest_exec({ tool: "nuclei", args: ["-update-templates"] }); they land in /root/.local/nuclei-templates and -tl lists them without touching a target.

API test drawer with discovery inventory and fuzzing controls

An API audit looks like this:

pentest_api_discover { baseUrl: "https://app.example/api/", browserId: "br_…", probeLimit: 40, maxRequests: 80 }
pentest_api_request  { method: "GET", url: "https://app.example/api/v1/me", headers: { "Authorization": "Bearer …" } }
pentest_api_fuzz     { url: "https://app.example/api/v1/items?id=1", location: "query", parameter: "id",
                       category: "sqli", maxRequests: 40, ratePerSecond: 5, concurrency: 2 }

Read the inventory first: undocumented endpoints and endpoints that answer without auth are the interesting ones. Then confirm behavior with one authenticated request, and only then fuzz one parameter with a small budget. Every exchange is already in the evidence vault.

OOB canaries

Some issues are proven by the target calling you: SSRF, blind XXE and similar. pentest_oob creates a local callback URL and records the hit.

pentest_oob { action: "create", label: "ssrf", target: "https://app.example" }   → url
# embed the url in the vulnerable parameter, then let the target fetch it
pentest_oob { action: "check", id: "canary_1" }
pentest_oob { action: "list" }
  • The route is /dsh-redteam/canary/rt-…; it answers a 1×1 PNG and records source address, user agent, method and path. It is rate-limited per token (60/min), dedupes identical metadata inside five seconds and caps bodies at 4 KiB.
  • Canaries expire (default 60 minutes, maximum 24 hours) and are removed with prune. A late hit on an expired canary is still kept as evidence until pruning.
  • Tokens are bearer capabilities. They are redacted from the panel snapshot, the audit tail and bundles; never paste a canary URL into a public ticket or report.
  • If DSH is behind a proxy or not reachable by the target on its current origin, set publicBaseUrl to the reachable origin and create a new canary. No external interactsh/webhook provider is used by default.

Retest replay

pentest_retest turns a stored request into a bounded replay so a fix can be verified.

pentest_retest { action: "plan", findingId: "finding_3" }
pentest_retest { action: "run", findingId: "finding_3", confirm: true }

plan parses raw-HTTP or curl evidence offline and reports the method, URL, risk and expected marker/status. run sends exactly one request, requires confirm: true and an in-scope URL, permits only GET, HEAD and POST, and refuses non-HTTP(S) targets and clearly destructive paths. The replay reuses the stored request headers; the lifecycle record redacts credential header values. The verdict is fixed, still-vulnerable or inconclusive; the finding is never changed to exploited. The response is captured as JSON evidence and a lifecycle record is added to state.retests.

Related

Clone this wiki locally