Skip to content

Instantly share code, notes, and snippets.

@arno
Created April 17, 2009 09:15
Show Gist options
  • Save arno/96938 to your computer and use it in GitHub Desktop.
Save arno/96938 to your computer and use it in GitHub Desktop.
automatic download of common bluetack blocklists and update pf table
#!/bin/sh
#
# in /etc/pf.conf:
# table <p2p_blocklist> file "/etc/pfdata/p2p_blocklist"
# set limit table-entries 500000
# block log quick from <p2p_blocklist>
# block return log quick from any to <p2p_blocklist>
BLOCKLIST_URL="http://www.bluetack.co.uk/config"
DOWNLOAD_DIR="/tmp/blocklists"
PF_FILE="/etc/pfdata/p2p_blocklist"
blocklists="level1 level2 Microsoft badpeers bogon dshield"
[ ! -d $DOWNLOAD_DIR ] && mkdir -p $DOWNLOAD_DIR
rm -f $DOWNLOAD_DIR/*
for bl in $blocklists; do
f=$DOWNLOAD_DIR/$bl
/usr/bin/fetch -q -o $DOWNLOAD_DIR $BLOCKLIST_URL/$bl.gz || (echo "[-] problem downloading $bl rules"; rm -f $f.gz; continue)
/usr/bin/gunzip -cd $f.gz | /usr/bin/awk -F: '{ print $NF }' > $f
rm -f $f.gz
done
cat $DOWNLOAD_DIR/* | /usr/local/bin/tableutil -q text > $PF_FILE
/sbin/pfctl -t p2p_blocklist -T replace -f $PF_FILE
# vim: et sw=4 ts=4:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment