Use PHPBB2 Login Credentials in my site

白昼怎懂夜的黑 提交于 2019-12-04 14:54:04
random

If a user is logged into PHPBB, there's a good chance, though not always likely, that they will then have a cookie that you can read and help with checking who's who against the database.

In this case, you'll want to break the crumbs of the cookie below:

$_COOKIE["phpbb2mysql_data"]

Let's use an example and blow it out to find the data we need to query against the database. Below is the chunk found in the above cookie:

a:2:{s:11:"autologinid";s:0:"";s:6:"userid";s:1:"3";}

For this, you'll want to go in and extract that "3" which happens to correspond to the logged in PHPBB user.

Unserialize that data to yank that user_id out:

 $goo = unserialize($_COOKIE["phpbb2mysql_data"]);
 $extracted_id = $goo["userid"];

(Thanks to epochwolf on pointing out the above serialized form of that cookie)

That number will be good to run against the database to check out which group the member belongs to. And you would run the check against the phpbb_user_group table (if you had phpbb_ as the prefix of your forum tables.)

If you didn't want to keep track of the group IDs from the database, then you will need to do some kind of join and test against the name. Maybe something like this:

SELECT pug.user_id FROM phpbb_user_group pug 
 LEFT JOIN phpbb_groups g 
 ON pug.group_id=g.group_id
 WHERE pug.user_id='$extracted_id'
 AND g.group_name='Foo';

If you can pull a row out of that, then you've found yourself a logged in user who belongs to that Foo group.

Use PHPBB2's user table and it's login and permissions code in the other pages. It's dirty but it works.

By using PHPBB2's code, I mean:

Dig into PHPBB2's code, figure out how PHPBB2 authenticates users, and copy the relevant chunks of code. If PHPBB2 is decently structured, you may be able to just include a couple of files from within PHPBB2 and use them without a major hack job. If it's not nicely structured, it's going to be dirty and ugly.

Don't forgot to test your new secured additions to your website! Make sure that you get the hacks right.

You can use phpBB 2's user and group tables directly. As I recall, the password column is just an md5() of the actual password.

This trick no longer works in phpBB3, as the password is (finally) salted.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!