📅  最后修改于: 2023-12-03 14:49:50.940000             🧑  作者: Mango
在这篇文章中,我们将探讨如何使用Python获取保存在计算机上的Wifi密码。这个功能有很多应用场景,比如当你忘记了自己的Wifi密码时,可以使用这个程序获取。
import subprocess
import re
wifi_names = []
results = subprocess.check_output(["netsh", "wlan", "show", "profiles"]).decode("utf-8", errors="ignore")
results = results.split("\n")
for result in results:
if "All User Profile" in result:
wifi_names.append(result.split(":")[1].strip())
passwords = {}
for name in wifi_names:
results = subprocess.check_output(["netsh", "wlan", "show", "profile", name, "key=clear"]).decode("utf-8", errors="ignore")
results = results.split("\n")
results = [line.strip() for line in results]
results = list(filter(None, results))
try:
ssid_index = results.index("SSID name : {}".format(name))
key_index = results.index("Key Content :")
password = results[key_index + 1]
passwords[name] = password
except ValueError:
passwords[name] = ""
import subprocess
import re
wifi_names = []
results = subprocess.check_output(["netsh", "wlan", "show", "profiles"]).decode("utf-8", errors="ignore")
results = results.split("\n")
for result in results:
if "All User Profile" in result:
wifi_names.append(result.split(":")[1].strip())
passwords = {}
for name in wifi_names:
results = subprocess.check_output(["netsh", "wlan", "show", "profile", name, "key=clear"]).decode("utf-8", errors="ignore")
results = results.split("\n")
results = [line.strip() for line in results]
results = list(filter(None, results))
try:
ssid_index = results.index("SSID name : {}".format(name))
key_index = results.index("Key Content :")
password = results[key_index + 1]
passwords[name] = password
except ValueError:
passwords[name] = ""
通过以上步骤,我们已经成功地获取了保存在计算机上的Wifi密码。如果你需要保存这些密码,你可以把它们保存到本地文件中。但是要注意,这些密码应该仅用于个人使用,不应该传播给他人,以保护网络安全。