zoukankan      html  css  js  c++  java
  • Linux/CentOS防CC攻击脚本

    #!/bin/sh
    cd /var/log/httpd/
    cat access_log|awk '{print $1}'|sort|uniq -c|sort -n -r|head -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}' a|awk -F. '{print $1"."$2"."$3}'|sort|uniq > b
    cat a|while read num ip
    do
    if [ "$num" -gt "20" ]
    then
    echo $ip >> c
    fi
    done
    cat c|awk -F. '{print $1"."$2"."$3}'|sort|uniq > b
    #cat c|sort|uniq > b
    for i in `cat b`
    #cat b|sed '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

    转自:http://www.lvtao.net/shell/478.html

  • 相关阅读:
    收藏的日历js算法 很实用
    autofac system.core 的版本问题
    and 组件ui等
    vc相关
    live传264流
    录转rtsphan
    ndk errno
    cpp all记录
    and 录音等+live等
    cmake
  • 原文地址:https://www.cnblogs.com/wangxusummer/p/4236328.html
Copyright © 2011-2022 走看看