Manipulating Databases to Create Admin Logins

Manipulating Databases to Create Admin Logins

by Vardaan S. Rathore -
Number of replies: 5
Say we have two Moodle databases. We’ll call these databases, Database A and Database B.
Now, Database A is just a copy of the database. While Database B happens to be a database inside a Moodle site, let’s call this site, old site


Let's assume, we have been assigned the task to login into Database A and perform some testing. However, we do not have any credentials for this database. Luckily, both the databases have an admin account with the same username - admin. 

To tackle this problem, here’s what we are going to do:

  1. Import Database A into a fresh Moodle install, let’s call this Moodle site, new site

  2. Access Database B and find the admin user and their encrypted password. Copy this encrypted password

  3. Access Database B and find the admin user and replace the encrypted password with the password you got from Database A

  4. Clear all browser cache and login with the credentials you used to login with the same admin credentials you used to login with in your old site.


Sorry to drag this out for so long, I really wanted to know whether someone has tried this out?

Average of ratings: -
In reply to Vardaan S. Rathore

Re: Manipulating Databases to Create Admin Logins

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Didn't understand the issue. I assume you have specific reason not to follow Forgotten password procedureyoursite/login/forgot_password.php. Then why not https://docs.moodle.org/en/Administration_via_command_line#Reset_user_password ?

Transplanting the password hash should work, unless there are no complications with https://docs.moodle.org/en/Password_salting and the like.
In reply to Visvanath Ratnaweera

Re: Manipulating Databases to Create Admin Logins

by Vardaan S. Rathore -
Hello :D

This is not any issue. I was just hoping to try something out.

Thank you for your inputs :D
In reply to Visvanath Ratnaweera

Re: Manipulating Databases to Create Admin Logins

by Vardaan S. Rathore -
Hello :D

This is not any issue. I was just hoping to try something out.

Thank you for your inputs :D
In reply to Vardaan S. Rathore

Re: Manipulating Databases to Create Admin Logins

by Vardaan S. Rathore -
*correction*

In point (3) Instead of Access Database B and find the admin user and replace the encrypted password with the password you got from Database A. It should be the other way around. Therefore, it should be - Access Database A and find the admin user and replace the encrypted password with the password you got from Database B