Last active
June 16, 2018 00:23
-
-
Save enginefeeder101/67265845408df73ae2e36a9766160bf7 to your computer and use it in GitHub Desktop.
Create Mega Adblock Hostsfile for use with Dnsmasq (Modified from Pi-hole)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Modified Pi-hole script to generate a generic hosts file | |
# for use with dnsmasq's addn-hosts configuration | |
# original : https://github.com/jacobsalmela/pi-hole/blob/master/gravity-adv.sh | |
# forked from: https://gist.github.com/chrisvella/5f3a18f1e442153cd685 | |
### Configuration ### | |
# Server to send ads to | |
adblock='0.0.0.0' | |
# Blocklist location | |
outlist='/config/adblocklist' | |
tmplist=$(mktemp) | |
# Whitelist location | |
whitelist='/config/whitelist' | |
### Download domains ### | |
# StevenBlack | |
curl -s https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts | grep '^0.0.0.0' | awk '{print $2}' >> $tmplist | |
# MalwareDomains | |
curl -s https://mirror1.malwaredomains.com/files/justdomains >> $tmplist | |
# Cameleon | |
curl -s http://sysctl.org/cameleon/hosts | grep '^127.0.0.1' | awk '{print $2}' >> $tmplist | |
# Zeustracker | |
curl -s https://zeustracker.abuse.ch/blocklist.php?download=domainblocklist >> $tmplist | |
# Disconnect.me | |
curl -s https://s3.amazonaws.com/lists.disconnect.me/simple_tracking.txt >> $tmplist | |
curl -s https://s3.amazonaws.com/lists.disconnect.me/simple_ad.txt >> $tmplist | |
# Hosts-file.net | |
curl -s https://hosts-file.net/ad_servers.txt | grep '^127.0.0.1' | awk '{print $2}' >> $tmplist | |
curl -s https://hosts-file.net/emd.txt | grep '^127.0.0.1' | awk '{print $2}' >> $tmplist | |
curl -s https://hosts-file.net/fsa.txt | grep '^127.0.0.1' | awk '{print $2}' >> $tmplist | |
curl -s https://hosts-file.net/hjk.txt | grep '^127.0.0.1' | awk '{print $2}' >> $tmplist | |
curl -s https://hosts-file.net/mmt.txt | grep '^127.0.0.1' | awk '{print $2}' >> $tmplist | |
curl -s https://hosts-file.net/psh.txt | grep '^127.0.0.1' | awk '{print $2}' >> $tmplist | |
# YoYo | |
curl -s http://pgl.yoyo.org/adservers/serverlist.php?hostformat=nohtml >> $tmplist | |
# WinHelp2002 | |
curl -s http://winhelp2002.mvps.org/hosts.txt | grep '^0.0.0.0' | awk '{print $2}' >> $tmplist | |
# AdAway | |
curl -s https://adaway.org/hosts.txt | grep '^127.0.0.1' | awk '{print $2}' >> $tmplist | |
# Malware Domain List | |
curl -s http://www.malwaredomainlist.com/hostslist/hosts.txt | grep '^127.0.0.1' | awk '{print $2}' >> $tmplist | |
# Some One Who Cares | |
curl -s http://someonewhocares.org/hosts/zero/hosts | grep '^0.0.0.0' | awk '{print $2}' >> $tmplist | |
# Mother of All Ad Blocks | |
curl -s -A 'Mozilla' http://adblock.mahakala.is | grep '^0.0.0.0' | awk '{print $2}' >> $tmplist | |
### Finalize and cleanup ### | |
# Combine blocklist and whitelist | |
comm -23 <(grep -v '#' $tmplist | tr -d '[:blank:]\r' | sort -u) <(grep -v '#' "$whitelist" | tr -d '[:blank:]\r' | sort -u) | awk -v "IP=$adblock" '{print IP" "$0}' > "$outlist" | |
# Removes temporary list | |
rm $tmplist |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0.0.0.0 | |
127.0.0.1 | |
localhost |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment