Overview
The challenge provides a replay archive containing a PCAP and a session log. The PCAP does not contain normal TCP, UDP, HTTP, or DNS traffic — it uses a custom USER 0 data-link type containing records beginning with either IDLE or LIVE. Most packets are IDLE records containing random-looking data; a small number are LIVE records containing structured metadata and encrypted data.
The goal is to recover the flag hidden in the replay.
Prerequisites / Setup
- Python 3 (
struct,hashlib) wget/curlandunzip(to fetchreplay.zip)capinfos/tsharkoptional (for initial reconnaissance)
Recon
Step 1 — Inspect the target and download the archive
Goal: Reach the challenge page and obtain replay.zip.
curl -i "$TARGET/"
The page exposes a replay archive at:
/downloads/replay.zip
wget "$TARGET/downloads/replay.zip"
unzip replay.zip
Archive contents: capture.pcap, session.log.
Enumeration
Step 2 — Inspect session.log
Goal: Read the supporting log for cryptographic clues.
cat session.log
18:44 volunteers crossed the end line
18:48 lights lowered
19:02 replay card: afterglow-17
The final line is the key clue:
replay card: afterglow-17
The value afterglow-17 is likely a password, key, identifier, or seed used later.
Step 3 — Inspect the PCAP
Goal: Determine the capture’s encapsulation and whether standard analysis applies.
capinfos capture.pcap
File type: pcap
File encapsulation: USER 0
Number of packets: 87
File size: 3,276 bytes
Data size: 1,860 bytes
Capture duration: 86.000000 seconds
Interpretation: USER 0 means the packets do not use normal Ethernet/IP/TCP/UDP encapsulation. Protocol hierarchy is just frame → user_dlt → data, with no useful TCP conversations, and http/dns filters reveal nothing — the PCAP must be parsed as raw custom data.
Exploitation
Step 4 — Identify the custom protocol
Goal: Parse raw packet payloads and find record structure.
import struct
with open("capture.pcap", "rb") as f:
b = f.read()
off = 24
n = 0
while off + 16 <= len(b):
ts_sec, ts_usec, incl_len, orig_len = struct.unpack_from("<IIII", b, off)
off += 16
payload = b[off:off+incl_len]
off += incl_len
n += 1
print(f"{n:02d} len={incl_len:02d} {payload[:4]!r} {payload[4:].hex()}")
The output reveals two record types: IDLE and LIVE. For example:
01 ... len=22 b'IDLE' ...
05 ... len=15 b'LIVE' 00020007b4e83f2a3822e2
Interpretation: Most of the 87 packets are IDLE; only seven are LIVE. The IDLE packets are noise/decoys; the LIVE packets contain the hidden message.
Step 5 — Extract the LIVE records
Goal: Isolate the seven LIVE packets and inspect their fields.
import struct
with open("capture.pcap", "rb") as f:
b = f.read()
off = 24
while off + 16 <= len(b):
ts_sec, ts_usec, incl_len, orig_len = struct.unpack_from("<IIII", b, off)
off += 16
p = b[off:off+incl_len]
off += incl_len
if p.startswith(b"LIVE"):
print(f"payload={p.hex()}")
The seven records:
packet=05 payload=4c49564500020007b4e83f2a3822e2
packet=27 payload=4c4956450005000772e9c7bda33828
packet=33 payload=4c4956450001000776fafbb326bbc4
packet=34 payload=4c4956450004000737282222f8abe1
packet=41 payload=4c495645000600026d3e
packet=42 payload=4c49564500000007ac95e2a67b7d74
packet=43 payload=4c49564500030007fabe71ead9e5fd
Step 6 — Understand the LIVE format
Goal: Parse each LIVE record into sequence, length, and payload.
Structure (big-endian):
LIVE | 2-byte sequence | 2-byte length | payload
For example LIVE 0002 0007 b4e83f2a3822e2 means sequence=2, length=7, payload=b4e83f2a3822e2.
The seven records become:
| Packet | Sequence | Length | Payload |
|---|---|---|---|
| 5 | 2 | 7 | b4e83f2a3822e2 |
| 27 | 5 | 7 | 72e9c7bda33828 |
| 33 | 1 | 7 | 76fafbb326bbc4 |
| 34 | 4 | 7 | 37282222f8abe1 |
| 41 | 6 | 2 | 6d3e |
| 42 | 0 | 7 | ac95e2a67b7d74 |
| 43 | 3 | 7 | fabe71ead9e5fd |
Interpretation: Packets arrive out of order (sequences 2, 5, 1, 4, 6, 0, 3). The sequence field tells us how to reconstruct the message.
Step 7 — Reassemble the hidden data
Goal: Sort chunks by sequence number and concatenate.
Correct order 0..6:
0: ac95e2a67b7d74
1: 76fafbb326bbc4
2: b4e83f2a3822e2
3: fabe71ead9e5fd
4: 37282222f8abe1
5: 72e9c7bda33828
6: 6d3e
Concatenation gives 44 bytes (6 × 7 + 2):
ac95e2a67b7d7476fafbb326bbc4b4e83f2a3822e2fabe71ead9e5fd37282222f8abe172e9c7bda338286d3e
The result is high-entropy with no recognizable file format — encryption or XOR obfuscation is indicated.
Step 8 — Derive the XOR key
Goal: Turn afterglow-17 from session.log into the repeating XOR key.
import hashlib
key = hashlib.sha256(b"afterglow-17").digest()[:12]
A full SHA-256 digest is 32 bytes; the construction uses only the first 12 bytes. The key repeats across the 44-byte ciphertext:
K0 K1 ... K11 | K0 K1 ... K11 | K0 K1 ...
Step 9 — Decrypt with repeating-key XOR
Goal: XOR the 44-byte ciphertext with the 12-byte key to recover the flag.
plaintext = bytes(
b ^ key[i % 12]
for i, b in enumerate(blob)
)
safctf{REDACTED}
Interpretation: The repeating-key XOR produces fully readable flag-format plaintext.
Flag
safctf{REDACTED}
Recovered by reassembling the seven out-of-order LIVE PCAP fragments and XOR-decrypting with the SHA-256(afterglow-17)[0:12] key.
Lessons / Takeaways
- Don’t assume a PCAP contains normal network traffic; when standard analysis yields nothing, inspect raw packet payloads.
- Look for magic values (
IDLE,LIVE) to understand a custom protocol. - Sequence numbers matter: out-of-order fragments must be reordered before decrypting.
- Small clues in supporting files (
session.log’sreplay card) can be cryptographic material. - High-entropy data may be a simple repeating-key XOR, not a standard cipher.
Techniques
References
- libpcap file format: https://wiki.wireshark.org/Development/LibpcapFileFormat

