Advertisement
Th3-822

[rapidleech][d] hitfile_net

Jan 3rd, 2016
574
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 15.13 KB | None | 0 0
  1. <?php
  2.  
  3. if (!defined('RAPIDLEECH')) {
  4.     require_once('index.html');
  5.     exit;
  6. }
  7.  
  8. class hitfile_net extends DownloadClass {
  9.     private $link, $page, $cookie, $pA, $RDregexp, $DLregexp;
  10.     public function Download($link) {
  11.         global $premium_acc, $Referer;
  12.         if (!preg_match('@^https?://(?:[^/]+\.)?hitfile\.net/(?:download/free/)?(\w+)@i', $link, $id)) html_error('Error: Invalid link entered.');
  13.         $this->link = $Referer = 'http://hitfile.net/' . $id[1];
  14.         $this->pA = (empty($_REQUEST['premium_user']) || empty($_REQUEST['premium_pass']) ? false : true);
  15.         $this->cookie = array('user_lang' => 'en');
  16.         $this->RDregexp = '@(https?://(?:[^/\"\'\t\r\n<>]+\.)?hitfile\.net(?:\:\d+)?)?//?download/redirect/[^\"\'\t\r\n<>]+@i';
  17.         $this->DLregexp = '@https?://s\d+\.hitfile\.net(?:\:\d+)?/download\.php\?[^\"\'\t\r\n<>]+@i';
  18.  
  19.         if (empty($_POST['step'])) {
  20.             $this->page = $this->GetPage($this->link);
  21.             is_present($this->page, 'File was deleted or not found', 'File Not Found.'); // 404
  22.             $this->cookie = GetCookiesArr($this->page, $this->cookie);
  23.         }
  24.  
  25.         if (($_REQUEST['premium_acc'] == 'on' && ($this->pA || (!empty($premium_acc['hitfile_net']['user']) && !empty($premium_acc['hitfile_net']['pass']))))) {
  26.             $user = ($this->pA ? $_REQUEST['premium_user'] : $premium_acc['hitfile_net']['user']);
  27.             $pass = ($this->pA ? $_REQUEST['premium_pass'] : $premium_acc['hitfile_net']['pass']);
  28.             if ($this->pA && !empty($_POST['pA_encrypted'])) {
  29.                 $user = decrypt(urldecode($user));
  30.                 $pass = decrypt(urldecode($pass));
  31.                 unset($_POST['pA_encrypted']);
  32.             }
  33.             return $this->CookieLogin($user, $pass);
  34.         } else {
  35.             $this->link = 'http://hitfile.net/download/free/' . $id[1];
  36.             return $this->FreeDL();
  37.         }
  38.     }
  39.  
  40.     private function FreeDL() {
  41.         $_POST['step'] = empty($_POST['step']) ? '' : $_POST['step'];
  42.         switch ($_POST['step']) {
  43.             case '1': { // Send Captcha && Get Countdown
  44.                 if (empty($_POST['captcha'])) html_error('You didn\'t enter the image-verification code.');
  45.                 $this->cookie = StrToCookies(decrypt(urldecode($_POST['cookie'])));
  46.  
  47.                 $post = array();
  48.                 $post['captcha_response'] = urlencode($_POST['captcha']);
  49.                 $post['captcha_type'] = urlencode($_POST['c_type']);
  50.                 $post['captcha_subtype'] = (!empty($_POST['c_subtype']) ? urlencode($_POST['c_subtype']) : '');
  51.                 $page = $this->GetPage($this->link, $this->cookie, $post);
  52.  
  53.                 is_present($page, 'Incorrect, try again!', 'Error: Wrong CAPTCHA entered.');
  54.                 is_present($page, 'Looks like your browser has disabled cookies.', 'Error: Invalid cookies.');
  55.  
  56.                 if (!preg_match('@\W(?:min)?Limit[\s\t]*:[\s\t]*([\d\s\t\r\n\+\-\*/\(\)]+)[\s\t]*[\,\;]@i', $page, $count)) html_error('Countdown not found.');
  57.                 $data = $this->DefaultParamArr($this->link, encrypt(CookiesToStr($this->cookie)));
  58.                 $data['step'] = '2';
  59.                 $this->JSCountdown($count[1], $data);
  60.                 break;
  61.             }
  62.             case '2': { // Download
  63.                 $this->cookie = StrToCookies(decrypt(urldecode($_POST['cookie'])));
  64.                 $page = $this->GetPage(str_replace('/download/free/', '/download/getLinkTimeout/', $this->link), $this->cookie, 0, $this->link . "\r\nX-Requested-With: XMLHttpRequest");
  65.  
  66.                 if (preg_match($this->RDregexp, $page, $redir)) {
  67.                     $redir = (empty($redir[1])) ? 'http://hitfile.net'.$redir[0] : $redir[0];
  68.                     $page = $this->GetPage($redir, $this->cookie, 0, $this->link);
  69.                     if (!preg_match($this->DLregexp, $page, $dllink)) html_error('Download-Link not Found.');
  70.                 } elseif (!preg_match($this->DLregexp, $page, $dllink)) html_error('Redirect-Link not Found.');
  71.                 $this->RedirectDownload(html_entity_decode($dllink[0]), 'hitfile_fr', $this->cookie);
  72.                 break;
  73.             }
  74.             default : { // Get Captcha
  75.                 $page = $this->GetPage($this->link, $this->cookie);
  76.  
  77.                 if (preg_match('@\W(?:min)?Limit[\s\t]*:[\s\t]*([\d\s\t\r\n\+\-\*/\(\)]+)[\s\t]*[\,\;]@i', $page, $count)) {
  78.                     $data = $this->DefaultParamArr($this->link, encrypt(CookiesToStr($this->cookie)));
  79.                     $this->JSCountdown($count[1], $data, 'FreeDL limit reached');
  80.                 }
  81.  
  82.                 if (!preg_match('@(https?://[^/\r\n\t\s\'\"<>]+)?/captcha/[^\r\n\t\s\'\"<>]+@i', $page, $imgurl)) html_error('Error: CAPTCHA not found.');
  83.                 $imgurl = (empty($imgurl[1])) ? 'http://hitfile.net'.$imgurl[0] : $imgurl[0];
  84.                 $imgurl = html_entity_decode($imgurl);
  85.  
  86.                 if (!preg_match('@\Wvalue\s*=\s*[\'\"]([^\'\"\r\n<>]+)[\'\"]\s+name\s*=\s*[\'\"]captcha_type[\'\"]@i', $page, $c_type) || !preg_match('@\Wvalue\s*=\s*[\'\"]([^\'\"\r\n<>]*)[\'\"]\s+name\s*=\s*[\'\"]captcha_subtype[\'\"]@i', $page, $c_subtype)) html_error('CAPTCHA data not found');
  87.  
  88.                 //Download captcha img.
  89.                 $capt_page = $this->GetPage($imgurl, $this->cookie);
  90.                 $capt_img = substr($capt_page, strpos($capt_page, "\r\n\r\n") + 4);
  91.                 $imgfile = DOWNLOAD_DIR . 'hitfile_captcha.png';
  92.  
  93.                 if (file_exists($imgfile)) unlink($imgfile);
  94.                 if (!write_file($imgfile, $capt_img)) html_error('Error getting CAPTCHA image');
  95.                 unset($capt_page, $capt_img);
  96.  
  97.                 $data = $this->DefaultParamArr($this->link, encrypt(CookiesToStr($this->cookie)));
  98.                 $data['step'] = '1';
  99.                 $data['c_type'] = urlencode($c_type[1]);
  100.                 $data['c_subtype'] = urlencode($c_subtype[1]);
  101.                 $this->EnterCaptcha($imgfile.'?'.time(), $data);
  102.                 exit;
  103.             }
  104.         }
  105.     }
  106.  
  107.     private function PremiumDL() {
  108.         $page = $this->GetPage($this->link, $this->cookie);
  109.         if (preg_match($this->RDregexp, $page, $redir)) {
  110.             $redir = (empty($redir[1])) ? 'http://hitfile.net'.$redir[0] : $redir[0];
  111.             $page = $this->GetPage($redir, $this->cookie);
  112.  
  113.             if (!preg_match($this->DLregexp, $page, $dllink)) html_error('Download Link not Found.');
  114.         } elseif (!preg_match($this->DLregexp, $page, $dllink)) html_error('Redirect Link not Found.');
  115.         $this->RedirectDownload(html_entity_decode($dllink[0]), 'hitfile_pr', $this->cookie);
  116.     }
  117.  
  118.     private function Login($user, $pass) {
  119.         $purl = 'http://hitfile.net/';
  120.         if (!empty($_POST['step']) && ($_POST['step'] == '1' || $_POST['step'] == '2')) {
  121.             $this->cookie = StrToCookies(decrypt(urldecode($_POST['cookie'])));
  122.  
  123.             $post = array();
  124.             $post['user%5Blogin%5D'] = urlencode($user);
  125.             $post['user%5Bpass%5D'] = urlencode($pass);
  126.             if ($_POST['step'] == '1') {
  127.                 if (empty($_POST['captcha'])) html_error('You didn\'t enter the image verification code.');
  128.                 $post['user%5Bcaptcha_response%5D'] = urlencode($_POST['captcha']);
  129.             } else {
  130.                 if (empty($_POST['recaptcha_response_field'])) html_error('You didn\'t enter the image verification code.');
  131.                 $post['recaptcha_challenge_field'] = urlencode($_POST['recaptcha_challenge_field']);
  132.                 $post['recaptcha_response_field'] = urlencode($_POST['recaptcha_response_field']);
  133.             }
  134.             $post['user%5Bcaptcha_type%5D'] = urlencode($_POST['c_type']);
  135.             $post['user%5Bcaptcha_subtype%5D'] = (!empty($_POST['c_subtype']) ? urlencode($_POST['c_subtype']) : '');
  136.             $post['user%5Bmemory%5D'] = 'on';
  137.             $post['user%5Bsubmit%5D'] = 'Login';
  138.  
  139.             $page = $this->GetPage($purl.'user/login', $this->cookie, $post, $purl.'login');
  140.             $this->cookie = GetCookiesArr($page, $this->cookie);
  141.  
  142.             $x = 0;
  143.             while ($x < 3 && stripos($page, "\nLocation: ") !== false && preg_match('@\nLocation: ((https?://[^/\r\n]+)?/[^\r\n]*)@i', $page, $redir)) {
  144.                 $redir = (empty($redir[2])) ? 'http://hitfile.net'.$redir[1] : $redir[1];
  145.                 $page = $this->GetPage($redir, $this->cookie);
  146.                 $this->cookie = GetCookiesArr($page, $this->cookie);
  147.                 $x++;
  148.             }
  149.  
  150.             is_present($page, 'Incorrect login or password', 'Login Failed: Login/Password incorrect.');
  151.             is_present($page, 'E-Mail address appears to be invalid.', 'Login Failed: Invalid E-Mail.');
  152.             is_present($page, 'Username(Email) does not exist', 'Login Failed: E-Mail is not registered.');
  153.             is_present($page, 'Incorrect verification code', 'Login Failed: Wrong CAPTCHA entered.');
  154.             is_present($page, 'Incorrect captcha code', 'Login Failed: Wrong Recaptcha entered.');
  155.             // is_present($page, 'Limit of login attempts exceeded for your account. It has been temporarily locked.', 'Login Failed: Account Temporally Locked.');
  156.  
  157.             if (empty($redir) || $redir != $purl) $page = $this->GetPage($purl, $this->cookie, 0, $purl);
  158.             is_notpresent($page, '/user/logout">Logout<', 'Login Failed.');
  159.  
  160.             $this->SaveCookies($user, $pass); // Update cookies file
  161.             is_present($page, 'Account: <b>free</b>', 'Login Failed: Account isn\'t premium.');
  162.             return $this->PremiumDL();
  163.         } else {
  164.             $post = array();
  165.             $post['user%5Blogin%5D'] = urlencode($user);
  166.             $post['user%5Bpass%5D'] = urlencode($pass);
  167.             $post['user%5Bmemory%5D'] = 'on';
  168.             $post['user%5Bsubmit%5D'] = 'Login';
  169.             $page = $this->GetPage($purl.'user/login', $this->cookie, $post, $purl.'login');
  170.             $this->cookie = GetCookiesArr($page, $this->cookie);
  171.  
  172.             if (!empty($this->cookie['user_isloggedin']) && $this->cookie['user_isloggedin'] == '1') {
  173.                 $page = $this->GetPage($purl, $this->cookie, 0, $purl);
  174.                 $this->SaveCookies($user, $pass); // Update cookies file
  175.                 is_present($page, 'Account: <b>free</b>', 'Login Failed: Account isn\'t premium');
  176.                 return $this->PremiumDL();
  177.             }
  178.  
  179.             $x = 0;
  180.             while ($x < 3 && stripos($page, "\nLocation: ") !== false && preg_match('@\nLocation: ((https?://[^/\r\n]+)?/[^\r\n]*)@i', $page, $redir)) {
  181.                 $redir = (empty($redir[2])) ? 'http://hitfile.net'.$redir[1] : $redir[1];
  182.                 $page = $this->GetPage($redir, $this->cookie);
  183.                 $this->cookie = GetCookiesArr($page, $this->cookie);
  184.                 $x++;
  185.             }
  186.             if ($x < 1) html_error('Login redirect not found');
  187.  
  188.             is_present($page, 'Incorrect login or password', 'Login Failed: Login/Password incorrect');
  189.             is_present($page, 'E-Mail address appears to be invalid.', 'Login Failed: Invalid E-Mail');
  190.             is_present($page, 'Username(Email) does not exist', 'Login Failed: E-Mail is not registered.');
  191.             // is_present($page, 'Limit of login attempts exceeded for your account. It has been temporarily locked.', 'Login Failed: Account Temporally Locked');
  192.  
  193.             if (preg_match('@(https?://[^/\r\n\t\s\'\"<>]+)?/captcha/[^\r\n\t\s\'\"<>]+@i', $page, $imgurl)) {
  194.                 $imgurl = (empty($imgurl[1])) ? 'http://hitfile.net'.$imgurl[0] : $imgurl[0];
  195.                 $imgurl = html_entity_decode($imgurl);
  196.  
  197.                 if (!preg_match('@\Wvalue\s*=\s*[\'\"]([^\'\"\r\n<>]+)[\'\"]\s+name\s*=\s*[\'\"]user\[captcha_type\][\'\"]@i', $page, $c_type) || !preg_match('@\Wvalue\s*=\s*[\'\"]([^\'\"\r\n<>]*)[\'\"]\s+name\s*=\s*[\'\"]user\[captcha_subtype\][\'\"]@i', $page, $c_subtype)) html_error('CAPTCHA data not found.');
  198.  
  199.  
  200.                 //Download captcha img.
  201.                 $capt_page = $this->GetPage($imgurl, $this->cookie);
  202.                 $capt_img = substr($capt_page, strpos($capt_page, "\r\n\r\n") + 4);
  203.                 $imgfile = DOWNLOAD_DIR . 'hitfile_captcha.png';
  204.  
  205.                 if (file_exists($imgfile)) unlink($imgfile);
  206.                 if (!write_file($imgfile, $capt_img)) html_error('Error getting CAPTCHA image.');
  207.                 unset($capt_page, $capt_img);
  208.  
  209.                 $data = $this->DefaultParamArr($this->link, encrypt(CookiesToStr($this->cookie)));
  210.                 $data['step'] = '1';
  211.                 $data['c_type'] = urlencode($c_type[1]);
  212.                 $data['c_subtype'] = urlencode($c_subtype[1]);
  213.                 $data['premium_acc'] = 'on';
  214.                 if ($this->pA) {
  215.                     $data['pA_encrypted'] = 'true';
  216.                     $data['premium_user'] = urlencode(encrypt($user)); // encrypt() will keep this safe.
  217.                     $data['premium_pass'] = urlencode(encrypt($pass)); // And this too.
  218.                 }
  219.                 $this->EnterCaptcha($imgfile.'?'.time(), $data);
  220.                 exit;
  221.             } elseif (preg_match('@https?://(?:[^/]+\.)?(?:(?:google\.com/recaptcha/api)|(?:recaptcha\.net))/(?:(?:challenge)|(?:noscript))\?k=([\w\.\-]+)@i', $page, $pid)) {
  222.                 $data = $this->DefaultParamArr($this->link, encrypt(CookiesToStr($this->cookie)));
  223.                 $data['step'] = '2';
  224.                 $data['c_type'] = 'recaptcha';
  225.                 $data['premium_acc'] = 'on';
  226.                 if ($this->pA) {
  227.                     $data['pA_encrypted'] = 'true';
  228.                     $data['premium_user'] = urlencode(encrypt($user)); // encrypt() will keep this safe.
  229.                     $data['premium_pass'] = urlencode(encrypt($pass)); // And this too.
  230.                 }
  231.                 $this->reCAPTCHA($pid[1], $data, 0, 'Login');
  232.                 exit;
  233.             } elseif (stripos($page, '/user/logout">Logout<') !== false) {
  234.                 $this->SaveCookies($user, $pass); // Update cookies file
  235.                 is_present($page, 'Account: <b>free</b>', 'Login Failed: Account isn\'t premium');
  236.                 return $this->PremiumDL();
  237.             } else html_error('CAPTCHA not found.');
  238.         }
  239.     }
  240.  
  241.     private function IWillNameItLater($cookie, $decrypt=true) {
  242.         if (!is_array($cookie)) {
  243.             if (!empty($cookie)) return $decrypt ? decrypt(urldecode($cookie)) : urlencode(encrypt($cookie));
  244.             return '';
  245.         }
  246.         if (count($cookie) < 1) return $cookie;
  247.         $keys = array_keys($cookie);
  248.         $values = array_values($cookie);
  249.         $keys = $decrypt ? array_map('decrypt', array_map('urldecode', $keys)) : array_map('urlencode', array_map('encrypt', $keys));
  250.         $values = $decrypt ? array_map('decrypt', array_map('urldecode', $values)) : array_map('urlencode', array_map('encrypt', $values));
  251.         return array_combine($keys, $values);
  252.     }
  253.  
  254.     private function CookieLogin($user, $pass, $filename = 'hitfile_dl.php') {
  255.         global $secretkey;
  256.         if (empty($user) || empty($pass)) html_error('Login Failed: User or Password is empty.');
  257.  
  258.         $filename = DOWNLOAD_DIR . basename($filename);
  259.         if (!file_exists($filename)) return $this->Login($user, $pass);
  260.  
  261.         $file = file($filename);
  262.         $savedcookies = unserialize($file[1]);
  263.         unset($file);
  264.  
  265.         $hash = hash('crc32b', $user.':'.$pass);
  266.         if (array_key_exists($hash, $savedcookies)) {
  267.             $_secretkey = $secretkey;
  268.             $secretkey = sha1($user.':'.$pass);
  269.             $testCookie = (decrypt(urldecode($savedcookies[$hash]['enc'])) == 'OK') ? $this->IWillNameItLater($savedcookies[$hash]['cookie']) : '';
  270.             $secretkey = $_secretkey;
  271.             if (empty($testCookie) || (is_array($testCookie) && count($testCookie) < 1)) return $this->Login($user, $pass);
  272.  
  273.             $page = $this->GetPage('http://hitfile.net/', $testCookie);
  274.             if (stripos($page, '/user/logout">Logout<') === false) return $this->Login($user, $pass);
  275.             $this->cookie = GetCookiesArr($page, $testCookie); // Update cookies
  276.             $this->SaveCookies($user, $pass); // Update cookies file
  277.             is_present($page, 'Account: <b>free</b>', 'Account isn\'t premium.');
  278.             return $this->PremiumDL();
  279.         }
  280.         return $this->Login($user, $pass);
  281.     }
  282.  
  283.     private function SaveCookies($user, $pass, $filename = 'hitfile_dl.php') {
  284.         global $secretkey;
  285.         $maxdays = 31; // Max days to keep cookies saved
  286.         $filename = DOWNLOAD_DIR . basename($filename);
  287.         if (file_exists($filename)) {
  288.             $file = file($filename);
  289.             $savedcookies = unserialize($file[1]);
  290.             unset($file);
  291.  
  292.             // Remove old cookies
  293.             foreach ($savedcookies as $k => $v) if (time() - $v['time'] >= ($maxdays * 24 * 60 * 60)) unset($savedcookies[$k]);
  294.         } else $savedcookies = array();
  295.         $hash = hash('crc32b', $user.':'.$pass);
  296.         $_secretkey = $secretkey;
  297.         $secretkey = sha1($user.':'.$pass);
  298.         $savedcookies[$hash] = array('time' => time(), 'enc' => urlencode(encrypt('OK')), 'cookie' => $this->IWillNameItLater($this->cookie, false));
  299.         $secretkey = $_secretkey;
  300.  
  301.         file_put_contents($filename, "<?php exit(); ?>\r\n" . serialize($savedcookies), LOCK_EX);
  302.     }
  303. }
  304.  
  305. //[09-1-2013] Written by Th3-822.
  306. //[07-6-2013] Added login recaptcha support. - Th3-822
  307. //[03-1-2016] Replaced 'turbobit' with 'hitfile' && small edits to make it work. - Th3-822
  308.  
  309. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement