Challenge
We’re given a binary that implements a custom stack-based esoteric language interpreter. The program reads a sequence of instructions and executes them against an internal stack, then checks whether the resulting state matches the expected flag bytes.
Approach
- Load the binary in Ghidra and identify the main dispatch loop — a large switch on single-byte opcodes.
- Map out the semantics of each opcode:
PUSH <byte>,POP,DUP,ADD,XOR,CMP,JNE, etc. - Extract the embedded bytecode from the
.datasection. - Write a Python emulator that traces execution, collecting the sequence of
CMPoperands — these are the expected flag bytes. - Reassemble bytes in order.
Solution
| |
Running the emulator prints the flag.
Flag
boroCTF{r3verse_by_guessncheck}