forked from amitgupta85878/Important_programs_for_placements
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwifipw_extractor.py
More file actions
32 lines (22 loc) · 1002 Bytes
/
Copy pathwifipw_extractor.py
File metadata and controls
32 lines (22 loc) · 1002 Bytes
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
import subprocess as sp
data = sp.check_output(['netsh', 'wlan', 'show', 'profiles']).decode('utf-8', errors="backslash")
'''
data2 = data.split("\n")
print(data2)
for i in range(len(data2)):
if "All User Profile" in data2[i]:
s = len(data2[i+1])
print(data2[i+1][0:s-25])
'''
profiles = [i.split(":")[1][1:-1] for i in data.split('\n') if "All User Profile" in i]
for i in profiles:
try:
results = sp.check_output(['netsh', 'wlan', 'show', 'profiles', i, 'key=clear']).decode('utf-8', errors="backslash")
results = [b.split(":")[1][1:-1] for b in results.split('\n') if "Key Content" in b]
try:
print("{:<30}| {:<}".format(i, results[0]))
except IndexError:
print("{:<30}| {:<}".format(i, ""))
except sp.CalledProcessError:
print("{:<30}| {:<}".format(i, "ENCODING ERROR"))
input("")