MyBB password hash
#1

I'm trying to make a MyBB hash generator but it keeps giving me wrong hashes and cancers.

My function:
pawn Код:
stock HashMyBBPassword(string[], salt[])
{
    new string2[48];
    format(string2, sizeof(string2), "%s%s", MD5_Hash(salt), string);
    string2 = MD5_Hash(string2);
    return string2;
}
Original function (PHP):
PHP код:
function salt_password($password$salt)
{
    return 
md5(md5($salt).$password);

What am I doing wrong?
Reply
#2

Still waiting for help.
Reply
#3

MyBB code:
PHP код:
function generate_salt()
{
    return 
random_str(8);
}
function 
salt_password($password$salt)
{
    return 
md5(md5($salt).$password);
}

$pass $mybb->input['password'];

$md5pass md5($pass);
$salt generate_salt();

$salted_pass salt_password($md5pass$salt); 
As you can see, $md5pass, which contains a MD5 hash, gets passed to the function salt_password.

So there's your mistake.
Reply
#4

http://community.mybb.com/thread-124386.html
Reply
#5

Quote:
Originally Posted by AndreT
Посмотреть сообщение
MyBB code:
PHP код:
function generate_salt()
{
    return 
random_str(8);
}
function 
salt_password($password$salt)
{
    return 
md5(md5($salt).$password);
}
$pass $mybb->input['password'];
$md5pass md5($pass);
$salt generate_salt();
$salted_pass salt_password($md5pass$salt); 
As you can see, $md5pass, which contains a MD5 hash, gets passed to the function salt_password.

So there's your mistake.
Oh, didn't see that part. I'll test it, thanks.

Also thanks to Smally.
Reply
#6

Idk... I'm still getting wrong hashes.

pawn Код:
stock HashMyBBPassword(string[], salt[])
{
    new string2[96];
    format(string2, sizeof(string2), "%s%s", MD5_Hash(salt), MD5_Hash(string));
    string2 = MD5_Hash(string2);
    return string2;
}
Reply
#7

Bump.
Reply
#8

problem is MD5_Hash always return a upper string (:

check this code to see what's different:
pawn Код:
// old hash
stock HashMyBBPassword(string[], salt[])
{
    new string2[96];
    format(string2, sizeof(string2), "%s%s", MD5_Hash(salt), MD5_Hash(string));
    string2 = MD5_Hash(string2);
    return string2;
}

//new hash
stock HashMyBBPassword2(string[], salt[])
{
    new string2[96];
    format(string2, sizeof(string2), "%s%s", MD5_Hash(salt), MD5_Hash(string));
    for(new i=0; i < sizeof(string2); i++)
    {
        string2[i] = tolower(string2[i]);
    }
    string2 = MD5_Hash(string2);
    return string2;
}

public OnGameModeInit()
{
    new string[128];
    format(string, sizeof(string), "%s", HashMyBBPassword("password", "salt"));
    printf("old hash : %s", string);
    format(string, sizeof(string), "%s", HashMyBBPassword2("password", "salt"));
    printf("new hash : %s", string);
    return 1;
}
Reply
#9

YEAH! Working, repping you asap. I didn't think about case.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)