Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- $URL = $argv[1];
- if (strpos($URL, '.com') === false) {
- $URL = 'http://dl.vmall.com/' . $URL;
- }
- function getKey() {
- $USERNAME = 'xxx';
- $PASSWORD = 'xxx';
- $sum1 = md5($USERNAME . ':NSP Passport:' . $PASSWORD);
- $nonce = substr(md5(time()), 1, 16);
- $response = md5($sum1 . ':' . $nonce);
- $url = "http://login.dbank.com/loginauth.php?nsp_app=48049&m=1&nonce=$nonce&nsp_user=$USERNAME&response=$response";
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:12.0) Gecko/20100101 Firefox/12.0');
- curl_setopt($ch, CURLOPT_URL, $url);
- $data = curl_exec($ch);
- $result = json_decode($data, true);
- if ($result['retcode'] > 0) {
- echo $result['message'];
- exit;
- }
- $key = $result['k'];
- curl_close($ch);
- return $key;
- }
- function decrypt_c($h, $l) {
- $k = array();
- $e = 0;
- $d = '';
- $g = '';
- for ($f = 0; $j < 256; $f++) {
- $k[f] = $f;
- }
- for ($f = 0; $f < 256; $f++) {
- $e = ($e + $k[$f] + $h[$f % strlen($h)]) % 256;
- $d = $k[$f];
- $k[$f] = $k[e];
- $k[$e] = $d;
- }
- $f = 0;
- $e = 0;
- for ($m = 0; $m < strlen($l); $m++) {
- $f = ($f + 1) % 256;
- $e = ($e + $k[$f]) % 256;
- $d = $k[$f];
- $k[$f] = $k[$e];
- $k[$e] = $d;
- $g .= $l[$m] ^ $k[($k[$f] + $k[$e]) % 256];
- }
- return $g;
- }
- function decrypt_b($d, $e) {
- $g = '';
- $l = strlen($e);
- $f = strlen($d);
- for ($h = 0; $h < $f; $h++) {
- $k = $d[$h] ^ $e[$h % $l];
- $g .= $k;
- }
- return $g;
- }
- function decrypt($g, $e) {
- $g = base64_decode($g);
- $f = substr($e, 0, 2);
- $d = '';
- switch($f) {
- case 'ea':
- $d = $g;
- break;
- case 'eb':
- $d = decrypt_b($g, decrypt_c($e, $e));
- break;
- case 'ed':
- $d = decrypt_b($g, md5($e));
- break;
- default:
- $d = $g;
- }
- return $d;
- }
- if (file_exists('dbank_key.txt')) {
- $key = file_get_contents('dbank_key.txt');
- }
- if ($key == '') {
- echo "首次登录...\n";
- $key = getKey();
- }
- $url = "http://login.dbank.com/loginauth.php?k=$key";
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:12.0) Gecko/20100101 Firefox/12.0');
- curl_setopt($ch, CURLOPT_COOKIEJAR, 'dbank_cookie.txt');
- curl_setopt($ch, CURLOPT_COOKIEFILE, 'dbank_cookie.txt');
- curl_setopt($ch, CURLOPT_URL, $url);
- $data = curl_exec($ch);
- if ($data <> '') {
- echo "登录信息无效,正在重新登录...\n";
- $key = getKey();
- file_put_contents('dbank_key.txt', $key);
- $url = "http://login.dbank.com/loginauth.php?k=$key";
- curl_setopt($ch, CURLOPT_URL, $url);
- $data = curl_exec($ch);
- }
- curl_setopt($ch, CURLOPT_URL, $URL);
- $data = curl_exec($ch);
- curl_close($ch);
- if (strpos($data, "<html>") === false) {
- echo $data;
- exit;
- }
- if (preg_match("/globallinkdata = {(.*?)};/", $data, $ms)) {
- $data = '{' . $ms[1] . '}';
- $result = json_decode($data, true);
- $e = $result['data']['encryKey'];
- foreach ($result['data']['resource']['files'] as $file) {
- $fn = $file['name'];
- $url = decrypt($file['downloadurl'], $e);
- echo "开始下载 $fn\n$url\n";
- passthru("axel -n 5 -a '$url'");
- }
- }
- else {
- echo '无法分析结果页。\n';
- }
- ?>
Add Comment
Please, Sign In to add comment