-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
87 lines (73 loc) · 3.05 KB
/
main.py
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# sourcery skip: convert-to-enumerate, for-append-to-extend, list-comprehension, move-assign-in-block, use-dict-items
# Imports
import subprocess
import os
import time
# Functions
def writeCustomLine(max_line_len, word1, word2):
line_spaces = (max_line_len // 4) - 3
word1_space = line_spaces - len(word1)
word1_result = f"{word1_space * ' '}{word1}{word1_space * ' '}"
word2_space = line_spaces - len(word2)
word2_result = f"{word2_space * ' '}{word2}{word2_space * ' '}"
return f"|{word1_result}|{word2_result}|"
# Main
while True:
# Clear screen
os.system('cls')
# Reset vars
profiles = []
passwords = {}
count = 0
# Grab all profiles (raw data)
profiles_raw = subprocess.check_output(["netsh", "wlan", "show", "profiles"], encoding="cp858")
# Format profiles into list
for line in profiles_raw.split("\n"):
if "Profile :" in line:
profiles.append(line[(line.find(":")) + 2:])
# Print info
print(f"""
-----] Wifi Key Scraper [-----
| [!] ({len(profiles)}) Profiles found""")
# Wait 1 seconds
time.sleep(1)
# Grab each key
for profile in profiles:
print(f'|\n| [! INIT] Profile: "{profile}"')
# Try execute code
try:
password_raw = subprocess.check_output(["netsh", "wlan", "show", "profile", f'name={profile.replace(" ", "*")}', "key=clear"], shell=True, encoding="cp858")
for line in password_raw.split("\n"):
if "Key Content :" in line:
passwords[f"profile{count + 1}"] = {
"status": "SUCESS",
"id": profile,
"password": line[(line.find(":")) + 2:]
}
print(f'|\n| [! DONE] Profile: "{profile}" // Password: "{line[(line.find(":")) + 2:]}"')
# Set password to null if fail
except Exception as e:
print(f'|\n| [! ERROR] Profile: "{profile}" // FAIL')
passwords[f"profile{count + 1}"] = {
"status": "ERROR",
"id": profile,
"password": "null"
}
count += 1
# Save output text
with open(os.path.join(os.path.dirname(__file__), "output.txt"), "w") as file:
max_line_len = 61
file.write(f"-" * max_line_len + "\n")
file.write(writeCustomLine(max_line_len, "ID", "PASSWORD") + "\n")
file.write(f"-" * max_line_len + "\n")
for item in passwords:
if (passwords[item]["status"] != "ERROR"):
file.write(writeCustomLine(max_line_len, passwords[item]["id"], passwords[item]["password"]) + "\n")
# file.write(f"[{item}/{passwords[item]['status']}] {passwords[item]['id']} <|> {passwords[item]['password']}" + "\n")
file.write(f"-" * max_line_len + "\n")
print("|\n| [!] 'output.txt' saved")
# Repeat loop?
if input("|\n-----] Execute again? (y/n) [-----\n>> ").lower() == "n":
break
# End
os.system('pause')