· 3 min read

CSAW26 Finals - Bombe

A homemade Enigma with no plugboard, three steppable rotors and an Atbash reflector. The key space is 2.2M, so a crib on the first four letters and an English check pick the one setting that decrypts the ciphertext.

Tagged: enigma, crib, brute-force, radare2, involution

Event
CSAW CTF Finals 2026
Category
rev
Points
500
Given
enigma.elf

Challenge

My handed me this binary alongside this ciphertext ICGR{LZ_VGUWS_CLL_PAMCLQ_WYI_HQB_KAZQPBPGNL} Flag in this challenge is uppercase CSAW, but not case sensitive either way.

Given: enigma.elf (x86-64 PIE, not stripped).

Analysis

The binary asks for three rotors (I–V), three offsets (0–25), and a line of text, then runs the text through a homemade Enigma. It isn’t stripped, so the symbol names (ROTOR1..5, ROTORS, rotate_rotor, map_forward, map_inverse, reflector, roman_int) lay out the whole design.

Reversing main and its helpers in radare2:

Component Behaviour
roman_int Converts I..V to an index 0..4 into ROTORS[], which points at ROTOR1..5.
Rotor 26 (in, out) byte pairs. The wirings show up in strings, e.g. AYBACZDD….
map_forward / map_inverse Look up a letter by its in byte or its out byte.
rotate_rotor Rotates the out column left by one position.
reflector 155 - c, i.e. Atbash (A↔Z).
Offsets Each rotor is rotated offset times before encryption starts.
Stepping Rotor 1 steps after every letter. Rotor 2 steps every 8 letters (count & 7 == 0). Rotor 3 never steps.
Non-letters Passed through unchanged, and they don’t advance the rotors.
Plugboard None.

The signal path is fwd(R1) → fwd(R2) → fwd(R3) → reflector → inv(R3) → inv(R2) → inv(R1). The reflector makes the whole thing an involution, so encrypting the ciphertext with the right settings decrypts it — no separate decrypt routine to find.

Solve

The key space is tiny: 5³ rotor choices (repeats allowed) × 26³ offsets ≈ 2.2M. A C reimplementation of the machine, using the rotor tables read straight out of the ELF (file offset 0x3020, stride 64), keeps every setting that maps ICGR → CSAW and decrypts the full ciphertext for each one. The search takes about a second.

About 100 settings match the four-letter crib. Exactly one produces English:

IV II V | 15 4 24 | CSAW{WE_BRING_THE_BOOMBE_BIG_FUN_CONFERENCE}

Verified against the real binary:

$ printf 'IV II V\n15 4 24\nICGR{LZ_VGUWS_CLL_PAMCLQ_WYI_HQB_KAZQPBPGNL}\n' | ./enigma.elf
CSAW{WE_BRING_THE_BOOMBE_BIG_FUN_CONFERENCE}

Flag

CSAW{WE_BRING_THE_BOOMBE_BIG_FUN_CONFERENCE}

Solver files

  • rotors.h — rotor tables extracted from the binary
  • bf.c — the brute-forcer (gcc -O2 -o bf bf.c && ./bf)