-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd.fwb.bat
70 lines (63 loc) · 3.23 KB
/
add.fwb.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
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
@echo off
@title [FWB.bat] Add to BlockList and Firewall [fwb-bat.e-girl.eu.org]
@setlocal enableextensions
@setlocal enabledelayedexpansion
@cd /d "%~dp0"
>nul 2>&1 net session || (
call :displayArt
echo The script requires administrative privileges to act on the Windows Firewall.
echo Restart it as administrator.
echo.
pause
exit /b
)
call :displayArt
echo *: (it will be created in the same folder and leave blank for default name)
set /p "blockedProgramsFile=Enter the name of the blocked programs file.txt* : "
if not defined blockedProgramsFile set "blockedProgramsFile=FWBblockedPrograms.txt"
if not "%blockedProgramsFile:~-4%"==".txt" set "blockedProgramsFile=%blockedProgramsFile%.txt"
if exist "%blockedProgramsFile%" del "%blockedProgramsFile%"
call :displayArt
echo Currently blocks Internet access via the firewall to all executable files with one of its extensions :
echo *.exe, *.bat, *.com, *.cmd, *.sh, *.ps1, *.sh, *.bin, *.run, *.out, *.command, *.app, *.elf, *.jar,
echo *.py, *.pl, *.deb, *.rpm, *.tar.gz, *.tar, *.xz, *.zip, *.dmg, *.app, *.pkg, *.js, *.html, *.rb,
echo *.gem, *.java, *.class, *.jsp, *.war, *.html, *.htm, *.css, *.scss, *.less, *.sass, *.php,
echo *.py, *.pyc, *.pyo, *.pyd, *.lua
echo.
echo Now adding firewall rules...
echo Affected folder and its subfolders: %~dp0
for /R %%f in ( *.exe *.bat *.com *.cmd *.sh *.ps1 *.sh *.bin *.run *.out *.command *.app *.elf *.jar *.py *.pl *.deb *.rpm *.tar.gz *.tar *.xz *.zip *.dmg *.app *.pkg *.js *.html *.rb *.gem *.java *.class *.jsp *.war *.html *.htm *.css *.scss *.less *.sass *.php *.py *.pyc *.pyo *.pyd *.lua ) do ( if /i "%%~nxf" neq "add_firewall_blocklist.bat" if /i "%%~nxf" neq "count_and_list_number_blocked.bat" if /i "%%~nxf" neq "BlockedPrograms.txt" if /i "%%~nxf" neq "%blockedProgramsFile%" if /i "%%~nxf" neq "remove_firewall_blocklist.bat" (
netsh advfirewall firewall add rule name="FWB.bat Out for %%f" dir=out program="%%f" action=block >nul
netsh advfirewall firewall add rule name="FWB.bat In for %%f" dir=in program="%%f" action=block >nul
echo %%f >> "%blockedProgramsFile%"
)
)
call :displayArt
for /f %%c in ('find /c /v "" ^< "%blockedProgramsFile%"') do set "lineCount=%%c"
echo %lineCount% programs have been blocked by the firewall.
echo The list of blocked programs has been saved to %blockedProgramsFile%.
set /p "viewList=Do you want to view the list of blocked programs? [y/N]: "
if /i "%viewList%"=="y" (
call :displayArt
echo The list of executables concerned is as follows.
echo.
type "%blockedProgramsFile%"
echo.
pause
)
echo.
pause
exit /b
:displayArt
cls
echo [+] Firewall Blocklist
echo 8888888888 888 888 888888b. 888 888
echo 888 888 o 888 888 "88b 888 888
echo 888 888 d8b 888 888 .88P 888 888
echo 8888888 888 d888b 888 8888888K. 88888b. 8888b. 888888
echo 888 888d88888b888 888 "Y88b 888 "88b "88b 888
echo 888 88888P Y88888 888 888 888 888 .d888888 888
echo 888 8888P Y8888 888 d88P d8b 888 d88P 888 888 Y88b.
echo 888 888P Y888 8888888P" Y8P 88888P" "Y888888 "Y888
echo 2024 (C) fwb-bat.e-girl.eu.org
echo.