forked from LandGrey/toolsparty
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvpnTrafficSwitcher.bat
44 lines (40 loc) · 1.71 KB
/
vpnTrafficSwitcher.bat
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
@echo off
Rem Build By LandGrey
title Vpn Traffic Switcher
::get administrator privilege
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
if '%errorlevel%' NEQ '0' (goto UACPrompt) else ( goto gotAdmin )
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
exit /B
:gotAdmin
if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" )
pushd "%CD%"
CD /D "%~dp0"
::wait for choosing
:loop
cls
color 8e
echo ************************ Vpn Traffic Switcher ************************
echo.
set /p choice=[*] Input yes or no (y/n):
if %choice%==y (goto enable) else if %choice%==yes (goto enable)
if %choice%==n (goto disable) else if %choice%==no (goto disable) else (goto loop)
:enable
echo.
set /p ipaddress=[*] Input ip range, such as 1.1.1.1 or 1.1.1.1/24 or 1.1.1.1-1.2.3.4:
netsh advfirewall set domainprofile firewallpolicy blockinbound,blockoutbound
netsh advfirewall set privateprofile firewallpolicy blockinbound,blockoutbound
netsh advfirewall set publicprofile firewallpolicy blockinbound,blockoutbound
netsh advfirewall firewall delete rule name="only_allow_me_connect"
netsh advfirewall firewall add rule name="only_allow_me_connect" dir=out action=allow profile=public,private,domain remoteip=%ipaddress% enable=yes
exit
:disable
echo.
netsh advfirewall set domainprofile firewallpolicy blockinbound,allowoutbound
netsh advfirewall set privateprofile firewallpolicy blockinbound,allowoutbound
netsh advfirewall set publicprofile firewallpolicy blockinbound,allowoutbound
netsh advfirewall firewall delete rule name="only_allow_me_connect"
exit