CSCTF 2026 · Misc · 297 pts
ultralight.
Two MIFARE Ultralight C dumps, a shared secret that was a decoy, and a factory 3DES key that decrypts the whole record.
| Event | CSCTF 2026, Operation Dawn (online jeopardy) |
|---|---|
| Category | Misc |
| Points | 297 |
| Status | Solved during the event |
| Target | Card validation service (assigned container, port 8000) |
TL;DR. The 16-byte value shared by both dumps was a decoy. Offsets 0x10–0x9F are a 3DES-CBC record encrypted under the Ultralight C factory key BREAKMEIFYOUCAN! (2-key 3DES, IV 0). Decrypting it reveals a CHRONOS1 record whose user_type byte is 0x01. Change it to 0x03 (ADMIN), give the card a fresh UID and the username root, recompute the CRC32, re-encrypt, and upload.
Challenge
Two 192-byte MIFARE Ultralight C dumps were recovered from informers Sam and Frida. The validator accepts a .bin card image and returns the access code only for an administrator card. The upload is server-side; editing the page does nothing.
192 bytes is 48 pages of 4 bytes, which matches the Ultralight C memory layout.
First look
Both dumps pass the structural checks, so they are real card images rather than random blobs:
| Offset | Pages | Content |
|---|---|---|
0x00–0x07 | 0–1 | UID0–UID6 and BCC0 |
0x08–0x0B | 2 | BCC1, internal, lock bytes |
0x0C–0x0F | 3 | 43 55 01 00 ("CU", version 1) |
0x10–0x1F | 4–7 | 16-byte value, identical in both dumps |
0x20–0x9F | 8–39 | 128 bytes, high entropy, different per card |
0xA0–0xAF | 40–43 | 00×8 04 00 00 00 00×4 |
0xB0–0xBF | 44–47 | zeros |
BCC0 is 0x88 ^ UID0 ^ UID1 ^ UID2; BCC1 is UID3 ^ UID4 ^ UID5 ^ UID6. The UID is split around BCC0, so the seven UID bytes are file offsets [0,1,2,4,5,6,7].
The shared 16-byte value at 0x10 looked like an issuer key. The structured value at 0xA0 looked like a user key. Both readings were wrong, but they were wrong in a useful direction: the actual key was the factory default that every Ultralight C ships with.
Dead ends
- Replacing pages 40–43 with the shared secret produced a structurally valid card and was rejected. So were 39 variants: two-dump XOR shares, page-3 role markers, counter bumps, alternate UIDs, default and
0xFFkeys. - The 128 per-card bytes were not plaintext under any obvious key or mode. Treating them as a challenge/response transcript, a hash chain, an LFSR stream or a stego payload also failed.
- The counter hypothesis was a dead end because the only structured value at
0xA8sits inside the standard key pages. A card cannot simultaneously hold a key there and a bumped counter. - The first attempt at the factory key failed because libfreefare stores the 2-key 3DES value byte-swapped. The validator uses the plain ASCII bytes, not the library representation.
What actually unlocked it was the hint: the encrypted region uses the Ultralight C factory default key. That reframed the problem from "find the admin key" to "decrypt the record with a known key and edit the role".
Solution
1. Decrypt the record
from cryptography.hazmat.primitives.ciphers import Cipher, modes
from cryptography.hazmat.decrepit.ciphers.algorithms import TripleDES
card = bytearray(open("card_sam.bin", "rb").read())
KEY = b"BREAKMEIFYOUCAN!" + b"BREAKME" # 24 bytes, 2-key 3DES
IV = b"\x00" * 8
REGION = slice(0x10, 0xA0) # 144 bytes = 9 blocks
d = Cipher(TripleDES(KEY), modes.CBC(IV)).decryptor()
rec = bytearray(d.update(bytes(card[REGION])) + d.finalize())
print(rec[:8], rec[16], rec[17], rec[20:40])
The plaintext record decodes as:
| Offset | Field |
|---|---|
| 0 | magic CHRONOS1 |
| 16 | version 0x01 |
| 17 | user_type: 0x01 user, 0x03 admin |
| 18 | username length |
| 20 | username |
| 40–47 | Unix timestamp, 8 bytes big-endian |
| 48–51 | CRC32, 4 bytes big-endian |
The CRC is computed over UID7 || timestamp || user_type, where UID7 is the seven UID bytes in card order.
2. Forge the admin record
import struct, zlib
uid = bytes.fromhex("04a1b2c3d4e5f6")
card[0:3] = uid[0:3]
card[4:8] = uid[3:7]
card[3] = 0x88 ^ uid[0] ^ uid[1] ^ uid[2]
card[8] = uid[3] ^ uid[4] ^ uid[5] ^ uid[6]
name = b"root"
rec[17] = 0x03
rec[18] = len(name)
rec[19] = 0
rec[20:20 + len(name)] = name
ts = bytes(rec[40:48]) # keep the valid timestamp
crc = zlib.crc32(uid + ts + bytes([rec[17]])) & 0xFFFFFFFF
rec[48:52] = struct.pack(">I", crc)
e = Cipher(TripleDES(KEY), modes.CBC(IV)).encryptor()
card[REGION] = e.update(bytes(rec)) + e.finalize()
open("card_admin.bin", "wb").write(card)
Fresh UID and username matter. The validator rejects an already-issued UID and an already-issued username before it checks the role, and both errors are visible in the response. A new UID also forces fresh BCC values, which is why the BCC bytes are recomputed rather than copied.
3. Upload
curl -s -F "card=@card_admin.bin" http://<host>:8000/api/validate
The reply is JSON: {ok, error, message, flag}. The error strings expose the check order (CRC, then user_type, then UID issuance, then username uniqueness), which is how the forge was narrowed without guessing.
Flag
CSCTF{DENPAuFivNpk6ux5hyJfnT5D}What I took from it
- A shared secret is a hypothesis, not a conclusion. Two dumps sharing 16 bytes is suspicious, but the bytes only become a key if a cipher actually consumes them.
- Factory defaults survive in production. The Ultralight C default key is public documentation and was the whole challenge.
- When a validator returns distinct errors, the errors are the spec. CRC, role, UID and username failures told me the exact order of checks and which fields had to be fresh.