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

想法吗?


当前回答

如果没有一个真正的验证码作为第一道防线,你是不是仍然容易受到垃圾邮件发送者编写浏览器脚本的攻击(使用VB和IE很简单)?即加载页面,浏览DOM,点击提交按钮,重复…

其他回答

将一个数学问题发布为IMAGE,为了清晰起见,可能会使用附图。

只是图像中清晰可见的文本。

(2+5)*2

我最喜欢的验证码:

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.

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

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

我有一些想法想和你们分享……

避免OCR的第一个想法

一个验证码对用户来说有一些隐藏的部分,但完整的图像是两个代码在一起,所以OCR程序和验证码农场读取图像,包括可见部分和隐藏部分,尝试解码它们,但未能提交…-我已经准备好解决这个问题,并在网上工作。

http://www.planethost.gr/IdeaWithHiddenPart.gif

第二个想法,让它更容易

一页有很多单词,人类必须选择正确的一个。我也创建了这个,很简单。文字是可点击的图像,用户必须点击正确的图像。

http://www.planethost.gr/ManyWords.gif

没有图像的第三个想法

和以前一样,但是有div和文本或小图标。用户必须只点击正确的一个div/字母/图像,无论如何。

http://www.planethost.gr/ArrayFromDivs.gif

最终想法——我称之为CicleCaptcha

还有一个我的CicleCaptcha,用户必须在图像上找到一个点。如果他找到并点击它,那么是一个人,机器可能会失败,或者需要制作新的软件来找到解决这个问题的方法。

http://www.planethost.gr/CicleCaptcha.gif

欢迎任何批评。

基于CSS的验证码怎么样?

<div style="position:relative;top:0;left:0">
<span style="position:absolute;left:4em;top:0">E</span>
<span style="position:absolute;left:3em;top:0">D</span>
<span style="position:absolute;left:1em;top:0">B</span>
<span style="position:absolute;left:0em;top:0">A</span>
<span style="position:absolute;left:2em;top:0">C</span>
</div>

这将显示“ABCDE”。当然,使用自定义机器人仍然很容易。