Th3-822

[rapidleech][u] rapidgator.net_member.php

Sep 9th, 2012
1,633
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 15.30 KB | None | 0 0
  1. <?php
  2. ######### Account Info #########
  3. $upload_acc['rapidgator_net']['user'] = ''; //Set your user
  4. $upload_acc['rapidgator_net']['pass'] = ''; //Set your password
  5. ##########################
  6.  
  7. $_GET['proxy'] = !empty($proxy) ? $proxy : (!empty($_GET['proxy']) ? $_GET['proxy'] : '');
  8. $not_done = true;
  9.  
  10. // This Plugin Requires cURL + HTTPs support
  11. $use_curl = extension_loaded('curl') && function_exists('curl_init') && function_exists('curl_exec') ? true : false;
  12. if ($use_curl) {
  13.     $cV = curl_version();
  14.     if (!in_array('https', $cV['protocols'], true)) html_error('This plugin requires cURL + HTTPs support. (Lacks HTTPs support)');
  15. } else html_error('This plugin requires cURL + HTTPs support. (cURL is disabled)');
  16.  
  17. if ($upload_acc['rapidgator_net']['user'] && $upload_acc['rapidgator_net']['pass']) {
  18.     $default_acc = true;
  19.     $_REQUEST['up_login'] = $upload_acc['rapidgator_net']['user'];
  20.     $_REQUEST['up_pass'] = $upload_acc['rapidgator_net']['pass'];
  21.     $_REQUEST['action'] = 'FORM';
  22.     echo "<b><center>Using Default Login.</center></b>\n";
  23. } else $default_acc = false;
  24.  
  25. if (empty($_REQUEST['action']) || $_REQUEST['action'] != 'FORM') {
  26.     echo "<table border='0' style='width:270px;' cellspacing='0' align='center'>
  27.     <form method='POST'>
  28.     <input type='hidden' name='action' value='FORM' />
  29.     <tr><td style='white-space:nowrap;'>&nbsp;Email*</td><td>&nbsp;<input type='text' name='up_login' value='' style='width:160px;' /></td></tr>
  30.     <tr><td style='white-space:nowrap;'>&nbsp;Password*</td><td>&nbsp;<input type='password' name='up_pass' value='' style='width:160px;' /></td></tr>\n";
  31.     echo "<tr><td colspan='2' align='center'><br /><input type='submit' value='Upload' /></td></tr>\n";
  32.     echo "<tr><td colspan='2' align='center'><small>*You can set it as default in <b>".basename(__FILE__)."</b></small></td></tr>\n";
  33.     echo "</table>\n</form>\n";
  34. } else {
  35.     $not_done = $login = false;
  36.     $domain = 'rapidgator.net';
  37.     $referer = "http://$domain/";
  38.  
  39.     // Login
  40.     echo "<table style='width:600px;margin:auto;'>\n<tr><td align='center'>\n<div id='login' width='100%' align='center'>Login to $domain</div>\n";
  41.  
  42.     $cookie = array('lang' => 'en');
  43.     if (!empty($_REQUEST['up_login']) && !empty($_REQUEST['up_pass'])) {
  44.         // Decrypt login if it was encrypted
  45.         if (!empty($_REQUEST['A_encrypted'])) {
  46.             $_REQUEST['up_login'] = decrypt(urldecode($_REQUEST['up_login']));
  47.             $_REQUEST['up_pass'] = decrypt(urldecode($_REQUEST['up_pass']));
  48.             unset($_REQUEST['A_encrypted']);
  49.         }
  50.  
  51.         $post = array();
  52.         $post['LoginForm%5Bemail%5D'] = urlencode($_REQUEST['up_login']);
  53.         $post['LoginForm%5Bpassword%5D'] = urlencode($_REQUEST['up_pass']);
  54.         $post['LoginForm%5BrememberMe%5D'] = 1;
  55.         if (!empty($_POST['step']) && $_POST['step'] == '1') {
  56.             $_POST['step'] = false;
  57.             if (empty($_POST['captcha'])) html_error('You didn\'t enter the image verification code.');
  58.             $cookie = StrToCookies(decrypt(urldecode($_POST['cookie'])));
  59.             $post['LoginForm%5BverifyCode%5D'] = urlencode($_POST['captcha']);
  60.         }
  61.  
  62.         //Redirects
  63.         $rdc = 0;
  64.         $page = false; // False value for starting the loop.
  65.         $redir = "http://$domain/auth/login";
  66.         if (!empty($_POST['referer'])) $referer = $_POST['referer'];
  67.         while (($redir = ChkRGRedirs($page, $redir, '(?:/auth/login|/site/ChangeLocation/key/)', $default_acc)) && $rdc < 15) {
  68.             $page = cURL($redir, $cookie, $post, $referer);
  69.             $cookie = GetCookiesArr($page, $cookie);
  70.             $referer = $redir;
  71.             $rdc++;
  72.         }
  73.  
  74.         is_present($page, 'Wrong e-mail or password.', 'Login Failed: Invalid Email or Password.');
  75.         is_present($page, 'E-mail is not a valid email address.', 'Login Failed: Login isn\'t an email address.');
  76.         is_present($page, 'We discovered that you try to access your account from unusual location.', 'Login Failed: Login Blocked By IP, Check Account Email And Follow The Steps To Add IP to Whitelist.');
  77.         if (stripos($page, 'The code from a picture does not coincide') !== false) {
  78.             if (!empty($post['LoginForm%5BverifyCode%5D'])) html_error('Login Failed: Incorrect CAPTCHA response.');
  79.             if (!preg_match('@(https?://(?:[^\./\r\n\'\"\t\:]+\.)?rapidgator\.net(?:\:\d+)?)?/auth/captcha/\w+/\w+@i', $page, $imgurl)) html_error('Error: CAPTCHA not found.');
  80.             $imgurl = (empty($imgurl[1])) ? 'http://rapidgator.net'.$imgurl[0] : $imgurl[0];
  81.             //Download captcha img.
  82.             $captcha = explode("\r\n\r\n", cURL($imgurl, $this->cookie), 2);
  83.             if (substr($captcha[0], 9, 3) != '200') html_error('Error downloading captcha img.');
  84.             $mimetype = (preg_match('@image/[\w+]+@', $captcha[0], $mimetype) ? $mimetype[0] : 'image/png');
  85.  
  86.             $data = array();
  87.             $data['step'] = '1';
  88.             $data['cookie'] = urlencode(encrypt(CookiesToStr($cookie)));
  89.             $data['action'] = 'FORM'; // I should add 'premium_acc' to DefaultParamArr()
  90.             if (!$default_acc) {
  91.                 $data['A_encrypted'] = 'true';
  92.                 $data['up_login'] = urlencode(encrypt($_REQUEST['up_login'])); // encrypt() will keep this safe.
  93.                 $data['up_pass'] = urlencode(encrypt($_REQUEST['up_pass'])); // And this too.
  94.             }
  95.             EnterCaptcha("data:$mimetype;base64,".base64_encode($captcha[1]), $data, 5, 'Login');
  96.             exit;
  97.         }
  98.         //is_present($page, 'The code from a picture does not coincide', 'Login Failed: Captcha... (T8: I will add it later)');
  99.         is_present($page, 'The code from a picture does not coincide', 'Login Failed: Captcha... (T8: I will add it later)');
  100.  
  101.         if (empty($cookie['user__'])) html_error("Login Error: Cannot find 'user__' cookie.");
  102.         $cookie['lang'] = 'en';
  103.         $login = true;
  104.     } else html_error('Login failed: User/Password empty.');
  105.  
  106.     // Retrive upload ID
  107.     echo "<script type='text/javascript'>document.getElementById('login').style.display='none';</script>\n<div id='info' width='100%' align='center'>Retrive upload ID</div>\n";
  108.  
  109.     //Redirects
  110.     $rdc = 0;
  111.     $page = false; // False value for starting the loop.
  112.     $redir = "http://$domain/";
  113.     while (($redir = ChkRGRedirs($page, $redir)) && $rdc < 15) {
  114.         $page = cURL($redir, $cookie, 0, $referer);
  115.         $cookie = GetCookiesArr($page, $cookie);
  116.         $referer = $redir;
  117.         $rdc++;
  118.     }
  119.  
  120.     if (!preg_match('@var\s+form_url\s*=\s*"(https?://[^/|\"]+/[^\"]+)"\s*;@i', $page, $form_url) || !preg_match('@var\s+progress_url_web\s*=\s*"(https?://[^/|\"]+/[^\"]+)"\s*;@i', $page, $prog_url)) {
  121.         is_present($page, 'Your storage space is full. Delete some files or upgrade to the new', 'Your storage space is full');
  122.         html_error('Error: Cannot find upload url.');
  123.     }
  124.  
  125.     $starttime = time();
  126.     $uuid = '';
  127.     $hexchars = str_split('0123456789abcdef');
  128.     for ($i = 0; $i < 32; $i++) $uuid .= $hexchars[array_rand($hexchars)];
  129.  
  130.     $up_url = $form_url[1]."$uuid&folder_id=0";
  131.  
  132.     // Uploading
  133.     echo "<script type='text/javascript'>document.getElementById('info').style.display='none';</script>\n";
  134.  
  135.     $url = parse_url($up_url);
  136.     $upfiles = upfile($url['host'], defport($url), $url['path'].(!empty($url['query']) ? '?'.$url['query'] : ''), $referer, $cookie, array(), $lfile, $lname, 'file', '', $_GET['proxy'], $pauth, 0, $url['scheme']);
  137.  
  138.     // Upload Finished
  139.     echo "<script type='text/javascript'>document.getElementById('progressblock').style.display='none';</script>";
  140.  
  141.     is_page($upfiles);
  142.  
  143.     // Pool Upload
  144.     echo "<div id='T8_div' width='100%' align='center'>Checking Finished Upload : Try <span id='T8_try'>0</span><br /><span id='T8_status'></span></div>\n";
  145.     $x = 1;
  146.     do {
  147.         echo "<script type='text/javascript'>document.getElementById('T8_try').innerHTML = '$x';</script>\n";
  148.         sleep($x + 5); // A little wait
  149.  
  150.         //Redirects
  151.         $rdc = 0;
  152.         $page = false; // False value for starting the loop.
  153.         $redir = $prog_url[1]."&data%5B0%5D%5Buuid%5D=$uuid&data%5B0%5D%5Bstart_time%5D=$starttime";
  154.         while (($redir = ChkRGRedirs($page, $redir)) && $rdc < 15) {
  155.             $page = cURL($redir, $cookie, 0, $referer);
  156.             $cookie = GetCookiesArr($page, $cookie);
  157.             $referer = $redir;
  158.             $rdc++;
  159.         }
  160.  
  161.         $resp = json2array($page, "Cannot get upload status $x");
  162.     } while ($x++ < 5 && $resp[0]['state'] == 'processing');
  163.  
  164.     if (!empty($resp[0]['download_url'])) {
  165.         $download_link = $resp[0]['download_url'];
  166.         if (!empty($resp[0]['remove_url'])) $delete_link = $resp[0]['remove_url'];
  167.     } else html_error("Download link not found ({$resp[0]['state']}).");
  168. }
  169.  
  170. function json2array($content, $errorPrefix = 'Error') {
  171.     if (!function_exists('json_decode')) html_error('Error: Please enable JSON in php.');
  172.     if (empty($content)) return NULL;
  173.     $content = ltrim($content);
  174.     if (($pos = strpos($content, "\r\n\r\n")) > 0) $content = trim(substr($content, $pos + 4));
  175.     $cb_pos = strpos($content, '{');
  176.     $sb_pos = strpos($content, '[');
  177.     if ($cb_pos === false && $sb_pos === false) html_error("[$errorPrefix]: JSON start braces not found.");
  178.     $sb = ($cb_pos === false || $sb_pos < $cb_pos) ? true : false;
  179.     $content = substr($content, strpos($content, ($sb ? '[' : '{')));$content = substr($content, 0, strrpos($content, ($sb ? ']' : '}')) + 1);
  180.     if (empty($content)) html_error("[$errorPrefix]: No JSON content.");
  181.     $rply = json_decode($content, true);
  182.     if ($rply === NULL) html_error("[$errorPrefix]: Error reading JSON.");
  183.     return $rply;
  184. }
  185.  
  186. // Edited For upload.php usage.
  187. function EnterCaptcha($captchaImg, $inputs, $captchaSize = '5', $sname = 'Enter Captcha', $iname = 'captcha') {
  188.     echo "\n<form name='captcha' method='POST'>\n";
  189.     foreach ($inputs as $name => $input) echo "\t<input type='hidden' name='$name' id='$name' value='" . htmlspecialchars($input, ENT_QUOTES) . "' />\n";
  190.     echo "\t<h4>" . lang(301) . " <img alt='CAPTCHA Image' src='$captchaImg' /> " . lang(302) . ": <input id='captcha' type='text' name='$iname' size='$captchaSize' />&nbsp;&nbsp;\n\t\t<input type='submit' onclick='return check();' value='$sname' />\n\t</h4>\n\t<script type='text/javascript'>/* <![CDATA[ */\n\t\tfunction check() {\n\t\t\tvar captcha=document.getElementById('captcha').value;\n\t\t\tif (captcha == '') {\n\t\t\t\twindow.alert('You didn\'t enter the image verification code');\n\t\t\t\treturn false;\n\t\t\t} else return true;\n\t\t}\n\t/* ]]> */</script>\n</form>\n</body></html>";
  191. }
  192.  
  193. function ChkRGRedirs($page, $lasturl, $rgpath = '/', $default_login = false) { // Edited for upload plugin usage.
  194.     if (!is_array($lasturl)) $lasturl = parse_url($lasturl);
  195.     if ($page === false) return rebuild_url($lasturl);
  196.     $hpos = strpos($page, "\r\n\r\n");
  197.     $headers = empty($hpos) ? $page : substr($page, 0, $hpos);
  198.  
  199.     if (stripos($headers, "\nLocation: ") === false && stripos($headers, "\nSet-Cookie: ") === false && stripos($headers, '<script') !== false && !(cut_str($page, '<title>', '</title>'))) {
  200.         if (empty($_REQUEST['rgredir'])) {
  201.             if (!($body = cut_str($page, '<body>', '</body>'))) $body = $page;
  202.             if (stripos($body, '<script') !== strripos($body, '<script')) html_error('Unknown error while getting redirect code.');
  203.             $data = array('action' => 'FORM', 'referer' => rebuild_url($lasturl), 'rgredir' => '');
  204.             if (!$default_login) {
  205.                 $data['A_encrypted'] = 'true';
  206.                 $data['up_login'] = urlencode(encrypt($_REQUEST['up_login']));
  207.                 $data['up_pass'] = urlencode(encrypt($_REQUEST['up_pass']));
  208.             }
  209.             if (!($js = cut_str($body, '<script language="JavaScript">', '</script>')) && !($js = cut_str($body, '<script type="text/javascript">', '</script>'))) html_error('Cannot get the redirect code.');
  210.             $js = str_ireplace(array('window.location.href','document.location.href'), 'document.getElementById("rgredir").value', $js);
  211.             if (strpos($js, 'document.body.onmousemove') !== false) { // New redirect code
  212.                 $js = preg_replace('@^[\s\t]*\w+\([^\;]+;@i', '', $js);
  213.                 $js = preg_replace('@document\.body\.onmousemove[\s\t]*=[\s\t]*function[\s\t]*\(\)[\s\t]*\{@i', '', $js);
  214.                 $js = preg_replace('@document\.body\.onmousemove[\s\t]*=[\s\t]*\'\';?\};[\s\t]*window\.setTimeout\([\s\t]*((\"[^\"]+\")|(\'[^\']+\'))[^\;]+;[\s\t\r\n]*$@i', '', $js);
  215.             } elseif (($funcPos = stripos($js, 'function WriteA(')) !== false) { // JS + aaaaaaaaaaaaaaaaaaaaaaaaa
  216.                 $links = array();
  217.                 if (preg_match_all('@<a\s*[^>]*\shref="((?:https?://(?:www\.)?rapidgator\.net)?/[^\"]+)"[^>]*\sid="([A-Za-z][\w\.\-]*)"@i', $body, $a)) $links = array_merge($links, array_combine($a[2], $a[1]));
  218.                 if (preg_match_all('@<a\s*[^>]*\sid="([A-Za-z][\w\.\-]*)"[^>]*\shref="((?:https?://(?:www\.)?rapidgator\.net)?/[^\"]+)"@i', $body, $a)) $links = array_merge($links, array_combine($a[1], $a[2]));
  219.                 if (empty($links)) html_error('Cannot get the redirect fields');
  220.                 unset($a);
  221.  
  222.                 $jsLinks = '';
  223.                 foreach ($links as $key => $link) {
  224.                     if (strpos($link, '://') === false) $link = (!empty($lasturl['scheme']) && strtolower($lasturl['scheme']) == 'https' ? 'https' : 'http').'://rapidgator.net' . $link;
  225.                     $jsLinks .= "$key: '".addslashes($link)."', ";
  226.                 }
  227.                 unset($links, $key, $link);
  228.                 $jsLinks = '{' . substr($jsLinks, 0, -2) . '}';
  229.                 $func = substr($js, $funcPos);
  230.                 if (!preg_match('@\.getElementById\(([\$_A-Za-z][\$\w]*)\)@i', $func, $linkVar)) html_error('Cannot edit redirect JS');
  231.                 $linkVar = $linkVar[1];
  232.                 unset($func);
  233.                 $js = substr($js, 0, $funcPos)."\nvar T8RGLinks = $jsLinks;\nif ($linkVar in T8RGLinks) document.getElementById('rgredir').value = T8RGLinks[$linkVar];";
  234.                 unset($jsLinks, $funcPos, $linkVar);
  235.             }
  236.             echo "\n<form name='rg_redir' method='POST'><br />\n";
  237.             foreach ($data as $name => $input) echo "<input type='hidden' name='$name' id='$name' value='" . htmlspecialchars($input, ENT_QUOTES) . "' />\n";
  238.             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\ttry {{$js}\n\t} catch(e) {\n\t\t$('#T8_emsg').html('<b>Cannot decode challenge: ['+e.name+'] '+e.message+'</b>').show();\n\t\tT8 = false;\n\t}\n\tif (T8) window.setTimeout(\"$('form[name=rg_redir]').submit();\", 300); // 300 ร‚ยตs to make sure that the value was decoded and added.\n/* ]]> */</script>\n\n</body>\n</html>";
  239.             exit;
  240.         } else {
  241.             $_REQUEST['rgredir'] = rawurldecode($_REQUEST['rgredir']);
  242.             if (strpos($_REQUEST['rgredir'], '://')) $_REQUEST['rgredir'] = parse_url($_REQUEST['rgredir'], PHP_URL_PATH);
  243.             if (empty($_REQUEST['rgredir']) || substr($_REQUEST['rgredir'], 0, 1) != '/') html_error('Invalid redirect value.');
  244.             $redir = (!empty($lasturl['scheme']) && strtolower($lasturl['scheme']) == 'https' ? 'https' : 'http').'://rapidgator.net'.$_REQUEST['rgredir'];
  245.             unset($_REQUEST['rgredir']);
  246.         }
  247.     } elseif (preg_match('@Location: ((https?://(?:[^/\r\n]+\.)?rapidgator\.net)?'.$rgpath.'[^\r\n]*)@i', $headers, $redir)) $redir = (empty($redir[2])) ? (!empty($lasturl['scheme']) && strtolower($lasturl['scheme']) == 'https' ? 'https' : 'http').'://rapidgator.net'.$redir[1] : $redir[1];
  248.  
  249.     return (empty($redir) ? false : $redir);
  250. }
  251.  
  252. // [09-9-2012] Written by Th3-822.
  253. // [02-10-2012] Fixed for new weird redirect code. - Th3-822
  254. // [31-10-2012] Fixed for https on login/redirects. - Th3-822
  255. // [28-1-2013] Added Login captcha support. - Th3-822
  256. // [14-6-2013] Removed https from first login try, for avoid block. - Th3-822
  257. // [10-8-2013] Fixed redirects (again). - Th3-822
  258. // [05-10-2013] Removed anon user support. - Th3-822
  259. // [25-11-2013] Fixed redirects function (aagain :D ). - Th3-822
  260. // [16-12-2015][WIP] Fixing Blocks, Redirect Handling & Forcing Plugin To Use cURL. - Th3-822
  261. // [27-11-2016] Added wait and retries to get download_link. - Th3-822
  262.  
  263. ?>
Add Comment
Please, Sign In to add comment