247CTF - The Encrypted Flag

Decrypt an OpenSSL-encrypted file. The file was encrypted with openssl enc using a password.

Vulnerability

OpenSSL's enc command uses EVP_BytesToKey for password derivation, which is relatively weak compared to modern key derivation functions. Common passwords can be cracked with a good wordlist.

Solution

Step 1: Identify the encryption

1
2
file encrypted_flag.enc
encrypted_flag.enc: openssl enc'd data with salted password

Step 2: Convert to crackable format

1
openssl2john encrypted_flag.enc > hash

Step 3: Crack the password

1
2
3
john hash --wordlist=rockyou.txt
john --show hash
encrypted_flag.enc:*7¡Vamos!

The retained john --show line contains the complete password *7¡Vamos!; neither its prefix nor the non-ASCII punctuation may be dropped. UTF-8 bytes must be preserved. The salted header alone does not identify cipher, digest or whether PBKDF2 was used. AES-256-CBC is the recorded candidate below; the attachment and matching KDF settings are unavailable, so decryption has not been reproduced.

Step 4: Decrypt

1
2
printf '%s' '*7¡Vamos!' > password.txt
openssl enc -d -aes-256-cbc -in encrypted_flag.enc -pass file:password.txt -out flag

Flag

247CTF{[flag redacted]}