Plesk 11 – Encrypted / Hashed password – authentication PHP on PSA database

For this new post we will disscuss about the new securty feature that encrypt or hash password in Plesk database.I need to authenticate within some PHP scripts the Plesk user.

Let’s have a look on the Plesk database, the table that contain the password for each accounts is “accounts”. There is an entry for each password in Plesk (Client account, E-mail, Database, FTP, etc…).

2016-06-18_02-39-48

Every password except the Plesk Client account is encrypted, that mean that we could uncrypt them. The Plesk Client account is hashed, so no way to get the original password but I don’t need it to authenticate the user. $5$ at the begining of the hash means that it use SHA-256. The password use a salt in order to avoid the usage of rainbow table to found the original password. The salt is present in the has between the second and third $ the result of the hash of the password plus the salt is located after the third $. So now to tests if the password given by the user correspond to the password in psa database, here is a little function that do the job.

Parameters are the plain password given by the user and the hash from the psa database. The function returns true if the password is correct, false otherwise.

That was the easy part, let’s now talk about the encrypted password that could be decrypted. The password is encrypted with using a salt and the Plesk private key. This key is very critical for the security so warning with this !
As the key is stored in binray format i suggest to get it in BASE64 format. When logged in root, write :

This command will give you the BASE64 version of the Plesk private key and this will be use full for the next functions.

These functions allow to decrypt Plesk password and encrypt them. For the first function the parameters are the encrypted password and the Plesk private key. The parameters of the second function are the plain password, the salt and the Plesk private key.

That’s all for this post, fell free to contact me if you want more details.
Stéphane

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.