Skip to content

BREAKING CAPTCHA WITH PHP PROBLEM

Hi.

The problem is that, when I want to get captcha solution from url server (http://127.0.0.1/gsa_test.gsa)  by hand choosing and submiting file (captcha.jpg), the program returns solution, but when i want to do it with code in php, program returns "[unable to break captcha, sorry]"
Path to folder is good for sure.



Code:
$fields = array(
            'file' => 'path/captcha.jpg',
            'source_url' => '',
            'captcha_platform' => '',
            'action' => 'Submit'
        );

        $c = curl_init();
        curl_setopt($c, CURLOPT_URL, '127.0.0.1/gsa_test.gsa');
        curl_setopt($c, CURLOPT_POST, 1);
        curl_setopt($c, CURLOPT_POSTFIELDS, $fields);
        curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
        $result = curl_exec($c);
        curl_close($c);
        $in = $result;
        preg_match_all('#<html><head><title>GSA CB Result</title></head><body><h1>The solution is :: (.*)</h1></body></html>#Us', $in, $out, PREG_PATTERN_ORDER);
        $out = implode($out[1]);
        debug($out);


Comments

  • SvenSven www.GSA-Online.de
    Did you resolve the "file" stuff correctly? Use WireShark to debug this. Im sure you will see the mistake.
  • Since php 5.5 you have to use

    'file' => new CurlFile('path/captcha.jpg')

    instead of

    'file' => '@path/captcha.jpg'

    It's explained here : https://wiki.php.net/rfc/curl-file-upload
  • exzajungexzajung thailand
    function breakcap($file){
        $fields = array(
        'file' => '@'.realpath('cap/'.$file),
        'source_url' => '',
        'captcha_platform' => '',
        'action' => 'Submit'
        );
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, 'http://127.0.0.1/gsa_test.gsa');
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        $result = curl_exec ($ch);
        curl_close ($ch);
        preg_match('/<span id="captcha_result">(.*)<\/span>/', $result, $matches);
        return $matches[1];
    }
    ?>
  • SvenSven www.GSA-Online.de
    thanks @exzajung
  • Is it possible to send request to remote system where this software is installed and get the result.
  • SvenSven www.GSA-Online.de
    for what reason?
  • We are running our service in linux environment. With some script here maybe the above php code I would like to send the captcha image to the one of the machine (which is running in windows) where the software is installed and get the response (solved captcha text).
  • SvenSven www.GSA-Online.de
    As interface you have to choose 0.0.0.0 inside CB. Then on your linux system you have to connect to the external IP on the server where CB runs.
  • Thanks for you reply.

    When I try to connect to remote system. I'm getting the requested URL for not found.


    PS : the ip 127.0.0.1 is set to remote host external ip address
  • SvenSven www.GSA-Online.de
    Then check your firewall on that server...something might block it.
Sign In or Register to comment.