Writeup · Cyberweek Africa 2026 - National CTF (Finals)

Blackout Protocol 3: The Broken Handshake

reversingunknownsolvedFlag: FLAG{REDACTED}

Category: Reverse Engineering / Offline Firmware & Handshake Analysis
Flag: FLAG{REDACTED} **B3 (retained for Chapter 4):** 8CD2027966B9 **B2 (from Chapter 2):**35C2C90A3900`


1[.] Objective

Find the single unauthorised, independently confirmed BEX-3 RECOVERY session that activated CTRL-A-ADMIN during the incident window (HELLO tick 250–290), using a VISITOR identity with a counter below the anti-replay floor, an echoed nonce different from the issued challenge, and a response that passes the actual firmware verification[.] Derive B3 using B2 from Chapter 2[.]


2[.] Provided Files

File Purpose
incident_brief.txt Incident scope, attack narrative, selection criteria
evidence_protocol[.]txt Audit record signing, TX/RX witness verification, VM_PROOF, B3 derivation
bytecode_spec[.]txt BEX-3 VM bytecode specification, input slot mapping, checkpoints
firmware_probe[.]py Decodes and disassembles the obfuscated firmware binary
evidence_probe[.]py Audit explorer — validates audit integrity and TX/RX witnesses
recovery_firmware[.]bin Obfuscated BEX-3 firmware containing NORMAL and RECOVERY VM programs
handshake_frames[.]csv 48 shuffled signed audit records (4 phases per session)
controller_witness_tx[.]csv Independent controller TX receipts
controller_witness_rx[.]csv Independent controller RX receipts
identity_register[.]csv Badge → role, anti-replay floor, controller
witness_roots[.]txt TX/RX HMAC verification keys
session_notes[.]txt Additional hints about the two VM programs

3. Methodology

3.1 Firmware Decoding

The firmware binary is obfuscated using B2 as a stream-cipher key. firmware_probe[.]py --token B2 decodes it:

  • Replay floor: 30
  • VM seed: 0x46C98E2B
  • VM key: 0xD7A28C31
  • Firmware CRC32: 0x8407CE50
  • Firmware SHA256 prefix: 6CF2648EBFE8

Two VM programs are stored: NORMAL (16 instructions), then RECOVERY (16 instructions).

3.2 VM Architecture

8 registers R0–R7 (initially 0), all arithmetic mod 2^32:

Opcode Mnemonic Operation
0x01 LOAD R[dst] = input[src]
0x02 XOR R[dst] ^= R[src]
0x03 ADD R[dst] += R[src]
0x04 ROL R[dst] = ROL32(R[dst], imm)
0x05 MUL R[dst] *= (imm | 1)
0x06 XKEY R[dst] ^= firmware_key
0xFF HALT Output R0 as 8 uppercase hex

Input slots:

Slot Source
0 First 4 bytes SHA256(badge_id | operator_id), big-endian
1 challenge_nonce (8 hex digits)
2 echo_nonce (8 hex digits)
3 HELLO counter (unsigned decimal)
4 CRC32(session_id)
5 hello_nonce (8 hex digits)
6 Firmware seed uint32

3.3 The Critical Flaw: NORMAL vs RECOVERY

The two programs are nearly identical, but instruction 4 differs:

Instruction NORMAL RECOVERY
04 LOAD R2, input[1] (challenge_nonce) LOAD R2, input[2] (echo_nonce)

The RECOVERY program XORs the echoed nonce instead of the challenge nonce[.] This means an attacker can supply a different echo_nonce and still get a valid response — the “second independent flaw” mentioned in the spec[.]

Additionally, RECOVERY mode does not enforce counter >= floor, allowing replay with stale counters[.]

3[.]4 Checkpoints

VM_PROOF uses R0 values after instruction indices 7 and 13 (0-indexed across all instructions):

  • Checkpoint 7: After ADD R0, R3 (adding counter)
  • Checkpoint 13: After XOR R0, R5 (XOR with CRC32(session_id))

3[.]5 Session Selection Criteria

Criterion Requirement
Mode RECOVERY
Badge role VISITOR
Counter < anti_replay_floor (30)
Echo nonce ≠ challenge nonce
HELLO tick 250–290 inclusive
Grant ACCEPTED, CTRL-A-ADMIN
Audit integrity All 4 records valid tags + intact chain
Firmware response Computed response_tag matches captured value
TX witness ACTUATED at GRANT_tick+1, valid HMAC
RX witness ADMIN_ACTIVE at GRANT_tick+2, valid HMAC

4[.] Investigation Walkthrough

Step 1 — Decode firmware

Replay floor: 30; VM seed: 46C98E2B; VM key: D7A28C31
Firmware CRC32: 8407CE50, SHA256 prefix: 6CF2648EBFE8

Both NORMAL and RECOVERY programs disassembled[.] The only difference is instruction 4’s input slot (1 vs 2)[.]

Step 2 — Identify candidate sessions

Using evidence_probe.py --list, sessions with VALID audit + BOTH VERIFIED witnesses + tick in [250,290]:

Session HELLO Tick Badge Role Counter Echo vs Challenge Audit Witnesses
HS-2473C0 250 BADGE-EDE1 VISITOR 17 SAME (5750E114) VALID BOTH
HS-6ABA47 258 BADGE-E7A9 VISITOR 12 DIFFERENT VALID BOTH
HS-74EC71 272 BADGE-985B VISITOR 13 DIFFERENT VALID BOTH
HS-A4400D 265 BADGE-5FB8 ENGINEER 21 DIFFERENT VALID BOTH

Eliminations:

  • HS-2473C0: echo_nonce == challenge_nonce (not different)
  • HS-A4400D: badge is ENGINEER, not VISITOR

Remaining: HS-6ABA47 and HS-74EC71[.]

Step 3 — Verify firmware response

Running the RECOVERY VM program for each candidate:

Session Computed Response Captured response_tag Match?
HS-6ABA47 FDBB5A34 FDBB5A34 ✓
HS-74EC71 307951B6 307941B6 ✗

HS-74EC71 fails the firmware response check — the gateway said ACCEPTED but the actual firmware would have rejected it[.]

Step 4 — Confirm HS-6ABA47

Session HS-6ABA47 passes every check:

Phase Frame ID Tick Payload
HELLO F-EBE7ACB 258 badge=BADGE-E7A9, counter=12, mode=RECOVERY, hello_nonce=70046167, operator=OP-1474
CHALLENGE F-0BEC264 259 challenge_nonce=E4F9C322, device=CTRL-A-REMOTE
RESPONSE F-BEC1B06 260 echo_nonce=1511F7F6, response_tag=FDBB5A34
GRANT F-3AAD5E6 261 gateway_status=ACCEPTED, requested_role=CTRL-A-ADMIN

Verification details:

  • Badge BADGE-E7A9: actual_role=VISITOR, anti_replay_floor=30, counter=12 < 30 ✓
  • echo_nonce (1511F7F6) ≠ challenge_nonce (E4F9C322) ✓
  • All 4 audit records: valid tags + intact prev_tag chain ✓
  • Firmware response: computed FDBB5A34 = captured FDBB5A34 ✓
  • TX witness: ACTUATED at tick 262 (GRANT+1), valid HMAC ✓
  • RX witness: ADMIN_ACTIVE at tick 263 (GRANT+2), valid HMAC ✓
  • Both witnesses use token 02C861021E4B ✓

5[.] Deriving B3

VM checkpoints for HS-6ABA47:

  • Checkpoint 7 (after instruction 7): A6013B1C
  • Checkpoint 13 (after instruction 13): 2A19D605

VM_PROOF:

SHA256("BP03-VM-PROOF|35C2C90A3900|HS-6ABA47|A6013B1C>2A19D605|8407CE50")[:12]
= CDE57D9D3BFC

Witness token:

SHA256("BP03-WIT|HS-6ABA47|E4F9C322|FDBB5A34")[:12]
= 02C861021E4B

B3 canonical string:

BP03|35C2C90A3900|HS-6ABA47|F-EBE7ACB>F-0BEC264>F-BEC1B06>F-3AAD5E6|CDE57D9D3BFC|02C861021E4B|6CF2648EBFE8

B3: SHA256(canonical)[:12] = 8CD2027966B9

Flag: `FLAG{REDACTED}


6[.] Verification with Official Console

The evidence probe confirms HS-6ABA47:

python3 evidence_probe[.]py --token 35C2C90A3900 --trace HS-6ABA47
TRACE HS-6ABA47
  HELLO     F-EBE7ACB tick=258 audit=OK [.][.][.]
  CHALLENGE F-0BEC264 tick=259 audit=OK [.][.][.]
  RESPONSE  F-BEC1B06 tick=260 audit=OK [.][.][.]
  GRANT     F-3AAD5E6 tick=261 audit=OK [.][.][.]
  IDENTITY {'badge_id': 'BADGE-E7A9', 'actual_role': 'VISITOR', [.][.][.]}
  witness_token=02C861021E4B TX=OK RX=OK

The custom solver additionally verified the firmware RECOVERY program produces FDBB5A34, matching the captured response_tag[.]


7[.] Solution

  • Session: HS-6ABA47
  • Badge: BADGE-E7A9 (VISITOR)
  • Operator: OP-1474
  • Attack: RECOVERY mode used echo_nonce instead of challenge_nonce (firmware flaw), bypassing the counter >= 30 floor check with counter=12
  • Final confirmed tick: 261 (within 250–290 window)
  • B3: 8CD2027966B9
  • Flag: `FLAG{REDACTED}

B3 is retained for Chapter 4 — The Poisoned Evidence.

Vulnerability Analysis