To try it out, I've written a small bot that tries to post the the visual captcha demo.
If first initiates the captcha session, telling is only wants 2 options using http://demo.visualcaptcha.net/start/2
. Than it picks one of the two possible results and posts to http://demo.visualcaptcha.net/try
.
Result:
✓☓☓✓✓✓☓☓☓☓☓☓☓✓✓☓☓☓☓☓✓☓✓✓☓✓✓☓✓✓☓✓✓✓✓✓☓✓☓✓✓✓☓✓☓✓☓✓✓✓
☓✓✓☓✓☓✓✓☓☓✓☓✓✓☓☓✓☓✓✓✓☓✓☓☓✓✓☓✓☓✓☓☓☓☓☓✓✓☓☓✓☓☓✓☓✓☓☓☓✓
✓☓☓✓✓✓☓✓☓☓✓☓☓✓☓☓☓☓☓☓✓✓✓☓✓☓✓☓☓☓✓✓☓✓☓☓✓✓☓☓☓✓✓☓✓☓☓✓✓✓
☓✓☓✓✓☓☓✓✓☓☓☓✓☓☓✓☓✓☓✓✓☓☓☓✓✓☓✓☓✓✓✓✓✓✓✓✓✓☓☓✓☓☓☓✓✓☓✓✓☓
☓✓☓☓✓✓✓✓☓✓✓✓☓✓✓☓☓✓☓✓✓✓✓☓☓✓✓✓☓☓✓☓✓☓✓✓✓☓✓✓☓☓✓☓✓☓☓☓☓☓
Of the 250 tries, I succeeded 127 times and failed 123 times.
Using a fixed number of images (eg 5), instead of letting the client pick the number of images, would help to reduce the successful tries to 1 in 5. Though I recon that's not sufficient for most use cases.
<?php
/**
* Try posting to the visualCaptcha demo
* @return boolean true if posted successfully
*/
function tryVisualCaptcha()
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_COOKIEJAR, "/tmp/visualcaptcha-cookies.txt");
curl_setopt($curl, CURLOPT_COOKIEFILE, "/tmp/visualcaptcha-cookies.txt");
curl_setopt($curl, CURLOPT_URL, "http://demo.visualcaptcha.net/start/2");
$ret = curl_exec($curl);
$result = json_decode($ret);
$post = [$result->imageFieldName => $result->values[0]];
curl_setopt($curl, CURLOPT_URL, "http://demo.visualcaptcha.net/try");
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($post));
curl_exec($curl);
$info = curl_getinfo($curl);
return strpos($info['redirect_url'], 'validImage') !== false;
}
// Main
$results = [0 => 0, 1 => 0];
for ($i = 1; $i <= 250; $i++) {
$success = tryVisualCaptcha();
$results[(int)$success]++;
echo $success ? "✓" : "☓", $i % 50 === 0 ? "\n" : "";
}
echo "Of the ", array_sum($results), " tries, I succeeded ", $results[1],
" times and failed ", $results[0], " times.\n";