To fix a problem, we should know the problem first.
So after a glance on the original "admin.php" file, the problem is the authentication process, about when a user is considered as not logged in, and when a user is considered as logged in and is considered as a valid admin and therefore display normal admin menu, etc.
The main problem is the admin script is only check the cookie value ($_COOKIE['admin'])
If the script recognizes "admin" cookie, and its value is "1", you are considered as logged in.
Here is the original troublesome code
So, if somewhat a user has an "admin" cookie, with "1" as the value, he is considered as the admin, no matter what (although he does not know the admin password & does not log in by the normal admin login form).PHP Code:if ((empty($_COOKIE['admin']) or $_COOKIE['admin']==0) and $access_flag==0){
$l_d=1;
if (isset($_POST['password']) and $_POST['password']==$admin_pass){
setcookie('admin','1');
$access_flag=1;
}
It can be performed by several ways, but i can not mention here.
So quickest fix is use session ($_SESSION) instead of cookie ($_COOKIE).
Because cookie is client side, anything inside cookie can be modified ( if the user knows how to)
But the session is somewhat "server side".
I've seen chetan's code.
At a glance, you modified the authorization code by checking the "admin" cookie value, and compare it with md5 hashed admin password.
Which means the attacker can not use simple "1" as the value,
but he should guess the admin password too![]()


LinkBack URL
About LinkBacks
)
Reply With Quote



Bookmarks