File: debug.php

package info (click to toggle)
simplesamlphp 1.14.11-1%2Bdeb9u2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 15,024 kB
  • sloc: php: 72,337; xml: 1,078; python: 376; sh: 220; perl: 185; makefile: 57
file content (80 lines) | stat: -rw-r--r-- 2,319 bytes parent folder | download
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php

$config = SimpleSAML_Configuration::getInstance();


function getValue($raw)
{
    $val = $raw;

    $url = parse_url($raw, PHP_URL_QUERY);
    if (!empty($url)) {
        $val = $url;
    }

    $arr = array();
    parse_str($val, $arr);

    if (array_key_exists('SAMLResponse', $arr)) {
        return $arr['SAMLResponse'];
    }
    if (array_key_exists('SAMLRequest', $arr)) {
        return $arr['SAMLRequest'];
    }
    if (array_key_exists('LogoutRequest', $arr)) {
        return $arr['LogoutRequest'];
    }
    if (array_key_exists('LogoutResponse', $arr)) {
        return $arr['LogoutResponse'];
    }

    return rawurldecode(stripslashes($val));
}

function decode($raw)
{
    $message = getValue($raw);

    $base64decoded = base64_decode($message);
    $gzinflated = gzinflate($base64decoded);
    if ($gzinflated !== false) {
        $base64decoded = $gzinflated;
    }
    $decoded = htmlspecialchars($base64decoded);
    return $decoded;
}

function encode($message)
{
    if (!array_key_exists('binding', $_REQUEST)) {
        throw new Exception('missing binding');
    }
    if ($_REQUEST['binding'] === 'redirect') {
        return urlencode(base64_encode(gzdeflate(stripslashes($message))));
    } else {
        return base64_encode(stripslashes($message));
    }
}

$decoded = '';
$encoded = 'fZJNT%2BMwEIbvSPwHy%2Fd8tMvHympSdUGISuwS0cCBm%2BtMUwfbk%2FU4zfLvSVMq2Euv45n3fd7xzOb%2FrGE78KTRZXwSp5yBU1hp'.
           'V2f8ubyLfvJ5fn42I2lNKxZd2Lon%2BNsBBTZMOhLjQ8Y77wRK0iSctEAiKLFa%2FH4Q0zgVrceACg1ny9uMy7rCdaM2%2Bs0BWrtppK2U'.
           'AdeoVjW2ruq1bevGImcvR6zpHmtJ1MHSUZAuDKU0vY7Si2h6VU5%2BiMuJuLx65az4dPql3SHBKaz1oYnEfVkWUfG4KkeBna7A%2Fxm6M1'.
           '4j1gZihZazBRH4MODcoKPOgl%2BB32kFz08PGd%2BG0JJIkr7v46%2BhRCaEpod17DCRivYZCkmkd4N28B3wfNyrGKP5bws9DS6PKDz%2F'.
           'Mpsl36Tyz%2F%2Fax1jeFmi0emcLY7C%2F8SDD0Z7dobcynHbbV3QVbcZW0TlqQemNhoqzJD%2B4%2Fn8Yw7l8AA%3D%3D';

$activeTab = 0;

if (array_key_exists('encoded', $_REQUEST)) {
    $decoded = decode($_REQUEST['encoded']);
    $activeTab = 1;
}
if (array_key_exists('decoded', $_REQUEST)) {
    $encoded = encode($_REQUEST['decoded']);
}

$t = new SimpleSAML_XHTML_Template($config, 'saml2debug:debug.tpl.php');
$t->data['encoded'] = $encoded;
$t->data['decoded'] = $decoded;
$t->data['activeTab'] = $activeTab;
$t->show();