EMLOG拓展|EMLOG簡易防CC攻擊代碼

EMLOG簡易防CC攻擊代碼

EMLOG沒有自己的防護措施,找了一款PHP代碼修改成EMLOG的。也就湊活用吧。

源代碼

<?php
//代理IP直接退出
empty($_SERVER['HTTP_VIA']) or exit('Access Denied');
//防止快速刷新
session_start();
$seconds = '3'; //時間段[秒]
$refresh = '5'; //刷新次數
//設置監控變量
$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;
}
?>

EMLOG版

將下面代碼插入在module.php文件內

<?php
function aeink_cc(){
//代理IP直接退出
empty($_SERVER['HTTP_VIA']) or exit('Access Denied');
//防止快速刷新
session_start();
$seconds = '3'; //時間段[秒]
$refresh = '5'; //刷新次數
//設置監控變量
$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;
}
}
?>

然后在header.php文件 <html>前插入<?php echo aeink_cc(); ?>

大功告成,快去試試吧~

轉載請注明出處 AE博客|墨淵 ? EMLOG拓展|EMLOG簡易防CC攻擊代碼

發表評論

路人甲

網友評論(0)