N-Bomb(Nerd) Posted June 14, 2009 Share Posted June 14, 2009 I'm trying to login to a website using curl, however there's a captcha on the login page. How would I go about still getting logged in, there isn't a way I could actually read the captcha or bypass it all together is there? Quote Link to comment https://forums.phpfreaks.com/topic/162095-solved-curl-login/ Share on other sites More sharing options...
.josh Posted June 14, 2009 Share Posted June 14, 2009 You have to grab the image file and then write a script that will scan the picture and try to pick apart the pixels and determine what the characters are. That is obviously not an easy task to accomplish. Which is the point of captchas. Quote Link to comment https://forums.phpfreaks.com/topic/162095-solved-curl-login/#findComment-855352 Share on other sites More sharing options...
N-Bomb(Nerd) Posted June 14, 2009 Author Share Posted June 14, 2009 The captcha is actually very baisc.. this wouldn't be that hard to crack I suppose. The background is a solid color, and the letters are just plain and basic.. no morphing or anything like that. After doing some investigating there's only 20 characters used within this captcha. I want to save a image for each of the 20 different characters in this captcha. I was trying to think of a way to do this and make things accurate, but I'm getting stuck. I saved a copy of one of the captchas as a jpeg and I've been trying to dissect it with no luck. Using the imagecopy I tried to take different sections of the captcha image every x pixels on the x-axis, however it seems the characters on the image aren't spaced exact and I can't get each character in the exact location so I can compare images. This captcha is 6 characters long -- So I wanted to break up all six characters and compare them to the images already stored on my server. However as I stated above, I'm having trouble finding the best way to handle this. Any suggestions? Also - after reading this post again it is quite confusing. If you aren't sure of anything let me know and I'll try my best to make things a bit more clear. Quote Link to comment https://forums.phpfreaks.com/topic/162095-solved-curl-login/#findComment-855398 Share on other sites More sharing options...
Alex Posted June 14, 2009 Share Posted June 14, 2009 I made an image reader, but as always it's extremely specific. The way that I did it is I found out that the numbers (in my case) were 4X8 pixels and were separated by 1 pixel. (And started at some x and y). So what I did is I created a loop that would loop through the pixels of each character and generate a string. The string consisted of 1's and 0's. 1 = text color (part of the character) = 0 not part of it, just the background. Then I created another function that would compare the string against an array of strings that had the actual maps (in 0's and 1's) of numbers/letters. Then if it matched you know it is that letter. In my case it was only necessary to loop through the first column of pixels in the image because the strings would've been unique at that point. Here's mine just in case it helps you figure out how to create yours: function check_number($number, $img) { $x_loc = (5 * ($number-1)) + (1 * ($number-1)); for($j = 0;$j < 8;$j++) { $color_index = imagecolorat($img, $x_loc + 90, $j + 48); $spec = imagecolorsforindex($img, $color_index); $colorMap .= ($spec['red'] == 220 && $spec['green'] == 220 && $spec['blue'] == 220) ? 1 : 0; } return find_number($colorMap); } function find_number($numberArr) { global $check; $numberMaps = array( '00111100', '00100001', '01000011', '01000010', '00011100', '11110010', '00111110', '10000000', '01101110', '01110001' ); for($i = 0;$i < count($numberMaps);$i++) { if($numberArr == $numberMaps[$i]) { return $i; } } $check = false; return false; } As I said it only loops through the first column. The first function takes the character you want to get (its position, eg, first(1), second(2), etc..) and the image. But mine is specific, as I said before. Just hope it helps. Quote Link to comment https://forums.phpfreaks.com/topic/162095-solved-curl-login/#findComment-855407 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.