Python Learning
Python Script to Retrieve Saved Wi-Fi Passwords (Windows)
Someone requested this… We thought it might help.
import subprocess
def get_wifi_passwords():
# To get list of all saved Wi-Fi profiles
profiles_data = subprocess.check_output(['netsh', 'wlan', 'show', 'profiles']).decode('utf-8', errors="ignore").split('\n')
profiles = [line.split(":")[1].strip() for line in profiles_data if "All User Profile" in line]
print("\nSaved Wi-Fi Networks & Passwords:\n" + "-"*40)
for profile in profiles:
try:
# To get password for each profile
profile_info = subprocess.check_output(
['netsh', 'wlan', 'show', 'profile', profile, 'key=clear']
).decode('utf-8', errors="ignore").split('\n')
password = [line.split(":")[1].strip() for line in profile_info if "Key Content" in line]
print(f"Network : {profile}")
print(f"Password: {password[0] if password else 'None / Open Network'}\n")
except:
print(f"Network : {profile}")
print("Password: Unable to retrieve\n")
if __name__ == "__main__":
get_wifi_passwords()
💻 How to use the above code:
1. Open any text editor (Notepad, VS Code, etc.)
2. Copy and paste the code above
3. Save the file as wifi_passwords.py
4. Open Command Prompt or PowerShell as Administrator
5. Navigate to the folder where you saved the file
6. Run the command:
python wifi_passwords.py
✅ The script will list all the Wi-Fi networks that are saved on your computer along with their passwords.
⚠️ This only works for networks that are already saved on your Windows PC. It cannot crack or find passwords of networks you have never connected to.
4 · 505 ·