看起来我们将为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>兼容的验证码,如果可能的话。

想法吗?


当前回答

有人还建议使用Raphael JavaScript库,它显然可以让你在所有流行的浏览器的客户端上作画:

http://dmitry.baranovskiy.com/raphael/

.. 但这并不完全适用于我的<noscript>情况,不是吗?:)

其他回答

@rob

蜜罐验证码怎么样? 哇,这么简单!看起来不错!尽管他们强调了无障碍问题。你认为这在SO会是一个问题吗?我个人觉得很难想象开发人员/程序员阅读屏幕有困难到需要屏幕阅读器的地步。

有些开发者不仅是法律上的盲人,而且是100%的盲人。手杖和辅助犬。我希望这个网站能支持他们在一个合理的方式。

然而,使用蜜罐验证码,您也可以放置一个隐藏的div,告诉他们将字段留空。如果他们填了,你也可以把它放在错误信息中,所以我不确定可访问性在这里有多大的问题。这肯定不太好,但也可能更糟。

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.

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

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

我推荐一些琐事问题。不是每个人都能理解字母的ASCII表示,有多个运算的数学问题会让人困惑。

我有一个vBulletin论坛,收到了大量的垃圾邮件。添加一个额外的规则解决了这一切;让人们输入一个单词的大写字母。由于我们的网站名为“TrefPuntMagic”,他们不得不输入“TPM”。我知道它不是动态的,如果一个垃圾邮件制造者想要真正的垃圾邮件我们的网站,他们可以做一个工作,但我们只是许多许多vBulletin论坛他们的目标,这是一个简单的解决方案。

使用样式化的HTML元素(如div)来显示验证码怎么样?从矩形区域中构造字母很容易,但很难分析它们。