看起来我们将为Stack Overflow添加CAPTCHA支持。这对于防止机器人、垃圾邮件发送者和其他恶意脚本活动是必要的。我们只希望人类在这里发布或编辑东西!

我们将使用JavaScript (jQuery)验证码作为第一道防线:

http://docs.jquery.com/Tutorials:Safer_Contact_Forms_Without_CAPTCHAs

这种方法的优点是,对于大多数人来说,CAPTCHA永远不会可见!

然而,对于禁用JavaScript的人,我们仍然需要一个备用方案,这就是棘手的地方。

我为ASP编写了一个传统的CAPTCHA控件。NET,我们可以重复使用。

但是,我更倾向于使用一些文本化的东西,以避免为每个请求在服务器上创建所有这些图像的开销。

我见过这样的事情…

ASCII文本验证码:\/\/(_)\/\/ 数学难题:7减3乘以2等于多少? 小问题:癞蛤蟆和冰棍,哪个更好吃?

也许我只是在风车这里倾斜,但我希望有一个更少的资源密集型,非图像为基础的<noscript>兼容的验证码,如果可能的话。

想法吗?


当前回答

我确信大多数页面都是使用支持鼠标悬停的控件(按钮、链接等)构建的。

不是显示图像并要求用户输入内容,而是要求用户将鼠标移动到任意控件(以随机顺序选择控件(任何按钮或链接))。 并将颜色应用到控件(一些随机的颜色)上鼠标(小JavaScript做的伎俩).. 然后让用户在鼠标上输入他/她所看到的颜色。

这只是一种不同的方法,我并没有实现这个方法。但这是可能的。

其他回答

这些JavaScript解决方案是否都适用于屏幕阅读器?而图像减去一个有意义的alt属性可能会破坏WCAG。

这一个使用1px块生成看起来像图像,但纯html/css。请参见此处的示例链接:http://www.nujij.nl/registreren.2051061.lynkx?_showInPopup=true

我用一个简单的“Leave this field空白:”字段就得到了惊人的好结果。机器人似乎什么都填,特别是如果你把字段命名为“URL”。加上严格的推荐人检查,我还没有一个机器人通过它。

请不要忘记可访问性。对于使用屏幕阅读器的人来说,验证码是出了名的不可用。简单的数学问题或非常琐碎的琐事(我喜欢“天空是什么颜色”的问题)对视力受损的用户更友好。

Make an AJAX query for a cryptographic nonce to the server. The server sends back a JSON response containing the nonce, and also sets a cookie containing the nonce value. Calculate the SHA1 hash of the nonce in JavaScript, copy the value into a hidden field. When the user POSTs the form, they now send the cookie back with the nonce value. Calculate the SHA1 hash of the nonce from the cookie, compare to the value in the hidden field, and verify that you generated that nonce in the last 15 minutes (memcached is good for this). If all those checks pass, post the comment.

This technique requires that the spammer sits down and figures out what's going on, and once they do, they still have to fire off multiple requests and maintain cookie state to get a comment through. Plus they only ever see the Set-Cookie header if they parse and execute the JavaScript in the first place and make the AJAX request. This is far, far more work than most spammers are willing to go through, especially since the work only applies to a single site. The biggest downside is that anyone with JavaScript off or cookies disabled gets marked as potential spam. Which means that moderation queues are still a good idea.

从理论上讲,这可以作为通过模糊性的安全,但在实践中,这是很好的。

我从未见过垃圾邮件发送者试图破解这种技术,尽管可能每隔几个月我就会收到一个手动输入的主题垃圾邮件条目,这有点怪异。

非常简单的算术很好。盲人也能回答。(但正如Jarod所说,要注意操作符优先级。)我想有人可以编写一个解析器,但这使得垃圾邮件的成本更高。

足够简单,并且围绕它编写代码并不困难。我看到了两个威胁:

随机的垃圾邮件机器人和可能支持它们的人类垃圾邮件机器人;而且 机器人创建游戏堆栈溢出

通过简单的算术,你可以打败威胁1,但不能打败威胁2。