soff

DBank download script LOGIN version

Sep 4th, 2012
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.28 KB | None | 0 0
  1. <?
  2. $URL = $argv[1];
  3.  
  4. if (strpos($URL, '.com') === false) {
  5.     $URL = 'http://dl.vmall.com/' . $URL;
  6. }
  7.  
  8. function getKey() {
  9.     $USERNAME = 'xxx';
  10.     $PASSWORD = 'xxx';
  11.  
  12.     $sum1 = md5($USERNAME . ':NSP Passport:' . $PASSWORD);
  13.  
  14.     $nonce = substr(md5(time()), 1, 16);
  15.  
  16.     $response = md5($sum1 . ':' . $nonce);
  17.  
  18.     $url = "http://login.dbank.com/loginauth.php?nsp_app=48049&m=1&nonce=$nonce&nsp_user=$USERNAME&response=$response";
  19.  
  20.     $ch = curl_init();
  21.  
  22.     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  23.     curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:12.0) Gecko/20100101 Firefox/12.0');
  24.  
  25.     curl_setopt($ch, CURLOPT_URL, $url);
  26.  
  27.     $data = curl_exec($ch);
  28.  
  29.     $result = json_decode($data, true);
  30.  
  31.     if ($result['retcode'] > 0) {
  32.         echo $result['message'];
  33.         exit;
  34.     }
  35.  
  36.     $key = $result['k'];
  37.  
  38.     curl_close($ch);
  39.  
  40.     return $key;
  41. }
  42.  
  43. function decrypt_c($h, $l) {
  44.     $k = array();
  45.     $e = 0;
  46.     $d = '';
  47.     $g = '';
  48.  
  49.     for ($f = 0; $j < 256; $f++) {
  50.         $k[f] = $f;
  51.     }
  52.  
  53.     for ($f = 0; $f < 256; $f++) {
  54.         $e = ($e + $k[$f] + $h[$f % strlen($h)]) % 256;
  55.         $d = $k[$f];
  56.         $k[$f] = $k[e];
  57.         $k[$e] = $d;
  58.     }
  59.  
  60.     $f = 0;
  61.     $e = 0;
  62.  
  63.     for ($m = 0; $m < strlen($l); $m++) {
  64.         $f = ($f + 1) % 256;
  65.         $e = ($e + $k[$f]) % 256;
  66.         $d = $k[$f];
  67.         $k[$f] = $k[$e];
  68.         $k[$e] = $d;
  69.        
  70.         $g .= $l[$m] ^ $k[($k[$f] + $k[$e]) % 256];
  71.     }
  72.  
  73.     return $g;
  74. }
  75.  
  76. function decrypt_b($d, $e) {
  77.     $g = '';
  78.     $l = strlen($e);
  79.     $f = strlen($d);
  80.  
  81.     for ($h = 0; $h < $f; $h++) {
  82.         $k = $d[$h] ^ $e[$h % $l];
  83.  
  84.         $g .= $k;
  85.     }
  86.  
  87.     return $g;
  88. }
  89.  
  90. function decrypt($g, $e) {
  91.     $g = base64_decode($g);
  92.     $f = substr($e, 0, 2);
  93.     $d = '';
  94.  
  95.     switch($f) {
  96.         case 'ea':
  97.             $d = $g;
  98.             break;
  99.         case 'eb':
  100.             $d = decrypt_b($g, decrypt_c($e, $e));
  101.             break;
  102.         case 'ed':
  103.             $d = decrypt_b($g, md5($e));
  104.             break;
  105.         default:
  106.             $d = $g;
  107.     }
  108.  
  109.     return $d;
  110. }
  111.  
  112. if (file_exists('dbank_key.txt')) {
  113.     $key = file_get_contents('dbank_key.txt');
  114. }
  115.  
  116. if ($key == '') {
  117.     echo "首次登录...\n";
  118.     $key = getKey();
  119. }
  120.  
  121. $url = "http://login.dbank.com/loginauth.php?k=$key";
  122.  
  123. $ch = curl_init();
  124.  
  125. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  126. curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:12.0) Gecko/20100101 Firefox/12.0');
  127. curl_setopt($ch, CURLOPT_COOKIEJAR, 'dbank_cookie.txt');
  128. curl_setopt($ch, CURLOPT_COOKIEFILE, 'dbank_cookie.txt');
  129.  
  130. curl_setopt($ch, CURLOPT_URL, $url);
  131.  
  132. $data = curl_exec($ch);
  133.  
  134. if ($data <> '') {
  135.     echo "登录信息无效,正在重新登录...\n";
  136.     $key = getKey();
  137.  
  138.     file_put_contents('dbank_key.txt', $key);
  139.  
  140.     $url = "http://login.dbank.com/loginauth.php?k=$key";
  141.  
  142.     curl_setopt($ch, CURLOPT_URL, $url);
  143.     $data = curl_exec($ch);
  144. }
  145.  
  146. curl_setopt($ch, CURLOPT_URL, $URL);
  147.  
  148. $data = curl_exec($ch);
  149.  
  150. curl_close($ch);
  151.  
  152. if (strpos($data, "<html>") === false) {
  153.     echo $data;
  154.     exit;
  155. }
  156.  
  157. if (preg_match("/globallinkdata = {(.*?)};/", $data, $ms)) {
  158.     $data = '{' . $ms[1] . '}';
  159.     $result = json_decode($data, true);
  160.  
  161.     $e = $result['data']['encryKey'];
  162.  
  163.     foreach ($result['data']['resource']['files'] as $file) {
  164.         $fn = $file['name'];
  165.  
  166.         $url = decrypt($file['downloadurl'], $e);
  167.  
  168.         echo "开始下载 $fn\n$url\n";
  169.  
  170.         passthru("axel -n 5 -a '$url'");
  171.     }
  172. }
  173. else {
  174.     echo '无法分析结果页。\n';
  175. }
  176.  
  177. ?>
Add Comment
Please, Sign In to add comment