基于Strom的日志实时流量分析主动防御(CCFirewall)系统
CC防火墙的架构采用Flume+Kafka+Strom+Zookeeper+Mysql实现,实现异常IP的及时封停功能
service CCfirewall{
string blockipbyiptables(1:string mkey,2: string ip)
string unblockipbyiptables(1:string mkey,2: string ip)
}
目录树
.
└─ccfirewall
├─config //存储防火墙配置信息
└─agent_list //存储Agent列表
└─iptables //使用iptables封锁的站点
├─10.0.0.1
├─10.0.0.1
├─...
config配置
{
"count": "50", //IP计数个数
"if_block": "true", //是否开启封停
"if_warning": "false", //是否开启警告
"threshold_w_secound": "10", //警告阈值秒数
"threshold_secound": "20", //封停阈值秒数
"block_second": "864000", //封停秒数
"ip_white_list": [ //IP白名单
"127.0.0.1",
"211.103.231.10"
],
"url_list": [{ //URL黑名单
"url": "all", //全部
"type": "normal" //normal (精确) 或 after (向后模糊)
}],
"special_rule": { //特殊规则
"reg.gyyx.cn/Login/Async": { //URL
"threshold_w_secound": "100", //警告阈值秒数
"threshold_secound": "300", //封停阈值秒数
"block_second": "86400" //封停秒数
}
}
}
启动Agent
python CCFirewall.py 本机IP
左上方可以设置防火前的配置,保存后实时生效,中上方可以查看当前已经上线的客户端,点击详情可以看到此客户端已经封停的IP格式,右上方可以看到曲线,地图,已经两个计数器信息
左下方显示最新的达到计数器的条目,右下方可以看到异常IP在客户端的封锁状况。