Challenge Overview
A file containing a long string of 1s and 0s — 71,192 characters total. The length is a multiple of 8, suggesting each group of 8 bits represents one byte of encoded data.
Analysis and Extraction
Converting each 8-bit group to its corresponding byte value and writing the result to a file:
with open("digits.bin", "r") as f:
data = f.read().strip()
byte_array = bytearray()
for i in range(0, len(data) - len(data) % 8, 8):
byte_array.append(int(data[i:i+8], 2))
with open("decoded.jpg", "wb") as f:
f.write(byte_array)File Type Identification
The first decoded bytes were FF D8 FF E0 followed by JFIF — the JPEG magic header. Running file decoded.jpg confirmed a valid JPEG image. Opening it revealed a white image with the flag printed in red text.
Magic Headers Reference
| Magic Bytes (hex) | File Type |
|---|---|
FF D8 FF | JPEG |
89 50 4E 47 | PNG |
25 50 44 46 | |
50 4B 03 04 | ZIP |
47 49 46 38 | GIF |
Key Insight: Always check the length of a binary string for divisibility by 8 — this is the primary indicator of byte-encoded data. After decoding, always run
file on the output before assuming its type. The magic header will tell you what you're dealing with before you open it.