Webmasterpals  

Go Back   Webmasterpals > Webmasterpals Network > PHP Login Script v2.0

Reply
 
Thread Tools Display Modes
  #1  
Old 02-16-2012, 10:13 PM
Rockroxx Rockroxx is offline
Junior Member
 
Join Date: Feb 2012
Posts: 3
Rockroxx is on a distinguished road
Cool Login from link in mail

Hey i've been stuck on this one for quite sometime now and just cant seem to get it to work. I made a mail that sends the users username and password(hash) in a link to them but i cant seem to get it to work. ive gotten around the salt check in login but dbc.php kicks em back out again in the security check for cookies. So i was wondering if there was a way around this or is it impossible to login from a link in mail with this loginscript?
Reply With Quote

DirTimes Web Directory - Premium General web directory of quality websites. Submit today!

Premium Web Directory - Premium general web directory. Submit your site for Inclusion

  #2  
Old 02-16-2012, 10:55 PM
Wombat76 Wombat76 is offline
Senior Member
 
Join Date: Mar 2011
Location: UK
Posts: 1,049
Wombat76 has a reputation beyond reputeWombat76 has a reputation beyond reputeWombat76 has a reputation beyond reputeWombat76 has a reputation beyond reputeWombat76 has a reputation beyond reputeWombat76 has a reputation beyond reputeWombat76 has a reputation beyond reputeWombat76 has a reputation beyond reputeWombat76 has a reputation beyond reputeWombat76 has a reputation beyond reputeWombat76 has a reputation beyond repute
Default Re: Login from link in mail

It would need a bit of rewriting of the script to log in that way, as normally a user would enter their password in plain text in the login form. If you're trying to log in using the hashed password then the password checking logic would need to be changed.

It would mean a straight comparison of the hashed password stored in the link with the hashed password stored in the database. That bypasses much of the security of the script, apart from the security implications of transmitting the hashed password from the email together with the username: the only 2 pieces of information that a hacker would need to successfully log in as that user. Unless you're using SSL.

I can't see that logging in that way would make dbc.php kick the user because of cookie checking. That must be a different issue. Don't forget to point your browser at logout.php in between test runs to clear the Session and Cookies. What error is dbc.php throwing up?
Reply With Quote
  #3  
Old 02-17-2012, 12:10 PM
Rockroxx Rockroxx is offline
Junior Member
 
Join Date: Feb 2012
Posts: 3
Rockroxx is on a distinguished road
Default Re: Login from link in mail

Quote:
Originally Posted by Wombat76 View Post
It would need a bit of rewriting of the script to log in that way, as normally a user would enter their password in plain text in the login form. If you're trying to log in using the hashed password then the password checking logic would need to be changed.
I got around that using a if and sending a random generated code with the mail which is deleted after login.

Quote:
Originally Posted by Wombat76 View Post
It would mean a straight comparison of the hashed password stored in the link with the hashed password stored in the database. That bypasses much of the security of the script, apart from the security implications of transmitting the hashed password from the email together with the username: the only 2 pieces of information that a hacker would need to successfully log in as that user. Unless you're using SSL.
Thats certainly true but if the mail is hacked isnt the person screwed anyway because he could do a forget login to change the pass.

Quote:
Originally Posted by Wombat76 View Post
I can't see that logging in that way would make dbc.php kick the user because of cookie checking. That must be a different issue. Don't forget to point your browser at logout.php in between test runs to clear the Session and Cookies. What error is dbc.php throwing up?
Its the else header thats being activated.
PHP Code:
     if( !empty($ckey) && is_numeric($_COOKIE['user_id']) && isUserID($_COOKIE['user_name']) && $_COOKIE['user_key'] == sha1($ckey)  ) {
           
session_regenerate_id(); //against session fixation attacks.
    
          
$_SESSION['user_id'] = $_COOKIE['user_id'];
          
$_SESSION['user_name'] = $_COOKIE['user_name'];
        
/* query user level from database instead of storing in cookies */    
          
list($user_level) = mysql_fetch_row(mysql_query("select user_level from users where id='$_SESSION[user_id]'"));

          
$_SESSION['user_level'] = $user_level;
          
$_SESSION['HTTP_USER_AGENT'] = md5($_SERVER['HTTP_USER_AGENT']);
          
       } else {
       
logout();
       }

  } else {
    
header("Location: login.php");
    exit();
    } 
Reply With Quote
  #4  
Old 02-17-2012, 05:26 PM
Wombat76 Wombat76 is offline
Senior Member
 
Join Date: Mar 2011
Location: UK
Posts: 1,049
Wombat76 has a reputation beyond reputeWombat76 has a reputation beyond reputeWombat76 has a reputation beyond reputeWombat76 has a reputation beyond reputeWombat76 has a reputation beyond reputeWombat76 has a reputation beyond reputeWombat76 has a reputation beyond reputeWombat76 has a reputation beyond reputeWombat76 has a reputation beyond reputeWombat76 has a reputation beyond reputeWombat76 has a reputation beyond repute
Default Re: Login from link in mail

Well, just going on what you've said about altering the password checking part of the script, I'd say the culprit for failing the check would be this part:

Code:
&& $_COOKIE['user_key'] == sha1($ckey)
If you echo these 2 values to the screen, what do you get? Do they match? If not, what's the difference?

If they do match, then you need to find out which of the conditions is failing. Display the variable values (use die($_COOKIE['user_key']."<br />".sha1($ckey)); or something so your values don't get overwritten by your page) and see if they are what you would expect.
Reply With Quote
  #5  
Old 02-17-2012, 06:19 PM
Rockroxx Rockroxx is offline
Junior Member
 
Join Date: Feb 2012
Posts: 3
Rockroxx is on a distinguished road
Default Re: Login from link in mail

Hey i got it working. I ended up duplicating most of the code in login.php dependent if my _get was set and removing the code i didn't need still it was a very weird error.

Thank you for your effort.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT. The time now is 09:21 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Webmasterpals.com (c) 2008 - All Rights Reserved