# Ctf Stego

> Front-loads steganography triage for CTF files. Use when an image, audio file, video, GIF, PDF or text file is described as containing something hidden, or when a challenge gives media with no obvious purpose, "stego", LSB, bit plane, palette, spectrogram, QR or metadata hints. Runs the project's preset sweep and filter library first instead of re-deriving extraction code, then routes to the stego MCP for structured checks. Do not use it for pure disk/memory/network forensics, for crypto on recovered data, or for reversing an encoder binary.

- Skill: `jiayaoqijia/ctf-stego` (Agent Skill, multi-file: 4 files)
- Install (CLI): `npx get-skill add jiayaoqijia/ctf-stego`
- Raw SKILL.md: https://api.skillmd.com/api/skills/jiayaoqijia/ctf-stego/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: AI & ML
- License: MIT
- Author: jiayaoqijia (https://skillmd.com/u/jiayaoqijia)
- Updated: 2026-11-16
- Page: https://skillmd.com/skills/jiayaoqijia/ctf-stego

---


# CTF Steganography

Do not write a new extractor. The project already ships the standard battery;
run it, read the output, then get specific.

## Step 1: the preset (always first)

```bash
# Media presets: pick the one that matches the file (run these before the sweep if the file is a video, GIF, image with LSB, QR, or audio)
docker exec ctf-solver python3 /app/presets/frame_diff.py /app/workspaces/<chal>/<video-or-gif>
docker exec ctf-solver python3 /app/presets/lsb_extract.py /app/workspaces/<chal>/<image>
docker exec ctf-solver python3 /app/presets/qr_decode.py /app/workspaces/<chal>/<image>
docker exec ctf-solver python3 /app/presets/audio_spectrum.py /app/workspaces/<chal>/<audio>
docker exec ctf-solver python3 /app/presets/gif_frames.py /app/workspaces/<chal>/<gif> --x X --y Y --hi H --lo L
scripts/ctf.sh py scripts/stego/sweep.py ctf-solver/workspaces/<chal>/<file>
scripts/ctf.sh py scripts/stego/sweep.py <file> --fast          # skip binwalk
scripts/ctf.sh py scripts/stego/sweep.py <jpg> --wordlist /usr/share/wordlists/rockyou.txt
scripts/ctf.sh run zsteg -a /app/workspaces/<chal>/<file>       # raw tool output if needed
```

`sweep.py` reports, in order: identity (type, size, entropy), metadata
(exiftool/identify/pngcheck comments and profiles), embedded data (binwalk,
printable runs, **appended bytes after PNG IEND / JPEG EOI / GIF trailer**, saved
to `*.appended`), known-tool scanners (zsteg -a, zbarimg, steghide info,
stegseek), the **filter sweep**, derived images, media branches, and a final
flag-candidate list with the filter that produced each hit.

Filter library, usable alone: `scripts/ctf.sh py scripts/stego/filters.py <file> --derived out/`.

## Step 2: what the filter sweep already covers

| Variant | Why it exists |
|---|---|
| Channel × bit plane 0–7 × row/column × big/little bit order | The `zsteg -a` matrix, in Python — catches plane 1–7 and MSB-first payloads that plane-0 LSB misses |
| RGB / BGR per-pixel interleave (planes 0–2) | Classic 3-bit-per-pixel encoding |
| `R^G`, `G^B`, `R^B`, `|R-G|`, `|G-B|` planes 0–3 | XOR/difference stego, where no single channel is readable |
| Palette index plane 0 (GIF/P mode) | Palette stego |
| Alpha plane (included in RGBA) | Payload in transparency |
| Derived PNGs (planes + channel maps) | Visual stego: text that only appears in one plane |

A hit needs either a flag regex or ≥92% printable bytes, so noise does not flood
the report. If nothing hits, the payload is not in the pixels — move on.

## Step 3: structured checks the sweep does not replace

Use the **`stego` MCP** (128 tools) for: `img_chi_square`, `img_lsb_detect`
(statistical presence), `img_known_tools`, `jpeg_structure`, `gif_*`
(palette/LZW/appext), `video_*` (frame LSB, inter-frame, EOF data), `audio_*`
(LSB, spectrum), `text_zwc_detect` / `text_invisible_scan` / `text_homoglyph`,
`file_appended` / `file_polyglot` / `file_identify`, `doc_pdf_streams`, `qr_*`.

## Step 4: by media type

- **PNG/BMP**: sweep → zsteg -a → check `tEXt`/`zTXt`/`iTXt` chunks → palette/alpha. Recompress to BMP3 before steghide (`convert in.png BMP3:out.bmp`) — steghide rejects ImageMagick's default BMP.
- **JPEG**: steghide (needs a passphrase → `stegseek` with a wordlist), outguess detection, DCT-coefficient tools, EXIF comments.
- **Audio**: spectrogram is generated by the sweep (`-x 2048 -y 1025` high-res too); look for text, SSTV, Morse (channel separation), DTMF. Deeper DSP: [../ctf-misc/audio.md](../ctf-misc/audio.md).
- **Video**: frames extracted at 1 fps; check frame LSB and inter-frame differences; audio track separately.
- **GIF**: palette LSB, comment/application extensions, per-frame delays.
- **PDF/DOCX**: `doc_pdf_streams`, hidden text layers, white-on-white text, ZIP members.
- **Text**: zero-width characters, Unicode tags (U+E0000–E007F, subtract 0xE0000), variation selectors, homoglyphs.

## When to pivot

- The recovered data is encrypted or needs RSA/AES work → `/ctf-crypto`
- The file is a firmware image or a logic capture → `/ctf-hardware`
- The challenge is a disk/memory/PCAP artifact → `/ctf-forensics`
- The media hides an encoder binary or VM → `/ctf-reverse`
- Pure encoding layers (base64 chains, esolangs) → `/ctf-misc`

## Verify

```bash
scripts/ctf.sh run zsteg --version
scripts/ctf.sh py scripts/stego/sweep.py --help
```

Report the filter that produced a flag, not just the flag — a write-up needs the
reproduction step.

