Skip to content

Instantly share code, notes, and snippets.

@rxw1
Last active August 29, 2015 14:04
Show Gist options
  • Save rxw1/a5e1f2c8fccf56aab6bc to your computer and use it in GitHub Desktop.
Save rxw1/a5e1f2c8fccf56aab6bc to your computer and use it in GitHub Desktop.
Blocklists w/ cronjob

Use it e.g. in Transmission's options as file:///tmp/blocklist

#!/usr/bin/env zsh
tmpdir="/tmp/blocklists-$(date +%Y-%M-%d)"
mkdir -p $tmpdir
# https://www.iblocklist.com/lists.php
if [[ $1 = '-a' ]]; then
blocklists=($(curl -s 'https://www.iblocklist.com/lists.php' | egrep -o '[a-z]{20}' | sort -u))
else
blocklists=(
dgxtneitpuvgqqcpfulq # bluetack ads
gihxqmhyunbxhbmgqrla # bluetack bogon
imlmncgrkbnacgcwfjvh # bluetack edu
usrcshglbiilevmyfhse # bluetack hijacked
ydxerpxkpcfqjaybcssw # bluetack level 1
gyisgnzbhppbvsphucsw # bluetack level 2
uwnukjqktoggdknzrhgh # bluetack level 3
xshktygkujudfnjfioro # bluetack microsoft
mcvxsnihddgutbjfbghy # bluetack spider
llvtlsjyoyiczbkjsxpf # bluetack spyware
ijfqtofzixtwayqovmxn # tbg primary threats
)
fi
for b in $blocklists; do
wget -q -O ${tmpdir}/${b}.gz "http://list.iblocklist.com/?list=${b}&fileformat=p2p&archiveformat=gz"
done
lc=$LC_ALL
export LC_ALL='C'
gzcat ${tmpdir}/*.gz | sort -u > /tmp/blocklist
export LC_ALL=$lc
rm -r ${tmpdir}
# every day five minutes after midnight
5 0 * * * $HOME/.local/bin/blocklists.sh
# More simple onliner that get's the job done as well
@daily curl -sL 'https://www.iblocklist.com/lists.php' | egrep -A1 'star_[45]' | egrep -o '[a-z]{20}' | sort -u | while read -r blocklist; do curl -sL "http://list.iblocklist.com/?list=${blocklist}&fileformat=p2p&archiveformat=gz" | gunzip -q > ~/Library/Application\ Support/Transmission/blocklists/$blocklist; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment