Ajay_kumar

zp_crack.sh

Jan 30th, 2015
640
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 4.43 KB | None | 0 0
  1. #!/usr/bin/env bash
  2. #
  3. # +===============================================+
  4. # || A Simple ZIP Password Cracker               ||
  5. # || Developed By : http:\\www.sec-articles.net  ||
  6. # +===============================================+
  7. #
  8.  
  9. declare -r TRUE=0
  10. declare -r FALSE=1
  11. flag=$FALSE
  12. counter=0
  13.  
  14. # Declaring char_sets
  15.  
  16. chars_1=`echo {a..z}`
  17. chars_2=`echo {A..Z}`
  18. chars_3=`echo {0..9}`
  19. chars_4="~ ! @ \$ % ^ - _ = + { } [ ] : , . / ?"
  20.  
  21.  
  22. # cracking function
  23. function cracker()
  24. {
  25.     pass=$1
  26.     echo "trying Password $pass"
  27.     counter=$(($counter + 1))
  28.     unzip -P $pass -o $file_name
  29.     [ $? -eq 0 ] && clear && Banner && echo "Password Found : $pass" && echo "Password tried : $counter"&& return $TRUE || return $FALSE
  30. }
  31.  
  32.  
  33.  
  34. # word_List generator
  35. function word_gen()
  36. {
  37.     args=$1
  38.     [ ${#args} -ge $length ] && cracker $1 && echo "Password Cracked" && flag=$TRUE && exit
  39.     if [ ${#args} -lt $length ]; then
  40.         for c in $chars; do
  41.             word_gen $1$c
  42.         done
  43.     fi
  44. }
  45.  
  46. function is_num()
  47. {
  48.     [ "$1" -eq "$1" ] > /dev/null 2>&1
  49.     return $?
  50. }
  51.  
  52.  
  53. function Show_message()
  54. {
  55.     echo "+===============================================+"
  56.     echo "|  A Simple ZIP Password Cracker                |"
  57.     echo "|  Developed By : http:\\\\www.sec-articles.net   |"
  58.     echo "+===============================================+"
  59.     echo " ./s_zipcrack [Mode b/d] {[Lenght_of_Passowrd] [Type_Password] [location]}  {[location]}"
  60.     echo""
  61.     echo " For brute_force Mode :- "
  62.     echo " ./s_zipcrack -b [Lenght_of_Passowrd] [Type_Password] [zip_file_location]"   
  63.     echo " Length_of_Password -  integer value"
  64.     echo " Type_of_Password   -  \"A\" Upper_case     A-Z"
  65.     echo "                    -  \"a\" Lower_case     a-z"
  66.     echo "                    -  \"n\" numeric        0-9"
  67.     echo "                    -  \"c\" Special_chars  !.?"
  68.     echo " zip_file_Location  -  Full Path of Zip File"
  69.     echo " Example : ./s_zipcrack -b 4 n /home/user/Desktop/secure.zip"
  70.     echo ""
  71.     echo " For Dictonary Mode : - "
  72.     echo " ./s_zipcrack -d [Password_dictonary_file] [zip_file_Location]"
  73.     echo " Password_dictonary_file - Full Path of Password dictonary file "
  74.     echo " zip_file_Location       - Full Path of Zip file"
  75. }
  76.  
  77. function Banner()
  78. {
  79.  
  80.         echo "+===============================================+"
  81.         echo "|  A Simple ZIP Password Cracker                |"
  82.         echo "|  Developed By : http:\\\\www.sec-articles.net   |"
  83.         echo "+===============================================+"
  84.     echo ""
  85. }
  86.  
  87.  
  88.  
  89. function brute_force()
  90. {
  91.     # Handling Arguments
  92.     if [ "$1" = "" ]
  93.     then
  94.         Show_message
  95.         exit
  96.     fi
  97.  
  98.     if is_num $1
  99.     then
  100.         length=$1
  101.     else
  102.         length=2
  103.     fi
  104.  
  105.     for args in "$@"; do
  106.         case $args in
  107.             a) chars="$chars $chars_1" ;;
  108.             A) chars="$chars $chars_2" ;;
  109.             n) chars="$chars $chars_3" ;;
  110.             c) chars="$chars $chars_4" ;;
  111.         esac;
  112.     done
  113.  
  114.  
  115.     if [ "$chars" = "" ]
  116.     then
  117.         chars="$chars_1"
  118.     fi
  119.  
  120.  
  121.     for arg in "$@"; do
  122.  
  123.         if [ -a $arg ]
  124.         then
  125.             file_name=$arg
  126.             break
  127.         fi
  128.  
  129.     done
  130.  
  131.     if [ "$file_name" = "" ]
  132.     then
  133.         Banner
  134.         echo "Could not find \"$3\""
  135.         echo "please check the file location & try Again."
  136.         exit
  137.     fi
  138.  
  139.     #calling word_gen function
  140.     for w in $chars; do
  141.         word_gen $w
  142.     done
  143.  
  144. }
  145.  
  146. function dictonary()
  147. {
  148.  
  149.     if [ "$1" = "" ]
  150.     then
  151.         Banner
  152.         echo "please give the password_list."
  153.         exit 1
  154.     elif [ "$2" = "" ]
  155.     then
  156.         Banner
  157.         echo "please give the zip file location."
  158.         exit 1
  159.     fi
  160.  
  161.     if [ -a $1 ]
  162.     then
  163.         pass_list=$1
  164.     else
  165.         Banner
  166.         echo "could not find \"$1\""
  167.         echo "please check the file location & try Again."
  168.         exit 1
  169.     fi
  170.  
  171.     if [ -a $2 ]
  172.     then
  173.         file_name=$2
  174.     else
  175.         Banner
  176.         echo "could not find \"$2\""
  177.         echo "please check the file location & try Again."
  178.         exit 1
  179.     fi
  180.  
  181.  
  182.     # reading passwords & calling to cracker function
  183.  
  184.     length=`cat $pass_list | wc -l`
  185.     for ((i=0;i<=$length;i++))
  186.     do
  187.         passwd=`sed -n "$i"p $pass_list`
  188.         cracker $passwd && echo "Password Cracked" && flag=$TRUE && exit
  189.     done
  190. }
  191.  
  192. # Main
  193.  
  194. if [ "$1" = "b" ]
  195. then
  196.         brute_force $2 $3 $4
  197. elif [ "$1" = "d" ]
  198. then
  199.         dictonary $2 $3
  200. elif [ "$1" = "" ]
  201. then
  202.     Show_message
  203.     exit
  204. else
  205.         Banner
  206.         echo "Error in Arguments..!?"
  207.         echo "please choose the correct mode. b/d [brute_force/dictonary_attack]"
  208.         exit
  209. fi
  210.  
  211. if [ $flag -eq $FALSE ]
  212. then
  213.     clear
  214.     Banner
  215.     echo "Could not Found Password ?? "
  216.     echo "Password tried : $counter"
  217.     echo "please Try Again with other Keywords."
  218. fi
Add Comment
Please, Sign In to add comment