centos防爆力破解

#! /bin/bash
cat /var/log/secure|awk '/Failed/{print $(NF-3)}'|sort|uniq -c|awk '{print $2"="$1;}' > /data1/ip.list
for i in `cat  /data1/ip.list`
do
  IP=`echo $i |awk -F= '{print $1}'`
  NUM=`echo $i|awk -F= '{print $2}'`
  if [ #NUM -gt 10 ]; then
    grep $IP /etc/hosts.deny > /dev/null
    if [ $? -gt 0 ];then
      echo "sshd:$IP:deny" >> /etc/hosts.deny
    fi
  fi
done

查看被封ip

cat /etc/hosts.deny

添加定时任务

vim /etc/crontab

*/59 * * * * sh disable-login.sh

查看crontab运行情况

cat /var/log/cron.log

cat /var/log/cron

posted @ 2023-07-03 09:46  太阳k  阅读(22)  评论(0)    收藏  举报