Th3-822

[rapidleech][d] depfile_com

Apr 28th, 2016
809
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 12.58 KB | None | 0 0
  1. <?php
  2.  
  3. if (!defined('RAPIDLEECH')) {
  4.     require_once('index.html');
  5.     exit;
  6. }
  7.  
  8. class depfile_com extends DownloadClass {
  9.     private $page, $cookie = array('sdlanguageid' => '2'), $pA, $DLRegexp = '@https?://(?:[\w\-]+\.)+[\w\-]+(?:\:\d+)?/\d/\d+/\d/\w+/[^\t\r\n\'\"<>]+@i';
  10.     public function Download($link) {
  11.         if (!preg_match('@(https://depfile\.com)/(?>downloads|([a-zA-Z\d]{8,})(?=/|$))(?(2)|/i/(\d+)/f/[^\s]+\.html)@i', str_ireplace(array('http://', '//www.depfile.com'), array('https://', '//depfile.com'), $link), $fid)) html_error('Invalid link?.');
  12.         $this->link = $GLOBALS['Referer'] = $fid[0];
  13.         $this->baseUrl = $fid[1];
  14.         $this->fid = empty($fid[3]) ? $fid[2] : $fid[3];
  15.  
  16.         if (empty($_POST['step'])) {
  17.             $this->page = $this->GetPage($this->link, $this->cookie);
  18.             $this->cookie = GetCookiesArr($this->page, $this->cookie);
  19.  
  20.             if (substr($this->page, 9, 3) == '404') html_error('Page Not Found.');
  21.  
  22.             if (is_numeric($this->fid)) is_present($this->page, 'File was not found in the DepFile database.', 'File Not Found or Link Invalid.');
  23.             else is_present($this->page, "\nLocation: /premium", 'File Not Found.');
  24.             $this->cookie['sdlanguageid'] = '2';
  25.  
  26.             if (stripos($this->page, '<h1>Download folder</h1>') !== false) return $this->Folder();
  27.         }
  28.  
  29.         $this->pA = (empty($_REQUEST['premium_user']) || empty($_REQUEST['premium_pass']) ? false : true);
  30.         if (($_REQUEST['premium_acc'] == 'on' && ($this->pA || (!empty($GLOBALS['premium_acc']['depfile_com']['user']) && !empty($GLOBALS['premium_acc']['depfile_com']['pass']))))) {
  31.             $user = ($this->pA ? $_REQUEST['premium_user'] : $GLOBALS['premium_acc']['depfile_com']['user']);
  32.             $pass = ($this->pA ? $_REQUEST['premium_pass'] : $GLOBALS['premium_acc']['depfile_com']['pass']);
  33.             if ($this->pA && !empty($_POST['pA_encrypted'])) {
  34.                 $user = decrypt(urldecode($user));
  35.                 $pass = decrypt(urldecode($pass));
  36.                 unset($_POST['pA_encrypted']);
  37.             }
  38.             return $this->CookieLogin($user, $pass);
  39.         } else return $this->FreeDL();
  40.     }
  41.  
  42.     private function Folder() {
  43.         if (isset($_GET['audl'])) return html_error('Cannot check folder in audl.');
  44.         if (!preg_match_all('@https?://(?:www\.)?depfile\.com/[a-zA-Z\d]{8,}(?=\')@i', $this->page, $links)) html_error('Empty folder?');
  45.         return $this->moveToAutoDownloader($links[0]);
  46.     }
  47.  
  48.     private function FreeDL() {
  49.         if (empty($_POST['step']) || $_POST['step'] != '1') {
  50.             is_present($this->page, 'File is available only for Premium users', 'This File Is Only Available For Premium Users.');
  51.             if (!preg_match('@/includes/vvc\.php\?vvcid=(\d+)@i', $this->page, $vvc)) html_error('CAPTCHA not Found.');
  52.             $data = $this->DefaultParamArr($this->link, $this->cookie, 1, 1);
  53.             $data['step'] = '1';
  54.             $data['vvcid'] = $vvc[1];
  55.             list($headers, $imgBody) = explode("\r\n\r\n", $this->GetPage($this->baseUrl.$vvc[0]), 2);
  56.             if (substr($headers, 9, 3) != '200') html_error('FreeDL: Error downloading captcha img.');
  57.             $mimetype = (preg_match('@image/[\w+]+@', $headers, $mimetype) ? $mimetype[0] : 'image/png');
  58.             return $this->EnterCaptcha("data:$mimetype;base64," . base64_encode($imgBody), $data);
  59.         }
  60.         if (empty($_POST['vvcid'])) html_error('FreeDL: Captcha\'s vvcid not Found.');
  61.         if (empty($_POST['captcha'])) html_error('FreeDL: You didn\'t enter the image verification code.');
  62.         $this->cookie = StrToCookies(decrypt(urldecode($_POST['cookie'])));
  63.         $this->cookie['sdlanguageid'] = '2';
  64.  
  65.         $post = array('vvcid' => urlencode($_POST['vvcid']), 'verifycode' => urlencode($_POST['captcha']), 'FREE' => 'Low+Speed+Download');
  66.         $page = $this->GetPage($this->link, $this->cookie, $post);
  67.         is_present($page, 'Wrong CAPTCHA', 'Incorrect CAPTCHA Answer.');
  68.         is_present($page, '>Download limit for free user.<', 'FreeDL Limit Reached.');
  69.         if (preg_match('@A file was recently downloaded from your IP address. No less than \d+ \w+ should pass before next download.@i', $page, $err)) html_error($err[0]);
  70.  
  71.         // Search Download Link
  72.         if (!preg_match($this->DLRegexp, $page, $DL)) {
  73.             if (!preg_match('@document\.getElementById\("wait_url"\)\.innerHTML\s*=\s*unescape\(\'([^\']+)\'\)@', $page, $inner)) html_error('Download Link Container not Found.');
  74.             $inner = rawurldecode($inner[1]);
  75.             if (!preg_match($this->DLRegexp, $inner, $DL)) html_error('Download Link not Found.');
  76.         }
  77.  
  78.         // Countdown
  79.         if (!preg_match('@var\s+sec\s*=\s*(\d+)\s*;@', $page, $cD)) html_error('Countdown not Found.');
  80.         $this->CountDown($cD[1]);
  81.  
  82.         return $this->RedirectDownload($DL[0], urldecode(parse_url($DL[0], PHP_URL_PATH)));
  83.     }
  84.  
  85.     private function PremiumDL() {
  86.         $page = $this->GetPage($this->link, $this->cookie);
  87.         $this->chkPremCaptcha($page);
  88.         is_present($page, 'Sorry, you spent downloads limit on urls/files per 24 hours.', 'Premium Download Limit Reached.');
  89.         if (!preg_match($this->DLRegexp, $page, $DL)) html_error('Download Link not Found.');
  90.         return $this->RedirectDownload($DL[0], urldecode(parse_url($DL[0], PHP_URL_PATH)));
  91.     }
  92.  
  93.     private function chkPremCaptcha(&$page) {
  94.         if (!preg_match('@/includes/vvc\.php\?vvcid=(\d+)@i', $page, $vvc)) return false;
  95.  
  96.         if (empty($_POST['step']) || $_POST['step'] != '3') {
  97.             $data = $this->DefaultParamArr($this->link, $this->cookie, 1, 1);
  98.             $data['step'] = '3';
  99.             $data['vvcid'] = $vvc[1];
  100.             if ($this->pA) {
  101.                 $data['pA_encrypted'] = 'true';
  102.                 $data['premium_user'] = urlencode(encrypt($_REQUEST['premium_user']));
  103.                 $data['premium_pass'] = urlencode(encrypt($_REQUEST['premium_pass']));
  104.             }
  105.             list($headers, $imgBody) = explode("\r\n\r\n", $this->GetPage($this->baseUrl.$vvc[0]), 2);
  106.             if (substr($headers, 9, 3) != '200') html_error('PremiumDL: Error downloading captcha img.');
  107.             $mimetype = (preg_match('@image/[\w+]+@', $headers, $mimetype) ? $mimetype[0] : 'image/png');
  108.             return $this->EnterCaptcha("data:$mimetype;base64," . base64_encode($imgBody), $data);
  109.         }
  110.         if (empty($_POST['vvcid'])) html_error('PremiumDL: Captcha\'s vvcid not Found.');
  111.         if (empty($_POST['captcha'])) html_error('PremiumDL: You didn\'t enter the image verification code.');
  112.  
  113.         $post = array('vvcid' => urlencode($_POST['vvcid']), 'verifycode' => urlencode($_POST['captcha']), 'prem_plus' => 'Next');
  114.         $page = $this->GetPage($this->link, $this->cookie, $post);
  115.         is_present($page, 'Wrong CAPTCHA', 'Incorrect CAPTCHA Answer.');
  116.         return true;
  117.     }
  118.  
  119.     private function loginTOTP(&$page) {
  120.         if (empty($_POST['step']) || $_POST['step'] != '2') {
  121.             if (strpos($page, "' name='user_otp_code'") === false) return false;
  122.             // Found otp input field
  123.             $data = $this->DefaultParamArr($this->link, $this->cookie, 1, 1);
  124.             $data['step'] = '2';
  125.             if ($this->pA) {
  126.                 $data['pA_encrypted'] = 'true';
  127.                 $data['premium_user'] = urlencode(encrypt($_REQUEST['premium_user']));
  128.                 $data['premium_pass'] = urlencode(encrypt($_REQUEST['premium_pass']));
  129.             }
  130.             echo "<form action='{$_SERVER['SCRIPT_NAME']}' method='POST'>\n";
  131.             foreach ($data as $key => $value) echo "<input type='hidden' name='$key' value='" . htmlspecialchars($value, ENT_QUOTES) . "' />\n";
  132.             echo 'Enter login TOTP' . ($this->pA ? ' for ' . htmlspecialchars($_REQUEST['premium_user']) : '') . ":<br />\n<input type='text' pattern='[0-9]{6}' name='totp_code' placeholder='Enter OTP token here' autofocus='autofocus' required='required' />\n<input type='submit' />\n</form>";
  133.             return html_error('Login TOTP (Time-based One-Time Password) Required');
  134.         }
  135.         $_POST['step'] = false;
  136.         if (empty($_POST['totp_code']) || !preg_match('/^\d{6}$/', $_POST['totp_code'])) html_error('Empty TOTP Code or Incomplete.');
  137.  
  138.         $page = $this->GetPage($this->baseUrl . '/', $this->cookie, array('user_otp_code' => $_POST['totp_code']));
  139.         is_present($page, "' name='user_otp_code'", 'Incorrect Login TOTP Token.');
  140.         $this->cookie = GetCookiesArr($page, $this->cookie); // Update cookies
  141.         $this->cookie['sdlanguageid'] = '2';
  142.  
  143.         return true;
  144.     }
  145.  
  146.     private function Login($user, $pass) {
  147.         $post = array('login' => 'login');
  148.         $post['loginemail'] = urlencode($user);
  149.         $post['loginpassword'] = urlencode($pass);
  150.         $post['submit'] = 'login';
  151.         $post['rememberme'] = 'on';
  152.         $page = $this->GetPage($this->baseUrl . '/', $this->cookie, $post);
  153.         is_present($page, 'E-mail not found.', 'Login Error: Wrong Email.');
  154.         is_present($page, 'Incorrect password', 'Login Error: Wrong Password.');
  155.         $this->cookie = GetCookiesArr($page, $this->cookie); // Update cookies
  156.         $this->cookie['sdlanguageid'] = '2';
  157.         if (empty($this->cookie['sduserid'])) html_error('Login Error: "sduserid" cookie not found.');
  158.         if (empty($this->cookie['sdpassword'])) html_error('Login Error: "sdpassword" cookie not found.');
  159.  
  160.         $this->SaveCookies($user, $pass); // Update cookies file
  161.  
  162.         if ($this->loginTOTP($page)) $this->SaveCookies($user, $pass);
  163.  
  164.         if (stripos($page, "<img src='/images/svg/i_premium.svg'") === false) {
  165.             $this->changeMesg('<br /><b>Account isn\'t premium?</b>', true);
  166.  
  167.             $this->page = $this->GetPage($this->link, $this->cookie);
  168.             $this->cookie = GetCookiesArr($this->page, $this->cookie);
  169.             $this->cookie['sdlanguageid'] = '2';
  170.  
  171.             return $this->FreeDL();
  172.         } else return $this->PremiumDL();
  173.     }
  174.  
  175.     private function IWillNameItLater($cookie, $decrypt = true) {
  176.         if (!is_array($cookie)) {
  177.             if (!empty($cookie)) return $decrypt ? decrypt(urldecode($cookie)) : urlencode(encrypt($cookie));
  178.             return '';
  179.         }
  180.         if (count($cookie) < 1) return $cookie;
  181.         $keys = array_keys($cookie);
  182.         $values = array_values($cookie);
  183.         $keys = $decrypt ? array_map('decrypt', array_map('urldecode', $keys)) : array_map('urlencode', array_map('encrypt', $keys));
  184.         $values = $decrypt ? array_map('decrypt', array_map('urldecode', $values)) : array_map('urlencode', array_map('encrypt', $values));
  185.         return array_combine($keys, $values);
  186.     }
  187.  
  188.     private function CookieLogin($user, $pass, $filename = 'depfile_dl.php') {
  189.         global $secretkey;
  190.         if (empty($user) || empty($pass)) html_error('Login Failed: User or Password is empty.');
  191.         $user = strtolower($user);
  192.  
  193.         $filename = DOWNLOAD_DIR . basename($filename);
  194.         if (!file_exists($filename)) return $this->Login($user, $pass);
  195.  
  196.         $file = file($filename);
  197.         $savedcookies = unserialize($file[1]);
  198.         unset($file);
  199.  
  200.         $hash = hash('crc32b', $user.':'.$pass);
  201.         if (is_array($savedcookies) && array_key_exists($hash, $savedcookies)) {
  202.             $_secretkey = $secretkey;
  203.             $secretkey = hash('crc32b', $pass).sha1($user.':'.$pass).hash('crc32b', $user); // A 56 char key should be safer. :D
  204.             $testCookie = (decrypt(urldecode($savedcookies[$hash]['enc'])) == 'OK') ? $this->IWillNameItLater($savedcookies[$hash]['cookie']) : '';
  205.             $secretkey = $_secretkey;
  206.             if (empty($testCookie) || (is_array($testCookie) && count($testCookie) < 1)) return $this->Login($user, $pass);
  207.  
  208.             $page = $this->GetPage($this->baseUrl.'/', $testCookie);
  209.             if (stripos($page, '\'/uploads/logout\'>') === false) return $this->Login($user, $pass);
  210.             $this->cookie = GetCookiesArr($page, $testCookie); // Update cookies
  211.             $this->cookie['sdlanguageid'] = '2';
  212.             $this->SaveCookies($user, $pass); // Update cookies file
  213.             if ($this->loginTOTP($page)) $this->SaveCookies($user, $pass);
  214.             if (stripos($page, "<img src='/images/svg/i_premium.svg'") === false) {
  215.                 $this->changeMesg('<br /><b>Account isn\'t premium?</b>', true);
  216.                 $this->page = $this->GetPage($this->link, $this->cookie);
  217.                 $this->cookie = GetCookiesArr($this->page, $this->cookie);
  218.                 $this->cookie['sdlanguageid'] = '2';
  219.                 return $this->FreeDL();
  220.             } else return $this->PremiumDL();
  221.         }
  222.         return $this->Login($user, $pass);
  223.     }
  224.  
  225.     private function SaveCookies($user, $pass, $filename = 'depfile_dl.php') {
  226.         global $secretkey;
  227.         $maxdays = 31; // Max days to keep extra cookies saved
  228.         $filename = DOWNLOAD_DIR . basename($filename);
  229.         if (file_exists($filename)) {
  230.             $file = file($filename);
  231.             $savedcookies = unserialize($file[1]);
  232.             unset($file);
  233.  
  234.             if (is_array($savedcookies)) {
  235.                 // Remove old cookies
  236.                 foreach ($savedcookies as $k => $v) if (empty($v['time']) || time() - $v['time'] >= ($maxdays * 24 * 60 * 60)) unset($savedcookies[$k]);
  237.             } else $savedcookies = array();
  238.         } else $savedcookies = array();
  239.         $hash = hash('crc32b', $user.':'.$pass);
  240.         $_secretkey = $secretkey;
  241.         $secretkey = hash('crc32b', $pass).sha1($user.':'.$pass).hash('crc32b', $user); // A 56 char key should be safer. :D
  242.         $savedcookies[$hash] = array('time' => time(), 'enc' => urlencode(encrypt('OK')), 'cookie' => $this->IWillNameItLater($this->cookie, false));
  243.         $secretkey = $_secretkey;
  244.  
  245.         file_put_contents($filename, "<?php exit(); ?>\r\n" . serialize($savedcookies), LOCK_EX);
  246.     }
  247. }
  248.  
  249. // [28-4-2016] Written by Th3-822.
  250. // [02-1-2017] Fixed premium check. - Th3-822
  251.  
  252. ?>
Add Comment
Please, Sign In to add comment