快捷搜索:   服务器  安全  linux 安全  MYSQL  dedecms

Linux/Cent OS防CC攻击脚本

#!/bin/sh
  cd /var/log/httpd/
  cat access_logawk '{print $1}'sortuniq -csort -n -rhead -n 20 > a
  cp /dev/null access_log
  cp /dev/null error_log
  cp /dev/null limit.sh
  cp /dev/null c
  #awk '{print $2}' aawk -F. '{print $1"."$2"."$3}'sortuniq > b
  cat awhile read num ip
  do
  if [ "$num" -gt "20" ]
  then
  echo $ip >> c
  fi
  done
  cat cawk -F. '{print $1"."$2"."$3}'sortuniq > b
  #cat csortuniq > b
  for i in `cat b`
  #cat bsed 's/\./ /g'while read i1 i2 i3 i4
  do
  if `cat ourip grep $i > /dev/null 2>&1`
  then
  echo "`date` $i" >> test
  else
  echo "iptables -I INPUT -p tcp -dport 80 -s $i.0/24 -j DROP" >> limit.sh
  fi
  done
  sh limit.sh

顶(0)
踩(0)

您可能还会对下面的文章感兴趣:

最新评论