madx
Source + static ELF reviewA fake hardware lock hides a 29-byte password check. The shortcut is not a traced comparison—it is understanding a position-dependent keystream and undoing its byte arithmetic.
- 1. Hardcoded lock
is_locked = 1The original program exits before asking for input. - 2. Input gate
strlen(input) == 29The first newline is removed; the length is in bytes. - 3. Per-byte check
(input[i] + K(i)) mod 256Must match target_a[i] XOR target_b[i]. - 4. One final decision
diff == 0All 29 positions must match to unlock the vault.
The scenario
madx is a small Linux executable that pretends to require a hardware key. In reality, lock_check() sets a local variable to 1, checks it against 1, and exits. Behind that gate is an input prompt and a custom password verifier.
The verifier does not call strcmp or memcmp. Instead, it generates a deterministic byte from the input position, adds that byte to the input character with 8-bit wrapping, and compares the result with two XOR-combined target arrays. It accumulates every mismatch and decides only after all 29 positions.
The exercise teaches how to follow control flow, distinguish instruction addresses from patch bytes, recover fixed-width arithmetic, extract actual referenced data, and algebraically invert a validator.
What was reviewed—and what was not run
The supplied madx.c, solve.py, README, and PDF text were read. The ELF header, symbols, disassembly, raw target bytes, and ZIP member were inspected as data. The executable and supplied solver were never executed, compiled, patched, or traced. Expected behavior below follows from the code, not a recorded run.
What a complete solve means
- Explain why the original hardware-lock branch always exits.
- Recover the exact 29-byte input requirement and newline handling.
- Identify the position-seeded xorshift operations and their 32-bit width.
- Read both 29-byte target arrays and invert the bytewise transformation.
- Distinguish recovering the correct password from merely forcing a success branch.
The important equation
input[i] = ((a[i] XOR b[i]) − K(i)) mod 256. No brute force is needed when all ingredients are available.
The important correction
No libc comparison means no simple ltrace comparison leak—not “dynamic analysis is impossible.”
Reveal the recovered password / challenge flag
This is the 29-byte answer reported by the README and PDF, and supported by their supplied target arrays and recovery formula. Acceptance by a running executable was not tested here.
madx{k3ystr34m_b34ts_ltr4c3!}The actual C program prints [+] Access Granted. Vault unlocked. when the password matches. It does not print the flag itself; the recovered password is the challenge answer.