Signal Fire dead FNV gate hides a signal-handler state machine

rev
flag RxR{m1st_r34p3r_sk7ll_cf2042}

A 475-point static musl ELF, x86-64, non-PIE, stripped. file and the error-string table said musl, not Go (the strerror block fooled me into guessing Go for a minute). It reads one line and prints a success or failure message - the success message claims "your flag" is whatever you typed, so the input itself is the flag. Nothing fancy about the premise; everything fancy is in getting there.

session
$printf 'test\n' | ./signal_fire
Light the signal fire. Every word must burn right.
words: [-] Wrong. The fire chokes on smoke.

The checker that looks real and isn't

main at 0x401030 reads the line, strips the newline, hashes 16 bytes at 0x408020 (seed 0x811c9dc5, prime 0x1000193), and compares against 0xede6c641. On match it tail-calls a checker at 0x401470. That checker is a tidy little recurrence - length must be 33, first byte R, then per-byte:

output
tableA[i & 7] ^ input[i]  ==  (target[i] - ecx) & 0xff ,  ecx = -13*i

which inverts cleanly to a 33-character string:

output
RxR{w1th3r_s3pulchr3_gr1m_cfdc74}

Pitfall

Fed to the binary, this is rejected. ~15 minutes gone before I noticed the actual bug in my reading: the compare instruction is cmp eax, 0xede6c641, but eax holds a scratch xor value - the running hash itself lives in ecx (imul ecx, eax, 0x1000193). The gate compares garbage against the constant and never fires. 0x401470 is dead code, and its clean, plausible 33-char answer is a decoy. Good one.

The real path: sigsetjmp and a divide-by-zero exit

The very first call in main is sigsetjmp(env, 1) (musl's 0x401a2f); the first return is 0, so execution falls through to the banner/read path. Three signal handlers are installed before that - SIGUSR1, SIGUSR2, SIGFPE - and that's the "smoke signal" in the challenge name.

1/4The FNV gate always fails

Control lands on the branch at 0x401142, which sets an accumulator to 29 ^ strlen(input) and loops 29 times, raising SIGUSR1 on even indices and SIGUSR2 on odd ones.

2/4Two handlers, one formula

Each raise runs a handler that folds the input byte at that index into the accumulator with an OR. Reassociating the odd-index handler's subtraction into an XOR gives the identical condition on both:

output
acc |= ( key[8 + (i&7)] ^ input[i] ^ ((C >> 8*(i&7)) & 0xff) - key[0x11 + i] - 5*i ) & 0xff

with C = 0xb1b7509a1e72f546 and key the block at 0x408020.

3/4Every term must be zero

The accumulator is only ever OR'd into, so landing on zero requires every term zero, plus 29 ^ len = 0 - length 29, and per byte:

output
input[i] = key[8+(i&7)] ^ (byte i&7 of C) ^ ((key[0x11+i] + 5*i) & 0xff)

4/4The exit is a deliberate crash

Once index hits 29, idiv [0x408380] runs against a dword that was never written - zero - and the resulting SIGFPE fires the third handler, which calls siglongjmp(env, 0x7e). main resumes at the top with eax == 0x7e and prints success or failure based on whether the accumulator stayed zero. The whole thing is a signal-driven state machine that uses an intentional divide-by-zero as its own exit.

Flip it and check

session
$python3 solve.py
candidate: RxR{m1st_r34p3r_sk7ll_cf2042} (29 chars)
binary stdout:
Light the signal fire. Every word must burn right.
words: [+] The fire answers from the next hill. That's your flag.

Negative controls (last char flipped, one char dropped) both print the failure line, confirming this is a value check, not just a length check.

Flag

output
RxR{m1st_r34p3r_sk7ll_cf2042}