Last active
September 17, 2022 11:00
-
-
Save chvancooten/34f26f90c1e174e16e4228764e9c5dcb to your computer and use it in GitHub Desktop.
Simple OpenSSL Decryption Bruteforcer (HTB - Hawk)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
### 0xc4s OpenSSL bruter for HTB's 'Hawk' | |
# Declare wordlists | |
wordlist = '/usr/share/wordlists/rockyou.txt' | |
# Declare array of possible ciphers (based on common ones from 'openssl help') | |
ciphers=( | |
-aes-256-cbc | |
-aes-128-cbc | |
-aes-256-ecb | |
-aes-128-ecb | |
) | |
# Loop through ciphers | |
for cipher in "${ciphers[@]}"; do | |
echo "TRYING CIPHER: $cipher" | |
# Loop through wordlist | |
while read passTry; do | |
openssl enc -d -a $cipher -k $passTry -in drupal.txt.enc -out tmp &>/dev/null | |
if [ $? -eq 0 ]; then | |
echo "PASSWORD FOUND!" | |
echo "Pass is: $passTry" | |
echo "===DECRYPTED TEXT BELOW===" | |
cat tmp | |
echo "===END DECRYPTED TEXT===" | |
# For Hawk, it gets the correct password on first try | |
# However, a 0-exit code doesn't always mean getting the key right | |
# As such, don't exit (spam alert!) | |
#exit 0 | |
fi | |
rm tmp | |
done < $wordlist | |
done | |
rm tmp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment