Advertisement
Guest User

Untitled

a guest
Apr 26th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.41 KB | None | 0 0
  1. #!/bin/bash
  2. # Argument 1 = source PGP symmetric key file (containing an encrypted PGP SYMMETRIC message)
  3. # Argument 2 = filename base for the PGP key
  4. # Ex: "PGP_INTRO_EXAMPLE" will create that file in crackmes, find its hash and create another file with the same name, but .hash type.
  5.  
  6. # Change pwd to dir of the script.
  7. cd "${0%/*}"
  8.  
  9. if [ -z $1 ]
  10. then
  11. echo "Invalid arguments. Please use the '--help' flag for more information."
  12. exit
  13. elif [ -z $1 ] && [ -z $2 ]
  14. then
  15. echo "Invalid arguments. Please use the '--help' flag for more information."
  16. exit
  17. elif [ $1 = --help ] || [$1 = '--h' ]
  18. then
  19. echo "Use this tool to quickly decrypt a PGP symmetric message, using a standard English dictionary/Rainbow Table."
  20. printf "\n"
  21. echo "ARGUMENTS: "
  22. echo "\$1 = source PGP symmetric message file."
  23. echo "\$2 = filename base for the created key information."
  24. echo " This file is also used to access JTR's stored password information."
  25. echo " Output info from JTR is stored in '$PWD/crackmes/\$2.output'"
  26. exit
  27. fi
  28.  
  29. if ! [ -r $1 ]
  30. then
  31. echo "File '$1' does not exist or cannot be read by bash."
  32. exit
  33. fi
  34.  
  35. # Everything appears to be in good order. Get started.
  36. echo "PGP source file: '$1'"
  37. echo "PGP destination file: '$PWD/crackmes/$2.hash'"
  38. echo "**Output information storage: '$PWD/crackmes/$2.output'"
  39. DSP_OUTPUT="$PWD/crackmes/$2.output"
  40. touch $DSP_OUTPUT
  41.  
  42. # Output the PGP hash of the file.
  43. ./run/gpg2john $1 >"crackmes/$2.hash"
  44.  
  45. # Run the crack with the wordsEn.txt rainbow table.
  46. echo "Running JTR cracking utility."
  47. echo "Wordlist is rainbow table: '$PWD/wordsEn.txt'"
  48. ./run/john --wordlist="$PWD/wordsEn.txt" --rules "crackmes/$2.hash"
  49.  
  50. # Make sure JTR exited cleanly.
  51. if ! [ $? -eq 0 ]
  52. then
  53. printf "\nThere was an issue with JTR. Please check your logs or reinstall the program.\n"
  54. exit
  55. fi
  56.  
  57. # Store the password. This method is likely over-complicating things and can be refined later.
  58. DSP_PASS=`./run/john --show "crackmes/$2.hash" | sed -n '/:[a-zA-Z0-9]/p' | grep -o "[a-zA-Z0-9]*$"`
  59.  
  60. if [ -z $DSP_PASS ]
  61. then
  62. echo "JTR did not manage to extract a user:password keypair :("
  63. exit
  64. fi
  65.  
  66. echo "Password of the key:" >$DSP_OUTPUT
  67. printf "$DSP_PASS\n\n" >>$DSP_OUTPUT
  68. echo "DECRYPTED MESSAGE:" >>$DSP_OUTPUT
  69.  
  70. # Decrypt the message file and output it into the output file.
  71. printf "$DSP_PASS" | gpg -d --passphrase-fd 0 "$1" | tee -a $DSP_OUTPUT
  72. printf "\n\n" >>$DSP_OUTPUT
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement