@echo off
title Internet Password-logger
color a
:MENU
cls
echo ================================
echo       WiFi Network Menu
echo ================================
echo Listing all connected networks:
netsh wlan show profiles
echo ================================
set /p wifiname=Enter WiFi Name (SSID) or "all": 

if /i "%wifiname%"=="all" (
    cls
    echo Running tree for visual effect...
    tree
    echo ================================
    echo Displaying all networks and passwords:
    del temp.txt >nul 2>&1
    for /f "tokens=*" %%i in ('netsh wlan show profiles ^| findstr ":"') do (
        for /f "tokens=2 delims=: " %%j in ("%%i") do (
            call :showPassword "%%j"
        )
    )
    echo ================================
    echo All passwords have been copied to the clipboard.
    type temp.txt | clip
    del temp.txt >nul 2>&1
    pause
    goto MENU
) else (
    cls
    echo Running tree for visual effect...
    tree
    echo ================================
    echo Retrieving password for "%wifiname%":
    netsh wlan show profiles name="%wifiname%" key=clear | findstr "Key Content" > temp.txt
    type temp.txt
    type temp.txt | clip
    del temp.txt >nul 2>&1
    echo ================================
    echo Password copied to clipboard.
    pause
    goto MENU
)

:showPassword
setlocal enabledelayedexpansion
set "profileName=%~1"
echo WiFi: !profileName! >> temp.txt
echo WiFi: !profileName!
netsh wlan show profile name="!profileName!" key=clear | findstr "Key Content" >> temp.txt
netsh wlan show profile name="!profileName!" key=clear | findstr "Key Content"
endlocal
exit /b