Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1597676
  • 博文数量: 101
  • 博客积分: 2465
  • 博客等级: 中尉
  • 技术积分: 2126
  • 用 户 组: 普通用户
  • 注册时间: 2010-12-09 15:39
个人简介

https://minminmsn.com/

文章分类

全部博文(101)

文章存档

2018年(2)

2017年(2)

2016年(11)

2015年(14)

2014年(9)

2013年(16)

2012年(47)

分类: LINUX

2012-10-16 12:08:16

#!/bin/bash
#Denyhosts SHELL SCRIPT
#2012-10-12
cat /var/log/secure|awk '/Failed/{print $(NF-3)}'|sort|uniq -c|awk '{print $2"=" $1;}' >/root/black.txt
DEFINE="10"
for i in `cat /root/black.txt`
do
        IP=`echo $i|awk -F= '{print $1}'`
        NUM=`echo $i|awk -F= '{print $2}'`
        if [$NUM -gt $DEFINE]
        then
                grep $IP /etc/hosts.deny >/dev/null
                if [$? -gt 0];
                then
                echo "sshd:$IP" >> /etc/hosts.deny
                fi
        fi
done
阅读(3222) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~