-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwifi.py
More file actions
40 lines (32 loc) · 1.53 KB
/
wifi.py
File metadata and controls
40 lines (32 loc) · 1.53 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
import subprocess
def wifiSnatch():
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]
output = [] # Create an empty list to store the output lines
for i in profiles:
results = subprocess.check_output(
['netsh', 'wlan', 'show', 'profile', i,
'key=clear']).decode('utf-8').split('\n')
results = [b.split(":")[1][1:-1] for b in results if "Key Content" in b]
try:
output.append("{:<30}| {:<}".format(i, results[0]))
except IndexError:
output.append("{:<30}| {:<}".format(i, ""))
# Join the lines in the output list into a single string with line breaks
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]
output = [] # Create an empty list to store the output lines
for i in profiles:
results = subprocess.check_output(
['netsh', 'wlan', 'show', 'profile', i,
'key=clear']).decode('utf-8').split('\n')
results = [b.split(":")[1][1:-1] for b in results if "Key Content" in b]
try:
output.append("{:<30}| {:<}".format(i, results[0]))
except IndexError:
output.append("{:<30}| {:<}".format(i, ""))
# Join the lines in the output list into a single string with line breaks
output_string = '\n'.join(output)
return (output_string)