Advertisement
Guest User

hosts file adblock script

a guest
Jun 24th, 2016
603
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. #!/bin/sh
  2. ###
  3. # Script that modifies the /etc/hosts file to blacklist malicious and
  4. # advertising-related domains.
  5. ###
  6. temphosts=$(mktemp)
  7.  
  8. # Make a backup if one doesn't already exist
  9. [ ! -e /etc/hosts.bk ] && cp /etc/hosts /etc/hosts.bk
  10.  
  11. # Download the new hosts file, overwriting the original
  12.  
  13. ## Download various pre-made lists into our temp file
  14.  
  15. wget -nv -O - http://someonewhocares.org/hosts/hosts >> $temphosts
  16. wget -nv -O - http://winhelp2002.mvps.org/hosts.txt >> $temphosts
  17. wget -nv -O - http://www.malwaredomainlist.com/hostslist/hosts.txt >> $temphosts
  18. wget -nv -O - http://adblock.gjtech.net/?format=hostfile >> $temphosts
  19. wget -nv -O - http://hosts-file.net/ad_servers.asp >> $temphosts
  20. wget -nv -O - "http://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&showintro=0&mimetype=plaintext" >> $temphosts
  21. wget -nv -O - http://www.sysctl.org/cameleon/hosts >> $temphosts
  22. wget -nv -O - http://securemecca.com/Downloads/hosts.txt >> $temphosts
  23.  
  24.  
  25. sed -e 's/\r//' -e '/^127.0.0.1/!d' -e '/localhost/d' -e 's/127.0.0.1/0.0.0.0/' -e 's/ \+/\t/' -e 's/#.*$//' -e 's/[ \t]*$//' < $temphosts | sort | uniq -u > /etc/hosts
  26.  
  27. #
  28. echo "# Last updated on $(date)
  29.  
  30.  
  31. 127.0.0.1 localhost <your host name here or sudo will hang when you first launch it>
  32.  
  33. " | cat - /etc/hosts >> temp && mv temp /etc/hosts
  34.  
  35. rm $temphosts
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement