Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Argument 1 = source PGP symmetric key file (containing an encrypted PGP SYMMETRIC message)
- # Argument 2 = filename base for the PGP key
- # Ex: "PGP_INTRO_EXAMPLE" will create that file in crackmes, find its hash and create another file with the same name, but .hash type.
- # Change pwd to dir of the script.
- cd "${0%/*}"
- if [ -z $1 ]
- then
- echo "Invalid arguments. Please use the '--help' flag for more information."
- exit
- elif [ -z $1 ] && [ -z $2 ]
- then
- echo "Invalid arguments. Please use the '--help' flag for more information."
- exit
- elif [ $1 = --help ] || [$1 = '--h' ]
- then
- echo "Use this tool to quickly decrypt a PGP symmetric message, using a standard English dictionary/Rainbow Table."
- printf "\n"
- echo "ARGUMENTS: "
- echo "\$1 = source PGP symmetric message file."
- echo "\$2 = filename base for the created key information."
- echo " This file is also used to access JTR's stored password information."
- echo " Output info from JTR is stored in '$PWD/crackmes/\$2.output'"
- exit
- fi
- if ! [ -r $1 ]
- then
- echo "File '$1' does not exist or cannot be read by bash."
- exit
- fi
- # Everything appears to be in good order. Get started.
- echo "PGP source file: '$1'"
- echo "PGP destination file: '$PWD/crackmes/$2.hash'"
- echo "**Output information storage: '$PWD/crackmes/$2.output'"
- DSP_OUTPUT="$PWD/crackmes/$2.output"
- touch $DSP_OUTPUT
- # Output the PGP hash of the file.
- ./run/gpg2john $1 >"crackmes/$2.hash"
- # Run the crack with the wordsEn.txt rainbow table.
- echo "Running JTR cracking utility."
- echo "Wordlist is rainbow table: '$PWD/wordsEn.txt'"
- ./run/john --wordlist="$PWD/wordsEn.txt" --rules "crackmes/$2.hash"
- # Make sure JTR exited cleanly.
- if ! [ $? -eq 0 ]
- then
- printf "\nThere was an issue with JTR. Please check your logs or reinstall the program.\n"
- exit
- fi
- # Store the password. This method is likely over-complicating things and can be refined later.
- DSP_PASS=`./run/john --show "crackmes/$2.hash" | sed -n '/:[a-zA-Z0-9]/p' | grep -o "[a-zA-Z0-9]*$"`
- if [ -z $DSP_PASS ]
- then
- echo "JTR did not manage to extract a user:password keypair :("
- exit
- fi
- echo "Password of the key:" >$DSP_OUTPUT
- printf "$DSP_PASS\n\n" >>$DSP_OUTPUT
- echo "DECRYPTED MESSAGE:" >>$DSP_OUTPUT
- # Decrypt the message file and output it into the output file.
- printf "$DSP_PASS" | gpg -d --passphrase-fd 0 "$1" | tee -a $DSP_OUTPUT
- printf "\n\n" >>$DSP_OUTPUT
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement