码迷,mamicode.com
首页 > 其他好文 > 详细

BADIP filter

时间:2016-09-20 06:49:16      阅读:140      评论:0      收藏:0      [点我收藏+]

标签:

#!/bin/bash
touch /tmp/badipnew.log;touch /tmp/newip.log;


if [ ! -f "/tmp/badip.log" ];then

cat /var/log/secure|grep "authentication failure\|Did not receive identification"|grep -o [0-9]\+\.[0-9\.]\+|grep \. |sort|uniq > /tmp/badip.log;
for i in `cat /tmp/badip.log`;
do
echo $i;
iptables -t filter -A INPUT -s $i -m state --state NEW -j DROP ;
done;


fi


cat /var/log/secure|grep "authentication failure\|Did not receive identification"|grep -o [0-9]\+\.[0-9\.]\+|grep \. |sort|uniq > /tmp/badipnew.log;
diff /tmp/badip.log /tmp/badipnew.log |sed 1d|grep ">"|awk {print $2} > /tmp/newip.log

cat /tmp/newip.log >> badip.log;

for i in `cat /tmp/newip.log`;
do
echo $i;
iptables -t filter -A INPUT -s $i -m state --state NEW -j DROP ;
done;
:>/tmp/badipnew.log;
:>/tmp/newip.log

 

BADIP filter

标签:

原文地址:http://www.cnblogs.com/archoncap/p/5887340.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!