# Hunt Sqli Union

> UNION-based extraction expert of the sqli split: the query result

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

---


# Hunt: SQLi - UNION expert (microskill)

UNION-based extraction expert of the sqli split: the query result
renders, so the union renders. The core (hunt-sqli) owns mapping and
the sqlmap contract; this skill owns column count, display sizing,
and bounded row extraction.

Load-bearing ideas: (1) UNION needs a REFLECTIVE sink - the result
must render (error-based covers the rest); (2) count columns with
ORDER BY first, then size the display - a column that truncates at
the UI is a lost extraction channel.

## Wiki

Hub: [[sql-injection]] - Primary page: [[sql-injection]]
**REFS:** [[sql-injection]]

qmd on hint only: "union sqli order by column count information
schema display truncation" - the sqli page first.

Shared obfuscation arsenal: `hunt-sqli/references/waf-bypass.md` -
UNION keyword games (DISTINCTROW, parens-only, split keywords),
json_arrayagg (16MB vs GROUP_CONCAT 1024 chars) for display-truncation
and rate-limit windows, information_schema alternatives.

## Paths (binding - shared with the core run)

    # seat side (wsl):
    ENG_DIR=/mnt/c/Users/Lenovo/Desktop/VMshare/<eng>/<eng>
    RUN=$ENG_DIR/hunt/sqli/<host>          # SHARED with hunt-sqli
    # VM side:
    ENG_DIR=/mnt/VMshare/<eng>/<eng>
    RUN=$ENG_DIR/hunt/sqli/<host>

Experts write probes/sqli-union.jsonl into the core's $RUN tree.

## 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); one argument per call; quotes
  ship as base64 (`echo <b64> | base64 -d | bash`).
- Target-facing curls MUST use /opt/scope-shim/bin/curl by absolute
  path; out-of-scope dies rc 126 (never work around); UNKNOWN =
  ADVISORY, self-deny.
- sqlmap escalation lives in the CORE's canonical contract - BY
  REFERENCE, never a second copy here.

## Entry gate

All four must pass; each is falsifiable:

1. Active engagement exists; the injection point is on
   targets/<eng>/scope.md in-scope. Scope-guard is the deny.
2. hunt-core loaded (skills/exploit/hunt/hunt-core/SKILL.md).
3. Core verified: $RUN/raw/vector-map.md exists AND the core pointer
   carries SQLI-HUNT-DONE with union named in next=. Missing =
   dispatch hunt-sqli core first.
4. Toolchain preflight (fails LOUD):

       for t in /usr/bin/jq /usr/bin/python3 \
                 /opt/scope-shim/bin/curl; do
         [ -x "$t" ] || { echo "MISSING TOOL: $t"; exit 1; }
       done

## Checklist (mandatory)

Copy checklist.md (this skill's dir) to
`$ENG_DIR/hunt/sqli/<host>/sqli-union-checklist.md` at run start.
Unchecked at stop = UNCHECKED lane, re-run from the first unchecked
step. SKILL.md 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 UNION query that returns 200 with no rendered
extra row; a column count guessed but never proven.

**IS confirmation:** attacker-controlled SELECT output RENDERED in
the response (a marker value landing in a displayed column),
extracting real schema/data rows, reproduced from your own written
steps.

## Methodology

### Step 1 - Column count

ORDER BY n walk (increment until the error/empty flip) - binary search
when the ceiling is high. Record n and the flip evidence.

### Step 2 - Display sizing

UNION SELECT with a marker per column: which columns RENDER (visible
in the response) and where they truncate (a UI that cuts at 20 chars
loses long values - use substring/HEX for those columns). Record the
usable column set.

### Step 3 - Schema shape

INFORMATION_SCHEMA (MySQL/MSSQL) / information_schema (Postgres) /
ALL_TABLES (Oracle): table_schema/table_name/column_name walk,
filtered to the app's schema (skip system schemas). Oracle/MSSQL
equivalents per the wiki page.

### Step 4 - Bounded extraction

Data targets ranked by the core's rank: extract schema first, then
the juicy table in bounded pages (LIMIT/OFFSET or ROWNUM), marker per
row, every row cites the rendered output verbatim. Values that exceed
display truncation: substring-walk or HEX.

### Step 5 - Exit

Append rows to the core's $RUN/candidates.jsonl;
`SQLI-UNION-DONE cols=<n> usable=<n> rows=<n>` appended to the core
pointer $ENG_DIR/hunt-sqli-<host>.md; _requests.md rows (lane =
hunt-sqli-union); Deadends per dead vector.

## Chaining

- Sink stops rendering under union (WAF/behavior change) ->
  hunt-sqli-error / hunt-sqli-boolean / hunt-sqli-time.
- sqlmap when manual extraction exceeds bounds: the CORE's contract.

## Validation

- Proof = marker value rendered in a displayed column + real rows.
- Negative control: benign UNION (NULLs) changes nothing visible.

## False Positives

- Columns counted but the sink renders none of the union (result set
  replaced, not appended).
- Truncated display read as empty table.
- WAF silently normalizing the payload (track a canary token).

## Severity

CRITICAL = credential/sensitive-table extraction. HIGH = schema +
partial table. MEDIUM = proof of union with low-value data.

## N/A escapes

- "N/A: no reflective sink" (the sink inventory shows no rendered
  result columns)
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 vector map, output ONLY $RUN/analysis/bitter-pill.md. The
rendered-marker gate survives freehand. Declare with a _requests.md
row (lane = hunt-sqli-union-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

Appends into the shared core $RUN: probes/sqli-union.jsonl,
candidates.jsonl rows, pointer line SQLI-UNION-DONE. Consumer:
triage. Findings leave ONLY through G1. Distill: `python3
scripts/wiki-stage.py --kind technique --slug <slug> --target-page
techniques/web/sql-injection.md`.

## Stop conditions

All steps terminal; rendered-marker proof on every claim; nothing
written into skill dirs; no unchecked boxes above REVIEW; hunt-core
stop conditions fire unchanged.

## Attack surface

**APPROACH:** Hit login/search/sort/report params first; probe every quote context, take in-band (error/UNION) before blind (boolean/time), confirm in 1-2 manual requests then hand the dump to sqlmap (scoped, gentle, resume).
**AVOID:** A generic 500, a WAF "SQL injection detected" string, an un-reproduced time delta, or a single-session login oracle is NOT confirmation - re-verify in a clean session, clear the cookie on a login oracle.

## Cross-routing

- Load hunt-auth for auth-bypass outcomes of the injection.
- Load hunt-cloud when the DB is managed-cloud (different blast radius/escalation).
- Not this skill: NoSQL/GraphQL operator shapes (hunt-injection).

