Post

WIFI Password

Ever forgotten the password of a Wi-Fi network you’ve already connected to? This little Python script has you covered.

Description

This script lets you quickly view all the saved Wi-Fi passwords stored on your device, super handy when you want to reconnect on another device or share the password with a friend.

In this post, I’ll walk you through how the script works, what commands it uses under the hood, and how to run it safely on your own machine.

You’ll find the full Python code below, feel free to copy it or improve it!

1
2
3
4
5
6
7
8
9
10
11
12
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, ""))
input("")

That’s all !

This post is licensed under CC BY 4.0 by the author.