Skip to content

Instantly share code, notes, and snippets.

@0xh3x
Created December 10, 2010 10:18
Show Gist options
  • Save 0xh3x/736053 to your computer and use it in GitHub Desktop.
Save 0xh3x/736053 to your computer and use it in GitHub Desktop.
Captcha cracker
#!/usr/bin/python
# By Giorgi Jvaridze
# 13.10.2008
# [email protected]
def chk(t):
n0="00001111100000011100111100100111111000011111100100111100111000000111110000"
n1="011111101101111110010000000000000000000001111111110"
n2="011111101100111110010001111100010011111001100111100111001100011110000101111100"
n3="01111110100111111000111111110011110111001111011100011000100100001000111001110"
n4="00111111110001111111010011111101100111110111001000000000000000000001110"
n5="0110000010011000000011101110011111011001111101100011100110100000111011000"
n6="000000111000000001001101110001111011100111101110001100110010000110011100"
n7="00111111100001111110110011111011100111101111001110111110011011111100001111111000"
n8="0011101110000100010011000100011110111001111011100011000100100001000111001110"
n9="001110011000010011001100011101111001110111100011101100100000000111000000"
if t.find(n0)!=-1:
return '0'
elif t.find(n1)!=-1:
return '1'
elif t.find(n2)!=-1:
return '2'
elif t.find(n3)!=-1:
return '3'
elif t.find(n4)!=-1:
return '4'
elif t.find(n5)!=-1:
return '5'
elif t.find(n6)!=-1:
return '6'
elif t.find(n7)!=-1:
return '7'
elif t.find(n8)!=-1:
return '8'
elif t.find(n9)!=-1:
return '9'
import Image
im = Image.open("target.bmp")
im2 = im.convert("L")
h=im2.size[1]
w=im2.size[0]
for hv in range(h):
for wv in range(w):
if im2.getpixel((wv,hv)) < 150:
im2.putpixel((wv,hv),0)
else:
im2.putpixel((wv,hv),1)
s1=im2.crop((0,7,30,17))
s2=im2.crop((30,7,50,17))
s3=im2.crop((50,7,80,17))
s1,s2,s3=s1.rotate(-90),s2.rotate(-90),s3.rotate(-90)
sd1,sd2,sd3="","",""
for c in list(s1.getdata()):
sd1=sd1+str(c)
for c in list(s2.getdata()):
sd2=sd2+str(c)
for c in list(s3.getdata()):
sd3=sd3+str(c)
cracked=chk(sd1)+chk(sd2)+chk(sd3)
print cracked
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment