linux cc脚本,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

if [ "$num" -gt "20" ]

then

echo $ip >> c

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

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

done

sh limit.sh

到这里结束

很简单,就不详细解释了

原文链接:https://blog.csdn.net/weixin_36410904/article/details/116625070?ops_request_misc=&request_id=1abb036c7ce94244b4621408ba62209b&biz_id=&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~koosearch~default-3-116625070-null-null.268%5Ev1%5Econtrol&utm_term=cc%E9%98%B2%E6%8A%A4

原创文章,作者:优速盾-小U,如若转载,请注明出处:https://www.cdnb.net/bbs/archives/22304

(0)
上一篇 2024年3月18日
下一篇 2024年3月18日

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

优速盾注册领取大礼包www.cdnb.net
/sitemap.xml