python寫的本地WIFI密碼查看器的具體代碼
本章教程,主要分享一個本地wifi密碼查看器,用python實(shí)現(xiàn)的,感興趣的可以試一試。
具體代碼
import subprocess # 導(dǎo)入 subprocess 模塊,用于執(zhí)行系統(tǒng)命令 import tkinter as tk # 導(dǎo)入 tkinter 模塊,用于創(chuàng)建圖形用戶界面 from tkinter import messagebox, ttk # 從 tkinter 模塊中導(dǎo)入 messagebox 和 ttk 子模塊 def get_wifi_passwords(): """ 獲取本地計(jì)算機(jī)上所有已連接過的 WiFi 配置文件及其密碼。 """ try: # 執(zhí)行命令獲取所有 WiFi 配置文件的列表 profiles_data = subprocess.check_output(['netsh', 'wlan', 'show', 'profiles']).decode('utf-8', errors='ignore') # 解析輸出,提取配置文件名稱 profiles = [line.split(':')[1].strip() for line in profiles_data.split('\n') if "All User Profile" in line] wifi_passwords = [] # 存儲 WiFi 名稱和密碼的列表 # 遍歷每個配置文件,獲取密碼 for profile in profiles: profile_info = subprocess.check_output(['netsh', 'wlan', 'show', 'profile', profile, 'key=clear']).decode('utf-8', errors='ignore') password_lines = [line.split(':')[1].strip() for line in profile_info.split('\n') if "Key Content" in line] password = password_lines[0] if password_lines else "N/A" # 如果沒有密碼,則顯示 "N/A" wifi_passwords.append((profile, password)) return wifi_passwords except Exception as e: # 如果發(fā)生錯誤,顯示錯誤信息 messagebox.showerror("錯誤", f"發(fā)生錯誤: {str(e)}") return [] def copy_password(event): """ 復(fù)制選中的 WiFi 密碼到剪貼板。 """ selected_item = tree.selection()[0] password = tree.item(selected_item, 'values')[1] root.clipboard_clear() root.clipboard_append(password) messagebox.showinfo("信息", "密碼已復(fù)制到剪貼板") def center_window(window, width, height): """ 將窗口顯示在屏幕中央。 """ screen_width = window.winfo_screenwidth() screen_height = window.winfo_screenheight() x = (screen_width - width) // 2 y = (screen_height - height) // 2 window.geometry(f'{width}x{height}+{x}+{y}') # 創(chuàng)建主窗口 root = tk.Tk() root.title("WiFi 密碼查看器") # 設(shè)置窗口標(biāo)題 window_width = 400 window_height = 300 root.geometry(f'{window_width}x{window_height}') # 設(shè)置窗口大小 center_window(root, window_width, window_height) # 窗口居中顯示 # 創(chuàng)建表格 tree = ttk.Treeview(root, columns=('SSID', '密碼'), show='headings') tree.heading('SSID', text='WiFi名稱', anchor='center') tree.heading('密碼', text='WiFi密碼', anchor='center') tree.column('SSID', anchor='center') tree.column('密碼', anchor='center') tree.pack(fill=tk.BOTH, expand=True) # 設(shè)置表格樣式 style = ttk.Style() style.configure('Treeview', rowheight=25) style.configure('Treeview.Heading', font=('Arial', 12, 'bold')) # 獲取 WiFi 密碼并顯示在表格中 wifi_passwords = get_wifi_passwords() for wifi, password in wifi_passwords: tree.insert('', tk.END, values=(wifi, password)) # 綁定雙擊事件,雙擊表格中的一行即可復(fù)制密碼 tree.bind('<Double-1>', copy_password) # 啟動主事件循環(huán) root.mainloop()
點(diǎn)擊wifi名稱行,可以快速復(fù)制wifi密碼到粘貼板上。
到此這篇關(guān)于python寫的本地WIFI密碼查看器的文章就介紹到這了,更多相關(guān)python WIFI密碼查看器內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
使用seaborn繪制強(qiáng)化學(xué)習(xí)中的圖片問題
這篇文章主要介紹了使用seaborn繪制強(qiáng)化學(xué)習(xí)中的圖片問題,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2023-01-01Python數(shù)字圖像處理代數(shù)之加減乘運(yùn)算
這篇文章主要介紹了Python數(shù)字圖像處理代數(shù)運(yùn)算,對其中的加、減、乘運(yùn)算分別作了詳細(xì)的講解,有需要的朋友可以借鑒參考下,希望能夠有所幫助2021-09-09python接口自動化(十六)--參數(shù)關(guān)聯(lián)接口后傳(詳解)
這篇文章主要介紹了python接口自動化參數(shù)關(guān)聯(lián)接口,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-04-04python實(shí)現(xiàn)圖片加文字水印OPenCV和PIL庫
本文來為大家介紹一下,使用python中的庫實(shí)現(xiàn)給圖片添加文字水印,openCV可以給圖片添加水印,如果要添加漢字水印那就要使用PIL庫2021-09-09MacOS(M1芯片?arm架構(gòu))下安裝tensorflow的詳細(xì)過程
這篇文章主要介紹了MacOS(M1芯片?arm架構(gòu))下如何安裝tensorflow,本節(jié)使用的版本是tensorflow2.4?python3.8,因此并未安裝加速插件,本文結(jié)合實(shí)例代碼詳細(xì)講解,需要的朋友可以參考下2023-02-02Python實(shí)現(xiàn)OpenCV的安裝與使用示例
這篇文章主要介紹了Python實(shí)現(xiàn)OpenCV的安裝與使用,結(jié)合實(shí)例形式分析了Python中OpenCV的安裝及針對圖片的相關(guān)操作技巧,需要的朋友可以參考下2018-03-03Python?Playwright進(jìn)行常見的頁面交互操作
在使用?Playwright?進(jìn)行?Web?自動化時(shí),頁面交互是核心操作之一,本文將詳細(xì)介紹如何使用?Playwright?進(jìn)行常見的頁面交互操作,希望對大家有所幫助2024-10-10python使用UDP實(shí)現(xiàn)客戶端和服務(wù)器對話
這篇文章主要為大家介紹了python使用UDP實(shí)現(xiàn)客戶端和服務(wù)器對話示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-03-03