windows wifi密码

5次阅读
没有评论

看到论坛里的其他朋友做的密码查看器,觉得好玩,自己用python写了一个很简陋的查看器 ( :
帖子1
帖子2

[Python] 纯文本查看 复制代码

import tkinter
from tkinter import ttk
import os
import re

cmd = "netsh wlan show profiles"
str0 = os.popen(cmd).read()
str1 = re.findall('(\u6240\u6709\u7528\u6237\u914d\u7f6e\u6587\u4ef6...)(.*)', str0)
outList1 = []
outList2 = []
for i in str1:
cmd = "netsh wlan show profiles name=\"" + i[1] + "\" key=clear"
str2 = os.popen(cmd).read()
output = re.search('(\u5173\u952e\u5185\u5bb9\s*.\s)(.*)', str2).group(2)
outList1.append(i[1])
outList2.append(output)
# GUI
top = tkinter.Tk()
top.geometry("250x60")
top.title("Wifi密码查看器")
lab1 = tkinter.Label(top, text="Wifi : ")
lab2 = tkinter.Label(top, text="PassWord : ")
lab1.grid(row=0)
lab2.grid(row=1)
entry = tkinter.Entry(top)
entry.grid(row=1, column=1)
cbox = ttk.Combobox(top)
cbox.grid(row=0, column=1)
cbox["value"] = outList1
def func(cbox):
index = cbox.current()
entry.delete(0, tkinter.END)
entry.insert(0, outList2[index])
cbox.bind("<<ComboboxSelected>>",lambda event:func(cbox))
top.mainloop()

文件过大了,放到阿里云了
阿里云
https://www.aliyundrive.com/s/GZR44GScvZq

第一次修改

由于通过命令行读取密码很容易有bug,因此改用读取WLAN配置文件的方式.
原理:
以管理员身份打开cmd,输入[Shell] 纯文本查看 复制代码

netsh wlan export profile folder=C:\ key=clear.

会生成一系列WLAN的配置文件(包括wifi的明文密码)
[Python] 纯文本查看 复制代码

import tkinter
from tkinter import ttk
import os
import tkinter.messagebox
import xml.etree.ElementTree
import time
# 生成WLAN配置文件
cmd = "mkdir C:\ProgramData\wlanPasswordView"
os.popen(cmd)
cmd = "netsh wlan export profile folder=C:\ProgramData\wlanPasswordView key=clear"
os.popen(cmd)
time.sleep(1)
# 解析XML
file_list = os.listdir('C:\ProgramData\wlanPasswordView')
wlan_list = []
for i in file_list:
if os.path.splitext(i)[1] == '.xml':
wlan_list.append(i)
for i in wlan_list:
if i[0:4] == 'WLAN':
pass # success
else:
wlan_list.remove(i)
# 生成名称及对应的密码
list_name = []
list_password = []
for i in wlan_list:
root = xml.etree.ElementTree.parse('C:\ProgramData\wlanPasswordView\\' + i).getroot()
list_name.append(root[0].text)
if root[4][0][0][0].text == 'open':
list_password.append("无密码")
else:
list_password.append(root[4][0][1][2].text)

# GUI
top = tkinter.Tk()
top.geometry("300x100")
top.title("Wifi密码查看器")
mainmenu = tkinter.Menu(top)
lab1 = tkinter.Label(top, text="Wifi : ")
lab2 = tkinter.Label(top, text="PassWord : ")
lab1.grid(row=0)
lab2.grid(row=1)
entry = tkinter.Entry(top)
entry.grid(row=1, column=1)
cbox = ttk.Combobox(top)
cbox.grid(row=0, column=1)
cbox["value"] = list_name

def func(cbox):
index = cbox.current()
entry.delete(0, tkinter.END)
entry.insert(0, list_password[index])

def doHelp():
tkinter.messagebox.showinfo("Help",
"1.请以管理员权限运行 \n "
"2.该程序会在C:\ProgramData\wlanPasswordView下生成一系列以WLAN开头,后缀名为'.xml'的WLAN配置文件,可随意删除\n"
"3.只能查看已保存的WiFi密码 ")

mainmenu.add_command(label="Help", command=doHelp)
cbox.bind("<<ComboboxSelected>>", lambda event: func(cbox))
top.config(menu=mainmenu)
top.mainloop()

阿里云:https://www.aliyundrive.com/s/68qiVQ8LDN4

正文完
 0
116博客
版权声明:本篇文章由 116博客 于2024-11-29发表,共计2665字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
评论(没有评论)
验证码