joomla 密码加密

2022-08-30 13:33:22

我需要访问joomla用户表以从外部php脚本[codeignitor]登录检查。jos_users

joomla存储密码,就像这样

4e9e4bcc5752d6f939aedb42408fd3aa:0vURRbyY8Ea0tlvnTFn7xcKpjTFyn0YT

看起来这不是正常的MD5,所以我不能使用。md5(password)

创建密码的可能方法是什么?

谢谢。


答案 1

Joomla密码是MD5散列的,但密码在散列之前是加盐的。它们存储在数据库中,因为此盐是长度为32个字符的随机字符串。{hash}:{salt}

因此,要创建新的密码哈希,您将要这样做md5($password.$salt)

编辑

好的,所以要检查密码,假设用户输入密码,您将从数据库中检索具有用户名的行。myguymypasswordmyguy

在这一行中,你会发现一个密码说。您将密码哈希和盐分开:4e9e4bcc5752d6f939aedb42408fd3aa:0vURRbyY8Ea0tlvnTFn7xcKpjTFyn0YT

$hashparts = preg_split (':' , $dbpassword);
echo $hashparts[0]; //this is the hash  4e9e4bcc5752d6f939aedb42408fd3aa
echo $hashparts[1]; //this is the salt  0vURRbyY8Ea0tlvnTFn7xcKpjTFyn0YT

现在使用此盐和输入的密码计算哈希值myguy

$userhash = md5($userpassword.$hashparts[1]); // This would be 'mypassword' and the salt used in the original hash

现在,如果此密码相同,则用户已输入正确的密码。$userhash$hashparts[0]


答案 2

从joomla Forum,这就是后面发生的事情:

A. Generate a password
B. Generate a string with 32 random characters
C. Concatenate Password (Step A) and RandomString (Step B)
D. Take md5(Result of Step C)
E. store Step D Result : Step B Result

例:

Generate a password - Let 'testing'
Generate a string of 32 random characters - 'aNs1L5PajsIscupUskaNdPenustelsPe'
Concatenate Password and random string - testingaNs1L5PajsIscupUskaNdPenustelsPe
md5(Step C Result) - 5cf56p85sf15lpyf30c3fd19819p58ly
store step d:step B - 5cf56p85sf15lpyf30c3fd19819p58ly:aNs1L5PajsIscupUskaNdPenustelsPe

你可以在Joomla中找到代码,比如

$salt = JUserHelper::genRandomPassword(32);
$crypt = JUserHelper::getCryptedPassword("testing", $salt);
$password = $crypt . ':' . $salt;

或者我们可以说

password DB field = md5(password + salt) + ":" + salt 

其中盐是随机的32个字符字符串。

谢谢


推荐