您的位置:首页 > 运维架构 > Shell

linux系统shell脚本实现 恶意扫描服务器密码 自动屏蔽

2013-04-08 17:17 801 查看
#!/bin/bash

log=/workspace/crontab/denyhostmessage
DEFINE=100
grep 'Failed password' /var/log/messages |awk '{print $(NF-3)}' |sort |uniq -c > $logfor i in `cat $log|awk '{print $2}'`
do
NUM=`grep $i $log|awk '{print $1}'`
if [ $NUM -gt $DEFINE ]
then
grep $i /etc/hosts.deny > /dev/null
if [ $? -gt 0 ]
then
iptables -I INPUT -s $ip -j DROP
fi
fi
done
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息