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

    多数CC攻击在web服务器日志中都有相同攻击的特征,我们可以根据这些特征过滤出攻击的ip,利用iptables来阻止


    #!/bin/bash
    #by LinuxEye
    #BLOG: http://blog.linuxeye.com
    OLD_IFS=$IFS
    IFS=$'n'
    not_status=`iptables -nvL | grep "dpt:80" | awk '{print $8}'`
    for status in `cat /usr/local/nginx/logs/wordpress_access.log | grep '特征字符串' | awk '{print $1}'  | sort -n | uniq -c | sort -r -n | grep -v "$not_status"`
    do
        IFS=$OLD_IFS
        NUM=`echo $status | awk '{print $1}'`
        IP=`echo $status | awk '{print $2}'`
        result=`echo "$NUM > 250" | bc`
        if [ $result = 1 ];then
        #   echo IP:$IP is over $NUM, BAN IT!
            /sbin/iptables -I INPUT -p tcp  -s $IP --dport 80 -j DROP
        fi
    done
  • 相关阅读:
    js dom
    js Number string
    jq ajax数据交互
    js date 和 math
    js中英文网页切换
    日常使用
    php求和
    empty()
    时间戳、日期相互转换
    数组转字符串之间相互转换
  • 原文地址:https://www.cnblogs.com/L-H-R-X-hehe/p/3786078.html
Copyright © 2011-2022 走看看