Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Title Hosts Blocklist Updater
- SETLOCAL ENABLEEXTENSIONS
- @echo off
- e:
- cd e:\Squid\etc\squid\hosts
- IF EXIST e:\Squid\etc\squid\hosts\AcrylicHosts.txt (mv e:\Squid\etc\squid\hosts\AcrylicHosts.txt e:\Squid\etc\squid\hosts\AcrylicHosts-old.txt) ELSE echo[
- rem Count how many domains were in original hosts file it can be displayed later in comparison to new entries
- for /f "delims=" %%i in ('cat AcrylicHosts-old.txt ^| wc -l ^| sed -e "s/^[ \t]*//"') do @set oldnumber=%%i
- IF EXIST e:\Squid\etc\squid\hosts\hosts.txt (mv e:\Squid\etc\squid\hosts\hosts.txt e:\Squid\etc\squid\hosts\hosts-old.txt) ELSE echo[
- rem Count how many domains were in original hosts file it can be displayed later in comparison to new entries
- for /f "delims=" %%i in ('cat hosts-old.txt ^| wc -l ^| sed -e "s/^[ \t]*//"') do @set oldnumber2=%%i
- rem First do MS telemtry domains.....
- echo Download Ancile MS Spyware Hosts
- curl --insecure https://bitbucket.org/ancile_development/ancileplugin_networking/raw/4d47fc58ab43fedec6119261fa6ade14dab0975e/data/modify_Hosts/modify_hosts.lst | grep -v "#" | sed -e "/^$/d" | sed -e "s/^/0.0.0.0 /" | sed -e "$a\ " > tempacrylichosts.txt
- echo Download Blackbird hosts file - Microsoft Telemetry
- curl http://www.getblackbird.net/documentation/Blackbird_Blacklist.txt | grep -v "#" | sed -e "/^$/d" | sed -e "s/^/0.0.0.0 /" | sed -e "$a\ " >> tempacrylichosts.txt
- rem Grab the telemtry domains, sort and remove duplicates
- cat tempacrylichosts.txt | sort | uniq -i > tempwindowshosts.txt
- cat windowshostsheader.txt tempwindowshosts.txt > windowshosts.txt
- rem backup and then overwrite the current windows hosts file - sending telemtry domains to windows hosts file just in case something bypasses Acrylic DNS...
- attrib -r -h "%WinDir%\System32\drivers\etc\hosts"
- IF EXIST "%WinDir%\System32\drivers\etc\hosts.orig" (del "%WinDir%\System32\drivers\etc\hosts.orig") ELSE echo[
- copy "%WinDir%\System32\drivers\etc\hosts" "%WinDir%\System32\drivers\etc\hosts.orig"
- copy "windowshosts.txt" "%WinDir%\System32\drivers\etc\hosts"
- attrib +r +h "%WinDir%\System32\drivers\etc\hosts"
- rem On with the main show for Acrylic and squid....
- rem Add shallalist advertising/spyware and tracker domains to hosts list
- IF EXIST e:\Squid\etc\squid\hosts\shallalist*.* (del e:\Squid\etc\squid\hosts\shallalist*.*) ELSE echo[
- IF EXIST e:\Squid\etc\squid\hosts\tempacrylichosts.txt (del e:\Squid\etc\squid\hosts\tempacrylichosts*.*) ELSE echo[
- IF EXIST e:\Squid\etc\squid\hosts\hosts.txt (del e:\Squid\etc\squid\hosts\hosts.txt) ELSE echo[
- echo Delete old shallalist databases...
- del e:\Squid\etc\squid\hosts\BL\*.* /S /F /Q
- echo "Download new shalllist block lists..."
- curl -s http://www.shallalist.de/Downloads/shallalist.tar.gz -o shallalist.tar.gz
- echo "Uncompressing block lists..."
- 7za x shallalist.tar.gz
- 7za x shallalist1.tar -y
- echo Processing shallalist blocklist domains...
- cat .\BL\adv\domains | sed -e "s/^/0.0.0.0 /" >> tempacrylichosts.txt
- cat .\BL\spyware\domains | sed -e "s/^/0.0.0.0 /" >> tempacrylichosts.txt
- cat .\BL\tracker\domains | sed -e "s/^/0.0.0.0 /" >> tempacrylichosts.txt
- rem Quick sort and uniq as most of the domains are in the hosts file by now, this will save time later
- cat tempacrylichosts.txt | sort | uniq -i > tempacrylichosts.tmp
- mv tempacrylichosts.tmp tempacrylichosts.txt
- echo Processing own blocklist domains...
- cat blacklist.txt | sort | uniq -i > blacklist.tmp
- mv blacklist.tmp blacklist.txt
- echo Processing own whitelist domains...
- cat whitelist.txt | sort | uniq -i > whitelist.tmp
- mv whitelist.tmp whitelist.txt
- rem continue grabbing and creating a hosts file for acrylic from various sources
- echo Getting fanboy malware hosts list...
- curl -s http://www.fanboy.co.nz/malwaredomains_full.txt | sed -e "/^!/d" | sed -e "/^\[/d" | sed -e "s/\^$//g" | sed -e "s/||//g" | sed -e "s/^/0.0.0.0 /" | sed -e "$a\ " >> tempacrylichosts.txt
- echo Getting yoyo ad hosts list...
- curl -s "http://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&showintro=0&mimetype=plaintext&useip=0.0.0.0" | grep -v "#" | sed -e "$a\ " >> tempacrylichosts.txt
- echo Getting winhelp2002 hosts list...
- curl -s http://winhelp2002.mvps.org/hosts.txt | grep -v "#" | sed -e "/^$/d" | sed -e "$a\ " >> tempacrylichosts.txt
- echo Getting adaway ad hosts list...
- curl -k https://adaway.org/hosts.txt | grep -v "#" | sed -e "/^$/d" | sed -e "s/127.0.0.1/0.0.0.0/" | sed -e "$a\ " >> tempacrylichosts.txt
- echo Getting hosts-file ad hosts list...
- curl -s http://hosts-file.net/.%5Cad_servers.txt | grep -v "#" | sed -e "s/\t//g" | sed -e "s/127.0.0.1/0.0.0.0 /" | sed -e "/^$/d" | sed -e "$a\ " >> tempacrylichosts.txt
- echo Getting malwaredomainlist malware hosts list...
- curl -s http://www.malwaredomainlist.com/hostslist/hosts.txt | grep -v "#" | sed -e "s/127.0.0.1 /0.0.0.0 /" | sed -e "/^$/d" | sed -e "$a\ " >> tempacrylichosts.txt
- echo Getting malwaredomains malware hosts list...
- curl -s http://mirror1.malwaredomains.com/files/justdomains | sed -e "s/^/0.0.0.0 /" | sed -e "$a\ " >> tempacrylichosts.txt
- echo Getting blocklist.de hosts list..."
- curl -s https://lists.blocklist.de/lists/all.txt | sed -e "$a\ " >> tempacrylichosts.txt
- echo Getting disconnectme malvertising list...
- curl -k https://s3.amazonaws.com/lists.disconnect.me/simple_malvertising.txt | sed -e "1d" | grep -v "#" | sed -e "/^$/d" | sed -e "s/^/0.0.0.0 /" | sed -e "$a\ " >> tempacrylichosts.txt
- echo Getting disconnectme malware list...
- curl -k https://s3.amazonaws.com/lists.disconnect.me/simple_malware.txt | sed -e "1d" |grep -v "#" | sed -e "/^$/d" | sed -e "s/^/0.0.0.0 /" | sed -e "$a\ " >> tempacrylichosts.txt
- echo Getting someone who cares hosts list...
- curl -s http://someonewhocares.org/hosts/hosts | grep -v "#" | sed -e "/^$/d" | sed -e "s/127.0.0.1/0.0.0.0/" | sed -e "$a\ " >> tempacrylichosts.txt
- echo Getting Mother of All Ad Blocks hosts list...
- curl -A "Mozilla/5.0 (X11; Linux x86_64; rv:30.0) Gecko/20100101 Firefox/30.0" -e http://forum.xda-developers.com/ http://adblock.mahakala.is/ | grep -v "#" | sed -e "$a\ " >> tempacrylichosts.txt
- echo Getting add.2o7Net hosts list...
- curl --insecure https://raw.githubusercontent.com/FadeMind/hosts.extras/master/add.2o7Net/hosts | grep -v "#" | sed -e "/^$/d" | sed -e "$a\ " >> tempacrylichosts.txt
- echo Getting add.Dead hosts list...
- curl --insecure https://raw.githubusercontent.com/FadeMind/hosts.extras/master/add.Dead/hosts | grep -v "#" | sed -e "/^$/d" | sed -e "$a\ " >> tempacrylichosts.txt
- echo Getting add.Risk hosts list...
- curl --insecure https://raw.githubusercontent.com/FadeMind/hosts.extras/master/add.Risk/hosts | grep -v "#" | sed -e "/^$/d" | sed -e "$a\ " >> tempacrylichosts.txt
- echo Getting add.Spam hosts list...
- curl --insecure https://raw.githubusercontent.com/FadeMind/hosts.extras/master/add.Spam/hosts | grep -v "#" | sed -e "/^$/d" | sed -e "$a\ " >> tempacrylichosts.txt
- echo Getting Badd Boyz hosts list...
- curl --insecure https://raw.githubusercontent.com/mitchellkrogza/Badd-Boyz-Hosts/master/hosts | grep -v "#" | sed -e "/^$/d" | sed -e "$a\ " >> tempacrylichosts.txt
- echo Getting KAD hosts list...
- curl --insecure https://raw.githubusercontent.com/azet12/KADhosts/master/KADhosts.txt | grep -v "#" | sed -e "/^$/d" | sed -e "$a\ " >> tempacrylichosts.txt
- echo Getting Steven Blacks hosts list...
- curl --insecure https://raw.githubusercontent.com/StevenBlack/hosts/master/data/StevenBlack/hosts | grep -v "#" | sed -e "/^$/d" | sed -e "$a\ " >> tempacrylichosts.txt
- echo Getting Unchecky hosts list...
- curl --insecure https://raw.githubusercontent.com/FadeMind/hosts.extras/master/UncheckyAds/hosts | grep -v "#" | sed -e "/^$/d" | sed -e "$a\ " >> tempacrylichosts.txt
- rem remove some common lines in some of the above hosts lists that arent needed, are duplicates of static lines in hosts file header or break DNS...
- cat tempacrylichosts.txt | sed -e "/0.0.0.0 * localhost.localdomain/d;/0.0.0.0 * localhost/d;s/\<0\.0\.0\.0 android\>//g;s/\<0\.0\.0\.0 test\>//g;/255.255.255.255/d;/^0.0.0.0 -/d" | sed -e "/::1/d;/\t/d;/:/d;/@/d" | grep -e "^0.0.0.0" > tempacrylichosts2.txt
- rem combine tempacrylichosts and facebookdomains, then remove any lone 0.0.0.0 <blank> lines, then remove any domains in whitelist, then sort and remove duplicates...
- cat tempacrylichosts2.txt facebook.txt | awk "NF>=2" | grep -v -f whitelist.txt | sort | uniq -i > tempacrylichosts3.txt
- rem will extract domains from 0.0.0.0 domain entries
- echo Extracting IP entries and sending to squids host blocklist...
- grep -Eo "([0-9]{1,3}\.){3}[0-9]{1,3}" tempacrylichosts3.txt | sort | uniq -i | sed -e "s/^/0.0.0.0 /" > hostips.txt
- rem remove leading 0.0.0.0 from ip's
- cat hostips.txt | sed -e "s/0.0.0.0 //g" | sed -e "s/0.0.0.0//g" | sed -e "/^$/d" > hoststmp.txt
- rem validate xxx.xxx.xxx.xxx and remove and ip's with .00x
- cat hoststmp.txt | grep -E "\b((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b" | sed -e "s/\.00/\./g" | sed -e "/127.0.0.1/d" | sort | uniq -i > hosts.txt
- echo Removing the IP entries and sending the remaining domains to Acrylic...
- comm -23 tempacrylichosts3.txt hostips.txt > tempacrylichosts4.txt
- rem for ipv4 only
- cat acrylichostsheader.txt tempacrylichosts4.txt | sed -e "$a\#End Of Hosts File" > AcrylicHosts.txt
- rem For ipv4 & ipv6
- rem cat acrylichostsheader.txt tempacrylichosts4.txt tempacrylichosts5.txt | sed -e "$a\#End Of Hosts File" > AcrylicHosts.txt
- rem Count how many domains were added so it can be displayed to the user
- for /f "delims=" %%i in ('cat AcrylicHosts.txt ^| wc -l ^| sed -e "s/^[ \t]*//"') do @set newnumber=%%i
- echo[
- echo ______________________________
- echo %oldnumber% domains originally blocked
- echo %newnumber% domains now blocked
- echo ______________________________
- echo[
- if %newnumber% leq %oldnumber% (set /a new=%oldnumber% - %newnumber%) else (set /a new=%newnumber% - %oldnumber%)
- if %newnumber% leq %oldnumber% (echo %new% domains removed) else (echo %new% domains added)
- rem Count how many domains were added so it can be displayed to the user
- for /f "delims=" %%i in ('cat hosts.txt ^| wc -l ^| sed -e "s/^[ \t]*//"') do @set newnumber2=%%i
- echo[
- echo ______________________________
- echo %oldnumber2% ips originally blocked
- echo %newnumber2% ips now blocked
- echo ______________________________
- echo[
- if %newnumber2% leq %oldnumber2% (set /a new2=%oldnumber2% - %newnumber2%) else (set /a new2=%newnumber2% - %oldnumber2%)
- if %newnumber2% leq %oldnumber2% (echo %new2% ips removed) else (echo %new2% ips added)
- rem backup and copy acrylichosts.txt to acrylic dns folder
- copy /y "C:\Program Files (x86)\Acrylic DNS Proxy\AcrylicHosts.txt" "C:\Program Files (x86)\Acrylic DNS Proxy\AcrylicHosts.orig"
- Copy /y AcrylicHosts.txt "C:\Program Files (x86)\Acrylic DNS Proxy\"
- rem remove working temp files
- del /q tempacrylichosts*.txt
- rem restart acrylic
- sc stop AcrylicServiceController
- PING 1.1.1.1 -n 1 -w 1000 >NUL
- sc start AcrylicServiceController
- rem restart squid
- sc stop squidsrv
- PING 1.1.1.1 -n 1 -w 3000 >NUL
- sc start squidsrv
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement