![]() |
Secure BCrypt Password Hashing
1 Attachment(s)
This is a 'howto' for using bcrypt for your password hashs, instead of the default vBulletin one, which is highly insecure.
Remember, backup your database before doing this!! Quote:
More information about BCrypt can be found here: http://codahale.com/how-to-safely-store-a-password/ - http://phpmaster.com/why-you-should-...red-passwords/ tl;dr: if you want to be moar secure, use bcrypt. " How much slower is bcrypt than, say, MD5? Depends on the work factor. Using a work factor of 12, bcrypt hashes the password 'password' in about 0.3 seconds on my laptop. MD5, on the other hand, takes less than a nanosecond." BEFORE YOU DO THIS, PLEASE CREATE A .PHP FILE WITH THIS IN IT Code:
<?php /includes/functions.php Add this to the end, just before the footer message. Code:
/** includes/class_dm_user.php Now.. Find this: Code:
if ($password == md5(md5($this->fetch_field('username')) . $salt)) Code:
if ($password == $this->hash_password($this->fetch_field('username'), $salt)) Then, on the same file, replace this: Code:
return md5($password . $salt); Code:
//No need to md5($password), since it is already md5'd above. includes/functions_login.php Find this: Code:
$vbulletin->userinfo['password'] != iif($password AND !$md5password, md5(md5($password) . $vbulletin->userinfo['salt']), '') AND Code:
$vbulletin->userinfo['password'] != iif($password AND !$md5password, hash_password_bcrypt(md5(md5($password) . $vbulletin->userinfo['salt']), $vbulletin->userinfo['salt']), '') AND So effectively, we are hashing the password using the normal vBulletin way of md5(md5($password) . $vbulletin->userinfo['salt']) however after doing that, we then run hash_password_bcrypt() around it. By doing it this way, we can now convert our old hashes to the new bcrypt method. Create a file called "convert.php", with the contents: Code:
<?php |
Thank you for the fast reply! I love you man!
|
After I applied the changes I am unable to login, it says my password is incorrect :(
EDIT Stupid me, there was an extra parenthesis in functions_login.php I will respond if it works in a bit! EDIT No it does not work :( vBulletin v4.2.0 |
excellent.
|
Quote:
|
Since your new algorithm basically encrypts the original hash, I think you could actually write a function to go through and convert all the passwords so that existing members could log in without having to change their pw. But of course when it's uninstalled there's nothing else to be done but have everyone change their pw. Either way you might want to add a warning in the description.
Anyway, nice mod, I was thinking about something like this a while back but never got around to it. |
Quote:
And yeah, it can only go 'one way'. I'll add a disclaimer to the OP |
First off, thanks for trying to make vBulletin more secure. BCrypt is an excellent algorithm and much much better than md5. From my latest research, it's the industry standard.
However - you are going to all this work to properly store the password using BCrypt, but then you md5 it. As soon as you md5 it, you have lost all of that security :(. Second - and this is just a future suggestion, you could have the system detect which password hash they are using, and check accordingly. This way you can update peoples passwords to the new system whenever they change their password (and probably mass-email everyone suggesting they do). but still authenticate the old hashes properly. Unfortunately the way it's implemented, nobody will want to use this except for starting new boards. It is possible. Cheers |
Quote:
I'm currently crteating the 'auto-bcrypt' pwd encrypter for it. it'll be done soon. |
No - once you md5 it, you have lost all of the security. You are still succeptable to md5 collissions which is md5's biggset weakness.
|
All times are GMT. The time now is 12:16 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|