Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gi #49

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Gi #49

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# red-python-scripts
3 changes: 3 additions & 0 deletions index.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
netsh wlan show profiles // for show the wifi
netsh wlan show profiles Redmi // for al information
netsh wlan show profiles Redmi key=clear// for all information (password)
16 changes: 5 additions & 11 deletions windows10-wifi.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
#! py
######################################
#Copyright of David Bombal, 2021 #
#https://www.davidbombal.com #
#https://www.youtube.com/davidbombal #
######################################

# Import subprocess so we can use system commands.
import subprocess
Expand All @@ -24,7 +18,7 @@
# To do this we specify the second argument as capture_output = True.
# This information gets stored in the stdout attribute as bytes and
# needs to be decoded before being used as a String in Python.
command_output = subprocess.run(["netsh", "wlan", "show", "profiles"], capture_output = True).stdout.decode()
command_output = subprocess.run(["netsh", "wlan", "show", "profiles"], capture_output = True).stdout.decode('iso-8859-1')

# We imported the re module to make use of regular expressions.
# We want to find all the wifi names which are listed after
Expand All @@ -47,7 +41,7 @@
# We can now run a more specific command to see the information
# about the wifi connection and if the Security key
# is not absent it may be possible to get the password.
profile_info = subprocess.run(["netsh", "wlan", "show", "profile", name], capture_output = True).stdout.decode()
profile_info = subprocess.run(["netsh", "wlan", "show", "profile", name], capture_output = True).stdout.decode('iso-8859-1')
# We use the regular expression to only look for the absent cases so we can ignore them.
if re.search("Security key : Absent", profile_info):
continue
Expand All @@ -56,7 +50,7 @@
wifi_profile["ssid"] = name
# These cases aren't absent and we should run the
# "key=clear" command part to get the password.
profile_info_pass = subprocess.run(["netsh", "wlan", "show", "profile", name, "key=clear"], capture_output = True).stdout.decode()
profile_info_pass = subprocess.run(["netsh", "wlan", "show", "profile", name, "key=clear"], capture_output = True).stdout.decode('iso-8859-1')
# Again run the regular expression to capture the
# group after the : (which is the password).
password = re.search("Key Content : (.*)\r", profile_info_pass)
Expand All @@ -70,7 +64,7 @@
wifi_profile["password"] = password[1]
# We append the wifi information to the variable wifi_list.
wifi_list.append(wifi_profile)

for x in range(len(wifi_list)):
#bug fixed with iso-8859-1
for x in range(len(wifi_list)):
print(wifi_list[x])