获取本机保存的WIFI SSID和密码
今天装Canon G5800打印机驱动时候忽然给我把我自己的Wifi密码全列出来了, 让我很震撼,哈哈
Windows
- 输入
netsh wlan show profile
获取本机已保存的wifi SSID - 3.输入
netsh wlan show profile name=“ ” key=clear
获取密码 name里写入WiFi SSID
Github上有个WIFIpass项目可以用Python一键获取,不过我觉得批处理应该也可以有类似效果. 果然在这个网址找到了bat的方式, 试了下,只适用于英文版Windows,中文的要修改下. 代码如下:
@echo off
::
:: (c) Elias Bachaalany <lallousz-x86@yahoo.com>
:: Batchography: The Art of Batch Files Programming
::
setlocal enabledelayedexpansion
:main
title WiFiPasswordReveal v1.0 (c) lallouslab.net - The Batchography book
echo.
echo Reveal all saved WiFi passwords Batch file script v1.0 (c) lallouslab.net
echo.
echo Inspired by the book "Batchography: The Art of Batch Files Programming"
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 "" (
>>"C:\WiFi-Passwords.txt" 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:"Key Content"`) 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 User Profile"`) DO (
set val=%%a
set val=!val:~1!
set result=%!val!,!result!
)
(
endlocal
set %1=%result:~0,-1%
)
goto :eof