#!/bin/bash
#script info:
# Analysis access_log.abc log for a certain period of time to visit the suffix: "mp3",
# and more than a certain number of requests an IP address, this IP address to iptables to filter to prevent the attack of CC.
cd /usr/local/apache/logs/
tail access_log.abc -n 2000 | awk '{print $1,$7}'| grep -E 'mp3$' | awk '{print $1,$2}' | sort | uniq -c | sort -nr | grep -v -E '127.0' | awk '{if($2!=null && $1>50){print $2}}' > drop_ip.txt
for i in `cat drop_ip.txt`
do
FLAG=0
for ai in `cat drop_ip_all.txt`
do
if [ "$i" = "$ai" ]; then
FLAG=1
break
fi
done
if [ $FLAG -eq 0 ]; then
#echo --new drop ip:$i
#add to iptables
/sbin/iptables -A INPUT -s $i -p tcp --dport 80 -j DROP
fi
done
#select drop_ip.txt append to drop_ip_all.txt
cat drop_ip.txt >> drop_ip_all.txt
#drop_ip_all remove repeat ip
#cat drop_ip_all.txt | sort | uniq > drop_ip_all.txt
分享到:
相关推荐
主要介绍了shell脚本结合iptables防端口扫描的实现,中间使用了inotify-tools工具,需要的朋友可以参考下
linux上防cc攻击,本脚本配置iptables使用,安装cckiller -i,卸载cckiller -U
好用的iptables脚本,包括iptables.rule,iptables.deny,iptables.allow三个文件。
主要介绍了Shell脚本实现监控iptables运行状态,本文直接给出实现代码,需要的朋友可以参考下
主要介绍了Shell脚本配合iptables屏蔽来自某个国家的IP访问,本文利用IPdeny的IP数据,然后用Shell脚本导入iptables实现屏蔽IP访问,需要的朋友可以参考下
最基础的iptables配置脚本,一键加固Linux防火墙
主要介绍了Shell实现的iptables管理脚本分享,本文脚本实现了添加、删除、查看、停止、启动等,需要的朋友可以参考下
主要介绍了一键配置CentOS iptables防火墙Shell脚本分享,可保存到一个脚本文件中,在新安装的CentOS系统时一条命令搞定iptables配置,需要的朋友可以参考下
主要介绍了Shell脚本实现监控iptables规则是否被修改,本文直接给出实现代码,需要的朋友可以参考下
关于iptables防火墙的Shell脚本。一个是其中学习的重点代码,有三个是企业级的应用。有需要的可以看一下啊!
主要介绍了一个简单的防CC攻击Shell脚本分享,主要原理是分析apache或者nginx的访问日志,对大量访问的IP加入iptables进行禁止访问,需要的朋友可以参考下
附件为Debian的iptables服务脚本,脚本有详细描述脚本的用法,主要作用时讲iptables像CentOS一样,注册成Linux服务,方便iptables管理
此iptables脚本基于cgi页面设置,即用户在mac\sourceIP\DestIP\SPortRange\DPortRange\等填写完毕后,提交。 在Linux底下运行的。
可以使用该脚本防护,禁止国外地址访问攻击。 执行过程:把2个文件上传到服务器任意目录。执行:chomod +x myiptables.sh && nohup sh myiptables.sh 等待1分钟后,即刻生效。如果自己懂的,可以编辑脚本修改自己的...
一些bash shell学习的脚本。iptables 防火墙设置脚本,脚本使用技巧等。
这样的话,只能自己用iptables解决了~~~~~~~~~ 关于 ip库 大家可以去 http://www.ipdeny.com/ipblocks/ 下载, 这里有各个国家的~~~ 代码如下: #下载ip库 #wget ...
替补使用Scapy的小型python脚本使用Linux内置的Iptables进行ARP中毒和IP地址重定向,以执行MITM攻击。 目前,它的测试很有限,这意味着当心它不起作用。 另外,这会弄乱您的Iptable配置的规则,因此,如果您关心这种...