Last active
July 23, 2022 14:58
-
-
Save wesleyit/a80f8c1e6489bfc31e372d59491a7701 to your computer and use it in GitHub Desktop.
Shell script to bruteforce SSH key with openssl using multi threads
This file contains 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 | |
export THREADS=8 | |
export WORDLIST='/opt/wordlists/rockyou.txt' | |
export PREFIX='/tmp/rockyou_' | |
# Generate N wordlists chunks | |
split -n "$THREADS" --numeric-suffixes=1 "$WORDLIST" "$PREFIX" | |
# Function to break the passwords given a list | |
function break_key() { | |
for guess in $(cat $1) | |
do | |
openssl rsa -in encrypted.key -out cracked.key -passin pass:$guess &> /dev/null && | |
echo "Key found! $guess" && | |
exit 0 | |
done | |
} | |
for n in $(seq -w 01 "$THREADS") | |
do | |
echo "Starting thread #${n}..." | |
break_key ${PREFIX}${n} & | |
done | |
wait | |
echo "Key not found!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment