Register Members List Search Today's Posts Mark Forums Read

Reply
 
Article Options
Changing vBulletin 4 its password hashing to use BCrypt
Dave
Join Date: Jun 2010
Posts: 2,015

Melbourne, FL
by Dave Dave is offline 03 Oct 2014
Rating: (3 votes - 3.67 average)

This article has also been published at http://blog.technidev.com/changing-v...to-use-bcrypt/, my personal blog about security, exploits, development, etc.

Introduction
By default, vBulletin uses a very basic and easy to crack password hashing:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

With the GPU's of these days, it may be a matter of minutes to crack a password using a dictionary attack/rainbow tables.

Fortunately, it's very easy to change the password hashing. I will change the password hashing of vBulletin to use BCrypt, a much better algorithm. The password hashing will look like this at the end of this guide:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


Requirements for this guide:
- Access to the FTP or permission to edit .php files on the server.
- PHP version of 5.5+ (we make use of the password_hash function)
- You must update all of the passwords in the current database.
- vBulletin 4.2.2 (this modification has been made on 4.2.2)
- Database access in the form of SSH/PHPMyAdmin or any other database manager tool

Create a backup of the files we are going to edit first so you can always restore it in case it goes wrong!

Step 1: modify password column type

First things first, we have to modify the type of the password column in the user table.
You can either do this in PHPMyAdmin by changing it to char(60) or by executing the following query:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


Step 2: edit /includes/functions_login.php

Now let's modify the verify_authentication function in the /includes/functions_login.php file.
Look for:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

And replace it with:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

This function will, as the function name describes, very the authentication.


Step 3: edit /includes/class_dm_user.php

This file contains the verify_password and hash_password function which must be changed as well.
Look for the hash_password function:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

And replace it with:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Now look for the verify_password function:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

And replace it with:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

We have to modify this function since there's a check to see if the password matches the current username, which is not allowed by default.


Step 4: update all passwords in the user table

The only downside of this is that we have to update all passwords in the database.
But no worries, no one will have to change or update their password to make this work since we use the old password hashing in BCrypt.

Please make a backup of your database or user table before doing this so you can restore it in case it does not work as intended!

Create a file in the root of your forum and name it something like update_passwords.php. Contents of the file:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

This will update all of the current password hashes to use BCrypt.
In case the script timed out, just run it again or change the script execution timeout.


Step 5: verifying functionality

Now try to login onto your forum and see if that works, in case you get an incorrect username/password error, it means you did something wrong in this guide.
In case it works, try to update your password and relog to see if that part works as well.

I tested the login, registration, remember me checkbox and changing password function on a local test forum which seemed to work fine.

Support will be provided here (comment box). I'll answer the most basic questions here at vbulletin.org.

Last edited by Dave; 07 Nov 2015 at 18:10..
Views: 3796
Reply With Quote
Comments
  #2  
Old 09 Nov 2014, 08:29
AndrewSimm's Avatar
AndrewSimm AndrewSimm is offline
 
Join Date: Sep 2006
Has anyone tried this?
Reply With Quote
  #3  
Old 09 Nov 2014, 10:16
Dave Dave is offline
 
Join Date: Jun 2010
Real name: Dave
Yeah I've done this on my local vBulletin testing forum.
__________________
https://technidev.com - security, development, exploits, vBulletin
dave[at]technidev[dot]com

Contact me for custom vBulletin 3/4 work & server/website management.
Reply With Quote
  #4  
Old 09 Nov 2014, 15:38
nerbert nerbert is offline
 
Join Date: May 2008
A problem I see here is that the browser still transmits the password with the md5 hashes and an eavesdropper can still intercept them and crack them. All your advanced hashing happens on the server after it receives the md5 hashes. What you could do is replace the original vbulletin_md5.js file with one that does the md5 and bcrypt hashing . Then the password is better encrypted in transit. I think you would have to use vBulletin's original code and then add more code (available as open source) to further encrypt both versions of the hashes. Once this is done you could skip the PHP code that bcrypt hashes on the server

There's a further thing to consider though, it seems to me that there's a problem with vbulletin_md5.js and older (and maybe newer) versions of IE, so it doesn't encrypt at all. You'll have to check this out with various browsers. There's open source md5 javascript available and you could copy the vbulletin code that handles the difference between vb_login_md5password and vb_login_md5password_utf into the new md5 algorithm.

Last edited by nerbert; 09 Nov 2014 at 16:25.
Reply With Quote
  #5  
Old 09 Nov 2014, 16:08
Dave Dave is offline
 
Join Date: Jun 2010
Real name: Dave
Originally Posted by nerbert View Post
A problem I see here is that the browser still transmits the password with the md5 hashes and an eavesdropper can still intercept them and crack them. All your advanced hashing happens on the server after it receives the md5 hashes. What you could do is replace the original vbulletin_md5.js file with one that does the md5 and bcrypt hashing . Then the password is better encrypted in transit. I think you would have to use vBulletin's original code and then add more code (available as open source) to further encrypt both versions of the hashes. Once this is done you could skip the PHP code that bcrypt hashes on the server

There's a further thing to consider though, it seems to me that there's a problem with vbulletin_md5.js and older (and maybe newer) versions of IE, so it don't encrypt at all. You'll have to check this out with various browsers. There's open source md5 javascript available and you could copy the vbulletin code that handles the difference between vb_login_md5password and vb_login_md5password_utf into the new md5 algorithm.
True, but this will be more difficult (because of cross-browser support if you want to implement other hashing methods with JavaScript). Also this is a reason why you should use HTTPS.
__________________
https://technidev.com - security, development, exploits, vBulletin
dave[at]technidev[dot]com

Contact me for custom vBulletin 3/4 work & server/website management.
Reply With Quote
  #6  
Old 09 Nov 2014, 21:45
Zachery's Avatar
Zachery Zachery is offline
 
Join Date: Jul 2002
Real name: Zachery Woods
If someone can get an MITM attack, you've got a lot bigger problems than the password being transmitted as md5 or plaintext.
__________________
Looking for ImpEx?
Reply With Quote
  #7  
Old 11 Nov 2014, 05:00
AndrewSimm's Avatar
AndrewSimm AndrewSimm is offline
 
Join Date: Sep 2006
Dave could this be written into a mod? It would help when IB updates vbulletin as I wouldn't have to redo the edits.
Reply With Quote
  #8  
Old 11 Nov 2014, 09:19
Dave Dave is offline
 
Join Date: Jun 2010
Real name: Dave
Originally Posted by AndrewSimm View Post
Dave could this be written into a mod? It would help when IB updates vbulletin as I wouldn't have to redo the edits.
Nope, this requires modifications in files which can not be done in hooks.
__________________
https://technidev.com - security, development, exploits, vBulletin
dave[at]technidev[dot]com

Contact me for custom vBulletin 3/4 work & server/website management.
Reply With Quote
Reply

Similar Article
Article Author Type Replies Last Post
Mini Mods Secure BCrypt Password Hashing MegaManSec vBulletin 4.x Add-ons 27 07 Jan 2016 14:52



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Article Options

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

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


New To Site? Need Help?

All times are GMT. The time now is 22:26.

Layout Options | Width: Wide Color: