2013-12-13 26 views
0

管理面板正常工作正常用戶!它需要密碼來訪問它,但是當我使用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 
+3

您正在將登錄標準**存儲在Cookie **中。捂臉! –

+1

你有沒有做過任何調試來縮小問題的範圍? acunetix工具是否會以某種方式導致頁面在標題調用之前生成輸出,以致它們不再起作用?你可能會考慮沒有函數控制頭文件,而是讓函數返回布爾值來判斷用戶是否是admin,並讓主應用程序邏輯處理重定向。 –

+1

基於Cookie的用戶名和密碼?一點都不好。你最好把你的網站「擱置」,直到你解決這個問題並使用不同的方法。 –

回答

0

我想一個錯誤可能是因爲該腳本將繼續執行,即使
標題(「位置:login.php中」);
刪除它的一種可能的方法是通過die()函數。只需在每個標題重定向之後添加die()即可。