Description
Download and analyze the key generator script to find the valid key.
Setup
Download keygenme-py.py.
Solution
- Step 1Read the source and find the key structureOpen keygenme-py.py. The script validates a key against a hardcoded structure. The static prefix is picoCTF{...}.cat keygenme-py.py
Learn more
A keygen (key generator) challenge asks you to reverse-engineer the validation logic of a program to produce a value that passes the check -- rather than recovering a stored secret. The key here is deterministic: it depends only on a hardcoded constant string, so there is exactly one valid answer.
SHA-256 is a cryptographic hash function that produces a 256-bit (64 hex character) digest. The script uses specific character positions from the hex digest as nibbles of the dynamic portion of the key. Nibble selection at specific indices is a common obfuscation pattern in crackme challenges.
- Step 2Compute the key from the SHA-256 hashHash the string GOUGH with SHA-256. Extract nibbles at indices [4, 5, 3, 6, 2, 7, 1, 8] from the hex digest. Concatenate the static prefix, the extracted nibbles, and the closing brace.python3 -c " import hashlib h = hashlib.sha256(b'GOUGH').hexdigest() suffix = ''.join(h[i] for i in [4, 5, 3, 6, 2, 7, 1, 8]) print('picoCTF{...}') "
Learn more
The indices
[4, 5, 3, 6, 2, 7, 1, 8]are not consecutive -- they are scrambled to make the pattern less obvious. By reading the source validation logic carefully and tracing each index access, you reconstruct the exact nibble order needed to form the correct suffix.This challenge illustrates why security through obscurity fails: once the source code is available (or reversible from a binary), any deterministic computation can be replicated. A truly secure key would involve an actual secret that is never stored in the program.
Flag
picoCTF{...}
The key is deterministic -- sha256 of a hardcoded constant, with specific nibbles extracted in a fixed order.