Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import subprocess
- import re
- # subprocess for running system commands
- command_output=subprocess.run(["netsh","wlan","show","profiles"],capture_output=True).stdout.decode()
- profile_names= (re.findall("All User Profile : (.*)\r",command_output))
- #username and passwords will be saved in a list
- wifi_list = list()
- if len(profile_names)!=0:
- # every wifi profile will have its own dictionary
- for name in profile_names:
- wifi_profile = dict()
- # if security key is not absent then we can get passwords for sure
- profile_info = subprocess.run(["netsh","wlan","show","profiles",name],capture_output=True).stdout.decode()
- if re.search("Security key :Absent",profile_info):
- continue
- else:
- wifi_profile["ssid"]= name
- profile_info_pass = subprocess.run(["netsh","wlan","show","profile",name,"key=clear"],capture_output=True).stdout.decode()
- password = re.search("Key Content : (.*)\r",profile_info_pass)
- if password == None:
- wifi_profile["password"]=None
- else:
- wifi_profile["password"]=password[1]
- # then we append wifi information to wifi_list
- wifi_list.append(wifi_profile)
- for x in range(len(wifi_list)):
- print(wifi_list[x])
Add Comment
Please, Sign In to add comment