看起来我们将为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:检查后时间减去加载时间大于HUMANISVERYFASTREADER。

禁用JavaScript: HTTP请求开始时间减去HTTP响应结束时间(存储在会话或隐藏字段中)大于HUMANISVERYFASTREADER加上NETWORKLATENCY乘以2。

在任何一种情况下,如果它返回真,那么你重定向到一个图像验证码。 这意味着大多数时候人们不需要使用图像验证码,除非他们的阅读速度非常快,或者垃圾邮件机器人设置为延迟响应。

注意,如果使用隐藏字段,我将为它使用一个随机id名称,以防bot检测到它被用作CAPTCHA并试图修改该值。

另一种完全不同的方法(只适用于JavaScript)是使用jQuery Sortable函数允许用户对一些图像进行排序。也许是一个小的3x3拼图。

其他回答

映像可以在客户端从服务器传递的基于矢量的信息中创建。

这将减少服务器上的处理和传输的数据量。

验证码过滤器的一个理论想法。向用户提出一个服务器可以简单回答的问题,用户也可以回答。共享答案成为用户和服务器都知道的一种公钥。

Stack Overflow的相关示例:

用户XYZ有多少声誉点?

提示:查看屏幕侧面的信息,或者点击这个链接。 用户可以从已知的堆栈溢出用户中随机抽取。

一个更一般的例子: 你住在哪里? 你住的地方星期六九点天气怎么样? 提示:使用雅虎天气,并提供湿度和一般条件。

然后用户输入他们的答案

西雅图 部分多云,湿度85%

计算机证实确实是西雅图当时的天气状况。

答案对用户来说是唯一的,但服务器有一种查找和确认答案的方法。

问题的类型可以多种多样。但其思想是,您对人类必须查找的事实组合进行一些处理,服务器可以简单地进行查找。这个过程是一个两部分的对话,需要一定程度的相互理解。这是一种反向转弯测试。让人类证明它可以提供可计算的数据,但它需要人类的知识来产生可计算的数据。

另一种可能的实现。你叫什么名字,什么时候出生的?

人会提供一个已知的答案,计算机可以在数据库中查找信息。

也许一个数据库可以由一个机器人来填充,但机器人需要一些智能来把相关的事实放在一起。服务器端的数据库或查找表可以被系统地删除明显的垃圾信息,如属性。

I am sure that there are flaws and details to be worked out in the implementation. But the concept seems sound. The user provides a combination of facts that the server can lookup, but the server has control over the kind of combinations that should be asked. The combinations could be randomized and the server could use a variety of strategies to lookup the shared answer. The real benefit is that you are asking the user to provide some sort of profiling and revelation of themselves in their answer. This makes it all the more difficult for bots to be systematic. A bunch of computers start using the same answers across many servers and captcha forms such as

我是1972年下午3:45出生的机器人。

然后,这种响应可以被整个网络分析和使用,以阻止机器人,有效地使自动化在几次迭代后变得毫无价值。

As I think about this more it would be interesting to implement a basic reading comprehension test for commenting on blog posts. After the end of a blog post the writer could pose a question to his or her readers. The question could be unique to each blog post and it would have the added benefit of requiring users to actually read before commenting. One could write the simple question at the end of a post with answers stored server side and then have an array of non sense questions to salt the database.

这篇文章谈到紫色验证码技术了吗? 服务器端回答(false, no)

这篇文章是关于验证码的吗? 服务器端回答(是,是)

这篇文章是关于迈克尔·杰克逊的吗? 服务器端回答(false, no)

以随机的顺序提出几个问题,并使这个顺序有意义,这似乎很有用。例如,上面的would = no, yes, no。打乱顺序,问一些无意义的问题,答案是“不是”和“是”。

为什么不设置简单的编程问题,用户可以回答他们最喜欢的语言-然后在服务器上运行代码,看看它是否有效。通过在不同的随机文本上运行答案来避免人工验证码农场。

例子: “从- s = hihiuhi@ewfwef.cfwe提取域名”

用Python回答: return = etc."

类似的领域知识,其他子网站。

所有这些都有可以自动测试的标准公式,但使用随机字符串或值进行测试。

显然,这个想法有很多缺陷;)

另外,每5分钟只允许一次登录尝试。

我认为一个定制的验证码是你最好的选择。这种方法需要一个专门针对机器人/脚本来破解它。这种努力因素应该会减少尝试的次数。人类毕竟是懒惰的

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.

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

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