徒涉春冰

导航

抄一段ssh vsftpd防暴力破解脚本

#!/bin/bash
#Denyhosts For vsftpd and sshd
#2012-12-04
awk '{for(i=1;i<=NF;i++){if($i ~ /rhost/)print substr($i,7)}}' /var/log/secure  | grep -v "centos1" | sort | uniq  -c  >/root/black.txt
DEFINE="100"
cat   /root/black.txt |  while read LINE
do
        NUM=`echo $LINE |awk '{print $1}'`
        host=`echo $LINE  |awk '{print $2}'`
        if [ $NUM -gt $DEFINE ];
        then
         grep $host  /etc/hosts.deny > /dev/null
          if [ $? -gt 0 ];
          then
          echo "sshd:$host"   >> /etc/hosts.deny
             echo "vsftpd:$host" >> /etc/hosts.deny
          fi
        fi
done

posted on 2013-01-27 11:37  徒涉春冰  阅读(168)  评论(0编辑  收藏  举报