Skip to content

Commit e085c5f

Browse files
authored
Merge pull request #138 from G-Balabhaskarrao/my-feature-branch
Adding security type for windows in the output
2 parents dd98afd + 21817de commit e085c5f

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
# [How to Extract Saved WiFi Passwords in Python](https://www.thepythoncode.com/article/extract-saved-wifi-passwords-in-python)
1+
# [How to Extract Saved WiFi Passwords in Python](https://www.thepythoncode.com/article/extract-saved-wifi-passwords-in-python)
2+
3+
This program lists saved Wi-Fi networks and their passwords on Windows and Linux machines. In addition to the SSID (Wi-Fi network name) and passwords, the output also shows the network’s security type and ciphers.

ethical-hacking/get-wifi-passwords/get_wifi_passwords.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,16 @@ def get_windows_saved_wifi_passwords(verbose=1):
2828
[list]: list of extracted profiles, a profile has the fields ["ssid", "ciphers", "key"]
2929
"""
3030
ssids = get_windows_saved_ssids()
31-
Profile = namedtuple("Profile", ["ssid", "ciphers", "key"])
31+
Profile = namedtuple("Profile", ["ssid", "security", "ciphers", "key"])
3232
profiles = []
3333
for ssid in ssids:
3434
ssid_details = subprocess.check_output(f"""netsh wlan show profile "{ssid}" key=clear""").decode()
35+
36+
#get the security type
37+
security = re.findall(r"Authentication\s(.*)", ssid_details)
38+
# clear spaces and colon
39+
security = "/".join(dict.fromkeys(c.strip().strip(":").strip() for c in security))
40+
3541
# get the ciphers
3642
ciphers = re.findall(r"Cipher\s(.*)", ssid_details)
3743
# clear spaces and colon
@@ -43,7 +49,7 @@ def get_windows_saved_wifi_passwords(verbose=1):
4349
key = key[0].strip().strip(":").strip()
4450
except IndexError:
4551
key = "None"
46-
profile = Profile(ssid=ssid, ciphers=ciphers, key=key)
52+
profile = Profile(ssid=ssid, security=security, ciphers=ciphers, key=key)
4753
if verbose >= 1:
4854
print_windows_profile(profile)
4955
profiles.append(profile)
@@ -52,12 +58,13 @@ def get_windows_saved_wifi_passwords(verbose=1):
5258

5359
def print_windows_profile(profile):
5460
"""Prints a single profile on Windows"""
55-
print(f"{profile.ssid:25}{profile.ciphers:15}{profile.key:50}")
61+
#print(f"{profile.ssid:25}{profile.ciphers:15}{profile.key:50}")
62+
print(f"{profile.ssid:25}{profile.security:30}{profile.ciphers:35}{profile.key:50}")
5663

5764

5865
def print_windows_profiles(verbose):
5966
"""Prints all extracted SSIDs along with Key on Windows"""
60-
print("SSID CIPHER(S) KEY")
67+
print("SSID Securities CIPHER(S) KEY")
6168
print("-"*50)
6269
get_windows_saved_wifi_passwords(verbose)
6370

0 commit comments

Comments
 (0)