Chinaunix首页 | 论坛 | 博客
  • 博客访问: 825042
  • 博文数量: 203
  • 博客积分: 2433
  • 博客等级: 大尉
  • 技术积分: 2195
  • 用 户 组: 普通用户
  • 注册时间: 2011-04-05 13:32
文章分类

全部博文(203)

分类: LINUX

2014-08-22 22:24:13

#!/bin/bash
#this is for count and block the hack ip for ssh login
ip=`grep "Failed" secure-20121223 | awk '{print $(NF-3)}' | sort | uniq -c | awk '{print $1"="$2}'`
count="4"
for i in $ip
do
number=`echo $i | awk -F "=" '{print $1}'`
blockip=`echo $i | awk -F "=" '{print $2}'`
echo "$number$blockip"
if [ $number -gt $count ];then
      grep $blockip /tmp/secret/test.txt > /dev/null
       if [ $? -gt 0 ];then       
echo "sshd:$blockip" >> /tmp/secret/test.txt
fi
fi
done
阅读(1880) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~