Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php function get_pssh_from_data($data) { $pssh_header = pack('C*', 0x70, 0x73, 0..

Decoded Output download

<?php 
 
function get_pssh_from_data($data) { 
    $pssh_header = pack('C*', 0x70, 0x73, 0x73, 0x68); 
    $output = array(); 
    $dataLength = strlen($data); 
 
    for ($count = 0; $count < $dataLength; $count++) { 
        if (substr($data, $count, 4) === $pssh_header) { 
            $kid = strtolower(bin2hex(substr($data, $count + 28, 16))); 
            $key_system = strtolower(bin2hex(substr($data, $count + 8, 16))); 
            $size_bytes = substr($data, $count - 4, 4); 
            $size = unpack("N", $size_bytes)[1]; 
            $pssh_data = substr($data, $count - 4, $size); 
            $pssh_base64 = base64_encode($pssh_data); 
            $output["keyid"][]["kid"] = $kid; 
            $output[$key_system][] = $pssh_base64; 
            $count += $size - 1; 
        } 
    } 
 
    return $output; 
} 
 
function getCURLURL_($rURL) { 
    $ch = curl_init(); 
    curl_setopt($ch, CURLOPT_URL, $rURL); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
    curl_setopt($ch, CURLOPT_ENCODING, "gzip, deflate"); 
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); 
 
$headers = array( 
        "Authority: svc40.main.vr.t-online.de", 
        "Accept: /", 
        "Accept-Language: fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7,ar;q=0.6,he;q=0.5,zh-CN;q=0.4,zh;q=0.3", 
        "Cache-Control: no-cache", 
        "Cookie: session=-,517794167248174544812322258792202566987,-,-", 
        "Pragma: no-cache", 
        'Sec-Ch-Ua: "Google Chrome";v="117", "Not;A=Brand";v="8", "Chromium";v="117"', 
        "Sec-Ch-Ua-Mobile: ?0", 
        'Sec-Ch-Ua-Platform: "Windows"', 
        "Sec-Fetch-Dest: empty", 
        "Sec-Fetch-Mode: cors", 
        "Sec-Fetch-Site: none", 
        "Referer: https://www.visionplus.id/", 
        "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36" 
); 
 
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); 
    $result = curl_exec($ch); 
    curl_close($ch); 
 
    return $result; 
} 
 
function get_pssh_from_inits_urls($input) { 
    $output = array(); 
    $response = getCURLURL_($input); 
    $pssh_data = get_pssh_from_data($response); 
 
    foreach ($pssh_data as $key => $values) { 
        if (!isset($output[$key])) { 
            $output[$key] = array(); 
        } 
 
        $output[$key] = array_merge($output[$key], $values); 
    } 
 
    return $output; 
} 
 
if ($_SERVER["REQUEST_METHOD"] == "POST") { 
    $rURL = $_POST["rURL"]; 
    $id = $_POST["id"]; 
    $rBaseURL = explode($id, $rURL)[0]; 
    $rData = getCURLURL_($rURL); 
    $rMPD = simplexml_load_string($rData); 
 
    foreach ($rMPD->Period as $rPeriod) { 
        foreach ($rPeriod->AdaptationSet as $rAdaptationSet) { 
            if ($rAdaptationSet->attributes()['mimeType'] == 'video/mp4') { 
                $rID = $rAdaptationSet->Representation[0]->attributes()['id']; 
                $rInitSegment = str_replace('$RepresentationID$', $rID, $rBaseURL . $rAdaptationSet->SegmentTemplate[0]->attributes()['initialization']); 
            } 
        } 
    } 
 
    if ($rInitSegment) { 
        $result = get_pssh_from_inits_urls($rInitSegment); 
        $widevine = $result["edef8ba979d64acea3c827dcd51d21ed"][0]; 
        $defaultKid = $result["keyid"][0]["kid"]; 
 
        if (!empty($widevine) && !empty($defaultKid)) { 
            $resultArray = array("widevine" => $widevine, "defaultKid" => $defaultKid); 
            echo json_encode($resultArray); 
        } else { 
            echo json_encode(["error" => "No Results"]); 
        } 
    } else { 
        echo json_encode(["error" => "Invalid Init Segment"]); 
    } 
} else { 
    echo json_encode(["error" => "Invalid Request"]); 
} 
?>

Did this file decode correctly?

Original Code

<?php

function get_pssh_from_data($data) {
    $pssh_header = pack('C*', 0x70, 0x73, 0x73, 0x68);
    $output = array();
    $dataLength = strlen($data);

    for ($count = 0; $count < $dataLength; $count++) {
        if (substr($data, $count, 4) === $pssh_header) {
            $kid = strtolower(bin2hex(substr($data, $count + 28, 16)));
            $key_system = strtolower(bin2hex(substr($data, $count + 8, 16)));
            $size_bytes = substr($data, $count - 4, 4);
            $size = unpack("N", $size_bytes)[1];
            $pssh_data = substr($data, $count - 4, $size);
            $pssh_base64 = base64_encode($pssh_data);
            $output["keyid"][]["kid"] = $kid;
            $output[$key_system][] = $pssh_base64;
            $count += $size - 1;
        }
    }

    return $output;
}

function getCURLURL_($rURL) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $rURL);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_ENCODING, "gzip, deflate");
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);

$headers = array(
        "Authority: svc40.main.vr.t-online.de",
        "Accept: /",
        "Accept-Language: fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7,ar;q=0.6,he;q=0.5,zh-CN;q=0.4,zh;q=0.3",
        "Cache-Control: no-cache",
        "Cookie: session=-,517794167248174544812322258792202566987,-,-",
        "Pragma: no-cache",
        'Sec-Ch-Ua: "Google Chrome";v="117", "Not;A=Brand";v="8", "Chromium";v="117"',
        "Sec-Ch-Ua-Mobile: ?0",
        'Sec-Ch-Ua-Platform: "Windows"',
        "Sec-Fetch-Dest: empty",
        "Sec-Fetch-Mode: cors",
        "Sec-Fetch-Site: none",
        "Referer: https://www.visionplus.id/",
        "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36"
);

    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    $result = curl_exec($ch);
    curl_close($ch);

    return $result;
}

function get_pssh_from_inits_urls($input) {
    $output = array();
    $response = getCURLURL_($input);
    $pssh_data = get_pssh_from_data($response);

    foreach ($pssh_data as $key => $values) {
        if (!isset($output[$key])) {
            $output[$key] = array();
        }

        $output[$key] = array_merge($output[$key], $values);
    }

    return $output;
}

if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $rURL = $_POST["rURL"];
    $id = $_POST["id"];
    $rBaseURL = explode($id, $rURL)[0];
    $rData = getCURLURL_($rURL);
    $rMPD = simplexml_load_string($rData);

    foreach ($rMPD->Period as $rPeriod) {
        foreach ($rPeriod->AdaptationSet as $rAdaptationSet) {
            if ($rAdaptationSet->attributes()['mimeType'] == 'video/mp4') {
                $rID = $rAdaptationSet->Representation[0]->attributes()['id'];
                $rInitSegment = str_replace('$RepresentationID$', $rID, $rBaseURL . $rAdaptationSet->SegmentTemplate[0]->attributes()['initialization']);
            }
        }
    }

    if ($rInitSegment) {
        $result = get_pssh_from_inits_urls($rInitSegment);
        $widevine = $result["edef8ba979d64acea3c827dcd51d21ed"][0];
        $defaultKid = $result["keyid"][0]["kid"];

        if (!empty($widevine) && !empty($defaultKid)) {
            $resultArray = array("widevine" => $widevine, "defaultKid" => $defaultKid);
            echo json_encode($resultArray);
        } else {
            echo json_encode(["error" => "No Results"]);
        }
    } else {
        echo json_encode(["error" => "Invalid Init Segment"]);
    }
} else {
    echo json_encode(["error" => "Invalid Request"]);
}
?>

Function Calls

None

Variables

None

Stats

MD5 6c6390ee1717add66e443838acab688f
Eval Count 0
Decode Time 38 ms