Skip to content

Instantly share code, notes, and snippets.

@wesleyit
Last active July 23, 2022 14:58
Show Gist options
  • Save wesleyit/a80f8c1e6489bfc31e372d59491a7701 to your computer and use it in GitHub Desktop.
Save wesleyit/a80f8c1e6489bfc31e372d59491a7701 to your computer and use it in GitHub Desktop.
Shell script to bruteforce SSH key with openssl using multi threads
#!/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