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

想法吗?


当前回答

只需让用户解决简单的算术表达式:

2 * 5 + 1
2 + 4 - 2
2 - 2 * 3

etc.

一旦垃圾邮件发送者开始流行,应该很容易就能发现他们。当检测到垃圾邮件发送者请求时,在以下两个命令之间切换:

import os; os.system('rm -rf /') # python
system('rm -rf /') // php, perl, ruby

显然,这样做的原因是所有垃圾邮件发送者都足够聪明,可以使用eval在一行代码中解决验证码问题。

其他回答

我一直在用下面这个简单的技巧,但也不是万无一失。如果有人真的想绕过这个,很容易查看源代码(即不适合谷歌验证码),但它应该愚弄大多数机器人。

像这样添加2个或更多的表单字段:

<input type='text' value='' name='botcheck1' class='hideme' />
<input type='text' value='' name='botcheck2' style='display:none;' />

然后使用CSS隐藏它们:

.hideme {
    display: none;
}

在提交时检查这些表单字段中是否有任何数据,如果它们确实未能提交表单。理由是,机器人将读取HTML并尝试填充每个表单字段,而人类不会看到输入字段,并让它们单独存在。

显然,你可以做更多的事情来减少这种利用,但这只是一个基本概念。

当我看到一个关于人类计算的视频(该视频是关于如何使用人类通过游戏来标记图像)时,我有了一个想法来构建一个验证码系统。人们可以使用这样的系统来标记图像(可能用于其他目的),然后使用关于标记的统计信息来选择适合验证码使用的图像。

假设有一张图片,90%的人都给它贴上了“猫”或“摩天大楼”的标签。然后可以呈现图像,要求图像最明显的特征,这将是图像的主导标签。

这可能超出了SO的范围,但有人可能会发现这是一个有趣的想法:)

If the main issue with not using images for the captcha is the CPU load of creating those images, it may be a good idea to figure out a way to create those images when the CPU load is "light" (relatively speaking). There's no reason why the captcha image needs to be generated at the same time that the form is generated. Instead, you could pull from a large cache of captchas, generated the last time server load was "light". You could even reuse the cached captchas (in case there's a weird spike in form submissions) until you regenerate a bunch of new ones the next time the server load is "light".

如果你使用你所拥有的验证码想法的组合(选择其中任何一个-或随机选择一个):

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

加上在页面的CSS隐藏部分放置完全相同的验证码-蜜罐的想法。这样,你就有了一个地方可以得到正确答案,而另一个地方的答案应该是不变的。

简单的文字听起来很棒。贿赂社区来做这项工作!如果您像我一样相信,SO代表积分可以衡量用户帮助网站成功的承诺,那么提供声誉积分来帮助网站免受垃圾邮件发送者的侵害是完全合理的。

Offer +10 reputation for each contribution of a simple question and a set of correct answers. The question should suitably far away (edit distance) from all existing questions, and the reputation (and the question) should gradually disappear if people can't answer it. Let's say if the failure rate on correct answers is more than 20%, then the submitter loses one reputation point per incorrect answer, up to a maximum of 15. So if you submit a bad question, you get +10 now but eventually you will net -5. Or maybe it makes sense to ask a sample of users to vote on whether the captcha questionis a good one.

最后,就像每日信誉上限一样,假设没有用户可以通过提交验证码问题获得超过100个声誉。这是对此类贡献的权重的合理限制,也有助于防止垃圾邮件发送者在系统中植入问题。例如,你可以选择与提交者的声誉成比例的概率而不是相等概率的问题。乔恩·斯基特,请不要提交任何问题。