Ejemplo n.º 1
0
function load_proxies_url($url)
{
    $proxies = array();
    $data = curl_cache_exec(array(CURLOPT_URL => $url), null, false);
    if (!empty($data['data'])) {
        $groups = array();
        preg_match_all('/[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+:[0-9]+/', $data['data'], $groups);
        if (isset($groups[0]) && !empty($groups[0])) {
            foreach ($groups[0] as $ip) {
                if (!in_array($ip, $proxies)) {
                    $proxies[] = $ip;
                }
            }
        }
    }
    return $proxies;
}
Ejemplo n.º 2
0
 private function handleCaptcha($html, $proxy, $dc, $origUrl)
 {
     global $dbc;
     global $proxies;
     global $captchaBrokenCurrentRun;
     if ($dbc == null) {
         $this->w("DeathByCaptcha not initialized");
         return null;
     }
     $docCaptcha = new DOMDocument();
     if (empty($html) || !@$docCaptcha->loadHTML($html)) {
         $this->w("Can't parse captcha HTML");
         return null;
     }
     $imgsrc = null;
     $elts = $docCaptcha->getElementsByTagName("img");
     if ($elts != null) {
         foreach ($elts as $elt) {
             $src = $elt->getAttribute("src");
             if ($src != null && strncmp($src, "/sorry/image", 12) === 0) {
                 $imgsrc = "http://" . $dc . $src;
             }
         }
     }
     $groupRegex = array();
     if ($imgsrc == null || !preg_match("|/sorry/image\\?id=([0-9]+)&?|", $imgsrc, $groupRegex)) {
         $this->w("Can't extract captcha from HTML");
         return null;
     }
     $params = array();
     $params['id'] = $groupRegex[1];
     $params['continue'] = $origUrl;
     $params['submit'] = "Submit";
     $data = curl_cache_exec(array(CURLOPT_URL => $imgsrc), $proxy, false);
     $captcha = $data['data'];
     if ($captcha == null || strlen($captcha) < 10 || ord($captcha[0]) !== 0xff || ord($captcha[1]) !== 0xd8) {
         $this->w("Can't fetch captcha image");
         return null;
     }
     $time = round(microtime(true) * 1000);
     $solved = null;
     try {
         $solved = $dbc->decode(unpack('C*', $captcha), CAPTCHA_TIMEOUT);
         ++$captchaBrokenCurrentRun;
     } catch (Exception $ex) {
         $solved = null;
     }
     $time = round(microtime(true) * 1000) - $time;
     if ($solved == null || !is_array($solved) || !isset($solved['is_correct']) || !isset($solved['text']) || !isset($solved['captcha'])) {
         // not proxy fault
         $proxies->preventfail($proxy);
         $this->w("DeathByCaptcha failed breaking");
         return null;
     }
     $this->w("Solved captcha to '" . $solved['text'] . "' in {$time} ms");
     $params['captcha'] = $solved['text'];
     $sendUrl = "http://" . $dc . "/sorry/Captcha?";
     foreach ($params as $key => $value) {
         $sendUrl .= $key . "=" . urlencode($value) . "&";
     }
     $sendUrl = rtrim($sendUrl, "&");
     $data = curl_cache_exec(array(CURLOPT_URL => $sendUrl), $proxy, false);
     if (empty($data['data'])) {
         $this->w("Can't send captcha answer [1]");
         return null;
     }
     if (strstr($data['data'], '<img src="/sorry/')) {
         $this->w("Captcha incorrectly solved, report to DeathByCaptcha");
         try {
             $dbc->report($captcha['captcha']);
         } catch (Exception $ex) {
         }
         // not proxy fault
         $proxies->preventfail($proxy);
         return null;
     }
     if (!strstr($data['data'], '<TITLE>Redirecting</TITLE>')) {
         $this->w("Can't send captcha answer [1]");
         return null;
     }
     $this->l("Captcha succesfully solved");
     $data = curl_cache_exec(array(CURLOPT_URL => $origUrl), $proxy, false);
     if ($data['status'] != 200) {
         $this->w("Bad redirection after captcha solving");
         print_r($data);
         return null;
     } else {
         if (empty($data['data'])) {
             $this->w("Bad content after captcha solving");
             return null;
         } else {
             return $data['data'];
         }
     }
 }