Skip to content

Instantly share code, notes, and snippets.

@Hamz-a
Last active August 29, 2015 14:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Hamz-a/7b0980fc69d4f3e81cba to your computer and use it in GitHub Desktop.
Save Hamz-a/7b0980fc69d4f3e81cba to your computer and use it in GitHub Desktop.
<?php
$data = file_get_contents('http://www.ssmailsubscription.tk/inc/captcha.php');
$r = 120; $g = 95; $b = 95;
file_put_contents('original.png', $data);
$img = imagecreatefromstring($data);
$width = imagesx($img);
$height = imagesy($img);
for($i = 0;$i < $width; $i++){
for($j = 0;$j < $height; $j++){
$rgb = imagecolorat($img, $i, $j);
$colors = imagecolorsforindex($img, $rgb);
if($colors['red'] != 120 || $colors['green'] != 95 || $colors['blue'] != 95){
imagecolorset($img, $rgb, 255, 255, 255);
}
}
}
imagepng($img, 'image.png');
exec('tesseract.exe image.png code'); // Let's OCR !!!
echo 'The original<br><img src="original.png"><br><br>The filtered<br><img src="image.png"><br>And the code is: ';
echo file_get_contents('code.txt');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment