手机
当前位置:查字典教程网 >脚本专栏 >linuxshell >一个简单的防CC攻击Shell脚本分享
一个简单的防CC攻击Shell脚本分享
摘要:实现代码:复制代码代码如下:#!/bin/shcd/var/log/httpd/cataccess_log|awk'{print$1}'|s...

实现代码:

复制代码 代码如下:#!/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,这样就会把访问量过高的IP加入防火墙,并禁止访问

【一个简单的防CC攻击Shell脚本分享】相关文章:

25个好用的Shell脚本常用命令分享

一个测试下载速度的shell脚本

获取同一网段下所有机器MAC地址的shell脚本

图片批量压缩大小脚本分享

分享个简易版Linux服务器初始化Shell脚本

自动杀掉占用较多CPU资源的Shell脚本

备份网站内容的shell脚本代码

一个用了统计CPU 内存 硬盘 使用率的shell脚本

简单的Linux查找后门思路和shell脚本分享

自动生成linux网卡配置脚本分享

精品推荐
分类导航