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

想法吗?


当前回答

虽然我们都应该知道基本的数学,但这个数学难题可能会引起一些困惑。在你的例子中,我相信有些人会回答“8”而不是“1”。

用粗体或斜体突出显示随机字符的简单文本字符串是否合适?用户只需要输入粗体/斜体字母作为验证码。

例如ssdfatwerweajhcsadkoghvefdhrffghlfgdhowfgh

在这种情况下,“堆栈”将是验证码。 显然,这个观点有很多不同的版本。

编辑:解决与此想法相关的一些潜在问题的示例变体:

使用随机颜色的字母代替粗体/斜体。 使用每秒钟红色字母作为验证码(减少机器人识别不同格式的字母来猜测验证码的可能性)

其他回答

我必须承认我没有对抗垃圾邮件机器人的经验,也不知道它们有多复杂。也就是说,我在jQuery文章中没有看到任何不能纯粹在服务器上完成的事情。

要改写jQuery文章的摘要:

When generating the contact form on the server ... Grab the current time. Combine that timestamp, plus a secret word, and generate a 32 character 'hash' and store it as a cookie on the visitor's browser. Store the hash or 'token' timestamp in a hidden form tag. When the form is posted back, the value of the timestamp will be compared to the 32 character 'token' stored in the cookie. If the information doesn't match, or is missing, or if the timestamp is too old, stop execution of the request ...

如果您希望使用传统的图像CAPTCHA,而不需要在每个请求上生成它们,那么另一种选择是离线预生成它们。然后你只需要随机选择一个来显示每个表单。

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

令人困惑的一件事是谷歌,显然是世界上拥有最多CS博士的公司,他们的验证码被破坏了,而且似乎没有采取任何措施。

@ pc1oad1letter我也注意到在我的帖子。然而,这只是一个想法,而不是实际的实现。改变字体或使用不同的颜色,而不是粗体/斜体,可以很容易地解决可用性问题。

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".