Writeup · SAF Pre-Qualifiers 2026

Long Exposure

forensicsmediumsolvedFlag: safctf{REDACTED}

Overview

The challenge provides a single ZIP archive (field-kit.zip) with four files:

File Size Notes
process.core 32 KB Memory dump of studio-worker
uplink.pcap 9 KB 158 packets, custom framing
modules.map tiny Memory map: 00001000-00009000 rw-p studio-worker
field-note.txt tiny Hint text

field-note.txt:

The camera spool retained a warm buffer after the blue-hour test. Original and processed takes were exported together.

This is the roadmap: the core is the “warm buffer”, and we have both an original (raw memory) and a processed (network exfil) version of the same data.

modules.map:

00001000-00009000 rw-p studio-worker

The mapping is 0x9000 − 0x1000 = 0x8000 = 32768 bytes, matching process.core exactly, so file offset 0 = virtual address 0x1000.

Prerequisites / Setup

  • Python 3 (struct, base64, hashlib, cryptography)
  • The four extracted files from field-kit.zip

Recon

Step 1 — Parse the PCAP

Goal: Read uplink.pcap as a classic libpcap stream (24-byte global header, 16-byte per-packet headers) and inventory the packets.

import struct

d = open('uplink.pcap','rb').read()
off = 24
pk = []
while off < len(d):
    ts, us, il, ol = struct.unpack('<IIII', d[off:off+16]); off += 16
    pk.append((ts, us, d[off:off+il])); off += il

print(f"packets = {len(pk)}")

Findings:

  • 158 packets, all len = 43
  • Timestamps: 1800000000 → 1800000157 (1 second apart)
  • Packet prefixes:
    • 150 × NOI (packet indices 0–149)
    • 8 × QRY (packet indices 150–157)

Packet structure:

NOI  : b'NOI' + 40 bytes of high-entropy data
QRY  : b'QRY' + <2-byte index> + <15-char base32> + b'.img.field.test'

Interpretation: The NOI packets are 150 × 40 = 6000 bytes of pure noise (no column bias, no XOR structure, no per-packet nonce) — decoys. The QRY packets are DNS exfiltration: 8 chunks of base32.

Enumeration

Step 2 — Extract the DNS exfil payload

Goal: Pull the 8 QRY labels and order them by their 2-byte big-endian sequence number.

qry = [(p[4], p[5:].split(b'.')[0].decode()) for p in packets if p[:3] == b'QRY']
ordered = [lab for _, lab in sorted(qry)]
print(ordered)
# ['PZRA3C5MF2WARTI', '6CYYWT3ECKT45IY', 'B256MK23FAQL2VY',
#  'PVC46ZEQQHTN7UI', 'FJQLJ6KV2NM66HY', 'BZDPUAPZ44P4WHQ',
#  '4N6YDDXKVZSNSDI', 'UORLITSJBNLJVUI']
import base64
blob = b''.join(base64.b32decode(lab + '=')[:9] for lab in ordered)
print(len(blob), blob.hex())
# 72 bytes

Result: a 72-byte blob whose length is exactly 12 + 44 + 16 — the classic AES-GCM layout: nonce(12) ‖ ciphertext(44) ‖ tag(16).

Exploitation

Step 3 — Find the key in the core dump

Goal: Locate the AES-256 key in process.core using the EVPCTX marker.

core = open('process.core','rb').read()
evp = core.find(b'EVPCTX')
print(hex(evp))   # 0x1b70

At file offset 0x1b70 (vaddr 0x2b70):

00001b70: 45 56 50 43 54 58 30 33   EVPCTX03
00001b78: 68 16 c3 1d 3e 78 05 d2 ea 58 a8 ec f6 ab a0 7e   ← first 16 bytes
00001b88: d2 76 6c 3c ad d2 4e 37 ...                       ← more high-entropy data

The 8 ASCII bytes EVPCTX03 are a custom marker. Immediately after it, at file offset 0x1b78 = 7032, sit 32 bytes of high-entropy data:

key = core[7032:7064]
# 68 16 c3 1d 3e 78 05 d2 ea 58 a8 ec f6 ab a0 7e
# d2 76 6c 3c ad d2 4e 37 a6 79 7d 94 66 eb c0 59

This is the AES-256 key. The rest of the core is high-entropy filler — the “retained” encrypted working set — so no other structure is recoverable.

Vulnerability Analysis

n/a — this is a forensics/cryptography puzzle, not a software vulnerability. The “weakness” is that the key was left in recoverable memory (the warm buffer) alongside the exfiltrated ciphertext.

Step 4 — Decrypt with AES-256-GCM

Goal: Lay the blob out as nonce ‖ ciphertext ‖ tag and decrypt.

import base64, struct
from cryptography.hazmat.primitives.ciphers.aead import AESGCM

# Rebuild the 72-byte blob (per-chunk decode!)
ordered = [lab for _, lab in sorted(qry)]
blob = b''.join(base64.b32decode(lab + '=')[:9] for lab in ordered)
assert len(blob) == 72

# Key from the core dump
core = open('process.core','rb').read()
key = core[7032:7064]
assert len(key) == 32

# AES-256-GCM layout
nonce = blob[:12]
ct    = blob[12:]           # 60 bytes = 44 ciphertext + 16 tag

plaintext = AESGCM(key).decrypt(nonce, ct, None)
print(plaintext)

Output:

safctf{REDACTED}

The GCM tag verified successfully, so the decryption is cryptographically sound — not a lucky guess.

Step 5 — Submit the answer to the web service

Goal: The decrypted string is the answer the service checks; submitting it returns the platform flag.

The page’s JavaScript posts:

fetch('/submit', {
    method: 'POST',
    headers: {'Content-Type': 'application/json'},
    body: JSON.stringify({answer: <value>})
})
curl -s -i -X POST hxxp://54[.]72[.]82[.]22:8470/submit \
  -H 'Content-Type: application/json' \
  -d '{"answer":"safctf{REDACTED}"}'
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 65

{"message":"safctf{REDACTED}","ok":true}

The message field contains the platform flag — the “collection receipt” the page hinted at:

Keep your collection receipt when your visit is complete.

Sanity checks:

  • Bare UUID (no wrapper) → 403 {"message":"The request could not be completed.","ok":false}
  • GET /submit → 405 (Allow: POST, OPTIONS)

Flag

safctf{REDACTED}

Recovered via AES-256-GCM decryption, then confirmed by submitting the answer to /submit.

Lessons / Takeaways

  • Read the hints literally: “warm buffer” = the core dump; “original and processed takes” = the pcap (processed) and core (original) reference the same secret.
  • Packet framing is not always fixed: QRY packets had a 2-byte sequence number after the marker while NOI packets did not — check prefix uniformity before parsing.
  • Base32 boundaries matter: 15 base32 chars = 9 bytes + 3 pad bits; concatenating 120 chars before decoding breaks bit alignment. Decode per-chunk.
  • GCM tag verification is not optional: a successful AESGCM.decrypt() proves the key, nonce, and layout.
  • Marker conventions: EVPCTX03 is a custom serialization marker; the sensitive material (key) sits immediately after it.
  • The challenge answer ≠ the platform flag: the web service returns a receipt that is the flag — always submit the intermediate answer when told to “keep your receipt”.
  • Decoys are decoys: 6000 bytes of NOI noise resisted every cipher/key-window/stream-mode test — treat uniform noise as filler and move on.

Techniques

References