-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKillSwitchVPN.bat
More file actions
99 lines (82 loc) · 2.23 KB
/
KillSwitchVPN.bat
File metadata and controls
99 lines (82 loc) · 2.23 KB
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
@echo off
:: GetAdmin
:-------------------------------------
:: Verify permissions
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
:: On Error No Admin
if '%errorlevel%' NEQ '0' (
echo Getting administrative privileges...
goto DoUAC
) else ( goto getAdmin )
:DoUAC
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
:getAdmin
pushd "%CD%"
CD /D "%~dp0"
:--------------------------------------
@echo off
:: CHANGE DEFAULT GW IP BELOW
set defgw=127.0.0.1
:: DO NOT EDIT BELOW THIS LINE
set state=Off
@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 0F
echo MyVPN Kill Switch
if '%defgw%' EQU '127.0.0.1' (
FOR /F %%a IN (%temp%\myvpnkillswitch.txt) DO set defgw=%%a
)
if '%defgw%' EQU '127.0.0.1' (
echo Can NOT find your default gateway correctly, please edit the script and change it manually and run again...
pause
exit;
)
@echo %defgw% > %temp%\myvpnkillswitch.txt
echo.
echo MAKE SURE YOU ARE CONNECTED TO MyVPN FIRST
echo.
echo KILL SWITCH IS CURRENTLY: %state%
echo.
echo USAGE:
echo.
echo -Press "1" to Enable Kill Switch (IP "%defgw%")
echo -Press "2" to Disable Kill Switch (IP "%defgw%")
echo -Press "3" to Fix DNS leak and use google public DNS server
echo -Press "x" to exit Kill Switch.
echo.
set /p option=Your option:
if '%option%'=='1' goto :option1
if '%option%'=='2' goto :option2
if '%option%'=='3' goto :option3
if '%option%'=='x' goto :exit
echo Insert 1, 2, 3 or x
timeout 3
goto start
:option1
route delete 0.0.0.0 %defgw%
echo Default gateway "%defgw%" removed
set state=On
timeout 3
goto start
:option2
route add 0.0.0.0 mask 0.0.0.0 %defgw%
echo Default gateway "%defgw%" restored
set state=Off
timeout 3
goto start
:option3
ipconfig /flushdns
@for /f "tokens=3* delims= " %%a in ('netsh interface show interface ^| findstr "Connected."') do netsh interface IPv4 set dnsserver "%%b" static 8.8.8.8 both & ipconfig /flushdns
timeout 3
goto start
:exit
exit