优酷视频破解
2015-11-26 11:50
716 查看
<?php /* $vid = isset($_GET['vid']) ? $_GET['vid'] : ''; if(empty($vid)){ echo '失败'; } $m3u8 = new youkum3u8($vid); echo $m3u8->getM3u8();exit; */ class youkum3u8{ public $YK; public $YKP; public $d = array(19, 1, 4, 7, 30, 14, 28, 8, 24, 17, 6, 35, 34, 16, 9, 10, 13, 22, 32, 29, 31, 21, 18, 3, 2, 23, 25, 27, 11, 20, 5, 15, 12, 0, 33, 26); public $vid; public $data; public $videourl = 'http://v.youku.com/v_show/id_%s.html'; public function __construct($vid) { $this->YK['mk']['a4'] = 'boa4'; $this->YK['mk']['a3'] = 'b4et'; $this->YKP['userCache']['a1'] = 4; $this->YKP['userCache']['a2'] = 1; $this->vid = $this->getvid($vid); $this->data = $this->getjson(); $e = $this->rc4(strval($this->translate($this->YK['mk']['a3']."o0b".$this->YKP['userCache']['a1'], $this->d)), $this->decode64($this->data['data']['security']['encrypt_string'])); list($this->YKP['userCache']['sid'],$this->YKP['userCache']['token']) = explode('_', $e); } public function getvid($vid){ $url = vsprintf($this->videourl, array($vid)); $content = $this->contentHttp($url); preg_match('/videoId = \'(\d*)\';/', $content,$matches); return $matches[1]; } public function getjson(){ $url = 'http://play.youku.com/play/get.json?vid='.$this->vid."&ct=12"; return json_decode($this->contentHttp($url),true); } public function getM3u8(){ $translate = strval($this->translate($this->YK['mk']['a4']."poz".$this->YKP['userCache']['a2'], $this->d)); $rc4 = $this->rc4($translate, $this->YKP['userCache']['sid']. "_" . $this->vid . "_" . $this->YKP['userCache']['token']); $e = $this->encode64($rc4); $c['vid'] = $this->vid; $c['type'] = 'mp4'; $c['ts'] = time(); $c['keyframe'] = 0; $c['ep'] = $e; $c['sid'] = $this->YKP['userCache']['sid']; $c['token'] = $this->YKP['userCache']['token']; $c['ctype'] = 12; $c['ev'] = 1; $c['oip'] = $this->data['data']['security']['ip']; return "http://pl.youku.com/playlist/m3u8?".http_build_query($c); } //file_get获取数据 public function contentHttp($url){ $opts = array( 'http'=>array( 'method'=>"GET", 'timeout'=>5, ) ); $context = stream_context_create($opts); $data = @file_get_contents($url,false,$context); return $data; } public function encode64($a) { if (!$a) return ""; $a = strval($a); $b =''; $c=''; $d=''; $e=''; $f=''; $g=''; $h = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; for($d=strlen($a),$c=0,$b="";$d>$c;){ $e = 255 & ord($a{$c++}); if($c==$d){ $b .= $h{$e>>2}; $b .= $h{(3 & $e) << 4}; $b .= "=="; break; } $f=ord($a{$c++}); if($c==$d){ $b .= $h{$e>>2}; $b .= $h{(3 & $e) << 4 | (240 & $f) >> 4}; $b .= $h{(15 & $f) << 2}; $b .= "="; break; } $g = ord($a{$c++}); $b .= $h{$e >> 2}; $b .= $h{(3 & $e) << 4 | (240 & $f) >> 4}; $b .= $h{(15 & $f) << 2 | (192 & $g) >> 6}; $b .= $h{63 & $g}; } return $b; } public function decode64($a) { if (!$a) return ""; $a = strval($a); $b = ''; $c = ''; $d = ''; $e = ''; $f = ''; $g = ''; $h = ''; $i = Array(-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, -1, 0, 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, -1, -1, -1, -1, -1, -1, 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, -1, -1, -1, -1, -1); for($g = strlen($a),$f=0,$h=""; $g >$f;){ do{ $b = $i[255 & ord($a{$f++})]; } while ($g>$f && -1 ==$b); if(-1 == $b){ break; } do{ $c = $i[255 & ord($a{$f++})]; } while($g>$f && -1 == $c ); if(-1 == $c){ break; } $h .= chr($b << 2 | (48 & $c) >> 4); do{ $d = 255 & ord($a{$f++}); if(61== $d) return $h; $d = $i[$d]; } while ($g>$f && -1 == $d); if(-1 == $b){ break; } $h .= chr((15 & $c) << 4 | (60 & $d) >> 2); do{ $e = 255 & ord($a{$f++}); if(61== $e) return $h; $e = $i[$e]; } while ($g>$f && -1 == $e); if(-1 == $e){ break; } $h .= chr((3 & $d) << 6 | $e); } return $h; } public function translate($a, $b) { $alen = strlen($a); $c = array(); $e = 0; for($d=0;$d<$alen;$d++){ $e = $a[$d] >= "a" && $a[$d] <= "z" ? ord($a[$d]) - ord('a') : $a[$d] + 26; for($f=0;36>$f;$f++){ if($b[$f] == $e){ $e = $f; break; } } $c[$d] = $e > 25 ? $e - 26 : chr(($e+97)); } return implode('', $c); } public function rc4($a, $b) { for($c,$d=array(),$e=0,$f="",$g=0;256>$g;$g++) $d[$g] = $g; for($g=0;256>$g;$g++){ $e = ($e + $d[$g] + ord($a{$g%strlen($a)})) % 256; $c = $d[$g]; $d[$g] = $d[$e]; $d[$e] = $c; } $g = 0; $e = 0; for($h=0;$h<strlen($b);$h++){ $g = ($g+1) % 256; $e = ($e + $d[$g]) % 256; $c = $d[$g]; $d[$g] =$d[$e]; $d[$e] = $c; $f .= chr(ord($b{$h}) ^ $d[($d[$g]+$d[$e]) % 256]); } return $f; } }
相关文章推荐
- 一个关于if else容易迷惑的问题
- Android Native 绘图方法
- PHP5.2.*防止Hash冲突拒绝服务攻击的Patch
- 深入理解PHP之匿名函数
- JSP/PHP基于Ajax的分页功能实现
- 关于PHP通过PDO用中文条件查询MySQL的问题。
- 什么是设计模式
- PHP数据库长连接mysql_pconnect的细节
- Php Installing An Expansion
- C#中struct和class的区别详解
- PHP+Apache在Windows 9x下的安装和配置
- IIS 6 的 PHP 最佳配置方法
- 安装Apache和PHP的一些补充
- Linux Apache+MySQL+PHP
- 建立Apache+PHP+MySQL数据库驱动的动态网站
- PHP 5.3.0 安装分析心得
- apache 环境下 php 的配置注意事项
- VBS ArrayList Class vbs中的数组类
- 大家看了就明白了css样式中类class与标识id选择符的区别小结