Skip to content

Instantly share code, notes, and snippets.

@aligalehban
Last active January 13, 2022 21:53
Show Gist options
  • Save aligalehban/7ac586867fbc28a75afa9a0585726de2 to your computer and use it in GitHub Desktop.
Save aligalehban/7ac586867fbc28a75afa9a0585726de2 to your computer and use it in GitHub Desktop.
Extract saved WIFI passwords with python
import subprocess
data = subprocess.check_output(['netsh', 'wlan', 'show', 'profiles']).decode('utf-8', errors="backslashreplace").split('\n')
profiles = [i.split(":")[1][1:-1] for i in data if "All User Profile" in i]
for i in profiles:
try:
results = subprocess.check_output(['netsh', 'wlan', 'show', 'profile', i, 'key=clear']).decode('utf-8', errors="backslashreplace").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, ""))
except subprocess.CalledProcessError:
print ("{:<30}| {:<}".format(i, "ENCODING ERROR"))
input("")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment