cwonrails
2/14/2016 - 9:08 PM

blocking p2p peer snoopers and evil corp (for Tixati IP filter and such)

blocking p2p peer snoopers and evil corp (for Tixati IP filter and such)

#!/bin/sh

# This script runs every other night at 04:56 CET on a webserver I maintain
# Results are always at: https://jult.net/block.txt ( or https://jult.net/block.txt.gz )
# And much smaller, stripped of BS; https://jult.net/bloc.txt
# For use in Tixati IP filter: https://jult.net/bloc.txt.gz !!!
# And finally a txt file with just the bold IP-ranges: https://jult.net/bl.txt (or https://jult.net/bl.txt.gz )

# Download open block-lists, unpack, filter:
curl -s https://www.iblocklist.com/lists.php | grep -A 2 Bluetack | xargs wget -qO - --limit-rate=500k | gunzip -f | egrep -v '^#' > /tmp/xbp
sleep 9
# Assholes allowing kiddy-porn, uncomment if you are prepared to deprive yourself of speedy (non-porn) downloads as well, for a good cause:
#cd /tmp
#wget -q --trust-server-names http://list.iblocklist.com/?list=dufcxgnbjsdwmwctgfuj&fileformat=p2p&archiveformat=gz
#sleep 4
#cd /tmp
#gunzip duf*.gz
#cat /tmp/duf* >> /tmp/xbp

# and another list:
wget -qO - --limit-rate=500k http://www.wael.name/wael.list.p2p.gz > /tmp/xb2.gz
gunzip -f /tmp/xb2.gz
cat /tmp/xb2 >> /tmp/xbp
sleep 9

# and another
wget -qO - --limit-rate=500k http://john.bitsurge.net/public/biglist.p2p.gz > /tmp/xb3.gz
gunzip -f /tmp/xb3.gz
cat /tmp/xb3 >> /tmp/xbp
sleep 9

# Strip, Sort and Delete doubles:
sed -i "s/[[:space:]]*#.*$//g" /tmp/xbp
sleep 9
sed -i "s/.*value='\(http:.*\)'.*/\1/p" /tmp/xbp
sleep 9
sort /tmp/xbp | uniq > /yourwebdocroot/block.txt
sleep 9

# Strip everything but IPv4s (and ranges), for use in firewalls etc.
grep -Eo '([0-9]{1,3}\.){3}[0-9]{1,3}$|([0-9]{1,3}\.){3}[0-9]{1,3}\-([0-9]{1,3}\.){3}[0-9]{1,3}' /yourwebdocroot/block.txt > /tmp/xbl
sleep 9

sort /tmp/xbl | uniq > /yourwebdocroot/bl.txt
sleep 9

# Beautyfi for tixati pulling, add colon in front
sed "s/^/:/g" /yourwebdocroot/bl.txt > /yourwebdocroot/bloc.txt

# Keep as txt and gz file:
gzip -c /yourwebdocroot/block.txt > /yourwebdocroot/block.txt.gz
sleep 9
gzip -c /yourwebdocroot/bloc.txt > /yourwebdocroot/bloc.txt.gz
sleep 9
gzip -c /yourwebdocroot/bl.txt > /yourwebdocroot/bl.txt.gz
sleep 9

# Let's make sure next run is a clean one
rm -rf /tmp/xb*
#rm -rf /tmp/du*

exit 0