Advertisement
Guest User

Bluetack blocklist downloader

a guest
Mar 21st, 2010
2,449
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.36 KB | None | 0 0
  1. !/bin/bash
  2. #  This script downloads bluetack blocklists, then merges them.
  3. #
  4. #  For descriptions of each list, see
  5. #  http://www.bluetack.co.uk/forums/index.php?autocom=faq&CODE=02&qid=17
  6. #
  7. #  If using rtorrent with ipfilter enhancement patch from trac located at
  8. #  http://libtorrent.rakshasa.no/ticket/239 ,
  9. #  then remember to add the following 2 lines to your .rtorrent.rc:
  10. #  ip_filter=path/to/ipfilter/blocklist
  11. #  schedule = filter,18:30:00,24:00:00,reload_ip_filter=
  12. #  Remember to change "path/to/ipfilter" above to the same path as below,
  13. #  and then set cron to run this script daily.
  14.  
  15. #  Edit the following to the desired parent folder for the blocklist.
  16. #  This folder should only be used for this script.
  17. #  Choose either a writable nonexistant path, or an empty existing path.
  18. dir=/path/to/ipfilter
  19.  
  20. #  This sets the name of the blocklist to "blocklist".
  21. #  Change this if you need it to match your ip_filter= setting.
  22. bl=$dir/blocklist
  23.  
  24. #  Directory and blocklist check
  25. if [ -d $dir ]; then
  26.   if [ -f $bl ]; then
  27.     echo Blocklist exists.
  28.   else
  29.     touch $bl
  30.     if [ $? = 0 ]; then
  31.       echo Empty blocklist created.
  32.     else
  33.       echo -e "Error creating file.\nPlease repair permissions in $dir.\nExiting."
  34.       exit 0
  35.     fi
  36.   fi
  37. else
  38.   mkdir $dir
  39.   touch $bl
  40.     if [ $? = 0 ]; then
  41.       echo Directory and empty blocklist created.
  42.     else
  43.       echo -e "Error writing to directory.\nPlease repair permissions in parent directory.\nExiting."
  44.       exit 0
  45.     fi
  46. fi
  47.  
  48. cd $dir
  49.  
  50. #  Backup current blocklist
  51. mv -f blocklist blocklist.backup
  52. if [ $? = 0 ]
  53. then
  54.   echo Downloading blocklists...
  55. else
  56.   echo -e "Error backing up current blocklist.\nPlease repair permissions in $dir.\nExiting."
  57.   exit 0
  58. fi
  59.  
  60. #  Uncomment each file you want included in the final blocklist
  61. #
  62. #wget -q -t 3 http://www.bluetack.co.uk/config/ads-trackers-and-bad-pr0n.gz
  63. #wget -q -t 3 http://www.bluetack.co.uk/config/badpeers.gz
  64. wget -q -t 3 http://www.bluetack.co.uk/config/bogon.gz
  65. wget -q -t 3 http://www.bluetack.co.uk/config/dshield.gz
  66. #wget -q -t 3 http://www.bluetack.co.uk/config/edu.gz
  67. #wget -q -t 3 http://www.bluetack.co.uk/config/exclusions.gz
  68. #wget -q -t 3 http://www.bluetack.co.uk/config/fornonlancomputers.gz
  69. #wget -q -t 3 http://www.bluetack.co.uk/config/gnutella.gz
  70. #wget -q -t 3 http://www.bluetack.co.uk/config/hijacked.gz
  71. #wget -q -t 3 http://www.bluetack.co.uk/config/HOSTS.gz
  72. #wget -q -t 3 http://www.bluetack.co.uk/config/iana-multicast.gz
  73. #wget -q -t 3 http://www.bluetack.co.uk/config/iana-private.gz
  74. #wget -q -t 3 http://www.bluetack.co.uk/config/iana-reserved.gz
  75. wget -q -t 3 http://www.bluetack.co.uk/config/level1.gz
  76. wget -q -t 3 http://www.bluetack.co.uk/config/level2.gz
  77. #wget -q -t 3 http://www.bluetack.co.uk/config/level3.gz
  78. wget -q -t 3 http://www.bluetack.co.uk/config/Microsoft.gz
  79. #wget -q -t 3 http://www.bluetack.co.uk/config/proxy.gz
  80. #wget -q -t 3 http://www.bluetack.co.uk/config/rangetest.gz
  81. #wget -q -t 3 http://www.bluetack.co.uk/config/spider.gz
  82. #wget -q -t 3 http://www.bluetack.co.uk/config/spyware.gz
  83. #wget -q -t 3 http://www.bluetack.co.uk/config/webexploit-forumspam.gz
  84.  
  85. #  Extract blocklists (blocklist.backup is ignored)
  86. gunzip -r $dir
  87.  
  88. #  Combine blocklists into one file
  89. shopt -s extglob
  90. cat !(blocklist.backup) > blocklist
  91.  
  92. #  Cleanup individual blocklists
  93. rm !(bl*)
  94.  
  95. echo Done.
  96.  
  97. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement