Th3-822

[rapidleech][d] uploaded_net.php

May 29th, 2013
1,474
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 11.25 KB | None | 0 0
  1. <?php
  2. if (!defined('RAPIDLEECH')) {
  3.     require_once('index.html');
  4.     exit;
  5. }
  6.  
  7. class uploaded_net extends DownloadClass {
  8.     private $page, $cookie, $Login;
  9.     public function Download($link) {
  10.         global $premium_acc, $Referer;
  11.         if (!preg_match('@https?://(?:www\.)?(?:uploaded\.(?:to|net)/file|ul\.to(?:/file)?)/([a-zA-Z\d]+)@i', $link, $fid)) html_error('Invalid link?.');
  12.         $this->fid = $fid[1];
  13.         $this->link = $Referer = 'http://uploaded.net/file/'.$fid[1];
  14.  
  15.         if (empty($_POST['step']) || $_POST['step'] != 1) {
  16.             $x = 0;
  17.             do {
  18.                 $this->page = $this->GetPage($this->link, $this->cookie);
  19.                 $header = substr($this->page, 0, strpos($this->page, "\r\n\r\n"));
  20.                 $this->cookie = GetCookiesArr($header, $this->cookie);
  21.                 $x++;
  22.             } while ($x < 6 && substr($header, 9, 3) == '302' && stripos($header, "\nLocation: /file/{$fid[1]}") !== false);
  23.             is_present($header, '/404', 'File Not Found');
  24.             is_present($header, '/410', 'File Was Removed');
  25.             is_present($header, 'Please check the URL for typing errors,', 'File not Found or Removed.');
  26.         }
  27.  
  28.         $this->pA = (empty($_REQUEST['premium_user']) || empty($_REQUEST['premium_pass']) ? false : true);
  29.         if (($_REQUEST['cookieuse'] == 'on' && preg_match('@login[\s\t]*=[\s\t]*([\w\%\-]+);?@i', $_REQUEST['cookie'], $c)) || ($_REQUEST['premium_acc'] == 'on' && !empty($premium_acc['uploaded_net']['cookie']))) {
  30.             $cookie = (empty($c[1]) ? urldecode($premium_acc['uploaded_net']['cookie']) : urldecode($c[1]));
  31.             if (strpos($cookie, '%')) $cookie = urldecode($cookie);
  32.             $this->cookie = array('login' => urlencode($cookie));
  33.  
  34.             $x = 0;
  35.             do {
  36.                 $this->page = $this->GetPage('http://uploaded.net/me', $this->cookie, 0, 'http://uploaded.net/'.($x > 0 ? 'me' : ''));
  37.                 $this->cookie = GetCookiesArr($this->page, $this->cookie);
  38.                 $x++;
  39.             } while ($x < 6 && substr($this->page, 9, 3) == '302' && stripos($this->page, "\nLocation: /me") !== false);
  40.  
  41.             if (substr($this->page, 9, 3) != '200') html_error('Cookie Error: Invalid Cookie?.');
  42.             if (stripos($this->page, '<em>Free</em>') !== false) {
  43.                 $this->changeMesg(lang(300).'<br /><b>Cookie: Account isn\'t premium</b><br />Using it as member.');
  44.                 $this->page = $this->GetPage($this->link, $this->cookie);
  45.                 return $this->FreeDL();
  46.             }
  47.             return $this->PremiumDL();
  48.         } elseif (($_REQUEST['premium_acc'] == 'on' && ($this->pA || (!empty($premium_acc['uploaded_net']['user']) && !empty($premium_acc['uploaded_net']['pass']))))) {
  49.             return $this->CookieLogin(($this->pA ? $_REQUEST['premium_user'] : $premium_acc['uploaded_net']['user']), ($this->pA ? $_REQUEST['premium_pass'] : $premium_acc['uploaded_net']['pass']));
  50.         } else {
  51.             return $this->FreeDL();
  52.         }
  53.     }
  54.  
  55.     private function FreeDL() {
  56.         $url = 'http://uploaded.net';
  57.         $errs = array('host' => 'Download of this file isn\'t available right now, try again later.', 'limit-dl' => 'Free download limit reached.', 'parallel' => 'You\'re already downloading a file.', 'size' => 'Only Premium users can download this file.', 'slot' => 'Free download of this file isn\'t available right now, try again later.', 'captcha' => 'Wrong CAPTCHA entered.');
  58.  
  59.         if (empty($_POST['step']) || $_POST['step'] != 1) {
  60.             // Find countdown
  61.             if (!preg_match('@<span[^>]*>[^<>]+<span[^>]*>(\d+)</span>[\s\t\r\n]+seconds[^<>]*</span>@i', $this->page, $cD)) html_error('Countdown not found.');
  62.             // Check slots
  63.             $page = $this->GetPage("$url/io/ticket/slot/".$this->fid, $this->cookie, 0, 0, 0, 1);
  64.             if (stripos($page, 'succ:true') === false) {
  65.                 if (preg_match('@\"?err\"?\s*:\s*\"((?:[^\"]+(?:\\\")?)+)(?<!\\\)\"@i', $page, $err) && !empty($errs[$err[1]])) html_error($errs[$err[1]]);
  66.                 else html_error($errs['slot']);
  67.             }
  68.             // Download js and find site's recaptcha key
  69.             $js = $this->GetPage("$url/js/download.js", $this->cookie);
  70.             if (!preg_match('@Recaptcha\.create[\s\t]*\([\s\t]*\"[\s\t]*([\w\.\-]+)[\s\t]*\"@i', $js, $cpid)) html_error('reCAPTCHA Not Found.');
  71.             // Do countdown
  72.             if ($cD[1] > 0) $this->CountDown($cD[1]);
  73.             // Prepare data for reCAPTCHA and call it
  74.             $data = $this->DefaultParamArr($this->link, encrypt(CookiesToStr($this->cookie)));
  75.             $data['step'] = '1';
  76.             return $this->reCAPTCHA($cpid[1], $data);
  77.         }
  78.  
  79.         if (empty($_POST['recaptcha_response_field'])) html_error('You didn\'t enter the image verification code.');
  80.         $this->cookie = StrToCookies(decrypt(urldecode($_POST['cookie'])));
  81.  
  82.         $post = array('recaptcha_challenge_field' => $_POST['recaptcha_challenge_field'], 'recaptcha_response_field' => $_POST['recaptcha_response_field']);
  83.         $page = $this->GetPage("$url/io/ticket/captcha/".$this->fid, $this->cookie, $post, 0, 0, 1);
  84.         if (!preg_match('@https?://(?:[a-zA-Z\d\-]+\.)+uploaded\.(?:net|to)/dl/[^\r\n\s\t\'\"<>]+@i', $page, $dl)) {
  85.             if (preg_match('@\"?err\"?\s*:\s*\"((?:[^\"]+(?:\\\")?)+)(?<!\\\)\"@i', $page, $err)) {
  86.                 if (!empty($errs[$err[1]])) html_error($errs[$err[1]]);
  87.                 is_present($err[1], 'free downloads for this hour', $errs['limit-dl'].' Wait and hour an try again.');
  88.                 html_error('Unknown error after sending captcha: '.htmlentities($err[1]));
  89.             }
  90.             html_error('Download Link Not Found.');
  91.         }
  92.  
  93.         $this->RedirectDownload($dl[0], 'uploaded_net_fr', $this->cookie);
  94.     }
  95.  
  96.     private function PremiumDL() {
  97.         // Parse and show BW from $this->page
  98.         $cutted = cut_str($this->page, '<div id="traffic"', '</table>');
  99.         if (!empty($cutted) && preg_match_all('@>(\d+(?:,\d+)?\s+(?:[KMGT]i?)?B)<@i', $cutted, $bw)) $this->changeMesg(lang(300)."<br />[Acc. Traffic] Download: {$bw[1][0]} + Hybrid: {$bw[1][1]} = Total: ".$bw[1][2]);
  100.  
  101.         $page = $this->GetPage($this->link, $this->cookie);
  102.         if (!preg_match('@https?://(?:[a-zA-Z\d\-]+\.)+uploaded\.(?:net|to)/dl/[^\r\n\s\t\'\"<>]+@i', $page, $dl)) {
  103.             $body = trim(substr($page, strpos($page, "\r\n\r\n") + 4));
  104.             if ($body == '') html_error('Download-Link Not Found. (Empty page body)');
  105.             if (stripos($body, 'Traffic is completely exhausted,') !== false || stripos($body, 'Su tr&#225;fico h&#237;brido esta completamente gastado') !== false) html_error('Premium account is out of bandwidth.');
  106.             if (stripos($body, 'You used too many different IPs,') !== false || stripos($body, 'descarga bloqueada (ip)') !== false) html_error('Account blocked, too many IPs used for dl.');
  107.             html_error('Account IP-blocked? | Not enough traffic? | Download-Link Not Found');
  108.         }
  109.         $this->RedirectDownload($dl[0], 'uploaded_net_pr', $this->cookie);
  110.     }
  111.  
  112.     private function Login($user, $pass) {
  113.         $post = array_map('urlencode', array('id' => $user, 'pw' => $pass));
  114.         $page = $this->GetPage('http://uploaded.net/io/login', $this->cookie, $post, 'http://uploaded.net/', 0, 1);
  115.         $body = trim(substr($page, strpos($page, "\r\n\r\n") + 4));
  116.         is_present($body, 'No connection to database', 'Login failed: "No connection to database".');
  117.         if (preg_match('@\{\"err\":\"([^\"]+)\"@i', $body, $err)) html_error('Login Error: "'.html_entity_decode(stripslashes($err[1])).'".');
  118.         $this->cookie = GetCookiesArr($page, $this->cookie);
  119.         if (empty($this->cookie['login'])) {
  120.             if ($body == '') html_error('The host didn\'t replied the login request, wait 15-30 seconds and try again.');
  121.             html_error('Login Error: Cannot find "login" cookie.');
  122.         }
  123.  
  124.         $this->SaveCookies($user, $pass); // Update cookies file
  125.  
  126.         $this->page = $this->GetPage('http://uploaded.net/me', $this->cookie, 0, 'http://uploaded.net/');
  127.         if (stripos($this->page, '<em>Free</em>') !== false) {
  128.             $this->changeMesg(lang(300).'<br /><b>Account isn\'t premium</b><br />Using it as member.');
  129.             $this->page = $this->GetPage($this->link, $this->cookie);
  130.             return $this->FreeDL();
  131.         }
  132.  
  133.         return $this->PremiumDL();
  134.     }
  135.  
  136.     private function IWillNameItLater($cookie, $decrypt=true) {
  137.         if (!is_array($cookie)) {
  138.             if (!empty($cookie)) return $decrypt ? decrypt(urldecode($cookie)) : urlencode(encrypt($cookie));
  139.             return '';
  140.         }
  141.         if (count($cookie) < 1) return $cookie;
  142.         $keys = array_keys($cookie);
  143.         $values = array_values($cookie);
  144.         $keys = $decrypt ? array_map('decrypt', array_map('urldecode', $keys)) : array_map('urlencode', array_map('encrypt', $keys));
  145.         $values = $decrypt ? array_map('decrypt', array_map('urldecode', $values)) : array_map('urlencode', array_map('encrypt', $values));
  146.         return array_combine($keys, $values);
  147.     }
  148.  
  149.     private function CookieLogin($user, $pass) {
  150.         global $secretkey;
  151.         if (empty($user) || empty($pass)) html_error('Login Failed: User or Password is empty.');
  152.         $user = strtolower($user);
  153.  
  154.         $filename = DOWNLOAD_DIR . basename('uploaded_dl.php');
  155.         if (!file_exists($filename) || filesize($filename) <= 6) return $this->Login($user, $pass);
  156.  
  157.         $file = file($filename);
  158.         $savedcookies = unserialize($file[1]);
  159.         unset($file);
  160.  
  161.         $hash = hash('crc32b', $user.':'.$pass);
  162.         if (is_array($savedcookies) && array_key_exists($hash, $savedcookies)) {
  163.             $_secretkey = $secretkey;
  164.             $secretkey = hash('crc32b', $pass).sha1($user.':'.$pass).hash('crc32b', $user); // A 56 char key should be safer. :D
  165.             $testCookie = (decrypt(urldecode($savedcookies[$hash]['enc'])) == 'OK') ? $this->IWillNameItLater($savedcookies[$hash]['cookie']) : '';
  166.             $secretkey = $_secretkey;
  167.             if (empty($testCookie) || (is_array($testCookie) && count($testCookie) < 1)) return $this->Login($user, $pass);
  168.  
  169.             $x = 0;
  170.             do {
  171.                 $this->page = $this->GetPage('http://uploaded.net/me', $testCookie, 0, 'http://uploaded.net/'.($x > 0 ? 'me' : ''));
  172.                 $testCookie = GetCookiesArr($this->page, $testCookie);
  173.                 $x++;
  174.             } while ($x < 6 && substr($this->page, 9, 3) == '302' && stripos($this->page, "\nLocation: /me") !== false);
  175.  
  176.             if (substr($this->page, 9, 3) != '200') return $this->Login($user, $pass);
  177.             $this->cookie = $testCookie; // Update cookies
  178.             $this->SaveCookies($user, $pass); // Update cookies file
  179.             if (stripos($this->page, '<em>Free</em>') !== false) {
  180.                 $this->changeMesg(lang(300).'<br /><b>Account isn\'t premium</b><br />Using it as member.');
  181.                 $this->page = $this->GetPage($this->link, $this->cookie);
  182.                 return $this->FreeDL();
  183.             }
  184.             return $this->PremiumDL();
  185.         }
  186.         return $this->Login($user, $pass);
  187.     }
  188.  
  189.     private function SaveCookies($user, $pass) {
  190.         global $secretkey;
  191.         $maxdays = 31; // Max days to keep cookies for more than 1 user.
  192.         $filename = DOWNLOAD_DIR . basename('uploaded_dl.php');
  193.         if (file_exists($filename) && filesize($filename) > 6) {
  194.             $file = file($filename);
  195.             $savedcookies = unserialize($file[1]);
  196.             unset($file);
  197.  
  198.             // Remove old cookies
  199.             if (is_array($savedcookies)) {
  200.                 foreach ($savedcookies as $k => $v) if (time() - $v['time'] >= ($maxdays * 24 * 60 * 60)) unset($savedcookies[$k]);
  201.             } else $savedcookies = array();
  202.         } else $savedcookies = array();
  203.         $hash = hash('crc32b', $user.':'.$pass);
  204.         $_secretkey = $secretkey;
  205.         $secretkey = hash('crc32b', $pass).sha1($user.':'.$pass).hash('crc32b', $user); // A 56 char key should be safer. :D
  206.         $savedcookies[$hash] = array('time' => time(), 'enc' => urlencode(encrypt('OK')), 'cookie' => $this->IWillNameItLater($this->cookie, false));
  207.         $secretkey = $_secretkey;
  208.  
  209.         file_put_contents($filename, "<?php exit(); ?>\r\n" . serialize($savedcookies), LOCK_EX);
  210.     }
  211. }
  212.  
  213. //[29-5-2013] Written by Th3-822.
  214. //[09-1-2013] Added '410 Gone' error. - Th3-822
  215. //[06-12-2015] Added support for redirects blocking site access. #6DCambiemosVzla - Th3-822
  216.  
  217. ?>
Add Comment
Please, Sign In to add comment