Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 85473ef

Browse files
Merge pull request #1091 from vivekthedev/main
Add New Project : Get Saved Wi-Fi Passwords
2 parents d7cfe13 + c20195c commit 85473ef

File tree

4 files changed

+75
-0
lines changed

4 files changed

+75
-0
lines changed
63.8 KB
Loading[フレーム]
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Get Saved Wi-Fi Passwords
2+
3+
## Purpose
4+
5+
The purpose of this script is to get all the saved wi-fi to a text file.
6+
7+
## Short description of package/script
8+
9+
The Windows enviroment does not directly provide the saved Wi-Fi passwords on the system, but we can get the passwords using the command prompt using this feature we can call command prompt command through a python script and get multiple passwords within seconds.
10+
11+
## Workflow of the Project
12+
13+
- The project utilizes the subprocess built-in module to execute command prompt command from the python script
14+
- The script also uses ReGex to get only the Wi-Fi profiles from the output of the subprocess.
15+
- After getting all the Wi-Fi we need to execute the subprocess command once more to get password for each profile.
16+
- If the Wi-Fi is not password protected the script will set its Password as Open.
17+
- After getting all the password it is exported to a textfile.
18+
19+
## Setup instructions
20+
21+
- Open command prompt run `python saved_wifi_password.py`
22+
- As soon as you run the script
23+
24+
## Compilation Steps
25+
26+
- Open the python script code in any of your ide.
27+
- Follow the above mentioned Setup Instructions.
28+
29+
## Output
30+
31+
![](./Images/screen.png)
32+
33+
## Author
34+
35+
[Vivek](https://github.com/vivekthedev)
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import subprocess
2+
import re
3+
4+
# Get all the Wi-Fi profiles (ssid)
5+
out = subprocess.check_output("netsh wlan show profiles").decode()
6+
7+
# Filter out only profile names from the output
8+
matches = re.findall(r"(All User Profile)(.*)", out)
9+
10+
# List comprehension to remove any \n \r \t and spaces
11+
profiles = [str(match[1]).split(":")[1].strip() for match in matches]
12+
13+
14+
# File object to store passwords with ssid
15+
with open("passwords.txt", "w+") as f:
16+
17+
# Traversing each profile
18+
for profile in profiles:
19+
# try/except block to keep the script from crashing if there was an error while execution
20+
try:
21+
# Get password using key=clear flag
22+
get_pass = subprocess.check_output(
23+
f'netsh wlan show profile "{profile}" key=clear'
24+
).decode()
25+
26+
# Filter out the Password line from the output
27+
pass_by_profile = re.search(r"(Key Content)(.*)", get_pass)
28+
29+
# Check if the password is present or wi-fi was open
30+
if pass_by_profile:
31+
password = pass_by_profile.group().split(":")[1].strip()
32+
else:
33+
password = "THE WIFI IS OPEN"
34+
35+
# Write the profile name and password to the text file
36+
f.write(f"{profile} : {password}\n")
37+
except Exception:
38+
continue

‎EthicalHackingScripts/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@
1010
<h3>Projects Contributed</h3>
1111

1212
- [Family Key Logger](Family%20Key%20Logger)
13+
- [Get Saved Wi-Fi Passwords](https://github.com/vivekthedev/Awesome_Python_Scripts/tree/main/EthicalHackingScripts/Get%20Saved%20Passwords)
14+
- [UnSecure CLI](https://github.com/vivekthedev/Awesome_Python_Scripts/tree/main/EthicalHackingScripts/UnsecureCLI)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /