Puppeteer fork, ptrace, one int3 trap per byte

rev
flag RxR{f4ng_sk7ll_sc7th3_ed3948}

A 38 KB statically-linked, stripped musl x86-64 ELF. It prompts strings: , reads one line, and prints either "The puppet bows" or "The strings tangle and the puppet falls." One checker, no symbols.

The FNV gate, and the dead branch behind it

main (0x401030) hashes 16 bytes of .data at 0x40a020 with and compares:

asm
14010e4: cmp  eax, 0xede6c641
24010e9: je   0x4011a1          ; "self-check OK" -> straight to 0x401500

0x401500 runs a short xorshift over a 32-byte blob and ORs byte differences into an accumulator, requiring length 30. Inverting it (flag[i] = blob[i] ^ (S & 0xff) ^ ((S>>19) & 0xff)) gives a clean string:

output
RxR{bl00d_p4ss1ng_v31l_a533f3}

Pitfall

I patched the je to an unconditional jump to confirm 0x401500 accepts that string - it does. That felt like a solve for about a minute. It isn't: hashing the shipped bytes at 0x40a020..0x40a030 by hand gives 0xadc61e2f, not 0xede6c641 - the branch never fires on the real binary, 0x401500 is dead code, and the unmodified binary rejects this string outright.

The real path: fork, ptrace, int3-per-byte

strace -f on the unmodified binary shows the actual shape: main forks at 0x4010ef. The child calls ptrace(PTRACE_TRACEME), then reaches the checker at 0x4014a0, which walks the input buffer and executes one int3 per byte:

asm
14014d6: int3

Each trap lands in the parent's handler at 0x401297, which does PTRACE_GETREGS, computes a value from two of the child's registers, and writes it back with PTRACE_SETREGS. The child then folds the rewritten register into an accumulator (rdx |= r12) and exits 42 only if it stays zero.

parent trap handler (per byte i) asm
1w   = (0x210002366a63c01c >> 8*(i&7)) & 0xff
2rdx = ((tbl1[i&7] ^ input[i]) ^ w) + (i*0x61 - tbl2[i])
3r12 = rdx & 0xff
  1. 1w is one byte of a fixed 64-bit constant, selected by i mod 8.
  2. 2The core term XORs the input byte against a table and against w.
  3. 3The result is masked to a byte and OR'd into the child's running accumulator - every term has

Setting the term to zero inverts directly: input[i] = tbl1[i&7] ^ w ^ ((tbl2[i] - i*0x61) & 0xff), 29 bytes (matching the checker's 29 ^ len gate).

Verification

session
$printf 'RxR{f4ng_sk7ll_sc7th3_ed3948}\n' | ./puppeteer
The puppet only dances when the puppeteer pulls the right strings.
strings: [+] The puppet bows. That's your flag.
 
$printf 'RxR{bl00d_p4ss1ng_v31l_a533f3}\n' | ./puppeteer
strings: [-] Wrong. The strings tangle and the puppet falls.

Flag

output
RxR{f4ng_sk7ll_sc7th3_ed3948}