Get Odin Plesk passwords for ftp, database and emails

Have you ever wanted to get Odin Plesk Passwords ?. There you go, below you can find scripts which allow you to get passwords from Plesk Panel. Script will be able to get passwords from FTP accounts, email adressess, databases.


<?php

#This script allows you to get Database Passwords from Plesk

# Get all database passwords from Plesk 11/12+
# Kamil Zytkiewicz
# www.superbest.co.uk

$server = 'localhost';
$user = 'admin';
$password = str_replace(array("\r", "\n"), '', file_get_contents("/etc/psa/.psa.shadow"));
$key = file_get_contents("/etc/psa/private/secret_key");
$database = 'psa';

$connection = mysql_connect($server,$user,$password) or die(mysql_error());
 mysql_select_db($database) or die (mysql_error());

 $query = "SELECT domains.name 
 AS domain_name, data_bases.name 
 AS database_name, db_users.login, accounts.password 
 FROM data_bases, db_users, domains, accounts 
 WHERE data_bases.dom_id = domains.id 
 AND db_users.db_id = data_bases.id 
 AND db_users.account_id = accounts.id 
 ORDER BY domain_name";

 $result = mysql_query($query)or die(mysql_error());

 if(isset($result)) {

 $handle = fopen("database_passwords", "w+");
 $string = '';

 while($tab = mysql_fetch_array($result))
 {
 if($tab['domain_name'] != '') {
 $hash = explode('$', $tab['password']);
 $iv = base64_decode($hash[2]);
 $ct = base64_decode($hash[3]);
 $dec = str_replace("\0", "", mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, $ct , MCRYPT_MODE_CBC, $iv));
 $string .= "Host: ".$tab['domain_name']."\nDatabase name: ".$tab['database_name']."\nUsername: ".$tab['login']."\nPassword: ".$dec."\n\n";
 }

 }

 fwrite($handle,$string);
 fclose($handle);
 
 }

#This script allows you to get Mail Passwords from Plesk

# Get all mail passwords from Plesk 11/12+
# Kamil Zytkiewicz
# www.superbest.co.uk

$server = 'localhost';
$user = 'admin';
$password = str_replace(array("\r", "\n"), '', file_get_contents("/etc/psa/.psa.shadow"));
$key = file_get_contents("/etc/psa/private/secret_key");
$database = 'psa';

$connection = mysql_connect($server,$user,$password) or die(mysql_error());
 mysql_select_db($database) or die (mysql_error());

 $query = "SELECT accounts.id, mail.mail_name, accounts.password, domains.name
 FROM domains LEFT JOIN mail ON domains.id = mail.dom_id
 LEFT JOIN accounts ON mail.account_id = accounts.id";
 $result = mysql_query($query) or die(mysql_error());

 if(isset($result)) {

 $handle = fopen("mail_passwords", "w+");
 $string = '';

 while($tab = mysql_fetch_array($result))
 {
 if($tab['mail_name'] != '') {
 $hash = explode('$', $tab['password']);
 $iv = base64_decode($hash[2]);
 $ct = base64_decode($hash[3]);
 $dec = str_replace("\0", "", mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, $ct , MCRYPT_MODE_CBC, $iv));
 $string .= "Email: ".$tab['mail_name']."@".$tab['name']."\nPassword: ".$dec."\n\n";
 }
 }

 fwrite($handle,$string);
 fclose($handle);
 
 }

#This script allows you to get FTP Passwords from Plesk

# Get all FTP passwords from Plesk 11/12+
# Kamil Zytkiewicz
# www.superbest.co.uk

$server = 'localhost';
$user = 'admin';
$password = str_replace(array("\r", "\n"), '', file_get_contents("/etc/psa/.psa.shadow"));
$key = file_get_contents("/etc/psa/private/secret_key");
$database = 'psa';

$connection = mysql_connect($server,$user,$password) or die(mysql_error());
 mysql_select_db($database) or die (mysql_error());

 $query = "SELECT REPLACE(sys_users.home,'/home/httpd/vhosts/','') AS domain, sys_users.login,accounts.password
 FROM sys_users LEFT JOIN accounts on sys_users.account_id=accounts.id ORDER BY sys_users.home ASC";
 $result = mysql_query($query) or die(mysql_error());

 if(isset($result)) {

 $handle = fopen("ftp_passwords", "w+");
 $string = '';

 while($tab = mysql_fetch_array($result))
 {
 $hash = explode('$', $tab['password']);
 $iv = base64_decode($hash[2]);
 $ct = base64_decode($hash[3]);
 $domain = str_replace("/var/www/vhosts/","",$tab["domain"]);
 $domain = explode("/", $domain);
 $dec = str_replace("\0", "", mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, $ct , MCRYPT_MODE_CBC, $iv));
 $string .= "Host: ftp.".$domain[0]."\nLogin: ".$tab["login"]."\nPassword: ".$dec."\n\n";
 }

 fwrite($handle,$string);
 fclose($handle);
 
 }

?>

1 Comment
  • v

    April 26, 2016 at 1:09 pm Reply

    Great job, this saved my ass today. The script would be even more cooler if you had included option to get customers access credentials for Plesk panel itself.

Post a Comment