Writeup · 31 Nights of Root

Spectral

miscmediumsolvedFlag: r00t{REDACTED}
flowchart LR
    A[ledger_intercept.wav] -->|spectrogram| B["KEY=<32 hex>"]
    C[cover.png] -->|carve bytes after IEND| D["IV (16B) + ciphertext"]
    B --> E{AES-128-CBC}
    D --> E
    E --> F[inner.zip]
    F --> G[inside.png - noise]
    G -->|RGB LSB plane| H["r00t{REDACTED}"]

Overview

Two files that only make sense together. The WAV carries a key, drawn as text in its spectrogram. The PNG carries an encrypted payload, appended after its IEND chunk. Decrypting the payload yields a second PNG that looks like pure noise, and its least significant bits hold the flag.

Prerequisites / Setup

  • Python 3 (numpy, scipy, matplotlib, cryptography, Pillow)
  • unzip
  • Spectral.zip extracted in the working directory

Recon

Step 1 — File triage

Goal: List the archive contents and confirm file types.

unzip -l Spectral.zip
file Spectral/*
Spectral/ledger_intercept.wav  RIFF WAVE, PCM 16-bit, mono, 44100 Hz   (1,270,124 bytes)
Spectral/cover.png             PNG 320 x 180, 8-bit RGB                (199,228 bytes)
__MACOSX/...                   AppleDouble junk (only quarantine xattrs, ignore)
  • The WAV is exactly 14.4 s of audio and contains no appended data (44 + 635040 * 2 = 1270124).
  • The PNG is only 320×180 of mostly flat colour, yet it is about 199 KB. A real IDAT for that image is under 2 KB, so something else is stored in the file.
  • cover.png shows a gray label reading “ledger intercept - camera 4”. Nothing useful visually.

Exploitation

Stage 1 — Spectrogram of the WAV

Goal: Recover the AES key drawn in the frequency domain.

import numpy as np, wave
from scipy import signal
import matplotlib; matplotlib.use("Agg")
import matplotlib.pyplot as plt

w = wave.open("ledger_intercept.wav")
x = np.frombuffer(w.readframes(w.getnframes()), dtype=np.int16).astype(float)
f, t, S = signal.spectrogram(x, 44100, nperseg=2048, noverlap=1536)
plt.figure(figsize=(16, 8))
plt.pcolormesh(t, f, 10 * np.log10(S + 1e-9), shading="auto")
plt.savefig("spec.png", dpi=70)

The text KEY= followed by 32 hex characters is drawn in the roughly 2.5-5.5 kHz band. Dark vertical stripes across the whole spectrum are just gaps between glyphs.

A zoom on that band (nperseg=1024, noverlap=1000, only 2-6.2 kHz, three time windows) makes the glyphs legible enough to read.

The result is a 32-character hex string, so a 16-byte key: AES-128.

Stage 2 — The PNG trailer

Goal: Find where the legitimate PNG ends and the appended payload begins.

Walk the PNG chunk list to find where the legitimate file ends:

import struct

d = open("cover.png", "rb").read()
p = 8
while p < len(d):
    length, ctype = struct.unpack(">I4s", d[p:p+8])
    p += 12 + length
    if ctype == b"IEND":
        break
trailer = d[p:]
print(len(trailer), trailer[:32].hex())
197376 000102030405060708090a0b0c0d0e0fb7401f0a52dce0fdc30a02fa6be7d5ef...

Observations about the 197,376 trailing bytes:

  • The first 16 bytes are 00 01 02 ... 0f, which is an obvious IV.
  • The remaining 197,360 bytes are an exact multiple of 16 (12,335 blocks), which matches a block cipher.
  • Shannon entropy is about 7.999 bits/byte and all 12,335 blocks are unique. This is real ciphertext, not a compressed or encoded stream.

Together with a 16-byte key from the WAV, the natural hypothesis is AES-128-CBC, IV prefixed.

Step 3 — Decrypt (dead ends then repair)

Goal: Decrypt the ciphertext with AES-128-CBC.

Rather than eyeballing glyphs again, treat the key as “almost right” and search near it. CBC makes validation cheap: plaintext block 0 is AES_dec(C0) XOR IV, so one block decrypt tells us whether the output starts with a ZIP header.

A first attempt used PKCS#7 padding validity on the last block as the test. That is a weak oracle (about 1 in 256 random keys pass), and a 2-substitution search returned 400+ false positives. Single-substitution candidates were four, and decrypting each fully showed exactly one with a structured output: it began with PK\x03\x04.

The robust test is the ZIP magic on the first block (a 32-bit check):

from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
import itertools

HEXD = "0123456789abcdef"
iv, ct = trailer[:16], trailer[16:]

def is_zip(key: bytes) -> bool:
    blk = Cipher(algorithms.AES(key), modes.ECB()).decryptor().update(ct[:16])
    return bytes(a ^ b for a, b in zip(blk, iv))[:4] == b"PK\x03\x04"

def repair(guess: str, max_subs: int = 2):
    for r in range(max_subs + 1):
        for pos in itertools.combinations(range(32), r):
            for rep in itertools.product(HEXD, repeat=r):
                if any(rep[i] == guess[p] for i, p in enumerate(pos)):
                    continue
                cand = list(guess)
                for i, p in enumerate(pos):
                    cand[p] = rep[i]
                cand = "".join(cand)
                if is_zip(bytes.fromhex(cand)):
                    return cand, pos

The search settles on a single-character fix at index 10 of the string (a 0 that should be d). Key and IV then decrypt the full ciphertext:

pt = Cipher(algorithms.AES(bytes.fromhex(key)), modes.CBC(iv)).decryptor().update(ct)
pad = pt[-1]
pt = pt[:-pad]          # PKCS#7
open("inner.zip", "wb").write(pt)
Archive:  inner.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
   197174  2026-10-26 20:02   inside.png

Step 4 — inside.png

Goal: Extract the flag from the noise image’s LSB plane.

inside.png is a 256×256 RGB image that looks like uniform colour noise. File size is 197,174 bytes against 196,608 raw pixel bytes, so it is stored essentially uncompressed (stored deflate blocks) and no extra trailer is present. The chunk list is plain IHDR, IDAT ×4, IEND.

Noise in a lossless PNG usually means the information is in the low bits. Reading the least significant bit of every R, G, B value, row by row, packed MSB-first gives printable ASCII immediately:

from PIL import Image
import numpy as np

im = np.array(Image.open("inside.png").convert("RGB"))
bits = (im & 1).flatten()                 # R0 G0 B0 R1 G1 B1 ... row-major
raw = np.packbits(bits).tobytes()         # big-endian bit order
print(raw[:48])
b'r00t{REDACTED}\x00...'

The message ends with a \x00 terminator, and everything after it is random LSB noise.

Flag

r00t{REDACTED}

Lessons / Takeaways

  • Challenge names are hints. “Spectral” meant spectrogram; always look at audio in the frequency domain before reaching for LSB or metadata tools.
  • Size anomalies point at hidden data. A 320×180 near-flat PNG at about 199 KB was the tell for the appended payload. Walk the chunk list and look past IEND.
  • A prefix of 00 01 02 ... 0f is an IV. Cheap pattern, worth recognising immediately.
  • Do not trust a human OCR of a blurry glyph. Treat a recovered key as “close” and brute-force the neighbourhood against a strong oracle.
  • Choose the oracle carefully. PKCS#7 padding validity gives hundreds of false positives. A 4-byte magic number (PK\x03\x04, \x89PNG, %PDF) on the first CBC block is effectively exact and needs only one block decrypt.
  • Noise image in a lossless format means LSB. Try interleaved RGB bit 0, row-major, big-endian first, then vary channel, bit plane, order and endianness.

Techniques

  • Spectrogram Steganography
  • PNG Trailer Data
  • AES-CBC Decryption
  • Known-Plaintext Magic Byte Oracle
  • LSB Steganography
  • None yet. Link other steg notes that use spectrogram or LSB stages here.

References