Skip to content
This repository was archived by the owner on May 25, 2022. It is now read-only.

Commit c7dcc7f

Browse files
authored
Merge pull request #505 from Anthony-Raf/master
Add my wifi password tool
2 parents 8c4d76b + 9551b75 commit c7dcc7f

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Windows Wi-Fi password displayer
2+
3+
### Prerequisites
4+
glob
5+
os
6+
subprocess
7+
xml
8+
9+
### How to run the script
10+
python main.py
11+
12+
### Screenshot/GIF showing the sample use of the script
13+
14+
![image](https://user-images.githubusercontent.com/83010531/136707822-fa514554-0908-489d-b6f9-aeda0f6e2f5e.png)
15+
16+
## *Author Name*
17+
Anthony Rafidison
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import glob
2+
import os
3+
import subprocess
4+
import xml.etree.ElementTree as ET
5+
6+
class PwdDisplay:
7+
def __init__(self):
8+
# Définition du répertoire courant
9+
os.chdir("./")
10+
# Création du dossier mot de passe
11+
if not os.path.exists("passwords"):
12+
os.system("mkdir passwords")
13+
14+
self.export_xml(command="netsh wlan export profile interface=wi-fi key=clear folder=passwords")
15+
self.display_password()
16+
17+
def export_xml(self, command=None):
18+
with open("tmp.txt", "w") as tmp:
19+
export_command = command.split(' ')
20+
subprocess.run(export_command,stdout=tmp)
21+
os.remove("tmp.txt")
22+
23+
def file_path(self) -> list[str]:
24+
# Obtention du chemin des fichiers xml
25+
chemin_fichiers = glob.glob("passwords/"+"*xml")
26+
return chemin_fichiers
27+
28+
def get_ssid_pwd(self) -> list:
29+
ssid_pwd = {}
30+
for i in self.file_path():
31+
tree = ET.parse(i)
32+
root = tree.getroot()
33+
ssid = root[1][0][1].text # ssid
34+
pwd = root[4][0][1][2].text #pwd
35+
ssid_pwd[ssid] = pwd
36+
return ssid_pwd
37+
38+
def display_password(self):
39+
index=1
40+
info = self.get_ssid_pwd()
41+
list_ssid, list_pwd = [], []
42+
print("Here is the list of Wi-Fi networks registered on this device : \n")
43+
for i in info:
44+
print(f"[{index}] {i}")
45+
list_ssid.append(i)
46+
list_pwd.append(info[i])
47+
index+=1
48+
49+
nb = int(input("Please choose a number : "))
50+
print(f"SSID : {list_ssid[nb-1]}\nPassword : {list_pwd[nb-1]}\n")
51+
52+
def __del__(self):
53+
print("Thanks for using my tool :)")
54+
# Supression des fichiers
55+
for i in self.file_path():
56+
if os.path.exists(i):
57+
os.remove(i)
58+
59+
60+
if __name__ == '__main__':
61+
instance = PwdDisplay
62+
instance()

0 commit comments

Comments
 (0)