-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwifi_extractor.py
More file actions
65 lines (55 loc) · 2.24 KB
/
wifi_extractor.py
File metadata and controls
65 lines (55 loc) · 2.24 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import subprocess, qrcode
def get_password(result):
password = result.split(":")[1:]
if len(password)>1:
password[0] = password[0][1:]
password[-1] = password[-1][:-1]
return ":".join(password)
else:
return password[0][1:-1]
def get_connected_ssid():
result = subprocess.check_output(['netsh', 'wlan', 'show', 'interfaces'])
result = result.decode('utf-8') # Convert bytes to string
# Search for the SSID name
ssid = None
for line in result.split('\n'):
if 'SSID' in line:
return line.split(':')[-1][1:-1]
return ssid
def get_saved_networks():
WIFIs= {}
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]
with open("Saved-WIFI.txt",'w') as SSIDs:
for i in profiles:
try:
results = subprocess.check_output(['netsh', 'wlan', 'show', 'profile', i, 'key=clear']).decode('utf-8').split('\n')
for result in results:
if "Authentication" in result:
authentication = result.split(":")[1][1:-1]
if authentication == "Open":
password = ""
break
elif "Key Content" in result:
password = get_password(result)
break
SSIDs.write(i + ":" + password + ":" + authentication + "\n")
WIFIs[i] = [password, authentication]
except Exception as e:
with open("Errors.txt","a") as errors:
errors.write(str(e)+"\n"+"\n")
continue
return WIFIs
def main():
map_auth={
"WPA2-Personal":"WPA",
"WPA-Personal":"WPA"
}
WIFIs= get_saved_networks()
SSID = get_connected_ssid()
if SSID:
qr = qrcode.make(f"WIFI:S:{SSID};T:{WIFIs[SSID][0]};P:{map_auth[WIFIs[SSID][1]]};;")
qr.save(f"{SSID}.png")
qr.show()
return
main()