Get MySQL Passwords from Plesk (bash/command line)

Quick bash script to grep out MySQL passwords from Plesk’s PSA database.

Script:

[code language=”bash”]#!/bin/bash

clear;

echo "Searching MySQL user tables for: $1";
echo
mysql psa -uadmin -p`cat /etc/psa/.psa.shadow` -e ‘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;’ | grep $1;
[/code]

Usage:

[code gutter=”false”][root@mail bin]# grepmysql test[/code]

Output (domain | db | user | pass):

[code gutter=”false”]Searching MySQL user tables for: test

test.co.uk test p455
test1.co.uk auser p4551
example.co.uk username passtest123
[root@mail bin]#
[/code]




No Comments


No comments yet.



Leave a Reply

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