Advertisement
Th3-822

[rapidleech][d][freedl] zippyshare_com.php

Nov 24th, 2012
2,074
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 7.58 KB | None | 0 0
  1. <?php
  2.  
  3. if (!defined('RAPIDLEECH')) {
  4.     require_once('index.html');
  5.     exit;
  6. }
  7.  
  8. class zippyshare_com extends DownloadClass {
  9.     public $link;
  10.     private $page, $cookie, $fid;
  11.     public function Download($link) {
  12.         $this->link = str_ireplace('http://', 'https://', $link);
  13.         $this->cookie = array('ziplocale' => 'en');
  14.  
  15.         if (!preg_match('@https?://(?:[\w\-]+\.)*zippyshare\.com/\w/(\w+)@i', $this->link, $this->fid)) html_error('File ID not found at link. Invalid link?');
  16.         $this->fid = $this->fid[1];
  17.  
  18.         if (!empty($_POST['step'])) switch ($_POST['step']) {
  19.             case '1': return $this->CheckCaptcha();
  20.             case '2': return $this->GetDecodedLink();
  21.         }
  22.  
  23.         $this->page = $this->GetPage($this->link, $this->cookie);
  24.         is_present($this->page, '>File does not exist on this server<', 'File does not exist.');
  25.         is_present($this->page, '>File has expired and does not exist anymore on this server', 'File does not exist.');
  26.         $this->cookie = GetCookiesArr($this->page, $this->cookie);
  27.  
  28.         //if (($pos = stripos($this->page, 'getElementById(\'dlbutton\').href')) !== false || ($pos = stripos($this->page, 'getElementById("dlbutton").href')) !== false) return $this->GetJSEncodedLink();
  29.         if ($this->findJS()) return $this->GetJSEncodedLink();
  30.         else return $this->GetCaptcha();
  31.     }
  32.  
  33.     private function GetDecodedLink() {
  34.         if (empty($_POST['dllink']) || ($dlink = parse_url($_POST['dllink'])) == false || empty($dlink['path'])) html_error('Empty decoded link field.');
  35.         $this->cookie = urldecode($_POST['cookie']);
  36.  
  37.         $dlink = 'http://' . parse_url($this->link, PHP_URL_HOST) . $dlink['path'] . (!empty($dlink['query']) ? '?' . $dlink['query'] : '');
  38.         $fname = urldecode(basename(parse_url($dlink, PHP_URL_PATH)));
  39.         $this->RedirectDownload($dlink, $fname, $this->cookie);
  40.     }
  41.  
  42.     private function findJS() {
  43.         if (!preg_match_all('@<script(?:\s[^>]*)?>([^<]+)</script>@i', $this->page, $scripts)) html_error('No inline JS found at page.');
  44.         foreach ($scripts[1] as $script) {
  45.             if (preg_match('@\.getElementById\(\s*(?:(\'|\")(?i)(?:dlbutton|fimage)(?-i)\1|([\$_A-Za-z][\$\w]*))\)\.href\s*=\s*[\'\"](?i)(?:https?://(?:[\w\-]+\.)*zippyshare\.com)?/d/(?-i)'.$this->fid.'@', $script, $match)) {
  46.                 if (!empty($match[2])) $this->vname = $match[2];
  47.                 $this->script = $script;
  48.                 return true;
  49.             }
  50.             if (preg_match('@((?:[\$_A-Za-z][\$\w]*\.)*[\$_A-Za-z][\$\w]*)\s*\(\s*(?:(\'|\")(?:dlbutton|fimage)(?-i)\2|([\$_A-Za-z][\$\w]*))\s*,\s*[\'\"](?:https?://(?:[\w\-]+\.)*zippyshare\.com)?/d/(?-i)'.$this->fid.'@i', $script, $match)) {
  51.                 $this->fname = $match[1];
  52.                 if (!empty($match[3])) $this->vname = $match[3];
  53.                 $this->script = $script;
  54.                 return true;
  55.             }
  56.         }
  57.         return false;
  58.     }
  59.  
  60.     private function GetJSEncodedLink() {
  61.         $this->script = rtrim(str_replace(array(').href', "'dlbutton'", '"dlbutton"', '    '), array(').value', "'T8_dllink'", '"T8_dllink"', "\t\t"), $this->script));
  62.         if (!empty($this->fname)) $this->script = str_replace($this->fname, 'zsWriteLink', $this->script);
  63.         if (empty($this->script)) html_error('Error while getting js code.');
  64.  
  65.         $T8 = '';
  66.         if (preg_match_all('@getElementById[\s\t]*\([\s\t]*[\"\']([a-z][\w\.\-]*)[\"\'][\s\t]*\)@i', $this->script, $ids) && count($ids[0]) > 1) foreach (array_unique($ids[1]) as $id) {
  67.             if ($id == 'T8_dllink') continue;
  68.             if (!preg_match("@<([a-z][a-z\d]*)\s*(?:\w+\s*=\s*[\"\'][^\"\'<>]*[\"\']\s*)*(?:\s*id\s*=[\"\']{$id}[\"\']\s*)(?:\w+\s*=\s*[\"\'][^\"\'<>]*[\"\']\s*)*(?:(\s*>[^<>]*</\1)|(/)?[\s]*>)@i", $this->page, $tag)) break; // If it doesn't found the tag the decode will fail, im not sure if break or continue...
  69.             $T8 .= (!empty($tag[2]) ? $tag[0].'>' : (empty($tag[3]) ? $tag[0].'</'.$tag[1].'>' : $tag[0]));
  70.         }
  71.         $this->script = preg_replace('@^\s*(?:function\s+[\$_A-Za-z][\$\w]*|(?:var\s+)?[\$_A-Za-z][\$\w]*\s*=\s*function)\s*\([^)]*\)\s*\{\s*[\$_A-Za-z][\$\w]*\.\w+\s*\(\s*[\'\"]\w+[\'\"]\s*\)\.value\s*=\s*[\'\"][^\'\"]?[\'\"]*\s*;\s*\};?@', '', $this->script, 1);
  72.         if (preg_match('@^\s*function\s+([\$_A-Za-z][\$\w]*)\s*\(@i', $this->script, $funcName) || preg_match('@^\s*(?:var\s+)?([\$_A-Za-z][\$\w]*)\s*=\s*function\s*\(@i', $this->script, $funcName)) $this->script .= "\n\t\t{$funcName[1]}();";
  73.  
  74.         $data = $this->DefaultParamArr($this->link, $this->cookie);
  75.         $data['step'] = '2';
  76.         $data['dllink'] = '';
  77.         echo "\n<div style='display:none;'>$T8</div>\n<form name='zs_dcode' action='{$GLOBALS['PHP_SELF']}' method='POST'><br />\n";
  78.         foreach ($data as $name => $input) echo "<input type='hidden' name='$name' id='T8_$name' value='" . htmlspecialchars($input, ENT_QUOTES) . "' />\n";
  79.         echo("</form>\n<span id='T8_emsg' class='htmlerror' style='text-align:center;display:none;'></span>\n<noscript><span class='htmlerror'><b>Sorry, this code needs JavaScript enabled to work.</b></span></noscript>\n<script type='text/javascript'>/* <![CDATA[ Th3-822 */\n\tvar T8 = true;\n\tfunction zsWriteLink(a, b) {\n\t\tdocument.getElementById(a).value = b;\n\t}\n\ttry {{$this->script}\n\t} catch(e) {\n\t\t$('#T8_emsg').html('<b>Cannot decode link: ['+e.name+'] '+e.message+'</b>').show();\n\t\tT8 = false;\n\t}\n\tif (T8) window.setTimeout(\"$('form[name=zs_dcode]').submit();\", 300); // 300 µs to make sure that the value was decoded and added.\n/* ]]> */</script>\n\n</body>\n</html>");
  80.         exit;
  81.     }
  82.  
  83.     private function GetCaptcha() {
  84.         if (!preg_match('@/d/\w+/(\d+)/[^\r\n\t\'\"<>\;]+@i', $this->page, $dlpath)) html_error('Download Link Not Found.');
  85.         if (!preg_match('@\'sitekey\'\s*:\s*[\'\"]([\w\.\-]+)[\'\"]@i', $this->page, $cpid)) html_error('reCAPTCHA2 Not Found.');
  86.         //if (!preg_match('@\Wshortencode[\s\t]*:[\s\t]*\'?(\d+)\'?@i', $this->page, $short)) html_error('Captcha Data Not Found.');
  87.  
  88.         $data = $this->DefaultParamArr($this->link, $this->cookie);
  89.         $data['step'] = '1';
  90.         $data['dlpath'] = $dlpath[0];
  91.         $data['shortencode'] = $dlpath[1];
  92.  
  93.         $this->reCAPTCHAv2($cpid[1], $data);
  94.     }
  95.  
  96.     // Special Function Called by verifyReCaptchav2 When Captcha Is Incorrect, To Allow Retry. - Required
  97.     protected function retryReCaptchav2() {
  98.         $data = $this->DefaultParamArr($this->link, $this->cookie);
  99.         $data['step'] = '1';
  100.         $data['shortencode'] = (!empty($_POST['shortencode']) ? $_POST['shortencode'] : '');
  101.         $data['dlpath'] = (!empty($_POST['dlpath']) ? $_POST['dlpath'] : '');
  102.  
  103.         return $this->reCAPTCHAv2($_POST['recaptcha2_public_key'], $data);
  104.     }
  105.  
  106.     private function CheckCaptcha() {
  107.         $host = 'https://' . parse_url($this->link, PHP_URL_HOST);
  108.         $this->cookie = urldecode($_POST['cookie']);
  109.  
  110.         $post = array();
  111.         $post['response'] = $this->verifyReCaptchav2(true);
  112.         $post['shortencode'] = urlencode($_POST['shortencode']);
  113.  
  114.         $page = $this->GetPage($host . '/rest/captcha/test', $this->cookie, $post, $this->link . "\r\nX-Requested-With: XMLHttpRequest");
  115.         $body = strtolower(trim(substr($page, strpos($page, "\r\n\r\n"))));
  116.  
  117.         if ($body == 'false') html_error('Error: Wrong CAPTCHA Entered.');
  118.         elseif ($body != 'true') html_error('Unknown Reply from Server.');
  119.  
  120.         $dlink = $host . $_POST['dlpath'];
  121.         $fname = urldecode(basename(parse_url($dlink, PHP_URL_PATH)));
  122.         $this->RedirectDownload($dlink, $fname, $this->cookie);
  123.     }
  124. }
  125.  
  126. // [24-11-2012]  Written by Th3-822. (Only for rev43 :D)
  127. // [05-2-2013]  Added support for links that need user-side decoding of the link. - Th3-822
  128. // [04-3-2013]  Fixed File doesn't exists error msg... - Th3-822
  129. // [25-3-2014]  Fixed link decoder function. - Th3-822
  130. // [11-1-2015] Fixed link regexp. (Happy new year) - Th3-822
  131. // [07-3-2015]  Added Support for v2 reCAPTCHAs. - Th3-822
  132. // [13-3-2015]  Quick fix to decoder function. - Th3-822
  133. // [24-6-2018] Switched to https & small changes. - Th3-822
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement