@echo off :: BatchGotAdmin :------------------------------------- REM --> Check for permissions >nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system" REM --> If error flag set, we do not have admin. if '%errorlevel%' NEQ '0' ( echo Requesting administrative privileges... goto UACPrompt ) else ( goto gotAdmin ) :UACPrompt echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs" set params = %*:"="" echo UAC.ShellExecute "cmd.exe", "/c %~s0 %params%", "", "runas", 1 >> "%temp%\getadmin.vbs" "%temp%\getadmin.vbs" del "%temp%\getadmin.vbs" exit /B :gotAdmin pushd "%CD%" CD /D "%~dp0" :-------------------------------------- @echo off :: CHANGE DEFAULT GW IP BELOW. IT IS USED IF THE SCRIPT CAN'T DETECT YOUR GW IP set defgw=192.168.0.1 @For /f "tokens=3" %%1 in ( 'route.exe print 0.0.0.0 ^|findstr "\<0.0.0.0.*0.0.0.0\>"') Do set defgw=%%1 cls :start cls echo. color 0A echo VPN IP leak protection script, ver. 1.0 - by VPN.AC echo. echo. echo Your NON-VPN (ISP) gateway is probably "%defgw%" echo -if not displayed or incorrect, add it manually (Choice 3) echo. echo USAGE: echo. echo -Press "1" to REMOVE default gateway (IP "%defgw%") echo -Press "2" to RESTORE default gateway (IP "%defgw%") echo -Press "3" to add gateway IP manually if not detected/incorrect echo -Press "h" for more info. echo -Press "x" or CTRL-C to exit script. echo. set /p choice=Your choice: if '%Choice%'=='1' goto :choice1 if '%Choice%'=='2' goto :choice2 if '%Choice%'=='3' goto :choice3 if '%Choice%'=='x' goto :exit if '%Choice%'=='h' goto :help echo Insert 1, 2, x or h timeout 3 goto start :choice1 route delete 0.0.0.0 %defgw% echo Default gateway "%defgw%" removed timeout 3 goto start :choice2 route add 0.0.0.0 mask 0.0.0.0 %defgw% echo Defaulte gateway "%defgw%" restored timeout 3 goto start :choice3 echo set /p defgw=your gw IP (e.g. 192.168.0.1): goto start :help cls echo. echo. echo ====================== echo This script will remove or add back your default/non-VPN gateway IP echo to avoid IP leakage (traffic via ISP) when VPN disconnects. echo. echo Step 1: Connect to VPN echo Step 2: Remove the default gateway with this script (choice "1") echo -Now Internet traffic will pass only through VPN. echo -If VPN disconnects, you have to restore default gateway, either echo to reconnect to VPN or use the Internet via ISP/non-VPN. echo. echo. echo After the VPN disconnects on request or due to a problem: echo. echo Step 1: Close software that may leak real IP by falling back echo to default gateway. echo Step 2: Restore the default gateway (choice "2") echo Step 3: Reconnect VPN and remove the gateway again (Choice "1") echo. timeout /T -1 goto start :exit exit