-
Notifications
You must be signed in to change notification settings - Fork 2
/
DNS_block_lists_all.php
270 lines (205 loc) · 11.9 KB
/
DNS_block_lists_all.php
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
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
<?php
//*****************************************************************
//USER VARIABLES
//*****************************************************************
chdir("/volume1/web/DNS_FG-91G"); //location on server where the DNS files will be saved to. Ensure this directory has write permissions for the web-server running this PHP script
$refresh_data=true; //pull new data from online resources?
$debug=false; //create debug output showing address vs entry in the files
//note: due to the memory limits of default PHP server settings, the various websites below have been broken into six groups.
//this is done to prevent the "master" files from exceeding ~12MB in size. this is because the "master" files are read back into memory after being downloaded and exploded into an array
//the array cannot exceed the PHP memory limits or the script will fail. edit/adjust the various websites downloaded as desired.
//*****************************************************************
//SCRIPT START
//*****************************************************************
//function to determine if a website is available or not
//got code from https://stackoverflow.com/questions/24270027/how-to-check-if-website-is-accessible
function urlExists($url=NULL)
{
if($url == NULL) return false;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$data = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if($httpcode>=200 && $httpcode<300){
return true;
} else {
return false;
}
}
//download the data from the desired URL block list
function download_data($outputfile_local, $URL_local){
//if (urlExists($URL_local)){
$counter =0;
//$myfile = fopen($URL_local, "r");
if (($myfile = @fopen($URL_local, "r"))!==false ) {
if ( !$myfile ) {
print "<p style=\"color:red;\">".$URL_local." could not be opened</p>";
}else{
while(!feof($myfile)) {
//a lot of these lists are hosts lists so they have a IP address etc. prior to the domain name. this is going to search for and remove this information.
//this needs to be done as the fortigate external threat connectors just wants a simple list of domain names and or IP addresses only.
//they are not able to process the host file data format.
$search = array("127.0.0.1 ", "localhost", "::1 ", "0.0.0.0 ", "0.0.0.0", "127.0.0.1 ", ".localdomain", "255.255.255.255 broadcasthost", "::1" , "|" , "^");
$replace = array('', '', '', '', '', '', '', '', '', '', '', '');
$subject = fgets($myfile);
//determine if we saved any bytes of data to the file. if we did, then something probably downloaded correctly, if there is no data in the file, then something must have went wrong.
$counter = $counter + file_put_contents($outputfile_local,str_replace($search, $replace, $subject), FILE_APPEND);
}
if ($counter == 0){
print "<p style=\"color:red;\">".$URL_local." returned zero bytes</p>";
}
fclose($myfile);
}
}else{
print "<p style=\"color:red;\">".$URL_local." contents could not be downloaded</p>";
}
}
$outputfile = 'master1.txt';
if ($refresh_data){
$URL="https://zerodot1.gitlab.io/CoinBlockerLists/hosts_browser";
file_put_contents($outputfile, "");
download_data($outputfile, $URL);
$URL="https://raw.githubusercontent.com/DandelionSprout/adfilt/master/Alternate%20versions%20Anti-Malware%20List/AntiMalwareHosts.txt";
download_data($outputfile, $URL);
$URL="https://raw.githubusercontent.com/FadeMind/hosts.extras/master/add.Risk/hosts";
download_data($outputfile, $URL);
$URL="https://gitlab.com/quidsup/notrack-blocklists/raw/master/notrack-malware.txt";
download_data($outputfile, $URL);
$URL="https://v.firebog.net/hosts/Prigent-Crypto.txt";
download_data($outputfile, $URL);
$URL="https://urlhaus.abuse.ch/downloads/hostfile/";
download_data($outputfile, $URL);
$URL="https://raw.githubusercontent.com/FadeMind/hosts.extras/master/add.2o7Net/hosts";
download_data($outputfile, $URL);
$URL="https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/spy.txt";
download_data($outputfile, $URL);
$URL="https://hostfiles.frogeye.fr/firstparty-trackers-hosts.txt";
download_data($outputfile, $URL);
$URL="https://adaway.org/hosts.txt";
download_data($outputfile, $URL);
$URL="https://raw.githubusercontent.com/anudeepND/blacklist/master/adservers.txt";
download_data($outputfile, $URL);
$URL="https://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&showintro=0&mimetype=plaintext";
download_data($outputfile, $URL);
$URL="https://raw.githubusercontent.com/bigdargon/hostsVN/master/hosts";
download_data($outputfile, $URL);
$URL="https://raw.githubusercontent.com/PolishFiltersTeam/KADhosts/master/KADhosts.txt";
download_data($outputfile, $URL);
}
//*******************************************************************************************************************
//*******************************************************************************************************************
//*******************************************************************************************************************
//*******************************************************************************************************************
$outputfile = 'master2.txt';
if ($refresh_data){
file_put_contents($outputfile, "");
$URL="https://raw.githubusercontent.com/AssoEchap/stalkerware-indicators/master/generated/hosts";
download_data($outputfile, $URL);
$URL="https://v.firebog.net/hosts/static/w3kbl.txt";
download_data($outputfile, $URL);
$URL="https://v.firebog.net/hosts/AdguardDNS.txt";
download_data($outputfile, $URL);
$URL="https://v.firebog.net/hosts/Admiral.txt";
download_data($outputfile, $URL);
$URL="https://s3.amazonaws.com/lists.disconnect.me/simple_ad.txt";
download_data($outputfile, $URL);
$URL="https://v.firebog.net/hosts/Easylist.txt";
download_data($outputfile, $URL);
$URL="https://v.firebog.net/hosts/Easyprivacy.txt";
download_data($outputfile, $URL);
$URL="https://v.firebog.net/hosts/Prigent-Ads.txt";
download_data($outputfile, $URL);
$URL="https://raw.githubusercontent.com/hectorm/hmirror/master/data/spam404.com/list.txt";
download_data($outputfile, $URL);
$URL="https://s3.amazonaws.com/lists.disconnect.me/simple_ad.txt";
download_data($outputfile, $URL);
$URL="https://s3.amazonaws.com/lists.disconnect.me/simple_tracking.txt";
download_data($outputfile, $URL);
$URL="https://raw.githubusercontent.com/hectorm/hmirror/master/data/eth-phishing-detect/list.txt";
download_data($outputfile, $URL);
$URL="https://raw.githubusercontent.com/hectorm/hmirror/master/data/anudeepnd-adservers/list.txt";
download_data($outputfile, $URL);
$URL="https://raw.githubusercontent.com/hectorm/hmirror/master/data/adguard-simplified/list.txt";
download_data($outputfile, $URL);
}
//*******************************************************************************************************************
//*******************************************************************************************************************
//*******************************************************************************************************************
//*******************************************************************************************************************
$outputfile = 'master3.txt';
if ($refresh_data){
file_put_contents($outputfile, "");
$URL="https://raw.githubusercontent.com/FadeMind/hosts.extras/master/add.Spam/hosts";
download_data($outputfile, $URL);
$URL="https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts";
download_data($outputfile, $URL);
$URL="https://osint.digitalside.it/Threat-Intel/lists/latestdomains.txt";
download_data($outputfile, $URL);
$URL="https://bitbucket.org/ethanr/dns-blacklists/raw/8575c9f96e5b4a1308f2f12394abd86d0927a4a0/bad_lists/Mandiant_APT1_Report_Appendix_D.txt";
download_data($outputfile, $URL);
$URL="https://phishing.army/download/phishing_army_blocklist_extended.txt";
download_data($outputfile, $URL);
}
//*******************************************************************************************************************
//*******************************************************************************************************************
//*******************************************************************************************************************
//*******************************************************************************************************************
$outputfile = 'master4.txt';
if ($refresh_data){
file_put_contents($outputfile, "");
$URL="https://v.firebog.net/hosts/RPiList-Malware.txt";
download_data($outputfile, $URL);
$URL="https://v.firebog.net/hosts/RPiList-Phishing.txt";
download_data($outputfile, $URL);
$URL="https://raw.githubusercontent.com/Spam404/lists/master/main-blacklist.txt";
download_data($outputfile, $URL);
}
//*******************************************************************************************************************
//*******************************************************************************************************************
//*******************************************************************************************************************
//*******************************************************************************************************************
$outputfile = 'master5.txt';
if ($refresh_data){
file_put_contents($outputfile, "");
$URL="https://raw.githubusercontent.com/matomo-org/referrer-spam-blacklist/master/spammers.txt";
download_data($outputfile, $URL);
$URL="https://someonewhocares.org/hosts/zero/hosts";
download_data($outputfile, $URL);
$URL="https://raw.githubusercontent.com/VeleSila/yhosts/master/hosts";
download_data($outputfile, $URL);
$URL="https://winhelp2002.mvps.org/hosts.txt";
download_data($outputfile, $URL);
$URL="https://v.firebog.net/hosts/neohostsbasic.txt";
download_data($outputfile, $URL);
$URL="https://raw.githubusercontent.com/RooneyMcNibNug/pihole-stuff/master/SNAFU.txt";
download_data($outputfile, $URL);
$URL="https://paulgb.github.io/BarbBlock/blacklists/hosts-file.txt";
download_data($outputfile, $URL);
$URL="https://raw.githubusercontent.com/jdlingyu/ad-wars/master/hosts";
download_data($outputfile, $URL);
$URL="https://raw.githubusercontent.com/Perflyst/PiHoleBlocklist/master/android-tracking.txt";
download_data($outputfile, $URL);
$URL="https://raw.githubusercontent.com/Perflyst/PiHoleBlocklist/master/SmartTV.txt";
download_data($outputfile, $URL);
$URL="https://raw.githubusercontent.com/Perflyst/PiHoleBlocklist/master/AmazonFireTV.txt";
download_data($outputfile, $URL);
}
//*******************************************************************************************************************
//*******************************************************************************************************************
//*******************************************************************************************************************
//*******************************************************************************************************************
$outputfile = 'master6.txt';
if ($refresh_data){
file_put_contents($outputfile, "");
$URL="https://www.github.developerdan.com/hosts/lists/ads-and-tracking-extended.txt";
download_data($outputfile, $URL);
$URL="https://gitlab.com/quidsup/notrack-blocklists/raw/master/notrack-blocklist.txt";
download_data($outputfile, $URL);
$URL="https://raw.githubusercontent.com/NChaves/pi-hole/main/adBlockListGetAdmiral_ABP.txt";
download_data($outputfile, $URL);
}
print shell_exec("bash webblock.sh");
?>