网站的管理面板在未经验证的情况下被访问


Admin panel of the website is being accessed without verification

管理面板对普通用户来说工作正常!访问它需要密码,但当我使用acunetix的http编辑器访问它时,它会在没有验证的情况下打开管理面板。我正在使用一个功能来检查管理员是否登录。如果没有,则重定向到登录页面!这是函数代码,请帮我!谢谢

-->full()功能为mysqli_real_escape_string(htmlspecialchar());

-->acunetix是一个很好的应用程序漏洞测试工具。

function admin_check() {
global $users, $mysqli;
if(isset($_COOKIE['username'])){
    $username = full($_COOKIE['username']);
    $password = full($_COOKIE['password']);
    $id = full($_COOKIE['id']);
    if(is_numeric($id)){
        $id = $id;
            if($id < 0){
                $id = (-1)*$id;
            }
    }
    else {
        $id = 10;
    }

    $query = "SELECT * FROM $users WHERE username = '{$username}' and password = '{$password}' and id = $id ";
    $query_process = mysqli_query($mysqli, $query);
        if(!$query_process){
            die_message("There was some error checking admin login");
        }
    $check_rows = mysqli_num_rows($query_process);
    if($check_rows != 1){
        header("location: login.php");
    }
    while($rows = mysqli_fetch_assoc($query_process)){
        $admin_role = $rows['admin_role'];
    }
    if($admin_role != 1){
        header("location: logout.php");
    }

}//end of first if
else {

    header("location: login.php");
}
}// end of function

我想一个错误可能是因为即使在
之后脚本仍在执行header("location:login.php")
移除它的一种可能方法是使用die()函数。只需在每次进行头重定向后添加die()。

相关文章: