Skip to content

Instantly share code, notes, and snippets.

@pwittchen
Created July 15, 2012 18:19
Show Gist options
  • Save pwittchen/3118028 to your computer and use it in GitHub Desktop.
Save pwittchen/3118028 to your computer and use it in GitHub Desktop.
Sweet Captcha Breaker
<?php
set_time_limit(0);
$answer_not_found = TRUE;
$counter = 1;
echo("breaking sweet captcha in progress.");
while($answer_not_found)
{
$source = file_get_contents('http://sweetcaptcha.com');
preg_match('/question_[0-9]{1,}\\.png/', $source, $matches_question);
$question_number = explode('_',$matches_question[0]);
$question_number = explode('.',$question_number[1]);
$question_number = $question_number[0];
preg_match('/<li( )style="display:( )inline;"( )rel="[0-9a-zA-Z]*"><img( )alt="captcha"( )src="http:\\/\\/www.sweetcaptcha.com\\/upload\\/answer_'.$question_number.'\\.png"\\/>/', $source, $matches_answers);
if($matches_answers[0] != "")
{
echo("\ncaptcha broken after ".$counter." requests!");
$matches_answers2 = explode('rel="',$matches_answers[0]);
$matches_answers3 = explode('"><img',$matches_answers2[1]);
$scvalue = $matches_answers3[0];
echo("\nscvalue = ".$scvalue);
echo("\n");
$answer_not_found = FALSE;
}
if(!$answer_not_found)
{
preg_match('/name="sckey"( )value="[0-9a-zA-Z]*"/', $source, $matches_sckey);
$sckey = explode('value="',$matches_sckey[0]);
$sckey = substr($sckey[1],0,-1);
echo("sckey = ".$sckey);
echo("\n");
}
else
{
$counter++;
echo('.');
sleep(1);
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment