Description
The employer wants you to hash words with MD5 - do it three times fast enough.
Setup
Connect to the server. It sends a word, you must respond with its MD5 hash - three times in a row.
Automate with pwntools and hashlib for reliable timing.
nc saturn.picoctf.net <PORT>Solution
- Step 1Understand the protocolConnect and the server sends a prompt containing a word. You must reply with the MD5 hex digest of that word (without a trailing newline). The server repeats this three times; if all are correct it prints the flag.
Learn more
MD5 (Message Digest 5) is a cryptographic hash function that produces a fixed 128-bit (32 hex character) digest from any input. Hash functions are deterministic - the same input always produces the same output - and designed to be one-way: you cannot reverse a hash to recover the original input efficiently.
The server is running a challenge-response protocol: it sends a challenge (the word), and you must demonstrate knowledge of MD5 by returning the correct hash. This is similar to how some authentication systems work - instead of sending a password directly, the client proves it knows the password by responding correctly to a server-issued challenge.
The three-round structure with a time limit is the key constraint. A human could look up or compute one MD5 hash manually, but doing it three times quickly under a deadline requires automation - which is exactly what the challenge is teaching.
- Step 2Automate with pwntools and hashlibUse pwntools to receive each word, compute its MD5 hash with hashlib (which excludes trailing newlines unlike shell echo), and send the hex digest back.
python3 -c " from pwn import * import hashlib conn = remote('saturn.picoctf.net', <PORT>) for _ in range(3): conn.recvuntil(b'word: ') word = conn.recvline().strip() digest = hashlib.md5(word).hexdigest() conn.sendline(digest.encode()) print(conn.recvall().decode()) "Learn more
pwntools is the standard Python library for CTF exploitation and network interaction. Its
remote()function opens a TCP connection, and methods likerecvuntil(),recvline(), andsendline()handle the send/receive cycle cleanly, including proper newline handling.Python's hashlib module provides access to all standard hash algorithms including MD5, SHA-1, SHA-256, and SHA-512. The usage pattern is always the same:
hashlib.md5(data).hexdigest()wheredatamust bebytes, not a string - hence the.encode()call when working with string input.hexdigest()returns the lowercase hex string representation of the hash.The critical detail is stripping whitespace before hashing. The server sends the word followed by a newline (
\n). If you hash the word with the newline attached, you get a completely different MD5 value than the server expects. Always call.strip()on received lines before computing hashes.While MD5 is fast and widely supported, it is cryptographically broken for security purposes - collision attacks have been demonstrated, meaning two different inputs can produce the same hash. Modern systems use SHA-256 or SHA-3 instead. MD5 still appears in CTFs and legacy systems, so recognizing it is important.
Alternate Solution
Not sure what type of hash the server is using? Paste a sample hash into the Hash Identifier on this site to confirm the algorithm (MD5 = 32 hex chars) before automating the solution.
Flag
picoCTF{...}
echo -n suppresses the trailing newline that would corrupt the hash - hashlib.md5() in Python operates on the exact bytes provided, making it reliable for programmatic hashing without shell quoting issues.