其他分享
首页 > 其他分享> > 防止暴利破解,拒绝ip登陆

防止暴利破解,拒绝ip登陆

作者:互联网

#!/bin/bash
# 登陆失败次数过多,拒绝登陆,最多3次

#set -e
lastb|awk '{print $3}'|sort|grep [0-9]|uniq -c|awk '{print $2"="$1}' >/tmp/failed.list

for i in `cat /tmp/failed.list`
do
   IP=`echo $i |awk -F= '{print $1}'`
   NUM=`echo $i |awk -F= '{print $2}'`
   if [ $NUM -gt 3 ];then
      grep $IP /etc/hosts.deny > /dev/null
      if [ $? -gt 0 ];then
         echo "sshd:$IP:deny" >> /etc/hosts.deny
      fi
   fi
done

标签:IP,gt,ip,deny,echo,awk,暴利,print,破解
来源: https://blog.csdn.net/qq_16125927/article/details/111657953