-
Notifications
You must be signed in to change notification settings - Fork 121
/
get_wifi_pass.py
39 lines (31 loc) · 1.79 KB
/
get_wifi_pass.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import subprocess, re
class GetWifiPassword:
def __init__(self):
self.command = "netsh wlan show profile"
self.result = ""
def start(self):
networks = subprocess.check_output(self.command, shell=True, stderr=subprocess.DEVNULL, stdin=subprocess.DEVNULL)
networks = networks.decode(encoding="utf-8", errors="strict")
network_names_list = re.findall("(?:Profile\s*:\s)(.*)", networks)
for network_name in network_names_list:
try:
command = "netsh wlan show profile " + network_name + " key=clear"
current_result = subprocess.check_output(command, shell=True, stderr=subprocess.DEVNULL, stdin=subprocess.DEVNULL)
current_result = current_result.decode(encoding="utf-8", errors="strict")
ssid = re.findall("(?:SSID name\s*:\s)(.*)", str(current_result))
authentication = re.findall(r"(?:Authentication\s*:\s)(.*)", current_result)
cipher = re.findall("(?:Cipher\s*:\s)(.*)", current_result)
security_key = re.findall(r"(?:Security key\s*:\s)(.*)", current_result)
password = re.findall("(?:Key Content\s*:\s)(.*)", current_result)
self.result += "\n\nSSID : " + ssid[0] + "\n"
self.result += "Authentication : " + authentication[0] + "\n"
self.result += "Cipher : " + cipher[0] + "\n"
self.result += "Security Key : " + security_key[0] + "\n"
self.result += "Password : " + password[0]
except Exception:
pass
return self.result
if __name__ == '__main__':
test = GetWifiPassword()
result = test.start()
print(result)