Created
March 20, 2014 19:52
-
-
Save infoslack/9672383 to your computer and use it in GitHub Desktop.
Bloqueando Botnet da China
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 | |
ISO="cn" | |
IPT=/sbin/iptables | |
WGET=/usr/bin/wget | |
EGREP=/bin/egrep | |
SPAMLIST="countrydrop" | |
ZONEROOT="/root/iptables" | |
DLROOT="http://www.ipdeny.com/ipblocks/data/countries" | |
[ ! -d $ZONEROOT ] && /bin/mkdir -p $ZONEROOT | |
$IPT -N $SPAMLIST | |
for c in $ISO | |
do | |
tDB=$ZONEROOT/$c.zone | |
$WGET -O $tDB $DLROOT/$c.zone | |
SPAMDROPMSG="$c Country Drop" | |
BADIPS=$(egrep -v "^#|^$" $tDB) | |
for ipblock in $BADIPS | |
do | |
$IPT -A $SPAMLIST -s $ipblock -j LOG --log-prefix "$SPAMDROPMSG" | |
$IPT -A $SPAMLIST -s $ipblock -j DROP | |
done | |
done | |
$IPT -I INPUT -j $SPAMLIST | |
$IPT -I OUTPUT -j $SPAMLIST | |
$IPT -I FORWARD -j $SPAMLIST | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment