-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathpptv.php
124 lines (85 loc) · 2.48 KB
/
pptv.php
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/*
extractors/pptv.py
You need to make the call to api as
http://web-play.pptv.com/webplay3-0-$id.xml?version=4¶m=type=web.fpp&ahl_ver=1
to get HD streams
Then, in dt tree you can find key & iv, sh & bh servers, id & flag & st
mp4 is armed as follows
$mp4="http://$dtsh/$no/0/1023/$rid?fpp.ver=1.3.0.23&type=web.fpp&k=$k&key=$key";
where
$k=kdecrypt($dtkey, $dtflag, $dtsh, $VodPlayst, $dtid, $dtbh, $dtiv);
&
$key=ckey::encrypt(dechex(strtotime($VodPlayst)-60),"qqqqqww");
i.e.
ckey::encrypt(dechex(strtotime("Fri May 26 22:32:19 2017 UTC")-60),"qqqqqww") -> 43feaf57e8875f76fc96753953e2583e
*/
function kdecrypt($dtkey, $dtflag, $dtsh, $VodPlayst, $dtid, $dtbh, $dtiv)
{
$playAppKey="V8oo0Or1f047NaiMTxK123LMFuINTNeI";
$decrypt = substr($dtkey,0,32);
$key=hash("sha256",$dtsh.$VodPlayst.$dtid.$dtbh.$dtiv.$playAppKey);
$d=bin2hex(rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_128,pack("H*",$key),pack("H*",$decrypt),MCRYPT_MODE_ECB),"\x00..\x1F"));
return $d.substr($dtkey,32);
}
class ckey
{
function shiftright($decimal , $right)
{
$decimal&=0xFFFFFFFF;
$shift=$decimal >> $right;
if($decimal >= 0) return $shift;
return bindec(substr(decbin($shift),$right));
}
function charsToLongs($arg)
{
$l2 = array();$l3 = -1;
while (++$l3 < ceil((sizeof($arg) / 4)))
{
$temp=0;
for ($t=0;$t<4;$t++)
$temp+=$arg[$l3*4+$t] << $t*8;
$l2[] = $temp;
}
return $l2;
}
function longsToChars($arg)
{
$l3 = -1;$l2="";
while (++$l3 < sizeof($arg))
for ($t=0;$t<4;$t++) $l2.=strrev(dechex($arg[$l3] >> 8*$t & 0xFF));
return $l2;
}
function getkey($key)
{
$l2=array_values(unpack("C*",$key));
$l4=$l3=0;
while($l4<sizeof($l2))
$l3^=$l2[$l4]<<($l4++ %4)*8;
return $l3;
}
function encrypt($string, $key)
{
$key = ckey::getkey($key);//1896220160
for ($k=0;$k<4;$k++)
${"k$k"} = $key << 8*$k | ckey::shiftright($key , 32 - 8*$k);
$p=ckey::charsToLongs(array_map("ord",str_split($string)));
$x = 0; $y = -1;
while(++$y < 32)
{
$x+= 2654435769;
$t1 = ($p[1] << 4) + $k0;
$t2 = $p[1] + $x;
$t3 = ckey::shiftright($p[1] , 5) + $k1;
$p[0]+= $t1 ^ $t2 ^ $t3;
$p[0]&= 0xFFFFFFFF;
$t4 = ($p[0] << 4) + $k2;
$t5 = $p[0] + $x;
$t6 = ckey::shiftright($p[0] , 5);
$p[1]+= $t4 ^ $t5 ^ ($t6 + $k3);
$p[1]&= 0xFFFFFFFF;
}
for ($i=0;$i<8;$i++)
$z.=dechex(intval(rand(0,15))).dechex(intval(rand(0,15)));
return ckey::longsToChars(array($p[0],$p[1])).$z;
}
}