Lecturer: Иo1lz
Time: Oct. 11th, 2020
About netsh
About netsh
Step. 0
Create a file with a filename extension of ".py" and any filename you like.
Step. 1
This module can interact with cmd.
import subprocess
Step. 2
data = subprocess.check_output(['netsh', 'wlan', 'show', 'profiles']).decode('utf-8').split('\n')
Step. 3
profiles = [i.split(":")[1][1:-1] for i in data if "All User Profile" in i]
Step. 4 (in loop)
for i in profiles:
results = subprocess.check_output(['netsh', 'wlan', 'show', 'profile', i, 'key=clear']).decode('utf-8').split('\n')
Step. 5 (in loop)
results = [k.split(":")[1][1:-1] for k in results if "Key Content" in k]
Step. 6 (in loop)
try:
print("{:<30} | {:<}".format(i, results[0]))
except IndexError:
print("{:<30} | {:<}".format(i, ""))
Step. 7
input("")
import subprocess
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]
for i in profiles:
results = subprocess.check_output(['netsh', 'wlan', 'show', 'profile', i, 'key=clear']).decode('utf-8').split('\n')
results = [k.split(':')[1][1:-1] for k in results if "Key Content" in k]
try:
print("{:<30} | {:<}".format(i, results[0]))
except IndexError:
print("{:<30} | {:<}".format(i, ""))
input("")
import subprocess
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]
for i in profiles:
try:
results = subprocess.check_output(['netsh', 'wlan', 'show', 'profile', i, 'key=clear']).decode('utf-8').split('\n')
results = [k.split(':')[1][1:-1] for k in results if "Key Content" in k]
try:
print("{:<30} | {:<}".format(i, results[0]))
except IndexError:
print("{:<30} | {:<}".format(i, ""))
except subprocess.CallProcessError:
print("{:<30} | {:<}".format(i, "ENCODING ERROR!"))
input("")