如何将文本转换为 phpbb 哈希?

发布于 2024-10-21 20:14:08 字数 896 浏览 2 评论 0原文

我正在尝试将测试密码 (testing4) 转换为 phpbb3 哈希值。这是我尝试过的代码:

<?php
/** 
*
* @package phpBB3
* @version $Id: v3_dbal.xml 44 2007-07-25 11:06:55Z smithy_dll $
* @copyright (c) 2005 phpBB Group 
* @license http://opensource.org/licenses/gpl-license.php GNU Public License 
*
*/

/**
* @ignore
*/
define('IN_PHPBB', true);
include ("functions_phpbb.php");

$data['new_password'] = "testing4";

$user_row = array(
    'user_password' => phpbb_hash($data['new_password'])
    );

$hash = $user_row['user_password'];

echo $hash;
?>

这也不起作用:

$pass = "testing4";
$hash = phpbb_hash($pass);

两次我都收到以下错误消息:

Fatal error: Call to a member function sql_escape() on a non-object in /home/a8544020/public_html/Pass/functions_phpbb.php on line 149

我在两个不同的主机上尝试过,但没有任何运气。否则是否有一个在线服务可以简单地将文本转换为哈希值?

提前致谢

I am trying to convert a test password (testing4) into a phpbb3 hash. This is the code I have tried:

<?php
/** 
*
* @package phpBB3
* @version $Id: v3_dbal.xml 44 2007-07-25 11:06:55Z smithy_dll $
* @copyright (c) 2005 phpBB Group 
* @license http://opensource.org/licenses/gpl-license.php GNU Public License 
*
*/

/**
* @ignore
*/
define('IN_PHPBB', true);
include ("functions_phpbb.php");

$data['new_password'] = "testing4";

$user_row = array(
    'user_password' => phpbb_hash($data['new_password'])
    );

$hash = $user_row['user_password'];

echo $hash;
?>

and this doesn't work either:

$pass = "testing4";
$hash = phpbb_hash($pass);

Both times I recieve the following error message:

Fatal error: Call to a member function sql_escape() on a non-object in /home/a8544020/public_html/Pass/functions_phpbb.php on line 149

I have tried it on 2 different hosts without any luck. Otherwise is there an online service that simply converts text to the hash?

Thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

残龙傲雪 2024-10-28 20:14:08

我假设您的 functions_phpbb.php 文件是 phpBB3 包的 includes/functions.php 文件的副本。

现在,您收到此错误的原因是 phpbb_hash 函数使用 phpBB unique_id 函数来获取熵,这取决于数据库连接(以更改并保留熵)每个请求)。

有两种方法可以解决这个问题。

a) 包含 phpBB 的 common.php,它将引导您的 phpBB 代码(包括数据库连接、错误处理程序等)。

b) phpBB3 使用 phpass 进行哈希处理。我建议您只需下载独立的 phpass 包并使用它来生成哈希值。

小警告:phpBB3 将哈希标识符从 '$P$' 更改为 '$H$' (不要问我为什么),所以你必须将这一行更改

$output = '$P

$output = '$H

:由于选项 a) 增加了相当多的开销,并且您可能只想使用散列函数,我建议选项 b)。

;


:由于选项 a) 增加了相当多的开销,并且您可能只想使用散列函数,我建议选项 b)。

;

:由于选项 a) 增加了相当多的开销,并且您可能只想使用散列函数,我建议选项 b)。

;

:由于选项 a) 增加了相当多的开销,并且您可能只想使用散列函数,我建议选项 b)。

I'm assuming your functions_phpbb.php file is a copy of the includes/functions.php file of the phpBB3 package.

Now, the reason you are getting this error is because the phpbb_hash function uses the phpBB unique_id function for entropy, which depends on a database connection (to change and persist the entropy on every request).

There's two ways to fix this.

a) include phpBB's common.php, which will bootstrap your code for phpBB (including db connection, error handlers, etc).

b) phpBB3 uses phpass for hashing. I suggest you simply download the standalone phpass package and use that to generate the hash.

Little caveat: phpBB3 changes the hash identifier from '$P$' to '$H$' (don't ask me why), so you will have to change this line:

$output = '$P

to:

$output = '$H

Since option a) adds quite some overhead, and you are probably only wanting to use the hashing functions, I'd suggest option b).

;

to:


Since option a) adds quite some overhead, and you are probably only wanting to use the hashing functions, I'd suggest option b).

;

Since option a) adds quite some overhead, and you are probably only wanting to use the hashing functions, I'd suggest option b).

;

to:

Since option a) adds quite some overhead, and you are probably only wanting to use the hashing functions, I'd suggest option b).

瑾夏年华 2024-10-28 20:14:08

也许是另一种方式。我使用了以下库:http://www.openwall.com/phpass/工作时,您必须更改生成的 HASH 的前 3 个字符:

$P$

$H$

在 phpbb 中使用

Maybe the other way. I have used the library from: http://www.openwall.com/phpass/ To make it working, you must change first 3 characters of generated HASH:

$P$

to

$H$

used in phpbb

獨角戲 2024-10-28 20:14:08

我想知道为什么他们通过 SQL 转义函数运行密码哈希。但你可以简单地尝试将该函数定义为虚拟函数:

function sql_escape($str) { return $str; }

I wonder why they run a password hash through a SQL escaping function.. but you could simply try defining that function as a dummy:

function sql_escape($str) { return $str; }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文