Description
Hello? Can anybody hear me?
(./telephone FLAG
should print "you win!")
Attachments
https://imaginaryctf.org/r/7F40-telephone
Writeup
This program accepts input via argv, permutes the given bytes, scrambles each byte using a reversible function, and checks the result against a known expected value computed from the flag.
The main trick to reversing this is the tracking the steps of the computation, which is complicated by forking off several processes and communicating between them via signals and pipes.
At the start of the program, at most 34 bytes are copied from argv[1].
For each byte in the flag buffer, a new process is forked, given one of the input bytes determined by a fixed permutation.
Each process is told who it's "neighbor" is, that is the program it should signal to start once its processing has been completed.
The parent process kicks off the process by signaling the first child.
It computes the mangled value of its flag byte, converts this to two nibbles, and maps these to realtime signals according to a fixed mapping.
It then signals its parent twice, once for each calculated nibble.
It then signals its neighbor, initiating processing of the next byte.
The final child signals the parent once again.
If the resulting buffer matches the expected value for the flag, the win message is printed.
After figuring out the general setup steps of forking the children, noticing that signals raised in the child map to bytes in the calculated buffer should be the first step.
From this, figuring out the mangling step per child should allow derivation of one flag byte per input byte.
Reversing the permutation is the final step, which should yield the flag ictf{y0u_c@nt_s7op_th3_s1gn@l_m@l}
Solve script: https://imaginaryctf.org/r/581C-solve.py
Flag
ictf{y0u_c@nt_s7op_th3_s1gn@l_m@l}