Skip to content

Instantly share code, notes, and snippets.

@mjbalcueva
Last active February 28, 2025 15:34
Show Gist options
  • Save mjbalcueva/5ea7b72be872d1b469678e1ca5ab2aaa to your computer and use it in GitHub Desktop.
Save mjbalcueva/5ea7b72be872d1b469678e1ca5ab2aaa to your computer and use it in GitHub Desktop.
Wifi Password Retriever

WiFi Password Retriever Script

A simple one-line script that retrieves all stored WiFi network names and their passwords from a Windows system.

Usage

Command Prompt Version

for /f "tokens=2 delims=:" %i in ('netsh wlan show profiles^|findstr "All User Profile"') do @for /f "tokens=* delims= " %j in ("%i") do @(echo. & echo %j & for /f "tokens=2 delims=:" %k in ('netsh wlan show profile name^="%j" key^=clear^|findstr /C:"Key Content"') do @for /f "tokens=* delims= " %l in ("%k") do @echo %l)

PowerShell Version

(netsh wlan show profiles) -match 'All User Profile' | ForEach-Object { $name = $_ -replace '.*:\s+'; Write-Host "`n$name" -F Cyan; $key = netsh wlan show profile name="$name" key=clear | Select-String 'Key Content' -EA 0; if ($key) { $key.ToString() -replace '.*:\s+','' } else { Write-Host "none" -F DarkGray } }

Bash Version (for WSL or Git Bash on Windows)

netsh.exe wlan show profiles | grep "All User Profile" | sed -E 's/.*:\s*//' | while read -r n; do echo -e "\033[36m\n$n\033[0m"; k=$(netsh.exe wlan show profile name="$n" key=clear | grep "Key Content" 2>/dev/null | sed -E 's/.*:\s*//'); if [ -n "$k" ]; then echo "$k"; else echo -e "\033[90mnone\033[0m"; fi; done

Description

How it Works

  1. Lists all WiFi profiles using netsh wlan show profiles
  2. Filters to get just the network names
  3. For each network name:
    • Displays the network name in cyan
    • Retrieves the password using netsh wlan show profile name="network" key=clear
    • Extracts and displays the password, or shows none if no password is stored

Sample Output

NetworkName1
password123

NetworkName2
none

NetworkName3
securepassword

Note

  • This script only works for retrieving passwords of networks that the current user has already connected to and saved on the local machine.
  • Administrator privileges may be required to view all passwords.
  • This tool is provided for educational purposes and personal network management only.
  • Always respect privacy and only use on networks you own or have explicit permission to manage.
@mjbalcueva
Copy link
Author

here's what it looks like:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment