Documente Academic
Documente Profesional
Documente Cultură
Now the most interesting thing was if you copy the captcha image
url (which is http://www.site.com/captcha.php in this case) and
open the image in new tab of same browser ,the cpatcha will load
with a different number as I have told you earlier. Suppose you
have got "9090" this time. Now if you try to submit the feedback
form with the number that’s was loaded earlier with the feedback
form( which was "4567" )the application will not accept that
form. If you enter “9090” then the application will accept that
form.
For more clear idea I have created this simple Fig.
def get(link):
urlretrieve(link,'temp.png')
get('http://www.site.com/captcha.php');
im = Image.open("temp.png")
nx, ny = im.size
im2 = im.resize((int(nx*5), int(ny*5)), Image.BICUBIC)
im2.save("temp2.png")
enh = ImageEnhance.Contrast(im)
enh.enhance(1.3).show("30% more contrast")
imgx = Image.open('temp2.png')
imgx = imgx.convert("RGBA")
pix = imgx.load()
for y in xrange(imgx.size[1]):
for x in xrange(imgx.size[0]):
if pix[x, y] != (0, 0, 0, 255):
pix[x, y] = (255, 255, 255, 255)
imgx.save("bw.gif", "GIF")
original = Image.open('bw.gif')
bg = original.resize((116, 56), Image.NEAREST)
ext = ".tif"
bg.save("input-NEAREST" + ext)
image = Image.open('input-NEAREST.tif')
print image_to_string(image)
2)When this is done the script will make the image beigger to
better understading.
3)At last it will feed that processed image to OCR engine.
Here is another python script which is very useful while testing
captchas.You can add these line to your script if the taget captcha image
is too small.This python script can help you to change resolution of any
image.
im = Image.open("test.png")
nx, ny = im.size
im2 = im.resize((int(nx*5), int(ny*5)), Image.BICUBIC)
im2.save("final_pic.png")
enh = ImageEnhance.Contrast(im)
enh.enhance(1.3).show("30% more contrast")