-
Notifications
You must be signed in to change notification settings - Fork 0
/
v3.bat
242 lines (202 loc) · 10.6 KB
/
v3.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
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
@echo off
setlocal enabledelayedexpansion
chcp 65001 > nul
cd /d "%~dp0"
:: if "%1"=="list" (
:: netsh advfirewall firewall show rule Blockit | findstr RemoteIP
:: exit/b
:: )
:: Deleting existing block on ips
:: netsh advfirewall firewall delete rule name="Blockit"
:main
@echo.
@echo Y (그렇다) 규칙을 적용 할까요?
@echo N (종료) 아무 것도 하지 않고 종료 한다
@echo D (규칙제거) 자작으로 만든 규칙을 모두 제거 한다
@echo C (국가차단) 중국 러시아 북한 악성 ip 차단
@echo R (국가차단) 러시아 북한 악성 ip 차단
@echo B (백업) 규칙을 백업 합니다.
@echo S (복구) 내가 저장한 규칙복구
@echo.
@echo 만일을 위해서 미리 백업을 하세요.
@echo 다른 먼져 규칙을 적용 하려면 규칙제거를 하세요.
@echo.
set choice=
set /p choice=선택 하세요.
echo "%choice%".|findstr /x /i "\"[yndcrbs]\"\." 2>nul>nul&&goto :%choice%||goto :main
goto :quit
:y
:: 악성만 차단 하는 버전
:: 중국 러시아 북한 악성 ip 차단 버전
:: 다운로드 하기 중국 cn 러시아 ru 북한 kp cn.netset 차단 하고 싶지 않은 나라가 있다면 앞에 주석 처리 :: 하세요. https://mirror.dk.team.blue/firehol/ip2location_country/ 제공 합니다
powershell "(new-Object System.Net.WebClient).DownloadFile('https://iplists.firehol.org/files/firehol_level1.netset', '%temp%\firehol_level1.netset')"
:: powershell "(new-Object System.Net.WebClient).DownloadFile('https://mirror.dk.team.blue/firehol/ip2location_country/ip2location_country_cn.netset', '%temp%\ip2location_country_cn.netset')"
:: powershell "(new-Object System.Net.WebClient).DownloadFile('https://mirror.dk.team.blue/firehol/ip2location_country/ip2location_country_ru.netset', '%temp%\ip2location_country_ru.netset')"
:: powershell "(new-Object System.Net.WebClient).DownloadFile('https://mirror.dk.team.blue/firehol/ip2location_country/ip2location_country_kp.netset', '%temp%\ip2location_country_kp.netset')"
powershell "(new-Object System.Net.WebClient).DownloadFile('https://mirror.dk.team.blue/firehol/ip2location_country/ip2location_country_kr.netset', '%temp%\ip2location_country_kr.netset')"
:: 모두 다 하나에 뭉치기
type "%temp%\firehol_level1.netset" > %temp%\out.txt
:: type %temp%\ip2location_country_cn.netset >> %temp%\out.txt
:: type %temp%\ip2location_country_ru.netset >> %temp%\out.txt
:: type %temp%\ip2location_country_kp.netset >> %temp%\out.txt
:: 걸러내기 같은 out.txt 라서 out2.txt로 해야 정상적으로 작동 된다.
:: 차단 주소에서 가정집 공유기 구글 dns를 제외 합니다. 그래야 인터넷이 되니깐요.
type %temp%\out.txt | findstr /blv "# 0.0.0. 192.168.0.0/16 224.0.0.0/16 172.30. 192.168. 224.0. 168.126. 210.220. 219.250. 61.41. 1.214. 164.124. 203.248. 180.182. 94.140. 208.67. 1.1. 1.0. 8.8. 9.9. 149.112. 194.242. 185.222. 45.11. 10.0. 172.162" > %temp%\out2.txt
:: 차단목록에서 혹시나 있을 한국은 제외 하기
findstr /VG:%temp%\ip2location_country_kr.netset < %temp%\out2.txt > %temp%\out.txt
:: 중복 제거
sort /C /UNIQUE "%temp%\out.txt" /O "%temp%\out.txt"
:: 다른 이름으로 저장
copy %temp%\out.txt "%temp%\out_BAD_ip.csv" /y
:: 200 줄씩 가져와서 한 줄로 만들어서 화면에 출력.
:: 200 줄씩 ip 등록하기
set /a CountLine=0
set "str="
for /f "delims=" %%a in ('type "%temp%\out_BAD_ip.csv"') do (
set /a CountLine=!CountLine!+1
set "str=!str!,%%a"
if !CountLine! EQU 200 (
set /a CountLine=0
:: echo !str!
netsh advfirewall firewall add rule name="Blockit" protocol=any dir=in action=block remoteip=!str!
netsh advfirewall firewall add rule name="Blockit" protocol=any dir=out action=block remoteip=!str!
set "str="
)
)
:: 규칙을 다 등록 하고 오는 장소
gpupdate /force
echo.
echo [알림: 방어벽 설정]
echo 윈도우키+R WF.msc
echo.
goto :quit
:n
:: 아무 것도 하지 않고 나가기
echo.
echo [알림]
echo 아무 것도 하지 않고 배치 파일을 종료 합니다.
echo.
goto :quit
:d
echo.
echo DEL! 자작으로 만드신 Blockit 규칙을 모두 지우겠습니다. 걱정 하지 마세요 다른 것은 지워지지 않습니다.
echo.
netsh advfirewall firewall delete rule name="Blockit"
gpupdate /force
echo.
echo [알림: 방어벽 설정]
echo 윈도우키+R WF.msc
echo.
goto :quit
:c
:: 중국 러시아 북한 악성 차단 버전
:: 다운로드 하기 중국 cn 러시아 ru 북한 kp cn.netset 차단 하고 싶지 않은 나라가 있다면 앞에 주석 처리 :: 하세요. https://mirror.dk.team.blue/firehol/ip2location_country/ 제공 합니다
powershell "(new-Object System.Net.WebClient).DownloadFile('https://iplists.firehol.org/files/firehol_level1.netset', '%temp%\firehol_level1.netset')"
powershell "(new-Object System.Net.WebClient).DownloadFile('https://mirror.dk.team.blue/firehol/ip2location_country/ip2location_country_cn.netset', '%temp%\ip2location_country_cn.netset')"
powershell "(new-Object System.Net.WebClient).DownloadFile('https://mirror.dk.team.blue/firehol/ip2location_country/ip2location_country_ru.netset', '%temp%\ip2location_country_ru.netset')"
powershell "(new-Object System.Net.WebClient).DownloadFile('https://mirror.dk.team.blue/firehol/ip2location_country/ip2location_country_kp.netset', '%temp%\ip2location_country_kp.netset')"
powershell "(new-Object System.Net.WebClient).DownloadFile('https://mirror.dk.team.blue/firehol/ip2location_country/ip2location_country_kr.netset', '%temp%\ip2location_country_kr.netset')"
:: 모두 다 하나에 뭉치기
type %temp%\firehol_level1.netset > %temp%\out.txt
type %temp%\ip2location_country_cn.netset >> %temp%\out.txt
type %temp%\ip2location_country_ru.netset >> %temp%\out.txt
type %temp%\ip2location_country_kp.netset >> %temp%\out.txt
:: 걸러내기 같은 out.txt 라서 out2.txt로 해야 정상적으로 작동 된다.
:: 차단 주소에서 가정집 공유기 구글 dns를 제외 합니다. 그래야 인터넷이 되니깐요.
type %temp%\out.txt | findstr /blv "# 0.0.0. 192.168.0.0/16 224.0.0.0/16 172.30. 192.168. 224.0. 168.126. 210.220. 219.250. 61.41. 1.214. 164.124. 203.248. 180.182. 94.140. 208.67. 1.1. 1.0. 8.8. 9.9. 149.112. 194.242. 185.222. 45.11. 10.0. 172.162" > %temp%\out2.txt
:: 차단목록에서 혹시나 있을 한국은 제외 하기
findstr /VG:%temp%\ip2location_country_kr.netset < %temp%\out2.txt > %temp%\out.txt
:: 중복 제거
sort /C /UNIQUE "%temp%\out.txt" /O "%temp%\out.txt"
:: 다른 이름으로 저장
copy %temp%\out.txt "%temp%\out_CN_RU_KP_BAD_ip.csv" /y
:: 200 줄씩 가져와서 한 줄로 만들어서 화면에 출력.
:: 200 줄씩 ip 등록하기
set /a CountLine=0
set "str="
for /f "delims=" %%a in ('type "%temp%\out_CN_RU_KP_BAD_ip.csv"') do (
set /a CountLine=!CountLine!+1
set "str=!str!,%%a"
if !CountLine! EQU 200 (
set /a CountLine=0
:: echo !str!
netsh advfirewall firewall add rule name="Blockit" protocol=any dir=in action=block remoteip=!str!
netsh advfirewall firewall add rule name="Blockit" protocol=any dir=out action=block remoteip=!str!
set "str="
)
)
:: 규칙을 다 등록 하고 오는 장소
gpupdate /force
echo.
echo [알림: 방어벽 설정]
echo 윈도우키+R WF.msc
echo.
goto :quit
:r
:: 중국을 제외 한 버전 러시아 북한 악성 ip만 차단
:: 다운로드 하기 중국 cn 러시아 ru 북한 kp cn.netset 차단 하고 싶지 않은 나라가 있다면 앞에 주석 처리 :: 하세요. https://mirror.dk.team.blue/firehol/ip2location_country/ 제공 합니다
powershell "(new-Object System.Net.WebClient).DownloadFile('https://iplists.firehol.org/files/firehol_level1.netset', '%temp%\firehol_level1.netset')"
powershell "(new-Object System.Net.WebClient).DownloadFile('https://mirror.dk.team.blue/firehol/ip2location_country/ip2location_country_cn.netset', '%temp%\ip2location_country_cn.netset')"
powershell "(new-Object System.Net.WebClient).DownloadFile('https://mirror.dk.team.blue/firehol/ip2location_country/ip2location_country_ru.netset', '%temp%\ip2location_country_ru.netset')"
powershell "(new-Object System.Net.WebClient).DownloadFile('https://mirror.dk.team.blue/firehol/ip2location_country/ip2location_country_kp.netset', '%temp%\ip2location_country_kp.netset')"
powershell "(new-Object System.Net.WebClient).DownloadFile('https://mirror.dk.team.blue/firehol/ip2location_country/ip2location_country_kr.netset', '%temp%\ip2location_country_kr.netset')"
:: 모두 다 하나에 뭉치기
type %temp%\firehol_level1.netset > %temp%\out.txt
:: type %temp%\ip2location_country_cn.netset >> %temp%\out.txt
type %temp%\ip2location_country_ru.netset >> %temp%\out.txt
type %temp%\ip2location_country_kp.netset >> %temp%\out.txt
:: 걸러내기 같은 out.txt 라서 out2.txt로 해야 정상적으로 작동 된다.
:: 차단 주소에서 가정집 공유기 구글 dns를 제외 합니다. 그래야 인터넷이 되니깐요.
type %temp%\out.txt | findstr /blv "# 0.0.0. 192.168.0.0/16 224.0.0.0/16 172.30. 192.168. 224.0. 168.126. 210.220. 219.250. 61.41. 1.214. 164.124. 203.248. 180.182. 94.140. 208.67. 1.1. 1.0. 8.8. 9.9. 149.112. 194.242. 185.222. 45.11. 10.0. 172.162" > %temp%\out2.txt
:: 차단목록에서 혹시나 있을 한국은 제외 하기
findstr /VG:%temp%\ip2location_country_kr.netset < %temp%\out2.txt > %temp%\out.txt
:: 중복 제거
sort /C /UNIQUE "%temp%\out.txt" /O "%temp%\out.txt"
:: 다른 이름으로 저장
copy %temp%\out.txt "%temp%\out_RU_KP_BAD_ip.csv" /y
:: 200 줄씩 가져와서 한 줄로 만들어서 화면에 출력.
:: 200 줄씩 ip 등록하기
set /a CountLine=0
set "str="
for /f "delims=" %%a in ('type "%temp%\out_RU_KP_BAD_ip.csv"') do (
set /a CountLine=!CountLine!+1
set "str=!str!,%%a"
if !CountLine! EQU 200 (
set /a CountLine=0
:: echo !str!
netsh advfirewall firewall add rule name="Blockit" protocol=any dir=in action=block remoteip=!str!
netsh advfirewall firewall add rule name="Blockit" protocol=any dir=out action=block remoteip=!str!
set "str="
)
)
:: 규칙을 다 등록 하고 오는 장소
gpupdate /force
echo.
echo [알림: 방어벽 설정]
echo 윈도우키+R WF.msc
echo.
goto :quit
:b
:: 규칙을 백업 합니다
del /f "%temp%\advfirewall_file.wfw" 2> null
netsh advfirewall export "%temp%\advfirewall_file.wfw"
echo.
echo [알림: 방어벽 설정]
echo 윈도우키+R WF.msc
echo.
goto :quit
:s
:: 규칙을 복구 합니다.
echo 먼져 백업을 하지 않았다면 복구는 되지 않습니다.
netsh advfirewall import "%temp%\advfirewall_file.wfw"
echo.
echo [알림: 방어벽 설정]
echo 윈도우키+R WF.msc
echo.
goto :quit
:quit
:: 최종 목적지 배치 파일 종료
endlocal
pause
:: call this batch again with list to show the blocked IPs
:: call %0 list