I never said it was just because of security. Also just because you haven't had any problems with people hacking into PunBB forums doesn't mean you never will with a weak hash like that.
Anyway it isn't just because of security that I want to do it for, it's also because I wan to integrate PunBB and customize it for my own needs for a game server that uses MySQL as its information such as users and stats. I want to integrate PunBB into this system by being the forums for the gameserver as well as the user control panel for users to edit their in game characters from.
Basically PunBB would be the master account through the website and then players will be able to link their in-game accounts/create new in-game accounts thorough their master forum account.
Thanks for pointing those functions out, however changing those functions would break the login.php, reister.php, and install.php scripts where password hashing is involved?
Example:
// Login
if (isset($_POST['form_sent']) && empty($action))
{
$form_username = forum_trim($_POST['req_username']);
$form_password = forum_trim($_POST['req_password']);
$save_pass = isset($_POST['save_pass']);
($hook = get_hook('li_login_form_submitted')) ? eval($hook) : null;
// Get user info matching login attempt
$query = array(
'SELECT' => 'u.id, u.group_id, u.password, u.salt',
'FROM' => 'users AS u'
);
if (in_array($db_type, array('mysql', 'mysqli', 'mysql_innodb', 'mysqli_innodb')))
$query['WHERE'] = 'username=\''.$forum_db->escape($form_username).'\'';
else
$query['WHERE'] = 'LOWER(username)=LOWER(\''.$forum_db->escape($form_username).'\')';
($hook = get_hook('li_login_qr_get_login_data')) ? eval($hook) : null;
$result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
list($user_id, $group_id, $db_password_hash, $salt) = $forum_db->fetch_row($result);
$authorized = false;
if (!empty($db_password_hash))
{
$sha1_in_db = (strlen($db_password_hash) == 40) ? true : false;
$form_password_hash = forum_hash($form_password, $salt);
if ($sha1_in_db && $db_password_hash == $form_password_hash)
$authorized = true;
else if ((!$sha1_in_db && $db_password_hash == md5($form_password)) || ($sha1_in_db && $db_password_hash == sha1($form_password)))
{
$authorized = true;
$salt = random_key(12);
$form_password_hash = forum_hash($form_password, $salt);
// There's an old MD5 hash or an unsalted SHA1 hash in the database, so we replace it
// with a randomly generated salt and a new, salted SHA1 hash
$query = array(
'UPDATE' => 'users',
'SET' => 'password=\''.$form_password_hash.'\', salt=\''.$forum_db->escape($salt).'\'',
'WHERE' => 'id='.$user_id
);
($hook = get_hook('li_login_qr_update_user_hash')) ? eval($hook) : null;
$forum_db->query_build($query) or error(__FILE__, __LINE__);
}
}
($hook = get_hook('li_login_pre_auth_message')) ? eval($hook) : null;
if (!$authorized)
$errors[] = sprintf($lang_login['Wrong user/pass']);
If I changed the hashing functions to use Whirlpool it would break the above code completely would it not? I guess with the forum_hash function I would just change the sha1 function to use PHP's hash function. But because the above code checks for md5/sha1. In my situation would it be easier to re-write the login/register/install functions that handle passwords or is there an easier way around this?
Thanks.