1
+ import os
2
+ import subprocess
3
+ # For Linux OS
4
+ if os .name == 'posix' :
5
+ output = subprocess .run (["nmcli" , "-g" , "NAME" , "connection" , "show" ], capture_output = True )
6
+ allWifi = output .stdout .decode ('utf-8' , errors = 'strict' )
7
+ allWifiList = allWifi .split ("\n " )
8
+ allWifiList .pop ()
9
+ wifiPasslist = []
10
+ for wifi in allWifiList :
11
+ password = subprocess .run (["nmcli" , "-s" , "-g" , "802-11-wireless-security.psk" , "connection" , "show" , wifi ], capture_output = True )
12
+ wifiPasslist .append (wifi + ": " + password .stdout .decode ('utf-8' , errors = "strict" ))
13
+ f = open ('wifi-passwords-linux.txt' , 'w' )
14
+ f .writelines (wifiPasslist )
15
+ # For Windows OS
16
+ if os .name == 'nt' :
17
+ output = subprocess .run (["netsh" , "wlan" , "show" , "profiles" ], capture_output = True )
18
+ allWifi = output .stdout .decode ('utf-8' , errors = 'strict' )
19
+ allWifiList = allWifi .split ('\n ' )
20
+ completePasswordList = []
21
+ wifiProfileList = []
22
+ for wifi in allWifiList :
23
+ if "All User Profile" in wifi :
24
+ temp = wifi .split (":" )
25
+ wifiName = temp [1 ]
26
+ # Final Profile Name
27
+ wifiName = wifiName [1 :- 1 ]
28
+ wifiProfileList .append (wifiName )
29
+ for profile in wifiProfileList :
30
+ output2 = subprocess .run (["netsh" , "wlan" , "show" , "profile" , profile , "key=clear" ], capture_output = True )
31
+ allWifi2 = output2 .stdout .decode ('utf-8' , errors = 'strict' )
32
+ allWifiList2 = allWifi2 .split ('\n ' )
33
+ for wifi in allWifiList2 :
34
+ if "Key Content" in wifi :
35
+ temp2 = wifi .split (":" )
36
+ wifiPass = temp2 [1 ]
37
+ # Final Password
38
+ wifiPass = wifiPass [1 :- 1 ]
39
+ print ("Password : " + wifiPass )
40
+ completePasswordList .append (profile + ": " + wifiPass + "\n " )
41
+ f = open ('wifi-passwords-win.txt' , 'w' )
42
+ f .writelines (completePasswordList )
0 commit comments