Gadget's Crackme XOR-obscured comparison array in .data

rev
flag L3m0n{ab2434bb9a56f5a72e6975e42cc3314c}

A 125-point guided lesson, no plaintext flag hiding anywhere this time. "No strings this time. You'll need a decompiler to see how the lock works."

Hint

If strings has nothing, the comparison data itself must be obscured somehow - look for where the input actually gets checked.

strings on gadgets_crackme only turns up the prompt text, confirming the hint. The binary isn't stripped though, and the symbol table still names a check function and a lock array - which the lesson also points straight at. Disassembling check:

asm
1movq   $0x27,-0x10(%rbp)        ; expected input length = 39
2...
3movzbl (%rax),%eax              ; load input[i]
4mov    %eax,%ecx
5lea    0x2e58(%rip),%rdx        ; -> 0x404060 <lock>
6movzbl (%rax),%eax              ; load lock[i]
7xor    $0x5,%eax                ; lock[i] ^ 5
8cmp    %al,%cl                  ; equal?

Insight

The whole check, for all 39 bytes, is input[i] == lock[i] ^ 0x05. No hashing, no derived state - the "secret" comparison data is sitting right in .data, just XORed with a constant byte. Dump the section and undo it.

bash
1objdump -s -j .data gadgets_crackme
python
1LOCK = bytes.fromhex(
2    "49366835 6b7e6467 37313631 67673c64 30336330 64323760 333c3230 60313766"
3    "66363634 316678".replace(" ", ""))
4
5flag = bytes(b ^ 0x5 for b in LOCK).decode()
6print(flag)
output
L3m0n{ab2434bb9a56f5a72e6975e42cc3314c}

Note

No guessing required on the XOR constant: the first three decrypted bytes confirm it immediately - 0x49 ^ 5 = 'L', 0x36 ^ 5 = '3', 0x68 ^ 5 = 'm' - exactly the start of every flag in this event.