# Hunt Ics

> 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.

- Skill: `encod3d-sec/hunt-ics-2` (Agent Skill, multi-file: 3 files)
- Install (CLI): `npx get-skill add encod3d-sec/hunt-ics-2`
- Raw SKILL.md: https://api.skillmd.com/api/skills/encod3d-sec/hunt-ics-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-ics-2

---


# Hunt: ICS / SCADA / OT

> Current emphasis (update on wiki harvest): HMI-oracle register mapping and
> bounded, reverting, one-coil interlock probes over blind Modbus write loops
> - models over-index on over-represented old methods; the newest harvested
> technique leads the checklist 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.

## 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/ics/<host>
    # VM side (WHERE nmap + python3 run, same tree through the share):
    ENG_DIR=/mnt/VMshare/<eng>/<eng>
    RUN=$ENG_DIR/hunt/ics/<host>

Corpus and probes live in the VMshare tree. nmap/pymodbus runs from
the Kali VM as tz; HMI/Node-RED HTTP via the shim. 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:

    cd /mnt/c/Users/Lenovo/Documents/ObisidianVaults/ZTorch/ZTorch && bash scripts/vm-ssh.sh '<command>'

- vm-ssh lands as user tz (NOT root); one argument per call; quotes
  ship as base64 (`echo <b64> | base64 -d | bash`).
- HTTP fetches via /opt/scope-shim/bin/{curl,httpx}; out-of-scope
  dies rc 126 (never work around); UNKNOWN = ADVISORY, self-deny.
- python-snap7/pymodbus when needed (install-on-demand per the
  operator rule):

       python3 -c "import snap7" 2>/dev/null          || pip3 install --user --break-system-packages -q python-snap7          || echo "N/A: python-snap7 absent on VM (install failed)"
       python3 -c "import pymodbus" 2>/dev/null          || pip3 install --user --break-system-packages -q pymodbus          || echo "N/A: pymodbus absent on VM (install failed)"

- RoE: this is the no_dos/no_bruteforce heaviest skill - bounded,
  reverting, one-write-at-a-time probes ONLY (see SAFETY).

## Entry gate

All four must pass; each is falsifiable:

1. Active engagement exists (repo tree targets/<eng>/active.md) and
   the OT host is on targets/<eng>/scope.md in-scope AND explicitly
   an authorized lab/simulation for any write work. 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) state.md asset table has OT-port rows (502/102/44818/20000/
   1880/8080); \
   (b) a recon lane captured an HMI/Node-RED surface; \
   (c) kickoff seeded $RUN/raw/ot-port-map.md.
   None = dispatch the surface lane first.
4. Toolchain preflight (fails LOUD):

       for t in /usr/bin/jq /usr/bin/python3 /usr/bin/nmap                  /opt/scope-shim/bin/curl; do
         [ -x "$t" ] || { echo "MISSING TOOL: $t"; exit 1; }
       done
       python3 -c "import snap7" 2>/dev/null          || pip3 install --user --break-system-packages -q python-snap7          || echo "N/A: python-snap7 absent on VM (install failed)"

## Checklist (mandatory)

Copy checklist.md (this skill's dir) to
`$ENG_DIR/hunt/ics/<host>/ics-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.

## SAFETY - hard stop, overrides everything below

Writing to a live PLC moves real machinery: it can over-pressure a vessel, over-speed a motor, or disable a safety interlock, and so **damage equipment or injure and kill people**. Only ever drive a process toward a dangerous state on a target that is EXPLICITLY an authorized lab or CTF simulation. Never on a real plant, and never when scope carries `no_dos`/`passive_only` - there OT is READ-ONLY (FC1-4), never write (FC5/6/15/16). The instant the objective is met (e.g. the flag the HMI/CCTV reveals is in hand), STOP writing and revert any coil/register you changed if you can. This is a hard stop and it outranks every other note in this file.

2025-26 technique ladder: `references/bypass-arsenal.md` (NEW classes, defense->bypass map).

## Wiki

Hub: [[network-moc]] - Primary page: [[ics-scada-modbus]] - Payload arsenal: `wiki/payloads/modbus.md`
Anchors: [[iot-attacks]], [[firmware-hardware]], [[modbus]]
**REFS:** [[ics-scada-modbus]], wiki/payloads/modbus.md

mcp__wiki-search__query (lex) "ICS SCADA OT Modbus S7comm EtherNet/IP DNP3 OpenPLC Node-RED PLC HMI coil holding register" via wiki-search MCP - ONLY when you have a concrete hint the map above
doesn't cover (a specific sink/version/CVE, an observed escape); not a blanket first step.

## Attack surface (ranked by exploitation value)

**APPROACH:** Recon the OT ports (Modbus 502, S7 102, EtherNet/IP 44818, DNP3 20000), find the HMI/Node-RED oracle that NAMES the registers, dump and ASCII-decode FC1-4, map process variables, then (authorized lab ONLY) FC6 over-drive plus a bounded, reverting, one-coil-at-a-time probe to defeat the interlock.
**AVOID:** An open Modbus/S7 port, a readable coil/register, or a write that ACKs with no observed state change is NOT a control finding - the oracle (HMI/live-state) must flip to the intended state; a readable register alone is only reachability.

1. **Modbus / TCP 502** - no auth, no session, trivially readable AND writable. The primary lever: FC1-4 read coils/registers, FC5/6/15/16 write them. Highest value, highest danger.
2. **OpenPLC web (8080)** and **Node-RED (1880, dashboard `/ui`)** - the SCADA/IT side that drives the PLC. OpenPLC routes `/programs /monitoring /hardware /users`; authed OpenPLC = upload-program RCE. Node-RED `/ui` socket.io config NAMES the registers.
3. **HMI web app** (Flask/Werkzeug with an `/api/...` live-state endpoint) - not itself the lever but the ORACLE that tells you whether a write landed.
4. **S7comm / TCP 102** (S7/iso-tsap) - `python-snap7` `db_read` for creds/flags in data blocks.
5. **EtherNet/IP 44818**, **DNP3 20000**, then **BACnet 47808/udp**, **Fox 1911/4911**, **OPC-UA 4840** - enumerate with the matching nmap scripts; less commonly the CTF lever, but map them.

## Methodology
1. **Recon**: `nmap -p- ...` then `nmap -Pn -p102,502,20000,44818 --script s7-info,modbus-discover,enip-info,dnp3-info $T`. Note the unit/slave id ("sid 0x1").
2. **Find the oracle**: the HMI `/api/state`-style endpoint (it reads the PLC and tells you live status). Node-RED `/ui` socket.io config NAMES the registers ("Read Pressure" = FC3 reg0). This is how you know a write landed.
3. **Enumerate Modbus** (raw socket, not pymodbus): dump FC1-4, **ASCII-decode registers** (creds/flags hide there), scan unit ids. Reads (FC1-4) are safe; this step never writes. See [[modbus]].
4. **Map process variables -> registers/coils**. The pressure/temp/level sensor is a holding/input register; pumps/valves/cooling/safety are coils.
5. **Drive to the danger state (authorized lab/CTF ONLY - see SAFETY)**: `FC6` over-drive the process variable to max (65535); then **defeat the safety/protection interlock** - a controller loop (cooling/relief/ESD) fights you, and it is usually ONE coil. Find it with a BOUNDED, one-write-at-a-time probe, NEVER a free-running write loop (hunt-core: never enumerate writes; this narrow, reverting, oracle-gated probe on an authorized simulation is the sole carve-out): write ONE coil (FC5), read the HMI oracle, and if the state did not flip toward the goal, write that coil back before trying the next. Cover coils 0-31 this way - the control coil is rarely at 0-5, so go wide but stay bounded. If nothing in 0-31 flips the interlock, that is a Deadend; do not widen indefinitely.
6. **Read the payoff**: HMI flips (e.g. "Explosion Detected!") and points the CCTV/HMI at new media. **The flag is frequently a VISUAL overlay** in that image/video - fetch it, `ffmpeg -i x.mp4 -vf fps=1 f_%02d.jpg`, and VIEW the frames (not strings/exif). Objective met -> stop writing (SAFETY).
7. **S7**: `python-snap7` `db_read` the data blocks (creds/flags). Banner-only sims (s7-info works but no DBs) = decoy.
8. **OpenPLC**: try `openplc:openplc`; if changed, do NOT grind the login - the protection is usually disabled directly over Modbus (a coil flag the ladder reads). Authed OpenPLC = upload-program RCE.
9. **Distill (when confirmed):** stage a GENERIC candidate - `python3 scripts/wiki-stage.py --kind technique --slug <slug> --target-page techniques/mobile-iot/ics-scada-modbus.md`.

## Chaining
- HMI / Node-RED web app -> read the `/api/state` oracle and the register NAMES -> know exactly which Modbus address is the process variable and which is the interlock, instead of guessing blind.
- OpenPLC authed (default `openplc:openplc`) -> upload-program RCE on the SCADA host -> shell, not just process control. Prefer disabling protection over unauthenticated Modbus first (cheaper, no login grind).
- Danger state reached -> the payoff media (CCTV/HMI overlay) -> flag. The Modbus write is the pivot; the flag is in the frame (step 6).

## Evasion
- Wrong **unit/slave id** looks like a dead PLC: if FC1-4 error out, scan unit ids (the `modbus-discover` "sid" value) before concluding the device is read-only or absent.

## Lessons (THM Kaboom)
- The challenge NARRATIVE is the literal solve ("over-pressure the pump -> blow-out", "disable the protection"). Map each phrase to a Modbus write before chasing web creds.
- Coils 0-5 were inert; the safety kill-switch was **coil 10** -> sweep WIDE (still bounded and reverting, per step 5).
- The OpenPLC login (`openplc:openplc` changed) was a rabbit hole that OOM'd the tooling host with a brute. Disable protection over Modbus instead.
- Flag was burned into the CCTV explosion video (`/video?mode=explodedflag23`), invisible to strings -> extract + view frames.

## N/A escapes

- "N/A: no OT protocols in scope" (port map shows none of 502/102/
  44818/20000/1880/8080)
- "N/A: python-snap7 absent on VM (install failed)"
- "N/A: pymodbus absent on VM (install failed)"
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 OT port map, output ONLY $RUN/analysis/bitter-pill.md (tried/
found/dismissed, every claim carries evidence). The SAFETY hard stop
and the oracle-observed gate survive freehand. Declare with a
_requests.md row (lane = hunt-ics-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-ics-<host>.md (pointer with ICS-HUNT-DONE + counts).
Consumer (triage) finds at $RUN: raw/ot-port-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/mobile-iot/ics-scada-modbus.md`.

## Confirmation gate

**NOT confirmation:** a Modbus/S7/EtherNet-IP port open and banner-grabbed; a coil/register/data-block you can only READ; an FC1-4 dump that returns values; the HMI showing a value you did not change; a write (FC5/6/15/16) that returned an ACK with no observed state change. A readable register alone proves reachability, not control.

**IS confirmation (control/impact finding):** a coil/register you WROTE whose effect is observed on the oracle - the HMI / Node-RED live-state flips to the intended (danger) state, the simulated process variable moves, or the interlock is demonstrably defeated - reproduced on a clean connection, culminating in the payoff (the flag the HMI/CCTV reveals). No observed effect = no control finding; log it as reachability at most.

An unauthenticated READ of OT state is a valid lower-severity finding in its own right (confirmed by demonstrating the unauth read), but it is NOT a control or physical-impact claim - keep the two separate.

## Validation

- Proof (read-only): a point value change observed on TWO polls (cache vs live), from
  the PLC, not the gateway's shadow. Writes/actuation need explicit operator
  authorization BEFORE the request; default posture here is enumerate-and-stop.

## False Positives

- HMI running a demo/simulation mode (values move on their own).
- Read-only registers misidentified as actuators from a register map guess.
- Engineering port open but session-authenticated (portal, not protocol).
- Responses from a gateway/OPC server proxying, not the controller itself.

## Cross-routing

- Load hunt-vpn for the remote-access path IN (historically the entry vector).
- Load hunt-ad for domain-joined HMIs/engineering stations.
- Not this skill: corporate IT segment behind the same firewall (route by class).

## Severity

| Demonstrated impact | Rating |
|---|---|
| Unauth write to a safety-critical coil/register - physical impact, ESD or interlock bypass | critical |
| Unauth process-variable write (no safety bypass) | high |
| Unauth read of OT state (registers/coils/data blocks) | medium |

## Deadends

```
Append: - [ ] ICS <host> -- <proto> read-only / sim-only; no writable control coil found (swept 0-31)
```

Record the range you swept and whether an oracle existed, so the next pass does not re-run the same bounded probe.

## Stop conditions

Terminal states complete (probed | N/A with reason | deadend row
written), nothing written into skill dirs (skills/exploit/hunt/
hunt-ics/ stays untouched), no unchecked boxes above REVIEW. hunt-core
stop conditions fire unchanged (any write to a live safety-critical coil/register beyond the minimum needed to prove the primitive = stop immediately; a read-only confirmation is preferred over a write wherever one exists).

