0

我在服务器上有一个表单,并且 php 处理它,在另一台服务器上,此配置无法更改。我收到很多垃圾邮件,并试图修复它。由于跨域,SESSION 无法工作,因此没有令牌也没有验证码,$_SERVER["HTTP_REFERER"] 不可靠。我正在考虑实施一个每天更改一次的加密密钥,但我认为它是有限的。有更好的主意吗?

加密密钥示例:

$key = "string".date("d");
4

5 回答 5

1

您不需要会话即可使用 CAPTCHA。存在多种 CAPTCHA。即使是以下内容也可能会阻止 99% 的垃圾邮件程序:

<form action="...">
<input type="hidden" name="thequestion1" value="23">
<input type="hidden" name="thequestion2" value="-">
<input type="hidden" name="thequestion3" value="5">
How much is 23-5?
<input type="text" name="theanswer">
<input type="submit">
</form>

大多数垃圾邮件机器人看起来只是输入字段和提交按钮。

我敢打赌,这种 CAPTCHA 会阻止大多数垃圾邮件。

PS:一定要安全地评估服务器上的question1、thequest2、thequest3的值。

于 2012-08-17T10:00:24.890 回答
1

许多机器人不运行 javascript,因此您可以在表单中注入任意字段:

<form id="douchebag" action="http://yourotherserver.com/process.php" method="post">
<input type="text" name="name" />
.. bunch of other inputs
</form>

然后你的js:

var bugSpray = document.createElement('input');
bugSpray.setAttribute('type', 'hidden');
bugSpray.setAttribute('name', 'aa');
bugSpray.value = 'bb';
document.getElementById('douchebag').appendChild(bugSpray);

然后在你的process.php

if(empty($_POST['aa']) || $_POST['aa'] != 'bb') // bot
于 2012-08-17T10:06:05.797 回答
1

我之前使用的一种技术类似于@SiGanteng 建议的技术,但您可以更改现有字段的名称属性,而不是添加新字段,以删除或添加前缀。

<script>
var inputs = document.getElementById('myform').getElementsByTagname('input');
for(i=0; i<inputs.length; i++) {
    inputs[i].name = "antispam_" + inputs[i].name;
}
</script>
于 2012-08-17T10:18:43.390 回答
0

例如,您可以在服务器上添加一个新资源,该资源会生成一个密钥并将其存储在数据库中。加载网页时,您从服务器请求新密钥并将其插入hidden表单字段。

然后,当发出请求时,检查该字段的值并查看数据库中是否有相应的键。如果不是,则丢弃该请求。

当然,机器人仍然有可能绕过它(通过请求密钥),但这会更难。

于 2012-08-17T10:00:00.693 回答
0

另一种方法是使用简单的检查,获取两个文本输入并将它们连接起来,制作一个 md5 并通过 POST 发送。在另一台服务器上检查这个和瞧。

于 2012-08-17T14:33:32.450 回答