When we connect to a Wi-Fi network we usually need to enter a password. However, we cannot directly view the password that was previously entered for a saved network. In this article, we will explore how Python can be used to retrieve all the saved Wi-Fi names and passwords. To accomplish this we will utilize the module, in Python.
Wi-Fi is a technology that enables networking allowing devices like computers (laptops and desktops) devices (smartphones and wearables) and other equipment (printers and video cameras) to connect with the Internet.
Getting Wi-Fi password using Python code
import subprocess
data = (
subprocess.check_output(["netsh", "wlan", "show", "profiles"])
.decode("utf-8")
.split("\n")
)
profiles = [i.split(":")[1][1:-1] for i in data if "All User Profile" in i]
for i in profiles:
results = (
subprocess
.check_output(["netsh", "wlan", "show", "profile", i, "key=clear"])
.decode("utf-8")
.split("\n")
)
results = [b.split(":")[1][1:-1] for b in results if "Key Content" in b]
try:
print("{:<30}| {:<}".format(i, results[0]))
except IndexError:
print("{:<30}| {:<}".format(i, ""))
After successfully running this code you will be able to see the saved password result on your terminal. There you go now you learn how to get saved wifi password using python with just few lines of code
- Age calculator using Javascript, HTML & CSS - October 28, 2023
- Navigation bar using HTML & CSS - October 26, 2023
- Calculator using HTML, CSS & JS - October 26, 2023