将下面代码插入在module.php文件内:
代码一:
1 2 3 4 5 6 7 8 9 10 11
| <?php function maple\_cc(){ session\_start(); $timestampcc = time(); $cc\_nowtime = $timestampcc; if(isset($\_SESSION\['cc\_lasttime'\])){$cc\_lasttime = $\_SESSION\['cc\_lasttime'\];$cc\_times = $\_SESSION\['cc\_times'\]+1;$\_SESSION\['cc\_times'\] = $cc\_times; }else{$cc\_lasttime = $cc\_nowtime;$cc\_times = 1;$\_SESSION\['cc\_times'\] = $cc\_times;$\_SESSION\['cc\_lasttime'\] = $cc\_lasttime;} if(($cc\_nowtime-$cc\_lasttime)<60){if($cc\_times>=3){header(sprintf('Location:%s', 'http://127.0.0.1'));exit;}//60秒内刷新3次以上可能为cc攻击 }else{$cc\_times = 0;$\_SESSION\['cc\_lasttime'\] = $cc\_nowtime;$\_SESSION\['cc\_times'\] = $cc\_times;} } ?>
|
代码二:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| <?php function maple\_cc(){ //代理IP直接退出 empty($\_SERVER\['HTTP\_VIA'\]) or exit('Access Denied'); //防止快速刷新 session\_start(); $seconds = '60'; //时间段\[秒\] $refresh = '3'; //刷新次数 //设置监控变量 $cur\_time = time(); if(isset($\_SESSION\['last\_time'\])){ $\_SESSION\['refresh\_times'\] += 1; }else{ $\_SESSION\['refresh\_times'\] = 1; $\_SESSION\['last\_time'\] = $cur\_time; } //处理监控结果 if($cur\_time - $\_SESSION\['last\_time'\] < $seconds){ if($\_SESSION\['refresh\_times'\] >= $refresh){ //跳转至攻击者服务器地址 header(sprintf('Location:%s', 'http://127.0.0.1')); exit('Access Denied'); } }else{ $\_SESSION\['refresh\_times'\] = 0; $\_SESSION\['last\_time'\] = $cur\_time; } } ?>
|
然后在head.php文件的require\_once View::getView('module');
后面插入echo maple\_cc();