Current time: 11-24-2024, 09:00 PM Hello There, Guest! (LoginRegister)


Post Reply 
[Shell] Decrypt Mailpasswords
Author Message
Knut Offline
Member
***

Posts: 736
Joined: Nov 2006
Reputation: 10
Post: #1
[Shell] Decrypt Mailpasswords
In some cases, I need the decrypted password of a user's mail.
To make it easier for me, I have written a small php-shell-script.

Here we go:
(of course you need php-cli)

1. Save this code over here -> /root/bin
PHP Code:
#!/usr/bin/php -q

<?php

## Autor: Knut Herter
## Datum: 06.10.2009
## Web  : http://www.systemtechnics.de
##
## Usage: decrypt_mailpw.php |grep whatever_you_want
##
## Example: decrypt_mailpw.php |grep admin


###
# FIRST CHANGE THIS VALUES !
###

$SQLHST  "localhost";
$SQLUSR  "root";
$ISPCPDB "ispcp";

# if error_reporting on, you see some session errors at cli
error_reporting(0);

#################################
#### Do not change from here ####

echo "MySQL password for $SQLUSR@$SQLHST: ";
system('stty -echo');
$SQLPW trim(fgets(STDIN));
system('stty echo'); 

$QUERY "
        SELECT  `mail_users`.mail_acc,
                `mail_users`.mail_pass,
                `domain`.domain_name

        FROM    `domain`

        INNER JOIN `mail_users` ON (`mail_users`.domain_id = `domain`.domain_id)

        WHERE   `mail_type` LIKE 'normal_mail' OR `mail_type` LIKE 'normal_mail,normal_forward'"
;

require 
'/var/www/ispcp/gui/include/ispcp-lib.php';

$link mysql_connect$SQLHST$SQLUSR$SQLPW);
if (!
$link) {
    die(
'keine Verbindung möglich: ' mysql_error());
}

mysql_select_db$ISPCPDB$link) or die('Could not select database.');

$result mysql_query($QUERY);
if (!
$result) {
    die(
'Ungültige Abfrage: ' mysql_error());
}

$FORMAT "Domain MailAdr: [ %s@%s ] Passwort: [ %s ]\n";
while (
$row mysql_fetch_row($result)) {
    
printf $FORMAT$row[0], $row[2],  decrypt_db_password ($row[1]));
}
printf ("\n");

mysql_close($link);

####### DOMAINALIASE

$QUERY "
        SELECT  `mail_users`.mail_acc,
                `mail_users`.mail_pass,
                `domain_aliasses`.alias_name

        FROM    `domain_aliasses`

        INNER JOIN `mail_users` ON (`mail_users`.sub_id = `domain_aliasses`.alias_id)

        WHERE   `mail_type` LIKE 'alias_mail' OR `mail_type` LIKE 'alias_mail,alias_forward'"
;



$link mysql_connect$SQLHST$SQLUSR$SQLPW);
if (!
$link) {
    die(
'keine Verbindung möglich: ' mysql_error());
}

mysql_select_db$ISPCPDB$link) or die('Could not select database.');

$result mysql_query($QUERY);
if (!
$result) {
    die(
'Ungültige Abfrage: ' mysql_error());
}


$FORMAT "Aliasdomain MailAdr: [ %s@%s ] Passwort: [ %s ]\n";
while (
$row mysql_fetch_row($result)) {
    
printf $FORMAT$row[0], $row[2],  decrypt_db_password ($row[1]));
}
printf ("\n");

mysql_close($link); 

2. make it executable
Code:
chmod +x /root/bin/decrypt_mailpw.php

3. run :-)

4. If you want a special mailpassword, run with grep
example:
Code:
decrypt_mailpw.php |grep webmaster
or
Code:
decrypt_mailpw.php |grep mydomain.de
(This post was last modified: 10-06-2009 05:09 PM by Knut.)
01-21-2009 03:59 AM
Find all posts by this user Quote this message in a reply
Post Reply 


Messages In This Thread
[Shell] Decrypt Mailpasswords - Knut - 01-21-2009 03:59 AM
RE: [Shell] Decrypt Mailpasswords - Kotty - 01-26-2009, 05:22 PM
RE: [Shell] Decrypt Mailpasswords - Knut - 01-26-2009, 05:28 PM
RE: [Shell] Decrypt Mailpasswords - Knut - 04-17-2009, 07:42 PM
RE: [Shell] Decrypt Mailpasswords - Knut - 10-06-2009, 05:11 PM
RE: [Shell] Decrypt Mailpasswords - gOOvER - 10-06-2009, 05:15 PM
RE: [Shell] Decrypt Mailpasswords - rethus - 12-04-2010, 11:20 AM
RE: [Shell] Decrypt Mailpasswords - joximu - 04-09-2012, 07:49 PM

Forum Jump:


User(s) browsing this thread: 4 Guest(s)