Description
Can you figure out the password to this program? Provide the correct input to have the binary print the flag.
Setup
Download the binary and make it executable.
wget https://mercury.picoctf.net/static/.../checkpasschmod +x checkpassSolution
Walk me through it- Step 1Try ltrace to intercept library callsRun the binary under ltrace to intercept all dynamic library calls, especially strcmp and strncmp. The password being compared against will appear in the ltrace output.bash
ltrace ./checkpass AAAA 2>&1bashltrace ./checkpass 'picoCTF{test}' 2>&1Learn more
ltrace intercepts dynamic library calls made by a program (similar to strace for system calls). Every call to a C library function like
strcmp,printf,malloc, orstrcpyis printed with its arguments and return value. For password checking programs that usestrcmp(user_input, correct_password), ltrace reveals the correct password in plaintext without any reverse engineering of the binary.What success looks like. A real ltrace line for the password compare looks like this:
strcmp("AAAA", "picoCTF{s3cur3_p4ss}") = -1 ^ ^ your guess the answer (second arg of strcmp)The non-zero return value (
-1or1) is strcmp telling you the strings differ; the second argument is the answer in plaintext.Limitation: ltrace only works for dynamically linked binaries. If the binary is statically linked or uses inline comparison code, ltrace will not show the strcmp call. In that case, fall back to GDB. For the broader landscape of CLI tools that crack open dynamic-binary behavior, see Linux CLI for CTF.
- Step 2Verify with the discovered passwordRun the binary with the password found in the ltrace output. The binary should print the flag.bash
./checkpass 'picoCTF{...}'Learn more
strace is the companion to ltrace: it traces system calls (kernel interactions like
open,read,write,execve) rather than library calls. For programs that read the expected password from a file,straceshows theopenandreadcalls, revealing the filename. For programs that check a password character by character in hand-written code (no library calls), neither ltrace nor strace helps - use GDB or Ghidra.
Flag
picoCTF{...}
ltrace intercepts dynamic library calls including strcmp - the correct password appears in plaintext in the ltrace output without any disassembly required.