Created
June 14, 2012 20:59
Revisions
-
Samuirai revised this gist
Jun 14, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -77,7 +77,7 @@ In the end, this was the first time I tried to solve a Captcha. I think this is kind regards,<br> samuirai personal Website http://www.smrrd.de<br> I'm a member of the [Stuttgart Hackerspace - shackspace](http://www.shackspace) edit: -
Samuirai revised this gist
Jun 14, 2012 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -77,7 +77,8 @@ In the end, this was the first time I tried to solve a Captcha. I think this is kind regards,<br> samuirai personal Website http://www.smrrd.de I'm a member of the [Stuttgart Hackerspace - shackspace](http://www.shackspace) edit: to see really cool stuff with reCaptcha, check out what they did: http://www.dc949.org/projects/stiltwalker/ -
Samuirai revised this gist
Jun 14, 2012 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -72,6 +72,8 @@ I also don't understand, what they think this means and why they are so excited In the end, this was the first time I tried to solve a Captcha. I think this is the best example of how not to implement it. [YouTube Video Demo](http://www.youtube.com/watch?v=EisT_ZjkPkM) kind regards,<br> samuirai -
Samuirai revised this gist
Jun 14, 2012 . 1 changed file with 4 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -73,7 +73,9 @@ I also don't understand, what they think this means and why they are so excited In the end, this was the first time I tried to solve a Captcha. I think this is the best example of how not to implement it. kind regards,<br> samuirai Also checkout my Website http://www.smrrd.de edit: to see really cool stuff with reCaptcha, check out what they did: http://www.dc949.org/projects/stiltwalker/ -
Samuirai revised this gist
Jun 14, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -76,4 +76,4 @@ kind regards,<br> [samuirai/smrrd](http://www.smrrd.de) edit: to see cool Captcha stuff, check out what they did: http://www.dc949.org/projects/stiltwalker/ -
Samuirai revised this gist
Jun 14, 2012 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -73,4 +73,7 @@ I also don't understand, what they think this means and why they are so excited In the end, this was the first time I tried to solve a Captcha. I think this is the best example of how not to implement it. kind regards,<br> [samuirai/smrrd](http://www.smrrd.de) edit: to see cool Captcha stuff, check out what tehy did: http://www.dc949.org/projects/stiltwalker/ -
Samuirai revised this gist
Jun 14, 2012 . 1 changed file with 8 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,19 +1,19 @@ [G-WAN](http://gwan.ch/) is a new free web server. They seem to be very proud of it, or at least just want to make a lot of money. Well anyway, in almost every sentence they write, they claim that they are 20% cooler than anything else. It feels a bit arrogant. I have to admit, I don't know a lot about web servers, so I can't speak to how good they are. However, then I saw their [Captcha example](http://www.gwan.ch/csp_captcha.html). I also don't know much about machine learning algorithms, OCR, and stuff like that, but I do know how to read pixels. I also know how to compare values with python :P  They say the following about their Captcha: [...] difficult or even completely impossible for robots. Wait wat? If this is true, this is something really outstanding and maybe an alternative to reCaptcha... But then I was like:  @@ -70,7 +70,7 @@ I also don't understand, what they think this means and why they are so excited The two sums are: 13 and 8... for the same Captcha image! By just changing the HTML background color [...] In the end, this was the first time I tried to solve a Captcha. I think this is the best example of how not to implement it. kind regards,<br> [samuirai/smrrd](http://www.smrrd.de) -
Samuirai revised this gist
Jun 14, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ They seem to be very proud of it, or just want to make a lot of money. Well anyway, in almost all sentences they say, that they are 20% cooler than anything else. It even feels a bit arrogant. I have to admit, I don't know a lot about web servers, so I can't argue about how good they are. But then I saw their [Captcha example](http://www.gwan.ch/csp_captcha.html). I also don't know a lot about machine learning algorithms, OCR, and stuff like that, but I can read pixels. And I know how to compare values with python :P  -
Samuirai revised this gist
Jun 14, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ They seem to be very proud of it, or just want to make a lot of money. Well anyway, in almost all sentences they say, that they are 20% cooler than anything else. It even feels a bit arrogant. I have to admit, I don't know a lot about web servers, so I can't argue about how good they are. But then I saw their [Captcha example](http://www.gwan.ch/csp_captcha.html). I also don't know a lot about machine learning algorithms, OCR, and stuff like that, but I can read pixels. And I know how you to compare values with python.  -
Samuirai revised this gist
Jun 14, 2012 . 1 changed file with 4 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,3 @@ [G-WAN](http://gwan.ch/) is a new free web server. They seem to be very proud of it, or just want to make a lot of money. Well anyway, in almost all sentences they say, that they are 20% cooler than anything else. It even feels a bit arrogant. @@ -71,4 +70,7 @@ I also don't understand, what they think this means and why they are so excited The two sums are: 13 and 8... for the same Captcha image! By just changing the HTML background color [...] In the end, this was the first time I tried to solve a Captcha. I think this is the best example of how to not implement it. kind regards,<br> [samuirai/smrrd](http://www.smrrd.de) -
Samuirai revised this gist
Jun 14, 2012 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,3 @@ [G-WAN](http://gwan.ch/) is a new free web server. They seem to be very proud of it, or just want to make a lot of money. @@ -7,6 +6,8 @@ I have to admit, I don't know a lot about web servers, so I can't argue about ho But then I saw their [Captcha example](http://www.gwan.ch/csp_captcha.html). I also don't know a lot about machine learning algorithms, OCR, and stuff like that, but I can read pixels. And I know how you can compare values with python.  They say about their Captcha: [...] difficult or even completely impossible for robots. -
Samuirai revised this gist
Jun 14, 2012 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,5 @@  [G-WAN](http://gwan.ch/) is a new free web server. They seem to be very proud of it, or just want to make a lot of money. Well anyway, in almost all sentences they say, that they are 20% cooler than anything else. It even feels a bit arrogant. @@ -63,8 +65,6 @@ So I wrote this basic stupid pixel by pixel reading and comparing code, to decod --------------------- 8 | 13 I also don't understand, what they think this means and why they are so excited about it: The two sums are: 13 and 8... for the same Captcha image! -
Samuirai revised this gist
Jun 14, 2012 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -16,7 +16,6 @@ But I was like:  So I wrote this basic stupid pixel by pixel reading and comparing code, to decode the captcha. smrrd$ python crack_captcha.py GIF Image @@ -64,6 +63,8 @@ So I wrote this basic stupid pixel by pixel reading and comparing code, to decod --------------------- 8 | 13  I also don't understand, what they think this means and why they are so excited about it: The two sums are: 13 and 8... for the same Captcha image! -
Samuirai revised this gist
Jun 14, 2012 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -16,6 +16,7 @@ But I was like:  So I wrote this basic stupid pixel by pixel reading and comparing code, to decode the captcha.  smrrd$ python crack_captcha.py GIF Image -
Samuirai created this gist
Jun 14, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,71 @@ [G-WAN](http://gwan.ch/) is a new free web server. They seem to be very proud of it, or just want to make a lot of money. Well anyway, in almost all sentences they say, that they are 20% cooler than anything else. It even feels a bit arrogant. I have to admit, I don't know a lot about web servers, so I can't argue about how good they are. But then I saw their [Captcha example](http://www.gwan.ch/csp_captcha.html). I also don't know a lot about machine learning algorithms, OCR, and stuff like that, but I can read pixels. And I know how you can compare values with python. They say about their Captcha: [...] difficult or even completely impossible for robots. Wait wat? If this is true, this is something really good and maybe an alternative to reCaptcha... But I was like:  So I wrote this basic stupid pixel by pixel reading and comparing code, to decode the captcha. smrrd$ python crack_captcha.py GIF Image --------- R0lGODlhGAAZAJEAAP///9//v4SkZAAAACH5BAEAAAAALAAAAAAYABkAAAJfhI+pGB0rmHuGAmtEPJj7E23VYlmbeDnMB2guu44J2lWqQi/6Drl0k7hlSKwSiHeBgV5BTK2FNOKIsmQVJekIkdzgTEOVIERY4ApDPoczTOvzCbVtq/G6kt4CK+BdRQEAOw== Captcha Data Matrix ------------------- 1 1 1 1 2 1 1 1 1 1 1 1 2 2 1 1 1 2 2 1 1 1 2 2 1 1 1 1 1 1 2 2 2 2 2 1 1 1 2 1 1 1 1 1 2 1 2 2 2 2 2 1 1 1 1 1 1 2 1 1 1 1 2 1 1 2 2 2 2 1 1 1 2 1 1 2 1 1 1 1 2 1 1 1 1 1 1 1 2 2 2 1 1 1 2 2 1 1 1 1 2 2 1 1 1 2 2 2 2 1 1 1 2 1 1 1 1 1 1 2 2 1 1 2 2 2 1 color | pixel count ------------------- 0 | 472 1 | 81 2 | 44 color 1 | color 2 --------------------- 3 | 4 1 | 9 4 | --------------------- 8 | 13 I also don't understand, what they think this means and why they are so excited about it: The two sums are: 13 and 8... for the same Captcha image! By just changing the HTML background color [...] In the end, this was the first time I tried to solve a Captcha. I think this is the best example of how to not implement it. This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,212 @@ import base64, sys, io, Image, urllib2, re bg = 0 # background color cw = 8 # character width # get the new captcha url = urllib2.urlopen("http://62.75.175.163:8080/?captcha.c") html = url.read().replace('\n','').replace('\r','') url.close() # get the base64 gif image code # <img src="data:image/gif;base64,R0lGODlhG...AAADs=" alt="A tree" width="48" height="50" /> # => R0lGODlhG...AAADs= regex = re.compile('.*base64,(.*)" alt') gif_b64 = regex.match(html).group(1) print "GIF Image" print "---------" print gif_b64 # load the string as image f = io.BytesIO(base64.b64decode(gif_b64)) img = Image.open(f) pix = img.load() # print and analyse the pixels print "Captcha Data Matrix" print "-------------------" pixels = {} for y in xrange(0,25): for x in xrange(0,24): # collect data if pix[x,y] not in pixels: pixels[pix[x,y]]=0 else: pixels[pix[x,y]]+=1 # print pixels if pix[x,y]!=bg: print pix[x,y], else: print ' ', print '' # print the analyse - total useless, but looks cool print "color | pixel count" print "-------------------" for color in pixels: print "%5d | %10d" % (color,pixels[color]) # define all characters charset = { 0: [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0, 0], [0, 1, 0, 0, 0, 1, 0, 0], [0, 1, 0, 0, 1, 1, 0, 0], [0, 1, 0, 1, 0, 1, 0, 0], [0, 1, 1, 0, 0, 1, 0, 0], [0, 1, 0, 0, 0, 1, 0, 0], [0, 0, 1, 1, 1, 0, 0, 0]], 1: [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 1, 0, 0, 0], [0, 0, 1, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0]], 2: [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0, 0], [0, 1, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 0, 0]], 3: [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0, 0], [0, 1, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0], [0, 1, 0, 0, 0, 1, 0, 0], [0, 0, 1, 1, 1, 0, 0, 0]], 4: [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 1, 0, 0, 0], [0, 0, 1, 0, 1, 0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, 0, 0, 1, 0, 0], [0, 1, 0, 0, 0, 1, 0, 0], [0, 0, 1, 1, 1, 0, 0, 0]], } def find_character(tmp_char): highest_char = ['X',0,0,] for char in xrange(0,10): match = 0 fails = 0 for x in range(len(tmp_char)): for y in range(len(tmp_char[x])): #print str(tmp_char[x][y])+str(charset[char][x][y]), if (charset[char][x][y] != 0 and tmp_char[x][y] != 0) or (charset[char][x][y] == tmp_char[x][y]): match+=1 else: fails+=1 #print #print [char,match,fails,] if match>highest_char[1]: highest_char=[char,match,fails,] return highest_char def get_color(tmp_char): color = {} for x in range(len(tmp_char)): for y in range(len(tmp_char[x])): if tmp_char[x][y]!=bg: if tmp_char[x][y] not in color: color[tmp_char[x][y]] = 0 else: color[tmp_char[x][y]] += 1 return color.keys() # analyse each character color = {} for yl in xrange(0,3): for xl in xrange(0,3): tmp_char = [] for y in xrange(yl*cw,yl*cw+cw): tmp_line = [] for x in xrange(xl*cw,xl*cw+cw): tmp_line.append(pix[x,y]) #print pix[x,y], #print tmp_char.append(tmp_line) match = find_character(tmp_char) col = get_color(tmp_char) if not match[2]: if col[0] not in color: color[col[0]] = [match[0]] else: color[col[0]].append(match[0]) # print the sums print "" if len(color.keys())>=2: print "color %3d | color %3d" % (color.keys()[0],color.keys()[1]) else: print "color %3d | " % (color.keys()[0]) print "---------------------" left_list = color[color.keys()[0]] if len(color.keys())>=2: right_list = color[color.keys()[1]] else: right_list = [] longest_length = 0 if len(left_list)>len(right_list): longest_length = len(left_list) else: longest_length = len(right_list) for row in xrange(0,longest_length): left_val = '' right_val = '' if len(left_list)>row: left_val = str(left_list[row]) if len(right_list)>row: right_val = str(right_list[row]) print "%9s | %9s" % (left_val,right_val) print "---------------------" print "%9s | %9s" % (sum(left_list),sum(right_list))