-
Notifications
You must be signed in to change notification settings - Fork 64
/
WifiPasswordReveal-exp.bat
118 lines (94 loc) · 3.19 KB
/
WifiPasswordReveal-exp.bat
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
@echo off
::
:: (c) Elias Bachaalany <[email protected]>
:: Batchography: The Art of Batch Files Programming
::
setlocal enabledelayedexpansion
:main
title WiFiPasswordReveal v1.1 (c) lallouslab.net - The Batchography book
echo.
echo Reveal all saved WiFi passwords Batch file script v1.1 (c) lallouslab.net
echo.
echo Inspired by the book "Batchography: The Art of Batch Files Programming"
echo.
:: Default language is English
set KEYCONTENT=Key Content
set ALL_PROFILES=All User Profile
::
:: Detect the language (1033 English ; 1034 Spanish ; 1036 French ; 1040 Italian ; 1031 German)
:: See https://technet.microsoft.com/en-us/library/cc287874(v=office.12).aspx
::
for /F "usebackq tokens=*" %%a IN (`wmic os get OSLanguage /Value`) DO (
set _line=%%a
if "!_line:~0,10!"=="OSLanguage" (
set lang_id=!_line:~11!
)
)
if "%lang_id%"=="1033" (
echo English operating system language detected!
) else if "%lang_id%" == "1034" (
set KEYCONTENT=Contenido de la clave
set ALL_PROFILES=Perfil de todos los usuarios
echo Spanish operating system language detected!
) else if "%lang_id%" == "1036" (
set KEYCONTENT=Contenu de la cl
set ALL_PROFILES=Profil Tous les utilisateurs
echo French operating system language detected!
) else if "%lang_id%" == "1040" (
set KEYCONTENT=Contenuto chiave
set ALL_PROFILES=Tutti i profili utente
echo Italian operating system language detected!
) else if "%lang_id%" == "1031" (
set KEYCONTENT=Schlüsselinhalt
set ALL_PROFILES=Profil für alle Benutzer
echo Deutsches OS erkannt!
) else (
echo Warning: Unknown operating system language detected! The script might not work correctly!
)
echo.
:: Get all the profiles
call :get-profiles r
:: For each profile, try to get the password
:main-next-profile
for /f "tokens=1* delims=," %%a in ("%r%") do (
call :get-profile-key "%%a" key
if "!key!" NEQ "" (
echo WiFi: [%%a] Password: [!key!]
)
set r=%%b
)
if "%r%" NEQ "" goto main-next-profile
echo.
pause
goto :eof
::
:: Get the WiFi key of a given profile
:get-profile-key <1=profile-name> <2=out-profile-key>
setlocal
set result=
FOR /F "usebackq tokens=2 delims=:" %%a in (
`netsh wlan show profile name^="%~1" key^=clear ^| findstr /C:"%KEYCONTENT%"`) DO (
set result=%%a
set result=!result:~1!
)
(
endlocal
set %2=%result%
)
goto :eof
::
:: Get all network profiles (comma separated) into the result result-variable
:get-profiles <1=result-variable>
setlocal
set result=
FOR /F "usebackq tokens=2 delims=:" %%a in (
`netsh wlan show profiles ^| findstr /C:"%ALL_PROFILES%"`) DO (
set val=%%a
set val=!val:~1!
set result=%!val!,!result!
)
(
endlocal
set %1=%result:~0,-1%
)
goto :eof