html_error('Error getting CAPTCHA image.');
         }
         unset($capt_page, $capt_img);
         $data = array();
         $data['step'] = '1';
         $data['cookie'] = urlencode(encrypt(CookiesToStr($cookie)));
         $data['action'] = 'FORM';
         // I should add 'premium_acc' to DefaultParamArr()
         if (!$default_acc) {
             $data['A_encrypted'] = 'true';
             $data['up_login'] = urlencode(encrypt($_REQUEST['up_login']));
             // encrypt() will keep this safe.
             $data['up_pass'] = urlencode(encrypt($_REQUEST['up_pass']));
             // And this too.
         }
         EnterCaptcha($imgfile . '?' . time(), $data);
         exit;
     }
     //is_present($page, 'The code from a picture does not coincide', 'Login Failed: Captcha... (T8: I will add it later)');
     is_present($page, 'The code from a picture does not coincide', 'Login Failed: Captcha... (T8: I will add it later)');
     if (empty($cookie['user__'])) {
         html_error("Login Error: Cannot find 'user__' cookie.");
     }
     $cookie['lang'] = 'en';
     $login = true;
 } else {
     html_error('Login failed: User/Password empty.');
 }
 // 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";
 //Redirects
function Login($user, $pass)
{
    global $upload_acc, $cookie, $domain, $referer, $pauth;
    if (!empty($_POST['step']) && $_POST['step'] == '1') {
        if (empty($_POST['captcha'])) {
            html_error('You didn\'t enter the image verification code.');
        }
        $cookie = StrToCookies(decrypt(urldecode($_POST['cookie'])));
        $post = array();
        $post['user'] = urlencode($user);
        $post['pass'] = urlencode($pass);
        $post['captcha_code'] = urlencode($_POST['captcha']);
        $post['remember'] = 1;
        $post['login_submit'] = 'Login';
        $page = geturl($domain, 80, '/authenticate.php?login', $referer . 'authenticate.php?login', $cookie, $post, 0, $_GET['proxy'], $pauth);
        is_page($page);
        $cookie = GetCookiesArr($page, $cookie);
        if (stripos(substr($page, 0, strpos($page, "\r\n\r\n")), "\nLocation: ") !== false && preg_match('@\\nLocation: ((https?://[^/\\r\\n]+)?/authenticate\\.php[^\\r\\n]*)@i', substr($page, 0, strpos($page, "\r\n\r\n")), $redir)) {
            $url = parse_url(empty($redir[2]) ? 'http://www.putlocker.com' . $redir[1] : $redir[1]);
            $page = geturl($url['host'], defport($url), $url['path'] . (!empty($url['query']) ? '?' . $url['query'] : ''), $referer . 'authenticate.php?login', $cookie, 0, 0, $_GET['proxy'], $pauth);
            is_page($page);
            $cookie = GetCookiesArr($page, $cookie);
        }
        is_present($page, 'No such username or wrong password', 'Login Failed: Email/Password incorrect.');
        is_present($page, 'Please re-enter the captcha code', 'Login Failed: Wrong CAPTCHA entered.');
        if (empty($cookie['auth'])) {
            html_error('Login Error: Cannot find "auth" cookie.');
        }
        SaveCookies($user, $pass);
        // Update cookies file
        return true;
    } else {
        $page = geturl($domain, 80, '/authenticate.php?login', $referer . 'authenticate.php?login', $cookie, 0, 0, $_GET['proxy'], $pauth);
        is_page($page);
        $cookie = GetCookiesArr($page, $cookie);
        if (!preg_match('@(https?://[^/\\r\\n\\t\\s\'\\"<>]+)?/include/captcha\\.php\\?[^/\\r\\n\\t\\s\'\\"<>]+@i', $page, $imgurl)) {
            html_error('CAPTCHA not found.');
        }
        $imgurl = empty($imgurl[1]) ? 'http://www.putlocker.com' . $imgurl[0] : $imgurl[0];
        $imgurl = html_entity_decode($imgurl);
        //Download captcha img.
        $url = parse_url($imgurl);
        $page = geturl($url['host'], defport($url), $url['path'] . (!empty($url['query']) ? '?' . $url['query'] : ''), $referer . 'authenticate.php?login', $cookie, 0, 0, $_GET['proxy'], $pauth);
        is_page($page);
        $capt_img = substr($page, strpos($page, "\r\n\r\n") + 4);
        $imgfile = DOWNLOAD_DIR . 'putlocker_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['step'] = 1;
        $data['cookie'] = urlencode(encrypt(CookiesToStr($cookie)));
        $data['up_convert'] = !empty($_REQUEST['up_convert']) && $_REQUEST['up_convert'] == 'yes' ? 'yes' : 'no';
        EnterCaptcha($imgfile . '?' . time(), $data, $upload_acc['putlocker_com']['user'] && $upload_acc['putlocker_com']['pass']);
        exit;
    }
}
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['captcha'])) {
            html_error('You didn\'t enter the image verification code.');
        }
        $cookie = StrToCookies(decrypt(urldecode($_POST['cookie'])));
        $post = array();
        $post['user%5Blogin%5D'] = urlencode($user);
        $post['user%5Bpass%5D'] = urlencode($pass);
        $post['user%5Bcaptcha_response%5D'] = urlencode($_POST['captcha']);
        $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, $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.');
        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, $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, $post, 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');
        if (!preg_match('@(https?://[^/\\r\\n\\t\\s\'\\"<>]+)?/captcha/[^\\r\\n\\t\\s\'\\"<>]+@i', $page, $imgurl)) {
            if (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.');
            }
        }
        $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;
    }
}
function Login($user, $pass)
{
    global $cookie, $domain, $referer, $pauth, $default_acc;
    $post = array();
    $post['LoginForm%5Busername%5D'] = urlencode($user);
    $post['LoginForm%5Bpassword%5D'] = urlencode($pass);
    $post['LoginForm%5BrememberMe%5D'] = 1;
    if (empty($_POST['step']) || !in_array($_POST['step'], array('1', '2'))) {
        $page = geturl($domain, 80, '/login.html', $referer, 0, $post, 0, $_GET['proxy'], $pauth);
        is_page($page);
        $cookie = GetCookiesArr($page);
        if (stripos($page, 'The verification code is incorrect.') !== false) {
            $data = array();
            $data['cookie'] = urlencode(encrypt(CookiesToStr($cookie)));
            $data['action'] = 'FORM';
            if (!$default_acc) {
                $data['A_encrypted'] = 'true';
                $data['up_login'] = urlencode(encrypt($user));
                // encrypt() will keep this safe.
                $data['up_pass'] = urlencode(encrypt($pass));
                // And this too.
            }
            if (preg_match('@https?://(?:[^/]+\\.)?(?:(?:google\\.com/recaptcha/api)|(?:recaptcha\\.net))/(?:(?:challenge)|(?:noscript))\\?k=([\\w\\.\\-]+)@i', $page, $cpid)) {
                $data['step'] = '1';
                reCAPTCHA($pid[1], $data, 'Login');
            } elseif (preg_match('@\\W(auth/captcha\\.html\\?v=\\w+)@i', $page, $cpid)) {
                $data['step'] = '2';
                $imgReq = geturl($domain, 80, '/' . $cpid[1], $referer, $cookie, 0, 0, $_GET['proxy'], $pauth);
                is_page($imgReq);
                list($headers, $imgBody) = explode("\r\n\r\n", $imgReq, 2);
                unset($imgReq);
                if (substr($headers, 9, 3) != '200') {
                    html_error('Error downloading captcha img.');
                }
                $mimetype = preg_match('@image/[\\w+]+@', $headers, $mimetype) ? $mimetype[0] : 'image/png';
                EnterCaptcha("data:{$mimetype};base64," . base64_encode($imgBody), $data, 20, 'Login');
            } else {
                html_error('Login CAPTCHA not found.');
            }
            exit;
        }
        is_present($page, 'Incorrect username or password', 'Login Failed: Email/Password incorrect.');
        is_present($page, 'You logged in from different country IP', 'Login Failed: Your account was locked for security reasons, to unlock your account check your email.');
        if (empty($cookie['c903aeaf0da94d1b365099298d28f38f'])) {
            html_error('Login Cookie Not Found.');
        }
        if (empty($cookie['sessid'])) {
            html_error('Session Cookie Not Found.');
        }
        $test = k2s_apireq('test');
        if ($test['code'] != 403) {
            k2s_checkErrors($test, 'Login error');
        } else {
            $page = geturl($domain, 80, '/', $referer . 'login.html', $cookie, 0, 0, $_GET['proxy'], $pauth);
            is_page($page);
            is_notpresent($page, '/auth/logout.html">Logout', 'Login Error.');
        }
        SaveCookies($user, $pass);
        // Update cookies file
        return true;
    }
    if ($_POST['step'] == '1') {
        if (empty($_POST['recaptcha_response_field'])) {
            html_error('You didn\'t enter the image verification code.');
        }
        $post['LoginForm%5BverifyCode%5D'] = '';
        $post['recaptcha_challenge_field'] = urlencode($_POST['recaptcha_challenge_field']);
        $post['recaptcha_response_field'] = urlencode($_POST['recaptcha_response_field']);
    } else {
        if (empty($_POST['captcha'])) {
            html_error('You didn\'t enter the image verification code.');
        }
        $post['LoginForm%5BverifyCode%5D'] = urlencode($_POST['captcha']);
    }
    $_POST['step'] = false;
    $cookie = StrToCookies(decrypt(urldecode($_POST['cookie'])));
    $page = geturl($domain, 80, '/login.html', $referer, $cookie, $post, 0, $_GET['proxy'], $pauth);
    is_page($page);
    $cookie = GetCookiesArr($page, $cookie);
    is_present($page, 'The verification code is incorrect.');
    is_present($page, 'Incorrect username or password', 'Login Failed: Email/Password incorrect');
    is_present($page, 'You logged in from different country IP', 'Login Failed: Your account was locked for security reasons, to unlock your account check your email');
    if (empty($cookie['c903aeaf0da94d1b365099298d28f38f'])) {
        html_error('Login Cookie Not Found');
    }
    if (empty($cookie['sessid'])) {
        html_error('Session Cookie Not Found');
    }
    $test = k2s_apireq('test');
    if ($test['code'] != 403) {
        k2s_checkErrors($test, 'Login Error');
    } else {
        $page = geturl($domain, 80, '/', $referer . 'login.html', $cookie, 0, 0, $_GET['proxy'], $pauth);
        is_page($page);
        is_notpresent($page, '/auth/logout.html">Logout', 'Login Error');
    }
    SaveCookies($user, $pass);
    // Update cookies file
    return true;
}
示例#5
0
function DL_reCaptcha($pid, $data)
{
    global $pauth;
    $page = geturl('www.google.com', 80, "/recaptcha/api/challenge?k={$pid}", 0, 0, 0, 0, $_GET['proxy'], $pauth);
    is_page($page);
    if (!preg_match('/challenge \\: \'([^\']+)/i', $page, $ch)) {
        html_error('Error getting CAPTCHA data.');
    }
    $challenge = $ch[1];
    $data['challenge'] = $challenge;
    //Download captcha img.
    $page = geturl('www.google.com', 80, "/recaptcha/api/image?c={$challenge}", 0, 0, 0, 0, $_GET['proxy'], $pauth);
    is_page($page);
    $capt_img = substr($page, strpos($page, "\r\n\r\n") + 4);
    $imgfile = DOWNLOAD_DIR . 'fsharevn_captcha.jpg';
    if (file_exists($imgfile)) {
        unlink($imgfile);
    }
    if (!write_file($imgfile, $capt_img)) {
        html_error('Error getting CAPTCHA image.');
    }
    EnterCaptcha($imgfile . '?' . time(), $data, 20);
    exit;
}