· 7 years ago · Nov 03, 2018, 02:36 AM
1<?php error_reporting(-1);
2$SECRET_KEY = hash('SHA256', '267f7e281dae0e389211293f24859rrc1c4e0440', true);
3$IV = hex2bin('7feeba6ad419a91b8130672c152711f1');
4$CURL_OPTIONS = array(CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_RETURNTRANSFER => true, CURLOPT_SSL_VERIFYPEER => false,);
5$headers = array();
6$headers[] = "Accept: */*";
7$headers[] = "Referer: https://vue.playstation.com/watch/channels";
8$headers[] = "Reqpayload: " . trim(file_get_contents("reqPayload.txt"));
9$headers[] = "User-Agent: Mozilla/5.0 (Windows NT 10.0;
10 Win64;
11 x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36";
12$headers[] = "Origin: https://vue.playstation.com";
13require "links.php";
14$uri = $_SERVER['REDIRECT_URL'];
15$aeskey = "";
16$rez = "";
17$iv = "";
18$curl = curl_init();
19if (preg_match("#/(.+?)\.m3u8#", $uri, $matches)) {
20 curl_setopt($curl, CURLOPT_URL, "https://media-framework.totsuko.tv/media-framework/media/v2.1/stream/channel/" . $url[$matches[1]]);
21 curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
22 curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "GET");
23 curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
24 curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0;
25 Win64;
26 x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.167 Safari/537.36');
27 $content = json_decode(curl_exec($curl), true);
28 $link = explode("/", $content['body']['video']);
29 $link = $link[0] . "//" . $link[2] . "/" . $link[3] . "/" . $link[4] . "/" . $link[5] . "/" . $link[6] . "/" . $link[7] . "/";
30 if ($content) {
31 curl_setopt($curl, CURLOPT_URL, $content['body']['video']);
32 curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
33 curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "GET");
34 curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
35 curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0;
36 Win64;
37 x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.167 Safari/537.36');
38 $content = explode("\n", curl_exec($curl));
39 $pls = '';
40 $grab = false;
41 $resolution = 0;
42 foreach ($content as $r) {
43 if (preg_match("/RESOLUTION=(\d+)/", $r, $m)) {
44 if ($resolution < $m[1] && $m[1] < 1900) {
45 $resolution = $m[1];
46 $grab = true;
47 }
48 } else if ($grab) {
49 $pls = $r;
50 $grab = false;
51 }
52 }
53 $pls2 = explode("/", $pls);
54 $pls2 = $pls2[0] . "/" . $pls2[1] . "/" . $pls2[2] . "/" . $pls2[3] . "/" . $pls2[4] . "/";
55 $curl = curl_init();
56 curl_setopt($curl, CURLOPT_URL, $link . $pls);
57 curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
58 curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "GET");
59 curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
60 curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0;
61 Win64;
62 x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.167 Safari/537.36');
63 $content = curl_exec($curl);
64//BARRY ADDED THIS HERE -------------------------------------------------
65var_dump($content);
66exit();
67//BARRY ADDED THIS HERE -------------------------------------------------
68 if ($content) {
69 $content = trim($content);
70 $lines = explode("\n", $content);
71 foreach ($lines as $l) {
72 $l = trim($l);
73 if (preg_match("/^#/", $l)) {
74 if (preg_match('/https(.+?).key?(.*)/', $l, $aes)) {
75 $keys = explode(",", $aes[0]);
76 preg_match('"IV=0x([^\\"]+)"', $keys[1], $iv);
77 $iv = "IV" . $iv[1] . "IV";
78 $getaes = substr_replace($keys[0], "", -1);
79 curl_setopt($curl, CURLOPT_URL, $getaes);
80 curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
81 $f = fopen('/tmp/kr.log', 'a+');
82 $res = curl_exec($curl);
83 $aeskey = "AES" . bin2hex(rtrim($res)) . "AES";
84 if (strlen($aeskey) > 10) {
85 $key = $aeskey;
86 }
87 $l = "";
88 }
89 echo "$l\n";
90 } else {
91 $aeskey = $key;
92 $enc = encrypt($link . $pls2 . trim($l) . "$aeskey$iv") . ".ts";
93 for ($i = 200;$i < strlen($enc);$i+= 200) {
94 $enc = substr($enc, 0, $i) . '/' . substr($enc, $i);
95 }
96 echo "$enc\n";
97 }
98 }
99 exit;
100 }
101 }
102} else {
103 $uri = trim(decrypt(str_replace(['/', '.ts'], ['', ''], $uri)));
104 $rez = explode("AES", $uri);
105 if (preg_match('#IV(.+?)IV#', $uri, $m)) {
106 $iv = $m[1];
107 }
108 if (preg_match('#AES(.+?)AES#', $uri, $m)) {
109 $aeskey = $m[1];
110 }
111 $uri = $rez[0];
112 $CURL_OPTIONS[CURLOPT_URL] = $uri;
113 curl_setopt_array($curl, $CURL_OPTIONS);
114 curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0;
115 Win64;
116 x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.167 Safari/537.36');
117 $content = curl_exec($curl);
118 if ($aeskey and $iv) {
119 $decoded = openssl_decrypt($content, "aes-128-cbc", hex2bin($aeskey), OPENSSL_RAW_DATA, hex2bin($iv));
120 $f = fopen('/tmp/psvue.log', 'a+');
121 if ($decoded) {
122 echo $decoded;
123 fprintf($f, "%s %s key=%s iv=%s SUCCESS\n", date("Y-m-d H:i:s"), $uri, $aeskey, $iv);
124 } else {
125 fprintf($f, "%s %s key=%s iv=%s FAILED\n", date("Y-m-d H:i:s"), $uri, $aeskey, $iv);
126 }
127 fclose($f);
128 } else echo $content;
129}
130function encrypt($data) {
131 global $SECRET_KEY, $IV;
132 return strtr(base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $SECRET_KEY, $data, MCRYPT_MODE_CBC, $IV)), '+/', '-_');
133}
134function decrypt($data) {
135 global $SECRET_KEY, $IV;
136 return strtok(mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $SECRET_KEY, base64_decode(strtr($data, '-_', '+/')), MCRYPT_MODE_CBC, $IV), "\0");
137}