信息

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(); ?>
🌟-阅读剩余-🌟
版权声明 1、本网站名称:安鹿轩
2、本站永久网址:https://www.anlu1314.com
3、本网站的文章部分内容可能来源于网络,仅供大家学习与参考,如有侵权,请联系在本站私信站长进行删除处理。
4、本站一切资源不代表本站立场,并不代表本站赞同其观点和对其真实性负责。
5、本站一律禁止以任何方式发布或转载任何违法的相关信息,访客发现请向站长举报
6、本站资源大多存储在云盘,如发现链接失效,请联系我们我们会第一时间更新。

THE END