首页 > 代码库 > Linux/CentOS防CC攻击脚本

Linux/CentOS防CC攻击脚本

#!/bin/shcd /var/log/httpd/cat access_log|awk {print $1}|sort|uniq -c|sort -n -r|head -n 20 > acp /dev/null access_logcp /dev/null error_logcp /dev/null limit.shcp /dev/null c#awk {print $2} a|awk -F. {print $1"."$2"."$3}|sort|uniq > bcat a|while read num ipdoif [ "$num" -gt "20" ]thenecho $ip >> cfidonecat c|awk -F. {print $1"."$2"."$3}|sort|uniq > b#cat c|sort|uniq > bfor i in `cat b`#cat b|sed s/\./ /g|while read i1 i2 i3 i4doif `cat ourip |grep $i > /dev/null 2>&1`thenecho "`date` $i" >> testelseecho "iptables -I INPUT -p tcp -dport 80 -s $i.0/24 -j DROP" >> limit.shfidone

运行命令:sh limit.sh

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

Linux/CentOS防CC攻击脚本