Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- ::Block incoming IP's and manage them using CMD W/H GUI! ::
- ::Created by RU$$ [http://russdev.mooo.com/] ::
- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- @echo off
- title Block incoming IP's and manage them using CMD
- ::Check if CMD is open as admin
- NET SESSION >nul 2>&1
- IF %ERRORLEVEL% EQU 0 (goto :MENU) ELSE (goto :NOTADMIN)
- :NOTADMIN
- cls
- echo ERROR: You need to run as an Administrator!
- echo.
- pause
- exit.
- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- :: Main Menu
- :MENU
- cls
- ::List
- echo Current adress list:
- echo =======================================================
- netsh advfirewall firewall show rule name=all dir=in | find "IP Block:" | find " "
- echo =======================================================
- echo.
- echo Options:
- echo [1] Block an IP.
- echo [2] Unblock an IP.
- echo [3] Enable/Disable a rule.
- echo [4] Evaluate existing adress.
- echo [5] Exit.
- echo.
- ::Menu
- SET INPUT=
- SET /P INPUT= Select an option:
- IF /I '%INPUT%'=='' GOTO :MENU
- IF /I '%INPUT%'=='1' GOTO :BLOCK1
- IF /I '%INPUT%'=='2' GOTO :UNADD
- IF /I '%INPUT%'=='3' GOTO :ENDI
- IF /I '%INPUT%'=='4' GOTO :INFO
- IF /I '%INPUT%'=='5' exit
- goto :MENU
- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- :: Block IP
- :BLOCK1
- cls
- ::List
- echo Welcome to the adress blocking menu:
- echo #######################################################
- echo Overview:
- echo.
- echo 1. Select a rule name.
- echo 2. Select the remoteip. (IP ADRESS)
- echo #######################################################
- echo.
- echo Options:
- echo [1] Go back to menu.
- echo.
- ::Menu
- SET NAME=
- SET /P NAME= Imput a name for this IP:
- IF /I '%NAME%'=='' GOTO :BLOCK1
- IF /I '%NAME%'=='1' (GOTO :MENU) ELSE (GOTO :BLOCK2)
- goto :BLOCK1
- :BLOCK2
- cls
- ::List
- echo Welcome to the adress blocking menu:
- echo #######################################################
- echo Overview:
- echo.
- echo 1. Select a rule name.
- echo 2. Select the remoteip. (IP ADRESS)
- echo #######################################################
- echo.
- echo Options:
- echo [1] Change name.
- echo.
- ::Menu
- SET ADRESS=
- SET /P ADRESS= Imput an adress to block:
- IF /I '%ADRESS%'=='' GOTO :BLOCK2
- IF /I '%ADRESS%'=='1' (GOTO :BLOCK1) ELSE (GOTO :BLOCK3)
- goto :BLOCK2
- :BLOCK3
- cls
- ::List
- echo Please overview your details:
- echo.
- echo Name: %NAME%
- echo Adress: %ADRESS%
- echo -------------------------------------------------------
- echo.
- echo Options:
- echo [1] Change name.
- echo [2] Change adress.
- echo [3] Cancle operation.
- echo.
- ::Menu
- SET INPUT=
- SET /P INPUT= Are these credentials correct (Y/N):
- IF /I '%INPUT%'=='' GOTO :BLOCK3
- IF /I '%INPUT%'=='1' GOTO BLOCK1
- IF /I '%INPUT%'=='2' GOTO BLOCK 2
- IF /I '%INPUT%'=='3' GOTO :CANCLE
- IF /I '%INPUT%'=='y' GOTO :ADD
- IF /I '%INPUT%'=='Y' GOTO :ADD
- IF /I '%INPUT%'=='n' GOTO :BLOCK1
- IF /I '%INPUT%'=='N' GOTO :BLOCK1
- goto :BLOCK3
- :CANCLE
- cls
- echo Operation cancled. Returning to menu.
- echo.
- pause.
- GOTO :MENU
- :ADD
- SET COM=IP Block:
- SET oNAME=%COM%%NAME%
- cls
- echo Now creating blocked adress.. Please wait..
- echo.
- echo ##################
- echo Status:
- echo ##################
- netsh advfirewall firewall add rule name="%oNAME%" dir=in interface=any action=block remoteip=%ADRESS%
- echo ##################
- echo.
- echo Operation complete!
- pause.
- GOTO :MENU
- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- :: Unblock IP
- :UNADD
- cls
- ::List
- echo Welcome to the blocked adress removal menu:
- echo #######################################################
- echo Overview:
- echo.
- echo 1. Select a rule name.
- echo 2. Confirm the removal.
- echo #######################################################
- echo.
- echo Current adress list:
- echo =======================================================
- netsh advfirewall firewall show rule name=all dir=in | find "IP Block:" | find " "
- echo =======================================================
- echo.
- echo Options:
- echo [1] Go back to menu.
- echo.
- ::Menu
- SET NAME=
- SET /P NAME= Select an adress name to unblock:
- IF /I '%NAME%'=='' GOTO :UNADD
- IF /I '%NAME%'=='1' (GOTO :MENU) ELSE (GOTO :DELCONFIRM)
- goto :UNADD
- :DELCONFIRM
- cls
- ::List
- echo Welcome to the blocked adress removal menu:
- echo #######################################################
- echo Overview:
- echo.
- echo 1. Select a rule name.
- echo 2. Confirm the removal.
- echo #######################################################
- echo.
- echo Removing IP:
- echo =======================================================
- echo IP Adress: %name%
- echo =======================================================
- echo.
- echo Options:
- echo [1] Go back to menu.
- echo.
- ::Menu
- SET INPUT=
- SET /P INPUT= Do you wish to confirm this action? (Y/N):
- IF /I '%INPUT%'=='' GOTO :DELCONFIRM
- IF /I '%INPUT%'=='N' GOTO :UNADD
- IF /I '%INPUT%'=='n' GOTO :UNADD
- IF /I '%INPUT%'=='Y' GOTO :DELETE
- IF /I '%INPUT%'=='y' GOTO :DELETE
- goto :DELCONFIRM
- :DELETE
- cls.
- echo Now removing %NAME%.. Please wait..
- echo.
- echo ##################
- echo Status:
- echo ##################
- netsh advfirewall firewall delete rule name="IP Block: %NAME%"
- echo ##################
- echo.
- echo Operation complete!
- pause.
- GOTO :MENU
- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- :: ENDI (Enable/Disable)
- :ENDI
- cls
- ::List
- echo Welcome to the enable/disable rule menu:
- echo #######################################################
- echo Overview:
- echo.
- echo 1. Select a rule name.
- echo 2. Imput to enable or disable rule.
- echo #######################################################
- echo.
- echo Current adress list:
- echo =======================================================
- echo ENABLED RULES:
- echo.
- netsh advfirewall firewall show rule status=enabled name=all dir=in | find "IP Block:" | find " "
- echo.
- echo DISABLED RULES:
- echo.
- netsh advfirewall firewall show rule status=disabled name=all dir=in | find "IP Block:" | find " "
- echo =======================================================
- echo.
- echo Options:
- echo [1] Go back to menu.
- echo.
- ::Menu
- SET NAME=
- SET /P NAME= Select a rule to invoke:
- IF /I '%NAME%'=='' GOTO :ENDI
- IF /I '%NAME%'=='1' (GOTO :MENU) ELSE (GOTO :INVOKERULE)
- goto :ENDI
- :INVOKERULE
- cls
- ::List
- echo Welcome to the enable/disable rule menu:
- echo #######################################################
- echo Overview:
- echo.
- echo 1. Select a rule name.
- echo 2. Imput to enable or disable rule.
- echo #######################################################
- echo.
- echo Current adress list:
- echo =======================================================
- echo ENABLED RULES:
- echo.
- netsh advfirewall firewall show rule status=enabled name=all dir=in | find "IP Block:" | find " "
- echo.
- echo DISABLED RULES:
- echo.
- netsh advfirewall firewall show rule status=disabled name=all dir=in | find "IP Block:" | find " "
- echo =======================================================
- echo.
- echo Options:
- echo [1] Go back to name.
- echo.
- ::Menu
- SET OPTION=
- SET /P OPTION= Do you wish to (enable) or (disable) %NAME%:
- IF /I '%OPTION%'=='' GOTO :INVOKERULE
- IF /I '%OPTION%'=='enable' SET OPTION=yes & GOTO :INVOKE
- IF /I '%OPTION%'=='Enable' SET OPTION=yes & GOTO :INVOKE
- IF /I '%OPTION%'=='disable' SET OPTION=no & GOTO :INVOKE
- IF /I '%OPTION%'=='Disable' SET OPTION=no & GOTO :INVOKE
- IF /I '%OPTION%'=='1' GOTO :ENDI
- goto :INVOKERULE
- :INVOKE
- cls.
- echo Now changing %NAME%'s Rule.. Please wait..
- echo.
- echo ##################
- echo Status:
- echo ##################
- netsh advfirewall firewall set rule name="IP Block: %NAME%" new enable=%OPTION%
- echo ##################
- echo.
- echo Operation complete!
- pause.
- GOTO :MENU
- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- :: INFO
- :INFO
- cls
- ::List
- echo Current adress list:
- echo =======================================================
- netsh advfirewall firewall show rule name=all dir=in | find "IP Block:" | find " "
- echo =======================================================
- echo.
- echo Options:
- echo [1] Go back to menu.
- echo.
- ::Menu
- SET INPUT=
- SET /P INPUT= Select an adress name to view more info:
- IF /I '%INPUT%'=='' GOTO :INFO
- IF /I '%INPUT%'=='1' (GOTO :MENU) ELSE (GOTO :SET)
- goto :INFO
- :SET
- cls.
- echo Viewing info for %INPUT%.
- echo.
- netsh advfirewall firewall show rule dir=in name="IP Block: %INPUT%"
- echo.
- pause.
- GOTO :MENU
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement