手机
当前位置:查字典教程网 >脚本专栏 >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脚本分享】相关文章:

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

ftp自动上传脚本分享

linux自动重启tomcat脚本分享

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

shell监控脚本 准备工作分享

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

一个Linux系统安全设置的Shell脚本的分享(适用CentOS)

一个简单的转换输出的shell脚本代码

shell对比文件内容脚本分享

一个下载网页图片的shell脚本

精品推荐
分类导航