Created
April 17, 2009 09:15
-
-
Save arno/96938 to your computer and use it in GitHub Desktop.
automatic download of common bluetack blocklists and update pf table
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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