Example #1
0
function Login($user, $pass)
{
    global $default_acc, $cookie, $domain, $referer, $pauth;
    $errors = array('CaptchaInvalid' => 'Wrong CAPTCHA entered.', 'InvalidLogIn' => 'Invalid Login/Pass.', 'CaptchaRequired' => 'Captcha Required.');
    if (!empty($_POST['step']) && ($_POST['step'] == '1' || $_POST['step'] == '2')) {
        $cookie = StrToCookies(decrypt(urldecode($_POST['cookie'])));
        $post = array();
        $post['user%5Blogin%5D'] = urlencode($user);
        $post['user%5Bpass%5D'] = urlencode($pass);
        if ($_POST['step'] == '1') {
            if (empty($_POST['captcha'])) {
                html_error('You didn\'t enter the image verification code.');
            }
            $post['user%5Bcaptcha_response%5D'] = urlencode($_POST['captcha']);
        } else {
            if (empty($_POST['recaptcha_response_field'])) {
                html_error('You didn\'t enter the image verification code.');
            }
            $post['recaptcha_challenge_field'] = $_POST['recaptcha_challenge_field'];
            $post['recaptcha_response_field'] = urlencode($_POST['recaptcha_response_field']);
        }
        $post['user%5Bcaptcha_type%5D'] = urlencode($_POST['c_type']);
        $post['user%5Bcaptcha_subtype%5D'] = !empty($_POST['c_subtype']) ? urlencode($_POST['c_subtype']) : '';
        $post['user%5Bmemory%5D'] = 'on';
        $post['user%5Bsubmit%5D'] = 'Login';
        $page = geturl($domain, 80, '/user/login', $referer . 'login', $cookie, $post, 0, $_GET['proxy'], $pauth);
        is_page($page);
        $cookie = GetCookiesArr($page, $cookie);
        $x = 0;
        while ($x < 3 && stripos($page, "\nLocation: ") !== false && preg_match('@\\nLocation: ((https?://[^/\\r\\n]+)?/[^\\r\\n]*)@i', $page, $redir)) {
            $redir = empty($redir[2]) ? 'http://turbobit.net' . $redir[1] : $redir[1];
            $url = parse_url($redir);
            $page = geturl($url['host'], defport($url), $url['path'] . (!empty($url['query']) ? '?' . $url['query'] : ''), $referer, $cookie, 0, 0, $_GET['proxy'], $pauth);
            is_page($page);
            $cookie = GetCookiesArr($page, $cookie);
            $x++;
        }
        is_present($page, 'Incorrect login or password', 'Login Failed: Login/Password incorrect.');
        is_present($page, 'E-Mail address appears to be invalid.', 'Login Failed: Invalid E-Mail.');
        is_present($page, 'Incorrect verification code', 'Login Failed: Wrong CAPTCHA entered.');
        is_present($page, 'Incorrect captcha code', 'Login Failed: Wrong Recaptcha entered.');
        //is_present($page, 'Limit of login attempts exceeded for your account. It has been temporarily locked.', 'Login Failed: Account Temporally Locked.');
        if (empty($redir) || $redir != $referer) {
            $page = geturl($domain, 80, '/', $referer, $cookie, 0, 0, $_GET['proxy'], $pauth);
            is_page($page);
        }
        is_notpresent($page, '/user/logout">Logout<', 'Login Failed.');
        SaveCookies($user, $pass);
        // Update cookies file
        return $page;
    } else {
        $post = array();
        $post['user%5Blogin%5D'] = urlencode($user);
        $post['user%5Bpass%5D'] = urlencode($pass);
        $post['user%5Bmemory%5D'] = 'on';
        $post['user%5Bsubmit%5D'] = 'Login';
        $page = geturl($domain, 80, '/user/login', $referer . 'login', $cookie, $post, 0, $_GET['proxy'], $pauth);
        is_page($page);
        $cookie = GetCookiesArr($page, $cookie);
        if (!empty($cookie['user_isloggedin']) && $cookie['user_isloggedin'] == '1') {
            $page = geturl($domain, 80, '/', $referer, $cookie, 0, 0, $_GET['proxy'], $pauth);
            is_page($page);
            SaveCookies($user, $pass);
            // Update cookies file
            return $page;
        }
        $x = 0;
        while ($x < 3 && stripos($page, "\nLocation: ") !== false && preg_match('@\\nLocation: ((https?://[^/\\r\\n]+)?/[^\\r\\n]*)@i', $page, $redir)) {
            $redir = empty($redir[2]) ? 'http://turbobit.net' . $redir[1] : $redir[1];
            $url = parse_url($redir);
            $page = geturl($url['host'], defport($url), $url['path'] . (!empty($url['query']) ? '?' . $url['query'] : ''), $referer, $cookie, 0, 0, $_GET['proxy'], $pauth);
            is_page($page);
            $cookie = GetCookiesArr($page, $cookie);
            $x++;
        }
        if ($x < 1) {
            html_error('Login redirect not found');
        }
        is_present($page, 'Incorrect login or password', 'Login Failed: Login/Password incorrect');
        is_present($page, 'E-Mail address appears to be invalid.', 'Login Failed: Invalid E-Mail');
        // is_present($page, 'Limit of login attempts exceeded for your account. It has been temporarily locked.', 'Login Failed: Account Temporally Locked');
        if (preg_match('@(https?://[^/\\r\\n\\t\\s\'\\"<>]+)?/captcha/[^\\r\\n\\t\\s\'\\"<>]+@i', $page, $imgurl)) {
            $imgurl = empty($imgurl[1]) ? 'http://turbobit.net' . $imgurl[0] : $imgurl[0];
            $imgurl = html_entity_decode($imgurl);
            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.');
            }
            //Download captcha img.
            $url = parse_url($imgurl);
            $page = geturl($url['host'], defport($url), $url['path'] . (!empty($url['query']) ? '?' . $url['query'] : ''), $referer, $cookie, 0, 0, $_GET['proxy'], $pauth);
            is_page($page);
            $capt_img = substr($page, strpos($page, "\r\n\r\n") + 4);
            $imgfile = DOWNLOAD_DIR . 'turbobit_captcha.png';
            if (file_exists($imgfile)) {
                unlink($imgfile);
            }
            if (!write_file($imgfile, $capt_img)) {
                html_error('Error getting CAPTCHA image.');
            }
            $data = array();
            $data['action'] = 'FORM';
            $data['cookie'] = urlencode(encrypt(CookiesToStr($cookie)));
            $data['step'] = '1';
            $data['c_type'] = urlencode($c_type[1]);
            $data['c_subtype'] = urlencode($c_subtype[1]);
            if (!$default_acc) {
                $data['up_encrypted'] = 'true';
                $data['up_login'] = urlencode(encrypt($user));
                $data['up_pass'] = urlencode(encrypt($pass));
            }
            EnterCaptcha($imgfile . '?' . time(), $data);
            exit;
        } elseif (preg_match('@https?://(?:[^/]+\\.)?(?:(?:google\\.com/recaptcha/api)|(?:recaptcha\\.net))/(?:(?:challenge)|(?:noscript))\\?k=([\\w|\\-]+)@i', $page, $pid)) {
            $data = array();
            $data['action'] = 'FORM';
            $data['cookie'] = urlencode(encrypt(CookiesToStr($cookie)));
            $data['step'] = '2';
            $data['c_type'] = 'recaptcha';
            if (!$default_acc) {
                $data['up_encrypted'] = 'true';
                $data['up_login'] = urlencode(encrypt($user));
                $data['up_pass'] = urlencode(encrypt($pass));
            }
            Show_reCaptcha($pid[1], $data, 'Login');
            exit;
        } elseif (stripos($page, '/user/logout">Logout<') !== false) {
            $this->SaveCookies($user, $pass);
            // Update cookies file
            is_present($page, '<u>Turbo Access</u> denied', 'Login Failed: Account isn\'t premium');
            return $this->PremiumDL();
        } else {
            html_error('CAPTCHA not found.');
        }
    }
}
function Login($user, $pass)
{
    global $default_acc, $cookie, $domain, $referer, $pauth;
    $errors = array('CaptchaInvalid' => 'Wrong CAPTCHA entered.', 'InvalidLogIn' => 'Invalid Login/Pass.', 'CaptchaRequired' => 'Captcha Required.');
    if (!empty($_POST['step']) && $_POST['step'] == '1') {
        if (empty($_POST['recaptcha_response_field'])) {
            html_error('You didn\'t enter the image verification code.');
        }
        $post = array('recaptcha_challenge_field' => $_POST['recaptcha_challenge_field'], 'recaptcha_response_field' => $_POST['recaptcha_response_field']);
        $post['login'] = urlencode($user);
        $post['password'] = urlencode($pass);
        $page = geturl($domain, 80, '/api/user/login', $referer . 'login.php?return=%2F', $cookie, $post, 0, $_GET['proxy'], $pauth);
        is_page($page);
        $json = Get_Reply($page);
        if (!empty($json['error'])) {
            html_error('Login Error' . (!empty($errors[$json['error']]) ? ': ' . $errors[$json['error']] : '..'));
        } elseif ($json['status'] != 'OK') {
            html_error('Login Failed');
        }
        $cookie = GetCookiesArr($page, $cookie);
        if (empty($cookie['autologin'])) {
            html_error('Login Error: Cannot find "autologin" cookie');
        }
        SaveCookies($user, $pass);
        // Update cookies file
        return true;
    } else {
        $post = array();
        $post['login'] = urlencode($user);
        $post['password'] = urlencode($pass);
        $page = geturl($domain, 80, '/api/user/login', $referer . 'login.php?return=%2F', $cookie, $post, 0, $_GET['proxy'], $pauth);
        is_page($page);
        $json = Get_Reply($page);
        if (!empty($json['error']) && $json['error'] != 'CaptchaRequired') {
            html_error('Login Error' . (!empty($errors[$json['error']]) ? ': ' . $errors[$json['error']] : '.'));
        } elseif ($json['status'] == 'OK') {
            $cookie = GetCookiesArr($page, $cookie);
            if (empty($cookie['autologin'])) {
                html_error('Login Error: Cannot find "autologin" cookie.');
            }
            SaveCookies($user, $pass);
            // Update cookies file
            return true;
        } elseif (empty($json['error']) || $json['error'] != 'CaptchaRequired') {
            html_error('Login Failed.');
        }
        // Captcha Required
        $page = geturl($domain, 80, '/login.php?return=%2F', $referer, $cookie, 0, 0, $_GET['proxy'], $pauth);
        is_page($page);
        $cookie = GetCookiesArr($page, $cookie);
        if (!preg_match('@(https?://([^/\\r\\n\\t\\s\'\\"<>]+\\.)?(?:depositfiles|dfiles)\\.[^/:\\r\\n\\t\\"\'<>]+(?:\\:\\d+)?)/js/base2\\.js@i', $page, $jsurl)) {
            html_error('Cannot find captcha.');
        }
        $jsurl = empty($jsurl[1]) ? 'http://' . $domain . $jsurl[0] : $jsurl[0];
        $jsurl = parse_url($jsurl);
        $page = geturl($jsurl['host'], defport($jsurl), $jsurl['path'] . (!empty($jsurl['query']) ? '?' . $jsurl['query'] : ''), $referer . 'login.php?return=%2F', $cookie, 0, 0, $_GET['proxy'], $pauth);
        is_page($page);
        if (!preg_match('@recaptcha_public_key\\s*=\\s*[\'\\"]([\\w\\-]+)@i', $page, $cpid)) {
            html_error('reCAPTCHA Not Found.');
        }
        $post = array('action' => 'FORM');
        $post['step'] = '1';
        if (!$default_acc) {
            $post['up_encrypted'] = 'true';
            $post['up_login'] = urlencode(encrypt($user));
            $post['up_pass'] = urlencode(encrypt($pass));
        }
        Show_reCaptcha($cpid[1], $post, 'Login');
    }
}
         $post['recaptcha_challenge_field'] = $_POST['recaptcha_challenge_field'];
         $post['recaptcha_response_field'] = $_POST['recaptcha_response_field'];
     }
     //$post['back_url'] = 'http://uploading.com/';
     $ajax_req = geturl('uploading.com', 80, '/general/login_form/?ajax', $referer . "\r\nX-Requested-With: XMLHttpRequest", $cookie, $post, 0, $_GET['proxy'], $pauth);
     is_page($ajax_req);
     $json = Get_Reply($ajax_req);
     if (!empty($json['error'])) {
         html_error('Login Error... MSG: ' . $json['error']);
     }
     if (!empty($json['answer']) && isset($json['answer']['captcha']) && $json['answer']['captcha'] == true) {
         if (!preg_match('@build_recaptcha\\s*\\([^,|\\)]+,\\s*[\'|\\"](\\w+)[\'|\\"]\\s*\\)@i', $page, $pid)) {
             html_error('Error: Login captcha data not found.');
         }
         $data = array('action' => 'FORM', 'step' => 'captcha');
         Show_reCaptcha($pid[1], $data, $upload_acc['uploading_com']['user'] && $upload_acc['uploading_com']['pass']);
         exit;
     }
     $cookie = GetCookiesArr($ajax_req, $cookie);
     // if (empty($cookie['SID'])) html_error('Login Error: SID cookie not found.');
     if (empty($cookie['u']) || empty($cookie['remembered_user'])) {
         html_error('Login Error: Login cookies not found.');
     }
     // Yes.... u=1 is needed. :D
 } else {
     html_error("Login Failed: Email or Password are empty. Please check login data.", 0);
 }
 // Retrive upload ID
 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";
 $page = geturl('uploading.com', 80, '/', $referer, $cookie, 0, 0, $_GET['proxy'], $pauth);
 is_page($page);