【问题标题】:Password Authentication - Inconsistent Hashes密码验证 - 哈希不一致
【发布时间】:2013-02-26 02:07:50
【问题描述】:

我正在从 Joomla 1.5 迁移到 WordPress,我的客户不希望用户必须重新注册。所以我正在编写一个 WordPress 插件来匹配用户的密码和 jos_users 表中的内容,然后相应地更新他们在 WordPress 中的信息。

到目前为止,我所阅读的有关 Joomla 密码身份验证的所有内容都指向 getCryptedPassword 函数:

http://docs.joomla.org/API15:JUserHelper/getCryptedPassword

我的插件以同样的方式加密用户输入的内容:

$db_password = explode(':', $query); //what's in the password field of jos_users
$salt = $db_password[1];
$string_to_be_hashed = $user_entered_pass . $salt; 
$test_pass = md5($string_to_be_hashed);
$test_pass = $test_pass . ":" . $salt;
if($test_pass = query){echo "success"}

我已经使用这个测试了 3 个帐户...但只有 2 个正在验证。

具体:md5($password$salt):$salt != 数据库密码值

在数据库中,它不起作用的帐户的密码值似乎使用了相同的加密和相同的格式([md5hash]:salt)。我知道密码是正确的,因为我可以用它登录到客户的网站。

此外,我在整个 Joomla 代码库中搜索了 getCryptedPassword 函数。在所有情况下,都不会发送显式加密方法 - 代码和文档都表明默认使用 md5。

谁能想到我应该寻找替代加密可能性的任何地方?

我不知道还能去哪里看,也不知道为什么这个特定的用户帐户似乎以不同的方式加密。

【问题讨论】:

    标签: authentication joomla md5 joomla1.5


    【解决方案1】:

    在 Joomla 标准中,加密处理如下。

         jimport('joomla.user.helper');
         $salt = JUserHelper::genRandomPassword(32);
         $crypt = JUserHelper::getCryptedPassword($password_choose, $salt);
         $password = $crypt.':'.$salt;
    

    您可以通过将整个 joomla 框架加载到根目录中的单个文件来在单独的文件中运行比较。

    define( '_JEXEC', 1 );
    define('JPATH_BASE', dirname(__FILE__) );//this is when we are in the root
    define( 'DS', DIRECTORY_SEPARATOR );
    
    require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
    require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
    
    $mainframe =& JFactory::getApplication('site');
    $mainframe->initialise();
    

    您也无法解密 Joomla 密码。如果您知道密码(原始文本)然后尝试使用 wordpress 密码 fromat 。

    希望这可能会有所帮助..

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-20
      • 2016-08-27
      • 2015-05-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多