[英]Admin panel of the website is being accessed without verification
管理面板对普通用户而言正常工作! 它需要密码才能访问它,但是当我使用acunetix的http编辑器访问它时,它将打开管理面板而不进行验证。 我正在使用一个功能来检查admin是否已登录。如果没有,则重定向到登录页面! 这是功能代码,请帮助我! 谢谢。
-> 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()即可。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.