Skip to content

How to work via php?

Hi! Help please. How to work with the program via php? P.s.: Please give a detailed answer...

Comments

  • In CB options you need to check "run as webserver"
    In your php script you send a POST request to http://127.0.0.1/gsa_test.gsa
  • cherubcherub SERnuke.com
    edited November 2013
    First you'll need CB running as webserver and listening on port 80. Download the captcha image you want to use and save it locally. Next, POST it's full path with the variable name 'file' to http://127.0.0.1/gsa_test.gsa. You'll then get a result from the program that you can parse.

    eg
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL,"http://127.0.0.1/gsa_test.gsa");
    curl_setopt($curl, CURLOPT_POST,1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, "file=C:\temp\captcha.jpg");
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);

    $result=curl_exec($curl);
    curl_close($curl);
  • Fully working code :


    $captcha = file_get_contents('http://www.carrcentral.org/coppermine/captcha.php');
    file_put_contents(__DIR__ . '/captcha.jpg', $captcha);

    $fields = array(
        'file' => '@' . __DIR__ . '/captcha.jpg',
        '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);
    echo $matches[1];
  • Tell me, please, how OFAC type captchas. Whatever CB worked with captchas for a particular type?
Sign In or Register to comment.