247CTF - The Encrypted Password
The encrypted password
Challenge prompt:
You won't find the admin's secret password in this binary. We even encrypted it with a secure one-time-pad. Can you still recover the password?
1. Quick dynamic check with
ltrace
ltrace shows the binary compares our input against a
transformed string.
1 | $ ltrace ./encrypted_password |
This already hints that the expected secret is a printable 32-byte string.
2. Or debug in debugger
(pwndbg)
Set a breakpoint at the strcmp call
(0x555555400930) and run the program.
1 | pwndbg> b *0x555555400930 |
At compare time, s2 contains the final password
candidate.
3. Or reverse logic in IDA
Relevant decompiled logic:
1 | strcpy(s, "875e9409f9811ba8560beee6fb0c77d2"); |
So the binary builds s2, XORs it with s,
then compares it against input.
Reconstruct the secret with Python
1 | from pwn import p64, xor |