【发布时间】:2013-01-24 18:26:13
【问题描述】:
如果用户在您登录时选中“记住我”框,Joomla 会将密码存储在本地 cookie 中。 然后在成功登录时运行此代码。
if (!in_array(false, $results, true))
{
// Set the remember me cookie if enabled.
if (isset($options['remember']) && $options['remember'])
{
// Create the encryption key, apply extra hardening using the user agent string.
$privateKey = self::getHash(@$_SERVER['HTTP_USER_AGENT']);
$key = new JCryptKey('simple', $privateKey, $privateKey);
$crypt = new JCrypt(new JCryptCipherSimple, $key);
$rcookie = $crypt->encrypt(serialize($credentials));
$lifetime = time() + 365 * 24 * 60 * 60;
// Use domain and path set in config for cookie if it exists.
$cookie_domain = $this->getCfg('cookie_domain', '');
$cookie_path = $this->getCfg('cookie_path', '/');
setcookie(self::getHash('JLOGIN_REMEMBER'), $rcookie, $lifetime, $cookie_path, $cookie_domain);
}
return true;
}
注意 $credentials 有一个 ['password'] 键值,它确实包含登录表单中的密码。 因此,如果这是加密的,那么系统必须通过两种方式来反转它并从 cookie 中填充密码字段?
我的问题是我该怎么做..真正的明文密码没有保存在用户表上,而是一个 MD5 散列密码。所以joomla一定是通过这个cookie才能保存密码的。
【问题讨论】: