Skip to content

Instantly share code, notes, and snippets.

@ldong
Last active March 13, 2020 21:25
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ldong/7b80eae0210209b15212 to your computer and use it in GitHub Desktop.
Save ldong/7b80eae0210209b15212 to your computer and use it in GitHub Desktop.
crack recaptcha

#Crack reCAPTCHA

Dependencies

pip install pillow
brew install libpng
brew install libjpeg
pip install PIL --allow-external PIL --allow-unverified PIL

After that, let's try with an example

from PIL import Image
im = Image.open('image.jpeg') # jpeg or png
im = im.convert('L')
  1. Clean Noise.
def clean(im):
    im = im.convert('L')
    im = im.point(lambda x:255 if x>128 or x==0 else x)
    im = im.point(lambda x:0 if x<255 else 255)
    return im
  1. Splits into char images
#Divide by Columns
w, h = im.size
data = im.load()
jcolors = [sum(255-data[i,j] for j in range(h)) for i in range(w)]
print jcolors
  1. decode char images into chars
    def im2array(im):
        return [ int(x!='\xff') for x in im.tobytes() ]
    

References

Decoder JPEG not available error

Can't install PIL after Mac OS X 10.9

Python Image Library fails with message “decoder JPEG not available PIL”

decoding-weibo-captcha-in-python slides recommended

python captcha decoder library

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment