Michael Fürmann
2015-02-17 9f94a17eacd85144a1aee14929688b33e9393fe1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
ini_set('display_errors', false);
$username = 'prosody';
$password = '23fm%4ks0';
/*
$soap_location = 'http://localhost:8080/ispconfig3/interface/web/remote/index.php';
$soap_uri = 'http://localhost:8080/ispconfig3/interface/web/remote/';
*/
$soap_location = 'https://tepin.spicyweb.de:8080/remote/index.php';
$soap_uri = 'https://tepin.spicyweb.de:8080/remote/';
 
$auth_keys = array(
    'iplay-esports.de' => 'f47kmm5Yh5hJzSws2KTS',
    'weirdempire.de' => 'scNDcU37gQ7MCMeBgaJX'
);
 
$arg_email = '';
$arg_password = '';
 
if(count($argv) == 4){
    $arg_email = $argv[1].'@'.$argv[2];
    $arg_password = $argv[3];
}
$client = new SoapClient(null, array('location' => $soap_location, 'uri' => $soap_uri));
try {
    //* Login to the remote server
    if($session_id = $client->login($username,$password)) {
        //var_dump($client->mail_alias_get($session_id, array('source' => 'blablubb@divepage.net', 'type' => 'alias', 'active' => 'y')));
        // Is Mail Alias?
        $alias = $client->mail_alias_get($session_id, array('source' => $arg_email, 'type' => 'alias', 'active' => 'y'));
        if(count($alias))
            $arg_email = $alias[0]['destination'];
        $mailbox = $client->mail_user_get($session_id, array('email' => $arg_email));
        if(count($mailbox)){
            $password = $mailbox[0]['password'];
            echo checkAuth($argv[1], $argv[2], $arg_password, $password);//intval(crypt($arg_password, $password) == $password);
        }
        else
            echo 0;
        //* Logout
        $client->logout($session_id);
    }
    else
        echo 0;
} catch (SoapFault $e) {
    echo 0;
}
 
function checkAuth($user, $domain, $pw, $pw_mailbox){
    global $auth_keys;
    if(crypt($pw, $pw_mailbox) == $pw_mailbox)
        return intval(1);
 
    if(array_key_exists($domain, $auth_keys)){
        $datetime = new DateTime();
        $datetime->setTimezone(new DateTimeZone("UTC"));
        for($t = $datetime->getTimestamp(); $t >= $datetime->getTimestamp()-30; $t--){
            $pw_api = md5($domain.'@'.$auth_keys[$domain].'@'.$user.'@'.$t);
            if($pw_api == $pw)
                return intval(1);
        }
    }
    return intval(0);
}
?>