DL·SYS
Contact ↗

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.

MIFARE Ultralight C3DES-CBCCRC32Card forging
EventCSCTF 2026, Operation Dawn (online jeopardy)
CategoryMisc
Points297
StatusSolved during the event
TargetCard 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:

OffsetPagesContent
0x00–0x070–1UID0–UID6 and BCC0
0x08–0x0B2BCC1, internal, lock bytes
0x0C–0x0F343 55 01 00 ("CU", version 1)
0x10–0x1F4–716-byte value, identical in both dumps
0x20–0x9F8–39128 bytes, high entropy, different per card
0xA0–0xAF40–4300×8 04 00 00 00 00×4
0xB0–0xBF44–47zeros

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

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:

OffsetField
0magic CHRONOS1
16version 0x01
17user_type: 0x01 user, 0x03 admin
18username length
20username
40–47Unix timestamp, 8 bytes big-endian
48–51CRC32, 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

FlagCSCTF{DENPAuFivNpk6ux5hyJfnT5D}

What I took from it