Description
A password program proudly shows what it stores in its database output. Download `system.out`, inspect the binary, and recover what it is really checking.
Setup
Download system.out and inspect it.
Use strings, file, and reverse engineering tools to analyse the output.
file system.out
strings system.out
Solution
- Step 1Identify the file typeDownload system.out and check what kind of file it is.file system.outstrings system.out | grep -i 'picoCTF|flag|password'
- Step 2Try to find the flag in binary stringsRun strings to search for a direct or hex/base64-encoded picoCTF flag.strings system.out | grep picoCTFstrings system.out | grep -E '[0-9a-fA-F]{40,}'python3 -c "import re, base64; data=open('system.out','rb').read(); print(re.findall(rb'picoCTF\{[^}]+\}', data))"
- Step 3Trace the binary with ltraceRun the binary under ltrace to capture the arguments to strcmp/memcmp at the moment of the password check. The comparison value is the stored (possibly transformed) password.chmod +x system.outltrace -s 256 ./system.out <<< 'test'# Look for strcmp/memcmp calls — the second argument is the expected value
- Step 4Analyse the transformation with GDB or objdumpIf ltrace doesn't reveal the flag directly, set a breakpoint at the comparison function to read memory, or use objdump to find hardcoded comparison values in the binary.objdump -d system.out | grep -A5 'cmp\|strcmp\|memcmp'objdump -s -j .rodata system.out | stringsgdb -q ./system.out -ex 'break strcmp' -ex 'run <<< "AAAA"' -ex 'x/s $rdi' -ex 'x/s $rsi' -ex 'quit'
- Step 5Try XOR brute-force decodeIf the flag is XOR-encoded in the binary, try every single-byte key against the raw binary data.python3 - <<'EOF' import re data = open('system.out', 'rb').read() for key in range(1, 256): dec = bytes(b ^ key for b in data) m = re.search(rb'picoCTF[{][^}]+[}]', dec) if m: print(f'key=0x{key:02x}: {m.group().decode()}') EOF
Flag
picoCTF{s3cur3_p4ssw0rd_db_...}
Reverse engineering challenge. Try strings first, then ltrace to capture strcmp arguments, then objdump .rodata, then XOR brute-force decode. The program transforms the password before storing and comparing it.