daily pastebin goal
59%
SHARE
TWEET

adblock_gen.sh

rgnldo Jan 20th, 2019 (edited) 125 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2. # Modified Pi-hole script to generate a generic hosts file
  3. # for use with dnsmasq's addn-hosts configuration
  4. # original : https://github.com/jacobsalmela/pi-hole/blob/master/gravity-adv.sh
  5.  
  6. # Address to send ads to. This could possibily be removed, but may be useful for debugging purposes?
  7. destinationIP="10.0.30.3"
  8. permlist='/jffs/pattern.txt'
  9. outlist='/jffs/blocklist.txt'
  10. finalist='/jffs/domain.txt'
  11. tempoutlist="/tmp/outlist.tmp"
  12. echo "Apagando temporários..."
  13. COLOR_RED='\033[0;31m'
  14. COLOR_WHITE='\033[0m'
  15. COLOR_GREEN='\e[0;32m'
  16. [ -f /jffs/blocklist.txt.tmp ] && rm -f /jffs/blocklist.txt.tmp
  17.  
  18. echo "Baixando yoyo ad lista..."
  19. curl --progress-bar -d mimetype=plaintext -d hostformat=unixhosts http://pgl.yoyo.org/adservers/serverlist.php? | sort > $tempoutlist
  20. echo "Baixando winhelp2002 ad lista..."
  21. curl --progress-bar http://winhelp2002.mvps.org/hosts.txt | grep -v "#" | grep -v "127.0.0.1" | sed '/^$/d' | sed 's/\ /\\ /g' | awk '{print $2}' | sort >> $tempoutlist
  22. echo "Baixando Zeustracker ad lista..."
  23. curl --progress-bar https://zeustracker.abuse.ch/blocklist.php?download=domainblocklist | grep -v "#" | grep -v "::1" | sed '/^$/d' | sed 's/\ /\\ /g' | awk '{print $2}' | grep -v '^\\' | grep -v '\\$' | sort >> $tempoutlist
  24. echo "Baixando Adblock-nocoin ad lista..."
  25. curl --progress-bar https://raw.githubusercontent.com/hoshsadiq/adblock-nocoin-list/master/hosts.txt | grep -v "#" | grep -v "::1" | sed '/^$/d' | sed 's/\ /\\ /g' | awk '{print $2}' | grep -v '^\\' | grep -v '\\$' | sort >> $tempoutlist
  26. echo "Baixando Adway ad lista..."
  27. curl --progress-bar https://adaway.org/hosts.txt | grep -v "#" | grep -v "127.0.0.1" | sed '/^$/d' | sed 's/\ /\\ /g' | awk '{print $2}' | sort >> $tempoutlist
  28. echo "Baixando malwaredomainlist ad lista..."
  29. curl --progress-bar http://www.malwaredomainlist.com/hostslist/hosts.txt | grep -v "#" | sed '/^$/d' | sed 's/\ /\\ /g' | awk '{print $3}' | grep -v '^\\' | grep -v '\\$' | sort >> $tempoutlist
  30. echo "Baixando Disconnect simple_tracking ad lista..."
  31. curl --progress-bar https://s3.amazonaws.com/lists.disconnect.me/simple_tracking.txt | grep -v "#" | sed '/^$/d' | sed 's/\ /\\ /g' | grep -v '^\\' | grep -v '\\$' | awk '{print $2}' | grep -v '^\\' | grep -v '\\$' | sort >> $tempoutlist
  32. echo "Baixando Disconnect simple_ad ad lista...."
  33. curl --progress-bar https://s3.amazonaws.com/lists.disconnect.me/simple_ad.txt | grep -v "#" | grep -v "::1" | sed '/^$/d' | sed 's/\ /\\ /g' | awk '{print $2}' | grep -v '^\\' | grep -v '\\$' | sort >> $tempoutlist
  34. echo "Baixando Someonewhocares ad lista..."
  35. curl --progress-bar http://someonewhocares.org/hosts/hosts | grep -v "#" | sed '/^$/d' | sed 's/\ /\\ /g' | grep -v '^\\' | grep -v '\\$' | awk '{print $2}' | grep -v '^\\' | grep -v '\\$' | sort >> $tempoutlist
  36. echo "Baixando hosts-file ad lista..."
  37. curl --progress-bar http://hosts-file.net/ad_servers.txt | grep -v "#" | grep -v "::1" | sed '/^$/d' | sed 's/\ /\\ /g' | awk '{print $2}' | grep -v '^\\' | grep -v '\\$' | sort >> $tempoutlist
  38. echo "Baixando Ransomwaretracker ad lista..."
  39. curl --progress-bar https://ransomwaretracker.abuse.ch/downloads/RW_DOMBL.txt | grep -v "#" | grep -v "::1" | sed '/^$/d' | sed 's/\ /\\ /g' | awk '{print $2}' | grep -v '^\\' | grep -v '\\$' | sort >> $tempoutlist
  40. echo "Baixando CoinBlocker ad lista..."
  41. curl --progress-bar https://zerodot1.gitlab.io/CoinBlockerLists/hosts_browser | grep -v "#" | grep -v "::1" | sed '/^$/d' | sed 's/\ /\\ /g' | awk '{print $2}' | grep -v '^\\' | grep -v '\\$' | sort >> $tempoutlist
  42. echo "Baixando Immortal_domains ad lista..."
  43. curl --progress-bar http://mirror1.malwaredomains.com/files/immortal_domains.txt | grep -v "#" | grep -v "::1" | sed '/^$/d' | sed 's/\ /\\ /g' | awk '{print $2}' | grep -v '^\\' | grep -v '\\$' | sort >> $tempoutlist
  44. echo "Baixando WindowsSpyBlocker ad lista..."
  45. curl --progress-bar https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/spy.txt | grep -v "#" | grep -v "::1" | sed '/^$/d' | sed 's/\ /\\ /g' | awk '{print $2}' | grep -v '^\\' | grep -v '\\$' | sort >> $tempoutlist
  46.  
  47. # Remove entries from the whitelist file if it exists at the root of the current user's home folder
  48. echo "Removendo formatações duplicadas na lista de domínios..."
  49. # Removed the uniq command, using sort -u. Removes the dependency on uniq, which is not available on the router by default or via opkg.
  50. # Added a rough way to exclude domains from the list. If you have a number of domains to whitelist, a better solution could be explored.
  51. cat $tempoutlist | sed $'s/\r$//' | sed '/thisisiafakedomain123\.com/d;/www\.anotherfakedomain123\.com/d' | sort -u | sed '/^$/d' | awk -v "IP=$destinationIP" '{sub(/\r$/,""); print IP" "$0}' > $outlist
  52.  
  53. echo "Editando lista de dominios permitidos..."
  54.  
  55. fgrep -vf $permlist $outlist > $finalist
  56.  
  57. # Count how many domains/whitelists were added so it can be displayed to the user
  58. numberOfAdsBlocked=$(cat $finalist | wc -l | sed 's/^[ \t]*//')
  59. echo "$numberOfAdsBlocked domínios suspeitos bloqueados."
  60.  
  61. echo "Removendo arquivos temporários..."
  62. rm $tempoutlist
  63.  
  64. echo "Reiniciando servidores..."
  65. /opt/etc/init.d/S80pixelserv-tls restart
  66. service dnsmasq restart
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top