如何保护 html 表单免受垃圾邮件发送者的侵害?

发布于 2024-10-08 05:10:21 字数 228 浏览 7 评论 0原文

我通过注册表单在数据库中遇到垃圾邮件条目问题。 我尝试了很多开源验证码解决方案,但仍然面临同样的问题。

因此,我正在寻找替代解决方案。用户必须输入问题答案的解决方案怎么样?问题的答案将是服务器端特定的单词,那么这肯定会击败垃圾邮件机器人吗?

一系列简单的随机问题会更好,还是像“6 + ? = 9”这样的问题会更好?我唯一担心的是,如果保护注册这么容易,那么为什么像 Facebook 这样的巨头不这样做呢?

I'm getting problems with spam entries in my database through signup form.
I have tried many open source Captcha solution, but still facing same problem.

I am therefore looking for an alternative solution. What about the solution, where users would have to input the answer to a question? The answer to the question will be a server-side specific word then would this surely defeat a spambot?

Would it be better to have a series of simple randomized questions or something like "6 + ? = 9" be better as a question? The only thing that concerns me is that if it's as easy as this to protect a signup then why aren't the big giant like Facebook doing this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(10

无尽的现实 2024-10-15 05:10:21

更新:答案被接受,因为我推荐了 KeyCAPTCHA。从我来之不易的痛苦经历来看,KeyCAPTCHA 是专业垃圾邮件发送者的骗局。我删除了 KeyCAPTCHA 的建议


请注意,大多数专业垃圾邮件机器人都与 血汗工厂 (1 1000 美元的解决方案) 人类验证码 求解器 API。当垃圾邮件机器人无法通过 captcha 本身时(垃圾邮件机器人),会保留数百个打开的连接,发送屏幕截图(或网页代码)与 CAPTCHA 供血汗工厂人员解决。这是合法的、大生意。为了合法并通过 API 与机器人集成,人类解算者不能直接与破解的网页板(博客评论、注册页面、聊天、维基、论坛等)交互。

另一个问题是反垃圾邮件程序无法检测专业机器人发送的基于上下文的垃圾邮件。有很多方法。最简单的一种是从其他网页板上网络抓取多作者人工对话并根据上下文发布它们(机器人可以在不同时间检测来自不同国家的不同IP地址的主题),因此即使(博客)所有者(人类)也无法检测到机器人发布的对话(它们实际上来自存储在数据库中的人类对话)。

这只是专业垃圾邮件发送者或业余爱好者对您的网站感兴趣的问题,他们会自动规避大多数(如果不是全部)验证码

Update: The answer was accepted because I recommended KeyCAPTCHA. From my hard-earned painful expereince, KeyCAPTCHA is a scam by professional spammers. I removed my recommendations of KeyCAPTCHA


Note that most professional spambots are integrated with sweatshops (1 USD a 1000 solutions) human captcha solvers API. When a spambot cannot pass captcha itself it (spam bot), keeping hundreds of open connections, sends screenshot (or webpage code) with CAPTCHA for solving by sweatshop human. This is legal and big business. In order to be legal and integrate with bots through APIs the human solvers can not directly interact with cracked web boards (blog comments, registration pages, chats, wiki, forums, etc.).

Another problem is that anti-spam programs cannot detect context-based spamming by professionally made bot. There are many approaches. The simplest one is web scraping multi-author human dialogs from other web boards and posting them CONTEXT-SENSITIVELY (bots can detect topics) from different IP addresses of different countries at different times, so even (a weblog) owner (human) cannot detect that dialogs are posted by bots(they are really from stored in database human dialogs).

This is only the matter of interest to your website from professional spammers or time+qualified persistence of amateurs to automatically circumvent most (if not all) CAPTCHAs.

亚希 2024-10-15 05:10:21

说实话,我觉得这些东西没什么用。如果有人可以绕过您的验证码,那么他们肯定能够绕过简单的数学方程,因为这样做所需的努力要少得多。

如果是注册表单,我想最好的办法是通过电子邮件发送验证码+确认链接(并排除虚假电子邮件地址,例如邮寄程序)。您可以定期清除数据库中未经确认的注册。

当然,没有 100% 安全的方法,任何形式的验证码都可以被绕过(只要有足够的时间和资源),所以我想我们必须忍受这一点。

To be honest, I find those things quite useless. If someone can bypass your CAPTCHA then they will for sure be able to bypass simple mathematical equations, as it requires much less effort to do so.

If it is for a signup form I guess the best thing to do is to have a CAPTCHA + confirmation link sent by email (and exclude bogus email addresses, like mailinator). You can purge the DB from unconfirmed registrations periodically.

Of course there is no 100% safe method, any form of CAPTCHA can be bypassed (given enough time and resources), so I guess we have to live with that.

旧街凉风 2024-10-15 05:10:21

这个问题在本次会议上多次出现[需要参考:)]

这是一个相当复杂的问题,但我想简短的答案是我们坚持使用通常的方法!

我认为这个网站很好地解决了这个问题,但是,一如既往,我猜想在不严重损害用户可用性的情况下,您将可以使用验证码。使用它的次数越多,收到的垃圾邮件就越少,但请记住,当某个 IP 参与可疑活动时,始终可以通过 IP 进行限制。

至于垫子问题验证,我自己在 PHP 中做了一些尝试,它是这样的:

<?php

$x = mt_rand(1,5);
$y = mt_rand(1,5);

function add($x, $y) { return $x + $y; }
function subtract($x, $y) { return $x - $y; }
function multiply($x, $y) { return $x * $y; }

$operators = array(
    'add',
    'subtract', 
    'multiply'
    );

$rdno = $operators[array_rand($operators)];

$result = call_user_func_array($rdno, array($x, $y));
session_start();
$_SESSION['res'] = $result;

if ($rdno == "add") {
    $whato = "+";
}elseif ($rdno == "subtract") {
    $whato = "-";
} else {
    $whato = "*";
}
$output = $x . $whato . $y . " = ";
$_SESSION['out'] = $output;
?>
<img src="image.php" />
<form name="input" action="check.php" method="post">
<input type="text" name="result" />
<input type="submit" value="Check" />
</form>

chech.php:

<?php

session_start();


if($_SESSION['res'] == $_POST["result"]){
    echo "correct!";
    $_MCAPTCHA = TRUE;

}else{

    echo "incorrect";
    $_MCAPTCHA = FALSE;

}
session_unset();

?>

并且

<?php
session_start();
//image creation

// Create a 100*30 image
$im = imagecreate(100, 30);

// White background and blue text
$bg = imagecolorallocate($im, 255, 255, 255);
$textcolor = imagecolorallocate($im, 0, 0, 255);

// Write the string at the top left
imagestring($im, 5, 0, 0, $_SESSION['out'], $textcolor);

// Output the image
header('Content-type: image/png');

imagepng($im);
imagedestroy($im);
?>

您可以添加一些 高斯模糊 等等-

当然这只是一个例子(永远不要使用这个:))

但这只是一个可以做什么的想法。

这样做的坏处是,除非您希望用户进行非常复杂的数学运算(这可能只对某些受众有利),否则您的选择更加有限,此外,如果有人想要专门针对您的网站,则选择有限,可能会这是一个坏主意,因为非常脆弱。

总而言之,恕我直言,您被常规广告所困,将不得不忍受一些垃圾邮件,这只是您可能不得不忍受的妥协。

您可能会发现 Jeff 的恐怖编码文章非常有趣。

祝你好运!!

This question has come up many times on this sit [reference needed :) ]

It is quite a complex issue but I guess the short answer is that we are stuck with the usual methods!

I think this site addresses the issue quite well, but, as always I guess without horribly compromising the usability of the user you will have use CAPTCHA. The more you use it the less spam you'll get, but at a price remember that there is always the obtion of limiting by IP when a certain IP is involved in suspicious activity.

As fot the mat question validation, I have done som trying myself in PHP, it goes something like this:

<?php

$x = mt_rand(1,5);
$y = mt_rand(1,5);

function add($x, $y) { return $x + $y; }
function subtract($x, $y) { return $x - $y; }
function multiply($x, $y) { return $x * $y; }

$operators = array(
    'add',
    'subtract', 
    'multiply'
    );

$rdno = $operators[array_rand($operators)];

$result = call_user_func_array($rdno, array($x, $y));
session_start();
$_SESSION['res'] = $result;

if ($rdno == "add") {
    $whato = "+";
}elseif ($rdno == "subtract") {
    $whato = "-";
} else {
    $whato = "*";
}
$output = $x . $whato . $y . " = ";
$_SESSION['out'] = $output;
?>
<img src="image.php" />
<form name="input" action="check.php" method="post">
<input type="text" name="result" />
<input type="submit" value="Check" />
</form>

chech.php:

<?php

session_start();


if($_SESSION['res'] == $_POST["result"]){
    echo "correct!";
    $_MCAPTCHA = TRUE;

}else{

    echo "incorrect";
    $_MCAPTCHA = FALSE;

}
session_unset();

?>

and

<?php
session_start();
//image creation

// Create a 100*30 image
$im = imagecreate(100, 30);

// White background and blue text
$bg = imagecolorallocate($im, 255, 255, 255);
$textcolor = imagecolorallocate($im, 0, 0, 255);

// Write the string at the top left
imagestring($im, 5, 0, 0, $_SESSION['out'], $textcolor);

// Output the image
header('Content-type: image/png');

imagepng($im);
imagedestroy($im);
?>

You could add some gaussian blur to it to etc etc-

Of course this is only an example (DO NOT EVER USE THIS :) )

But is just and idea of what could be done.

This bad thing about this, is unless you want users to do very complex math (that may be fine to only some audiences) you have mor limited options and besides, if any one wants to target specifically your site, having limited options, might be a bad idea since very vulnerable.

To sum up, IMHO you are stuck with the usual ad will have to live with SOME spam, it's just a compromise that you might have to live with.

You might fint Jeff's article from coding horror very interesting.

Good luck!!

乖乖哒 2024-10-15 05:10:21

我遇到垃圾邮件条目问题
通过注册表单在我的数据库中。我
尝试过很多开源验证码
解决方案,但仍然面临同样的问题
问题。

您使用哪种垃圾邮件防护。我觉得很奇怪,垃圾邮件防护(完全)失败了。就像很多其他人都说 recapcha 非常好,很多大玩家都在使用它们(想想 Twitter)。

例如,您可以使用 recapcha 进行注册。接下来,使用 WordPress 的 akismet 测试多个(第一个)帖子是否存在垃圾邮件,以验证用户没有发布垃圾邮件。这应该可以帮助您更好地检测垃圾邮件。

话又说回来,彻底击败垃圾邮件确实很困难。完全击败垃圾邮件几乎是不可能的。我在某处读到,一些垃圾邮件发送者甚至廉价雇用印度人来破坏您的垃圾邮件防护。

如果有一系列更好
简单的随机问题或
像“6 + ? = 9”这样的东西会更好
作为一个问题?唯一的一点就是
我担心的是,如果它像
这是为了保护注册,那么为什么
不是像Facebook这样的巨头吗
做这个?

这种方法有几个缺点:

  • 这种逻辑很容易嵌入到垃圾邮件机器人中。我什至可以编写能够击败 6 + ? 的代码。 = 9 不费吹灰之力。
  • 有些用户可能(真的)数学不好或者不知道你的问题的答案。

I'm getting problems with spam entries
in my database through signup form. I
have tried many open source Captcha
solution, but still facing same
problem.

What kind of spamprotection are you using. I find it strange that the spamprotection is failing(completely). Like a lot of other people are saying recaptcha is pretty good and a lot of big players are using them(Think Twitter).

You could for example make registration use recaptcha. Next verify the user is not posting spam by testing a number of (first) post for spam using wordpress's akismet. This should help you even more detecting spam.

Then again completely defeating spam is really difficult. It is almost impossible to completely defeat spam. I read somewhere that some spammers even hire people from India cheap to break your spam protection.

Would it be better to have a series of
simple randomized questions or
something like "6 + ? = 9" be better
as a question? The only thing that
concerns me is that if it's as easy as
this to protect a signup then why
aren't the big giant like Facebook
doing this?

This approach has a couple of drawbacks:

  • This logic can easily be embedded inside of spambot. I could even write code that will defeat 6 + ? = 9 without any effort.
  • Some users could be bad(really) in math or don't know the answer to your question.
尾戒 2024-10-15 05:10:21

由于这里没有提到这一点,我将简要回顾一下我在一个访问量中等的论坛上相当成功地使用的方法。请注意,我只会解释基本思想。可以实施多种变体来使自动发送垃圾邮件变得更加困难。

我所做的是:

  1. 引入一些常数作为盐。该常量对于您的网站来说是唯一的,并且应该是一个秘密。
  2. 使用远程 IP、用户代理、一天中的时间(请注意,如果时间在请求和发送表单之间切换,这可能会导致失败)和类似的数据来计算加盐哈希(MD5、SHA1)...另一个输入它是论坛元素的原始字段名称(例如emailname,...),以便现在每个客户端计算每个字段名称。我在前面添加一些字母或类似的字母,以确保名称不以数字开头,否则可能会导致问题。
  3. 用户发送表单。
  4. 接收脚本具有相同的输入数据(即不必通过表单等发送)。
  5. 接收脚本使用与2.中相同的方法后,它可以评估表单数据并采取相应的操作。

同样,这可以与其他方式结合。但独特的盐将允许它被广泛使用 - 不同的盐值使得无法轻松预测字段名称,即使计算哈希的方法是已知的。不过,如果垃圾邮件发送者变得聪明(即,如果他们不只是查找字段名称),则必须使用其他方法来伪装相应的表单输入元素。

它很简单,100% 屏幕阅读器兼容(即即使对于盲人也可用),并且为我创造了奇迹。它极大地减少了我管理的论坛中的垃圾邮件。希望它也能帮助你。

Since that wasn't mentioned here, I'll briefly go over the method I have been using rather successfully on a moderately visited forum. Note, that I will only explain the basic idea. There are several variations that can be implemented to make automated spam even harder.

What I do is this:

  1. Introduce some constant as salt. This constant is unique to your site and it's supposed to be a secret.
  2. Use the remote IP, user agent, hour of the day (note that this can make it fail if the hour switches in between requesting and sending the form) and similar data to calculate a salted hash (MD5, SHA1) ... another input to it is the original field name of the forum element (e.g. email, name, ...) so that each field name is now computed per client. I prepend some letter or similar to make sure the name doesn't start with a digit, which can cause problems.
  3. User sends the form.
  4. Receiving script has the same input data (i.e. it does not have to be sent via the form or so).
  5. After the receiving script uses the same method as in 2., it can evaluate the form data and take respective action.

Again, this can be combined with other means. But the unique salt will allow this to be widely used - different salt values make it impossible to predict the field name easily, even if the method to compute the hash is known. Other means will have to be used to disguise the respective form input elements if the spammers get smart, though (i.e. if they don't just look for the name of the field).

It's simple, 100% screen-reader-compatible (i.e. usable even for blind people) and worked wonders for me. It cut down tremendously on spam in a forum I manage. Hope it'll help you, too.

以往的大感动 2024-10-15 05:10:21

甚至连验证码也会被解码,如 John Resig 的这篇文章所示:

OCR和 JavaScript 中的神经网络

而且也存在在线工具。

话虽如此,流行的Google 的 reCAPTCHA 解决方案似乎很不错,该网站也使用了该解决方案。

另一方面,人们总是可以选择节制。

Even captchas are decoded as can be seen in this article by John Resig:

OCR and Neural Nets in JavaScript

And there exist online tools too.

Having said that, the popular Google's reCAPTCHA solution seems to be good to go for, the one used by this site as well.

On the other hand, one always has the option of moderation.

三寸金莲 2024-10-15 05:10:21

您是否已经尝试过 reCAPTCHA

已经有很多垃圾邮件机器人可以解决简单的数学问题。

Facebook 没有使用类似的东西的原因是,如果他们这样做了,他们的解决方案将被专门破解,因为他们是一家拥有数百万用户的大公司。

Have you already tried reCAPTCHA?

There are already many spambots out there which can solve simple math questions.

The reason Facebook isn't using something like that is if they did, their solution would be specifically cracked because they are a massive company with millions of users.

笑看君怀她人 2024-10-15 05:10:21

您确定无法使用reCAPTCHA吗?我认为这是目前互联网上最好的验证码。

但我想到了一种完全不同的解决问题的方法,这可能值得尝试。

您可以使用 OpenID 进行注册。这样,垃圾邮件发送者就需要拥有一个 Google 帐户。我很确定他们不会以此为垃圾邮件。

Are you sure you can't use reCAPTCHA? I think it is the best captcha on the internet right now.

But I thought of a completely different approach to the problem, which may be worth trying.

You could saddle Google, Twitter, Facebook and others with the problem by using OpenID for sign up. This way, spammers need to have a Google Account, for instance. I'm pretty sure they won't spam with that.

浅忆 2024-10-15 05:10:21

我刚刚完成将 Jake Munson 编写的优秀 CFFormProtect 移植到 PHP。它托管在 http://code.google.com/p/phpformprotect/

它使用测试组合,包括基于 javascript 的鼠标移动检查、键盘使用情况和填写时间,以及对 url、垃圾邮件词的一些基本检查以及与 AkismetProject Honey Pot。我发现它是一种极好的威慑力,合法用户几乎完全看不到。

我确信该端口需要工作,但它对我有用。请随意贡献任何东西。

I've just finished porting the excellent CFFormProtect by Jake Munson to PHP. It's hosted at http://code.google.com/p/phpformprotect/

It uses a combination of tests including javascript-based checks for mouse movement, keyboard usage and time spent filling it out, as well as some basic checks for urls, spammy words and optional integration with Akismet and Project Honey Pot. I've found it to be an excellent deterrent that's pretty much completely invisible to legitimate users.

I'm sure the port needs work but it works for me. Feel free to contribute anything.

寒尘 2024-10-15 05:10:21

您可以在没有验证码的情况下做到这一点,您可以添加一个隐藏表单,然后检查人们看不到的这个表单是否已填写,您可以使用 php 做到

if($_POST['hidden_input'] != ""){
    echo('<p>You are a spam bot</p>');    
}

这一点,因为 spambot 通常会填充每个文本区域。

在表格中您应该只添加

 <input type="text" id="hidden_input" name="hidden_input" style="display:none;"/>

You can do that without captcha, you can add an hidden form and than check if this form that people can' t see is filled, you can do that with php

if($_POST['hidden_input'] != ""){
    echo('<p>You are a spam bot</p>');    
}

This because spambot usually fill every text area.

In the form you should add only

 <input type="text" id="hidden_input" name="hidden_input" style="display:none;"/>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文