Check Mates22 Mar 2008 10:54 pm
Here ya go. This is the del.icio.us captcha busted in Python.

#!/usr/bin/python
import Image,time,random,glob,re,os,sys
##$$$$
train = raw_input("train? (y/n)")
if(train == "y") : train= True
else: train = False
##
fileName = ''.join(sys.argv[1:])
def getNeighbourhood(i,width,height,pixels):
results = []
try:
if(pixels[i+1] != 0): results.append(i+1)
if(pixels[i-1] != 0): results.append(i-1)
if(pixels[i-width] != 0): results.append(i-width)
if(pixels[i+width] != 0): results.append(i+width)
if(pixels[i-width+1] != 0): results.append(i-width+1)
if(pixels[i+width+1] != 0): results.append(i+width+1)
if(pixels[i-width-1] != 0): results.append(i-width-1)
if(pixels[i+width-1] != 0): results.append(i+width-1)
except:pass
return results
now = time.time()
captcha = Image.open(fileName)
(width,height) = captcha.size
pixels = list(captcha.getdata())
i=0
for pixel in pixels:
if (pixel == 2): pixels[i] = 0
i+=1
toclean = []
for i in xrange(len(pixels)):
neighbourhood = getNeighbourhood(i,width,height,pixels)
if (len(neighbourhood) < 4) : pixels[i] = 0
captcha.putdata(pixels)
started=False
lowestY,highestY,count = 0,10000,0
captchas = []
slant = 15
for x in xrange(width):
hasBlack = False
for y in xrange(height):
thisPixel = captcha.getpixel((x,y))
if(thisPixel != 0):
if(started == False):
started=True
firstX = x
firstY = y
else:
lastX = x
if(y > lowestY): lowestY = y
if(y< highestY): highestY = y
hasBlack = True
if((hasBlack == False) and (started==True)):
if((lowestY - highestY) > 4):
croppingBox = (firstX,highestY,lastX,lowestY)
newCaptcha = captcha.crop(croppingBox)
if(train):
text = raw_input(”char:n”)
try: os.mkdir(”/home/dbyte/deliciousImages/” + text)
except:pass
text__ = “/home/dbyte/deliciousImages/” + text + “/” + str(random.randint(1,100000)) + “-.png”
newCaptcha.resize((20,30)).save(text__)
text_ = “/home/dbyte/deliciousImages/” + text + “/” + str(random.randint(1,100000)) + “-.png”
newCaptcha.resize((20,30)).rotate(slant).save(text_)
text_ = “/home/dbyte/deliciousImages/” + text + “/” + str(random.randint(1,100000)) + “-.png”
newCaptcha.resize((20,30)).rotate(360 - slant).save(text_)
captchas.append(Image.open(text__))
else:
#text = str(count)
#text = “tmp-delicious-” + text + “.png”
#newCaptcha.save(text)
captchas.append(newCaptcha.resize((20,30)))
started=False
lowestY,highestY = 0,10000
count +=1
if(train == False):
imageFolders = os.listdir(”/home/dbyte/deliciousImages/”)
images =[]
for imageFolder in imageFolders:
imageFiles = glob.glob(”/home/dbyte/deliciousImages/” + imageFolder + “/*.png”)
for imageFile in imageFiles:
pixels = list(Image.open(imageFile).getdata())
for i in xrange(len(pixels)):
if pixels[i] != 0: pixels[i] = 1
images.append((pixels,imageFolder))
crackedString = “”
for captcha in captchas:
bestSum,bestChar = 0,”"
captchaPixels = list(captcha.getdata())
for i in xrange(len(captchaPixels)):
if captchaPixels[i] != 0: captchaPixels[i] = 1
for imageAll in images:
thisSum = 0
pixels = imageAll[0]
for i in xrange(len(captchaPixels)):
try:
if(captchaPixels[i] == pixels[i]): thisSum+=1
except: pass
if(thisSum > bestSum):
bestSum = thisSum
bestChar = imageAll[1]
crackedString += bestChar
print crackedString
#print “time taken: ” + str(time.time() - now)
You are really in war against that dude…
hahah this keeps getting better and better. Get em eli. lol
nice man…those retards can’t evolve so they have to keep bitchin’
this is your code? it’s very neat, i might add.
LOL
I’m glad your site is back anyway
God damn it Eli… I actually use this one on my own already! argghhh.
Eh whatever. Time to evolve I guess. haha
what a lovely piece of code, great share Eli!
Great Eli, thanks
Keep it comin’!
Hi Eli!
I discovered your site just before it goes down…happy to see it’s back, anyway I spent some hours browsing Google cached results to read your past articles…very interesting.
Now, just a question on this script: what kind of parameters do I need to pass? It may be a stupid question, but I’m not a python programmer…
I think this is a little out of my league, but I think the idea is cool.
thanks . ssuper
Some comments in the code would be nice. A short introduction what the algorithm behind this is, would be perfect
After a short glance I guess the solution is, that the letters are always the same (pixelwise), so you are searching for letters from the left to the right buy comparing pixels?
cool….
but pythone is out of my list… anyways I am eagerly waitin for something, from u r box, which i can utilize on full fledged basis…
This is awesome - but unfortunately well out of my league at the moment - just a matter of time me hopes though! Once again Eli you have pulled some great stuff out of the bag
been waiting for this for ages. captcha is getting a joke these days. last week i have to type a 15 alpha numeric code just to submit something. i am glad this is now busted open
Thanks for the usefull information!
I gonna write sumular using php
Awesome post ! I wish I had some programming skills.
Damn crazy
Hope this will not end delicious life:)
Nice to see some new posts recently. Saw all of the drama on wf. To bad it took someone going after you server, though.
Anyway, hope to see more, and the seo empire pt. 2 post soon, too.
lol - please learn to code.
that code reads like some shit a 12 year old fat kid hacked into his xbox controller.
aka you
lol thats great…
phyton is beyond me i’m afraid. even though this is a great achievement. can someone explain what evil things they would do with this?
WOW I lost my bookmarks not to long ago and Im glad i found this site again! i’m never going to lose it this time..LOl Best SEO site hands down!
Thanks for sharing. Comes in handy
Thanks for the usefull information.
Have a nice day!
Great post Eli, as always! No one should mess with us )))).
Just when I thought the site was down and gone forever, I happen to land here and see that it’s back. I don’t know much about what you just posted, but I’m glad to see something here
Thanks for sharing this code. I will use it, for sure!
Seeing this in PHP would be nice.
::emp::
Good code! Thank you.
release more captchas!!
seconded.. i don’t know sh*t about python lol
couldnt help it.
Had to start one.
Wow, how can this be ?
If Delicious offered you money to devise a captcha that wasn’t crackable, would you do it..and for how much?
Nice article!!!
Hilarious! At least you’re making as many friends as enemies along the way. I’d second Gadgets4nowt’s questions about creating a captcha.
Well it might bring more secure captcha…
LOL! I read a little bit into the controversy that cracking captchas has caused. Some of those forum posts are pretty amusing, I like the fact that you redirected to the whitehouse.gov site to get even!
Thanks a lot for this - and good to see you back posting!
Hey…
is Seo Empire part II coming soon??
Haha, thanks!
That is so sneaky mr Blue Hat
Nice news. Thanks you!
Thanks for sharing this code. Of course, it’s good thing
Cool, thanks for sharing the code.
hahah awesome sweet thanks man appreciate it
Sweet Eli keep it up. For the win.
That’s awesome man, keep up the good work. Going to try and dissect the code and see what I can learn.
How long did it take you?
How can you beat it? It’s great! You are master!
Why you want to beat the captcha of Del.icio.us? What use does it have to crack the captcha
For the people who make automated bots to join and submit links.
I wonder if anybody could translate this into VB or C ?
You are very clever!
=)!Thank’s great code ! I will use it ! Continue in same direction! +1 for the post !
Nice! Now i just need to convert it to PHP
I will try to use this code on my blog. Thanks to the author!
Really nice but what about PHP?
I can’t understand why delicious haven’t done anything about this already.