5 ms·
I broke textCAPTCHA with Python
- Xk 16y agoI had yesterday off and so spent four or so hours writing this. I haven't made it recognize all of the cases. It still gets a few wrong, but usually it'll just say FAILURE when it can't solve it. As the page says, it's just a ~300 line grammar file and a parser-generator with syntax directed translation to solve the questions.
- lisper 16y agoVery nice. Any chance you'll release the code (or the grammar)?
- Xk 16y agoI'd like to wait a little bit to see if Rob (who it seems runs the site) will make it a little better. There are people who use this service and I don't think it would be right to let spammers attack them. Granted, it wouldn't be hard for someone else to do the same as me, but I just don't want my work used to do harm to someone else.
- mattmanser 16y agoGood job on the code and kudos for not just releasing the code without giving the author some time.
- jaspero 16y agoI think you should release your wonderful algorithm not directly as a way to hack text-captchas but in some other useful forms.
- jerf 16y agoYou might as well release it. The idea is fundamentally flawed, advantage attacker, and there is nothing they can do about it. You won't be hurting them, you'll sort of be doing them a favor. They've already sunk time into the idea, this is a chance for them to cut their time losses and run. Though they may take it wrong and try to start an arms race with your code, to which I'd say: An arms race in the CAPTCHA space is already a win for the attackers. In case of tie, spammers win.
- bl4k 16y agocare to publish the src?
- Xk 16y agoI replied to another comment, but since this one is getting upvoted I'll reply here too: I do not want to publish the grammar file yet. Later on, yeah, I can do that. But for now I want to leave it up to the people who run this service to improve it. I simply want to demonstrate that their scheme is not effective, I do not want to cause harm to anyone who uses it.
- davidjhall 16y agosrc or it didn't happen. ;-)
- jrockway 16y agoPeople using brand-new untested technology for security purposes are doing it for fun, not because it's a good idea. So releasing the source code to break it should not cause any problems.
- oofoe 16y agoCan I ask what you're using to do the parsing? Or did you write your own? This is definitely the kind of thing that I could see doing with REBOL's parse operator, but Python doesn't (seem to) come with such a tool built in. Thanks!
- Xk 16y agoFor a class in college I had to write a parser-generator, so I'm using mine.
- jasonlotito 16y agoChicken, egg: which came first? A: FAILURE sigh So close.
- amanuel 16y agothe rooster? FTW!
- bl4k 16y agoAs soon as I saw the story about textCAPTCHA I knew somebody would tackle it and solve it. There have been so many 'captcha alternatives' on HN recently, all of them forget that there is a very good reason why current captcha's are extremely distorted images.
- moshezadka 16y agoThis is a variant on Schneier's fundamental theorem: Any fool can design a CAPTCHA for which they cannot program a solver. Just like in crypto, the only true test of CAPTCHAs are which one survive the test of time after having been attacked again and again, which is why it's very dangerous to jump on the bandwagon of a new CAPTCHA scheme (or worse yet -- design your own). This is one reason why I'm partial to reCAPTCHA: there is a lot of experience in OCR systems, and we know what the current state of the art -- and we know what kind of things foil it.
- wwortiz 16y agoThe only problem is you get things like google's captcha system that make you question whether or not you are human.
- bjonathan 16y agoWow very impressive, just tried it: Q:Which word from list "duckweed, commendations, civilised, receptionists, flours" contains the letter "v"? A: FAILURE Q: What word from "interdisciplinary, disorientating, decamps, moan" begins with "i"? A: FAILURE Q: Egg, pink, white, green and pub: the 1st colour is? A: pink Q: The day of the week in dog, Wednesday, penguin, trousers, hotel or lion is? A: wednesday Q: Hand, jelly or Jennifer: the person's name is? A: jennifer Q: What is fifty three thousand seven hundred and one as digits? A: 53701 Q: Cake, rice, snake, head and jelly: how many body parts in the list? A: 1 Q: If yesterday was Tuesday, what day is today? A: wednesday Q: Which of these is a body part: lion, jelly, church, butter or nose? A: nose
- Xk 16y agoSince some people are asking how it works, I'll explain how some of those work/fail. Q: Which word from list "duckweed, commendations, civilised, receptionists, flours" contains the letter "v"? A: FAILURE This one fails because it recognizes 'duck' as a word and doesn't know what the trailing characters are, so it fails to parse. Adding it to let a word be followed by extra characters makes it twice as slow, but makes it pass it, and so I didn't do that. Q: Hand, jelly or Jennifer: the person's name is? A: jennifer This is one of the tricky cases, because I convert to lower case when I pass to the parser. So if parsing fails and the word 'name' is in the string, then I return the first capitalized word and hope for the best. Q: What is fifty three thousand seven hundred and one as digits? A: 53701 This one was an interesting exorcise in parsing as it is grouped ((fifty three) thousand) (seven hundred) and (one). I assume that all numbers are of the correct form, because it will parse 'one one and two' as the number 4 (1+1+2=4). Q: If yesterday was Tuesday, what day is today? A: wednesday This was just putting the dates in order and doing a lookup into the list.
- chaosmachine 16y agoGreat job. Seeing this solve 10/10, it almost feels like artificial intelligence. You should send a resume to the Wolfram Alpha guys (their hit rate was significantly lower: http://news.ycombinator.com/item?id=1891375 http://news.ycombinator.com/item?id=1891375)
- Xk 16y agoYeah, but I have the advantage of knowing all the forms of the questions. If you were to change one word then mine would break. Or misspell anything.
- techiferous 16y agoI just typed in similar questions without following the format and it performed poorly. But at least it's a good proof-of-concept! :) Name the third item in the list: book, fork and spoon. A: FAILURE Q: What is two times 8? A: Which is a number: yellow, seven, book, flag? A: FAILURE
- Xk 16y agoThey don't give questions formatted in other ways, so I didn't include that in the logic. As someone else pointed out, even deleting the question mark would break it. (However, making the question mark optional would be a two second fix.)
- joelvh 16y agoGreat job! I wrote up that post about WolframAlpha and wonder if there's an API so you could integrate WA to make it more robust?
- Xk 16y agoRight now there's no API or anything -- I wrote this just to see if I could. I'm not sure if I'll be putting up an API, because I figure by the time I'd do that I can just release the source for it. But if you really wanted I probably could provide an API it in a couple of days.
- deleted 16y ago[deleted]
- binarymax 16y agoVery impressive! 4/5 for me. Here's the only one that broke: The 6th letter in "aviator" is? A: FAILURE
- Xk 16y agoJust letting people know I dropped it from 10 questions down to 5 because right now it's a free google app and I'd rather not pay for CPU-time.
- bockris 16y agoIt's totally hilarious to me that you had to protect your captcha breaker with a captcha.
- Xk 16y agoHaha, yeah. I did it so that people wouldn't use it as a spamming service: I wanted to show that those captchas can be broken, but without any harm to anyone else.
- bockris 16y agoIt makes perfect sense why you did it, but still funny as hell. (to me anyway)
- ldite 16y agoYou should have protected it with one of the text captchas - so to use your service to bypass it they'd have to have broken it already :)
- deleted 16y ago[deleted]
- Xk 16y agoYeah :) But then it occurred to me that someone could solve one by hand, and then use that answer to solve five more captchas that I asked for, and then recurse, eventually solving thousands of a site's captchas.
- finemann 16y agoThese questions didn't work for me Q: How many thousands is a million? Q: How many millions is a billion? Q: There is a dog, cat and a goat: First animal? Q: There is a dog, cat and a goat: How many humans? Q: Black, White: Which is dark?
- Xk 16y agoThere are a few types of questions that it doesn't solve. I only had so much time yesterday and so I didn't put in all the different types of questions. Maybe later I'll go back and get all the questions that it can't solve.
- philfreo 16y agoCare to give a little more explanation on how it works?
- Xk 16y agoSure. I'm assuming you know what parsing is, and what syntax-directed translation is. If not, the wikipedia articles (http://en.wikipedia.org/wiki/Parsing http://en.wikipedia.org/wiki/Parsing and http://en.wikipedia.org/wiki/Syntax-directed_translation http://en.wikipedia.org/wiki/Syntax-directed_translation) offer a reasonable explanation. The grammar file is generally laid out as follows: Question ::= Phrase1 | Phrase2 | Phrase3 ... Phrase1 ::= 'if' 'the' Noun 'is' Color 'what' 'color' 'is' 'it' [and now return the word which matched Color] Noun ::= [sequence of characters] Color ::= 'red' | 'blue' ... The trickiest part of it was getting it to correctly interpret numbers like 'twenty one thousand eight hundred and ninety nine' That part is basically laid out as Number ::= Number QuantifiedNumber | Number 'and' QuantifiedNumber | QuantifiedNumber QuantifiedNumber ::= NumberGroup | NumberGroup Quantifier NumberGroup ::= SingleNumber SingleNumber | SingleNumber SingleNumber ::= 'one' | 'two' | ... 'twenty' | 'thirty' | ...
- c4urself 16y agoi noticed the form matters: so not including a question mark breaks it in "two plus fifteen equals?"
- l0nwlf 16y agoTried: Q: What does Python prompt look like ? Desired Answer: >>> Answer Given: None.
- jmatt 16y agoI like this sort of approach for community oriented captcha. Ask a question that anyone within the community would know or could easily find out but a general purpose spam bot or average person would be unable to solve. If the community is profitable enough or becomes big enough some spammer will spend 15 minutes or 50 dollars on mechanical turk and find all the answers. As others have mentioned it is an arms race in the end. Back and forth each side upping the challenge.
- chacha102 16y agoFailed on "The blue rainjacket is what color?". You might want to allow for both 'color' and 'colour'.
- Jach 16y agoNice little app, but here are two I've used it fails on: Please join these two "words" together (without spaces): zrtvyoav and ekozuarn A: FAILURE What starts with "bow" and ends with "ser"? A: FAILURE
- 9ec4c12949a4f3 16y agoCongrats, I suspected a higher cost of defeating this test. http://news.ycombinator.com/item?id=1891026 http://news.ycombinator.com/item?id=1891026
- 9ec4c12949a4f3 16y agoCongrats, I suspected a higher cost of defeating this test. http://news.ycombinator.com/item?id=1891026 http://news.ycombinator.com/item?id=1891026
- deleted 16y ago[deleted]
- harshpotatoes 16y agoGiven the recent wave of reinventing/breaking captchas, I saw the captcha at the end, and thought: "what if this free app is just a very clever way to get a bunch of intelligent people to answer captcha's for a bot?" Then I realized if somebody went through all this trouble to design a new app like this, they deserve to have me answer captcha's for a bot somewhere. Q: What nonsense word do the letters G-B-R-D spell? A: gbrd Q: Which three letter word starts with the letters TH and ends with the letter E? A: th Pretty neat.
- Xk 16y agoHaha, no, I don't have this answering questions for any bot anywhere. Actually, the reason those are solved isn't exactly what you'd expect. When it fails to find an answer, it checks to see if any word is upper-case. If it is, it cuts out all non-letters (to remove the comma at the end, for example) and then returns that word. The reason it does this is because it will occasionally asks questions such as "Which word IN this sentence is in all caps." So that's why G-B-R-D gets turned into 'gbrd', and why it says 'th'.
- amanuel 16y ago* What is 3 + 12 / equal too? FAIL