gogo
Last updated
Was this helpful?
Last updated
Was this helpful?
Hmmm this is a weird file... enter_password. There is a instance of the service running at
mercury.picoctf.net:48728
.
We can decompile the program using Ghidra and check out the main
functions. There is a checkPassword
function, which is shown below:
The checkPassword
function runs a loop that XORs two characters and compares the result to another variable. The loop in assembly is shown below:
We can use GDB and set a breakpoint at 0x080d4b28
so we have access to the values that our input is XORed with and the values that the result of the XOR operation is compared with.
We launch the program in gdb with gdb ./enter_password
and create the breakpoint with b* 0x080d4b28
. We run the program with r
and enter 32 a
s since the decompiled code shows that the loop runs 0x20
times. You can generate a string of 32 a
s for copy-pasting by running python -c "print('a'*32)"
. According to the disassembly, our input should be at $ecx
. If we run x /32 $ecx
, sure enough we see our input:
The values that our input is XORed with are at $esp+0x4
and the expected values are at $esp+0x24
:
Now, we can XOR these two values to get the input because if x ^ y = z
then y ^ z = x
, where x
is the input ($ecx
), y
are the values that the input is XORed with ($esp+0x4
), and x
are the expected values ($esp+0x24
). We can use to compute the XOR between 3836313833366631336533643632376466613337356264623833383932313465
and 4a53475d414503545d025a0a5357450d05005d555410010e4155574b45504601
to get reverseengineericanbarelyforward
as the output.
Let's run the program normally with ./enter_password
and enter reverseengineericanbarelyforward
for the password:
We need an unhashed key. The value that the input is XORed with at $esp+0x4
converted from hex to ascii looks like a hash: 861836f13e3d627dfa375bdb8389214e
. I noticed this while building the CyberChef recipe for decoding the password. If we paste this into we find that it is the md5 hash for goldfish
. If we enter the password and then type in goldfish
for the unhashed key, the program will read the flag.txt
file.
Connect to the web service with nc mercury.picoctf.net 48728
, send reverseengineericanbarelyforward
for the password and goldfish
for the unhashed key to get the flag:
picoCTF{p1kap1ka_p1c0b187f1db}