PythonTkinter 练习16之 自编工具 扫描 WIFI
#Time: 2020/03/21
#Author: Xiaohong
#运行环境: OS: Win7 64位 专业版Pack1
# Python: 3.7
功能: 1.先根据规则生成密码字典 2. 扫描 WIFI信号,并用密码字典方式暴力破解
效果如下:
源文件(使用Pywifi、comtypes 模块)
import tkinter as tk
import tkinter.messagebox
from tkinter import ttk
from tkinter import filedialog
import random
import os
import time
import pywifi
from pywifi import const
class Tl_wifi_scan_screen(object):
def __init__(self):
# self.master = tk.Toplevel(father_win)
self.master = tk.Tk()
self.master.title('wifi 地址扫描')
# 创建的Toplevel对象 在最上层
# self.master.attributes("-toolwindow", 1)
# self.master.wm_attributes("-topmost", 1)
self.setCenter(self.master, 620, 500)
self.SetupUI()
self.master.mainloop()
def __str__(self):
return '(WIFI:%s,%s)' % (self.wifi, self.iface.name())
def setCenter(self,root, w, h):
ws = root.winfo_screenwidth()
hs = root.winfo_screenheight()
x = int((ws / 2) - (w / 2))
y = int((hs / 2) - (h / 2))
root.geometry('{}x{}+{}+{}'.format(w, h, x, y))
def SetupUI(self):
# 存储要破解的wifi信号
self.get_wifi_value = tk.StringVar()
# 存储要破解wifi信号对应的密码
self.get_wifimm_value = tk.StringVar()
self.wifi = pywifi.PyWiFi() # 抓取网卡接口
self.iface = self.wifi.interfaces()[0] # 抓取第一个无线网卡
print(self.iface.name())
# self.iface.disconnect() # 测试链接断开所有链接
# time.sleep(1) # 休眠1秒
# # 测试网卡是否属于断开状态
# assert self.iface.status() in \
# [const.IFACE_DISCONNECTED, const.IFACE_INACTIVE]
fm1=tk.LabelFrame(self.master,text='密码文本生成',padx=5,pady=5,height=400)
fm1.grid(row=0,column=0,padx=5,pady=5)
tk.Label(fm1,text='密码内容').pack(anchor='w')
# # 设定默认值
self.pwd_str = tk.StringVar()
self.pwd_str.set('0,1,2,3,4,5,6,7,8,9')
tk.Entry(fm1, textvariable=self.pwd_str, font=('Arial', 10),width=20).pack(anchor='nw')
fm1_1 = tk.Frame(fm1, padx=1, pady=1)
fm1_1.pack(anchor='w',fill=tk.X)
tk.Label(fm1_1,text='密码长度').pack(anchor='nw')
# # 设定默认值
self.pwd_len = tk.IntVar()
self.pwd_len