irwan

Cracking Utility for SHA1

Nov 22nd, 2011
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.15 KB | None | 0 0
  1. #!/usr/bin/env bash
  2. # SHA1 Cracker V1.0
  3. # coded By 0x90 2009
  4. # 0x90[at]bsdmail.org
  5. # This small tool will bruteForce SHA1 hash
  6. # tested on Fedora Linux
  7. #
  8. #    I do not take any reponsibilty for what you do with this tool
  9. #    Hopefully it will make your life easier rather then making other
  10. #    peoples lives more difficult!
  11. ##############################
  12. #  ___        ___   ___  
  13. # / _ \      / _ \ / _ \
  14. #| | | |_  _| (_) | | | |
  15. #| | | \ \/ /\__, | | | |
  16. #| |_| |>  <   / /| |_| |
  17. # \___//_/\_\ /_/  \___/
  18. ##############################  
  19.  
  20. echo ".:: SHA1 Cracker, Coded By 0x90 ::."
  21. echo -n "Enter SHA1 Hash: "
  22. read hash
  23. if [ -z "$hash" ] || [ "${#hash}" != "40" ]; then
  24. echo "Error: please Enter a valid SHA1 hash"
  25. exit
  26.     fi
  27. echo
  28.  
  29.  
  30. echo -n "Select BruteForce Method:
  31. 1: Random BruteForce
  32. 2: Dictionary BruteForce
  33. Enter your choise 1 or 2: "
  34. read choise
  35. if [ -z "$choise" ] || [ "$choise" != "1" ] && [ "$choise" != "2" ]; then
  36. echo "Error: please choise between 1 or 2"
  37. exit 1
  38.     fi
  39. #########################
  40. # Random BruteForce
  41. #########################
  42.  
  43. if [ "$choise" == "1" ]; then
  44. echo "use Random method to crack"
  45. echo "trying to bruteforce SHA1 hash ..."
  46.  
  47. echo -n "enter min lengh: "
  48. read minlen
  49. echo -n "enter max lengh: "
  50. read maxlen
  51.  
  52. echo -n "Select bruteForce mode:
  53. all, alnum, lower, upper, digit, alpha, symbols
  54. > "
  55. read mode
  56.  
  57. if [ "$mode" = "all" ]; then
  58. char="a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # \$ % & \' ( ) \* + , - . / : ; & < = > ? @ [ \\ ] ^ _ { | } ~"
  59.     fi
  60. if [ "$mode" = "alnum" ]; then
  61. char="a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9"
  62.     fi
  63. if [ "$mode" = "alpha" ]; then
  64. char="a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 8 9"
  65.     fi
  66. if [ "$mode" = "lower" ]; then
  67. char="a b c d e f g h i j k l m n o p q r s t u v w x y z"
  68.     fi
  69. if [ "$mode" = "upper" ]; then
  70. char="A B C D E F G H I J K L M N O P Q R S T U V W X Y Z"
  71.     fi
  72. if [ "$mode" = "digit" ]; then
  73. char="0 1 2 3 4 5 6 7 8 9"
  74.     fi
  75. if [ "$mode" = "symbols" ]; then
  76. char="! # \$ % & \' ( ) \* + , - . / : ; & < = > ? @ [ \\ ] ^ _ { | } ~"
  77.         fi
  78.  
  79.  
  80. bf(){
  81.         for c in $char ; do
  82.  
  83.                 nc=$[$nc+1]
  84.                 ch[$nc]=$c
  85.         done
  86.         for x in `seq 1 $[$maxlen+1]` ; do
  87.  
  88.                 if [ $minlen -ge $x ] ; then
  89.                         ci[$x]=1
  90.                 else
  91.                         ci[$x]=0
  92.                 fi
  93.         done
  94.         for clen in `seq $minlen $maxlen` ; do
  95.  
  96.                 while [ ${ci[$[$clen+1]]} -ne 1 ] ; do
  97.                         wrd=""
  98.                         for x in `seq $clen -1 1` ; do
  99.                                 wrd=$wrd${ch[${ci[$x]}]}
  100.                         done
  101.  
  102.  
  103. sha1_hash=`echo -n "$wrd" | sha1sum | awk '{ print $1 }'`
  104.  
  105.  
  106. echo "$wrd: hash: $sha1_hash"
  107. if [ "$sha1_hash" == "$hash" ]; then
  108. echo
  109. echo "Cracked, SHA1 password is: $wrd"
  110.     exit 0
  111.     fi
  112.                         ci[1]=$[${ci[1]}+1]
  113.                         for x in `seq 1 $clen`; do
  114.                                 if [ ${ci[$x]} -gt $nc ] ; then
  115.                                         ci[$x]=1
  116.                                         ci[$[$x+1]]=$[${ci[$[$x+1]]}+1]
  117.                                 fi
  118.                         done
  119.                 done
  120.         done
  121. }
  122.  
  123. bf
  124.  
  125.  
  126.  
  127. fi
  128. #########################
  129. # Dictionary BruteForce
  130. #########################
  131. # Cain&Abel wordlist http://www.md5this.com/Wordlist.zip
  132. # dont forget to convert the wordlist to Unix file format
  133. # dos2unix Wordlist.txt
  134. if [ "$choise" == "2" ]; then
  135. echo "use dictionary method to crack"
  136. echo -n "Enter dictionary name: "
  137. read dic
  138. echo "trying to bruteforce SHA1 hash ..."
  139.  
  140. n=`cat $dic | wc -l`
  141.  
  142. echo "we have $n password to try"
  143. for (( i=1; i <= $n; i++));
  144.     do
  145. pass=`sed -n "$i"p $dic`
  146. sha1_hash=`echo -n "$pass" | sha1sum | awk '{ print $1 }'`
  147.  
  148. echo "$i: hash: $sha1_hash"
  149.  
  150. if [ "$sha1_hash" == "$hash" ]; then
  151. echo
  152. echo "Cracked, SHA1 password is: $pass"
  153.     exit 0
  154.     fi
  155.     done
  156. fi
  157.     exit
  158.  
Add Comment
Please, Sign In to add comment