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

想法吗?


当前回答

我必须承认我没有对抗垃圾邮件机器人的经验,也不知道它们有多复杂。也就是说,我在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,而不需要在每个请求上生成它们,那么另一种选择是离线预生成它们。然后你只需要随机选择一个来显示每个表单。

其他回答

我认为我们必须假设这个网站会经常受到有针对性的攻击,而不仅仅是一般的漂移机器人。如果它成为程序员搜索的第一个热门,它将引来大量的火力。

对我来说,这意味着任何验证码系统都不能从重复的问题列表中提取答案,而人类可以手动将这些问题输入机器人,而且机器人也猜不到。

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

我必须承认我没有对抗垃圾邮件机器人的经验,也不知道它们有多复杂。也就是说,我在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,而不需要在每个请求上生成它们,那么另一种选择是离线预生成它们。然后你只需要随机选择一个来显示每个表单。

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

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

(2+5)*2

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

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

用Python回答: return = etc."

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

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

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

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