简体   繁体   English

如何保护我的论坛免受垃圾邮件侵害?

[英]How do I protect my forum against spam?

I have a forum on a website I master, which gets a daily dose of pron spam. 我在我掌握的网站上有一个论坛,每天都会收到垃圾邮件。 Currently I delete the spam and block the IP. 目前我删除垃圾邮件并阻止IP。 But this does not work very well. 但这并不是很好。 The list of blocked IP's is growing quickly, but so is the number of spam posts in the forum. 被阻止的IP列表正在快速增长,但论坛中的垃圾邮件数量也在增长。

The forum is entirely my own code. 该论坛完全是我自己的代码。 It is built in PHP and MySQL. 它内置于PHP和MySQL中。

What are some concrete ways of stopping the spam? 什么是阻止垃圾邮件的具体方法?

Edit The thing I forgot to mention is that the forum needs to be open for unregistered users to post. 编辑我忘记提到的事情是论坛需要对未注册用户开放发布。 Kinda like a blog comment. 有点像博客评论。

In a guestbook app I wrote, I implemented two features which prevent most of the spam: 在我写的留言簿应用程序中,我实现了两个阻止大多数垃圾邮件的功能:

  • Don't allow POST as the first request in a session 不允许POST作为会话中的第一个请求

  • Require a valid HTTP Refer(r)er when posting 发布时需要有效的HTTP Refer(r)er

One way that I know which works is to use JavaScript before submitting the form. 我所知道的一种方法是在提交表单之前使用JavaScript。 For example, to change the method from GET to POST. 例如,要将方法从GET更改为POST。 ;) Spambots are lousy at executing JavaScript. ;)Spambots在执行JavaScript时很糟糕。 Of course, this also means that non-Javascript people will not be able to use your site... if you care about them that is. 当然,这也意味着非Javascript用户将无法使用您的网站......如果您关心他们的话。 ;) (Note: I don't) ;)(注意:我没有)

In my experience, the best easy defenses come from just doing something "non-standard". 根据我的经验,最好的轻松防御来自于做“非标准”的事情。 If you make your site non-standard, this makes it so that any automated spam would have to be coded specifically for your site, which (no offense) probably isn't worth the effort. 如果您使您的网站不标准,这使得任何自动垃圾邮件都必须专门为您的网站编码,这可能是不值得的。 Note that if the spam is coming from human spammers, there's not really anything you can do that won't also stop legitimate posters. 请注意,如果垃圾邮件来自人类垃圾邮件发送者,那么您无法做任何事情也不会阻止合法海报。 So the goal is to find a solution that will throw away any "standard" posts - that is, "fill out the whole form and push submit". 因此,我们的目标是找到一个可以丢弃任何“标准”帖子的解决方案 - 即“填写整个表单并推送提交”。

A couple examples that come to mind of things that you could try: 想到你可以尝试的事情的几个例子:

  • Have a hidden form field with a name that sounds like something a spammer would want to fill out, like "website" or "homepage" or something like that. 有一个隐藏的表单字段,其名称听起来像垃圾邮件发送者想要填写的内容,如“网站”或“主页”或类似的东西。 If the form field gets filled out, throw away the message instead of posting it, because it was a bot automatically filling in the whole form, even invisible fields. 如果填写表单字段,则抛弃消息而不是发布消息,因为它是一个机器人自动填写整个表单,甚至是不可见的字段。
  • You don't have to use a "real" captcha, but even something simple like "Enter the following word backwards: <random backwards word>" or "What is the domain name of this website?". 您不必使用“真实”验证码,但即使是“向后输入以下单词:<随机向后单词>”或“此网站的域名是什么?”之类的简单内容。 Easy for a human to do, but it would require a fairly complex bot to figure out what to fill in. 人类容易做,但需要一个相当复杂的机器人才能找出要填写的内容。

您可以使用验证码,有一些好的脚本,如PHPCaptcha或使用垃圾邮件控制服务,如Akismet ,他们有一个PHP API

You might want to look at this question , which has several answers that describe how you could implement a non-intrusive captcha. 您可能希望查看此问题 ,其中有几个答案描述了如何实现非侵入式验证码。

Another thing to consider is to require time between posts to prevent massive spamming. 另一件需要考虑的事情是在帖子之间需要时间来防止大量垃圾邮件。

包括始终为“橙色”的CAPTCHA。

The spams may be by bots or humans - bots are more likely. 垃圾邮件可能是机器人或人类 - 机器人更有可能。

To stop the bots, put in a hidden field populated by Javascript - there is a 99.5% chance that a standard, stupid bot that isn't customised to your site will fail to fill that in. 要停止机器人,请放入一个由Javascript填充的隐藏字段 - 有99.5%的可能性,未经您自定义的标准,愚蠢的机器人将无法填充。

If they fail to fill it in correctly, give them a message that Javascript is required or something, and give them an opportunity to post some other way (eg with a captcha or registration). 如果他们未能正确填写,请给他们一个消息,说明Javascript是必需的,或者让他们有机会发布其他方式(例如使用验证码或注册)。 That way anonymous users who aren't spambots can (mostly) still post with no problems, and most spambots (which haven't been tailored for your specific site) won't. 这样,不是垃圾邮件程序的匿名用户可以(大多数时候)仍然没有问题发布,并且大多数垃圾邮件程序(没有为您的特定站点量身定制)不会。

Don't bother blacklisting IP addresses or using third party blacklists, that will just generate false positives. 不要打扰列入黑名单的IP地址或使用第三方黑名单,这只会产生误报。 Almost all bots use the same IP addresses as (some) legitimate users. 几乎所有机器人都使用与(某些)合法用户相同的IP地址。


Another trick is to put in a text field with a plausible sounding name, which is made difficult to see with CSS - anyone filling this field in with anything is considered to be a bot. 另一个技巧是放入一个带有合理的声音名称的文本字段,这很难用CSS看到 - 任何填充此字段的人都被认为是机器人。

Advanced solutions: 高级解决方案

You can try your luck with non-standard form: 你可以用非标准形式试试运气:

  • fields that must stay empty hidden with CSS 必须保持空的字段,用CSS隐藏
  • fields with misleading names, eg <input name=email> for something that is not an e-mail. 带有误导性名称的字段,例如<input name=email>表示 <input name=email>字段。

For me CAPTCHA is like giving up to spammers and letting them damage your forum anyway – except that instead of spam damage, you get usability and accessibility damage. 对我而言,CAPTCHA就像放弃垃圾邮件发送者并让他们损坏你的论坛 - 除了垃圾邮件损坏,你获得可用性和可访问性损害。

Something I've found to be surprisingly effective: disallow comments that contain too many URLs (more than, say, 5). 我发现有些令人惊讶的有效:禁止包含太多网址的评论(超过5个)。 Since doing that, I've had zero comment spam. 从那以后,我没有评论垃圾邮件。

Edit: Since writing the above, I've had recurring comment spam with only one link. 编辑:自从编写上述内容以来,我只使用一个链接进行了定期评论垃圾邮件。 I have now added some honeypot fields and have had no commend spam for a few months now. 我现在已经添加了一些蜜罐字段,并且几个月来一直没有推荐垃圾邮件。

Don't let anybody post until they respond to an email sent to their registered email address. 在回复发送到其注册电子邮件地址的电子邮件之前,不要让任何人发帖。 You'll see lots of forums and mailing lists generate a unique email address or web url that is sent to the new user's given email address, and they have to respond to the email or click on the link to finalize their registration. 您会看到许多论坛和邮件列表生成一个唯一的电子邮件地址或网址,该网址会发送到新用户的指定电子邮件地址,他们必须回复该电子邮件或点击该链接以完成注册。

Captcha is definitely the easiest method - try KittenAuth if you want something bot-proof (Although I got pandas this time) Captcha绝对是最简单的方法 - 尝试KittenAuth,如果你想要一些机器人防护(虽然我这次有大熊猫)

There is no single answer since Spam is really a matter of economics: how much is it worth it to someone to put their stuff onto the web. 没有一个答案,因为垃圾邮件真的是经济问题:有人把他们的东西放到网上是多少钱。 There, however, some solutions that seem pretty good 然而,有些解决方案似乎相当不错

I want to say that in most time, a CAPTCHA is enough for you to prevent SPAMers. 我想说,在大多数时候,CAPTCHA足以让你阻止SPAMers。 But do use a strong one, like http://www.captcha.net/ . 但要使用强大的,如http://www.captcha.net/

Remember that SPAMers do not want to spend much time to deal with a particular site(except heavy traffic sites), they use a tool to post AD on a lot of sites. 请记住,垃圾邮件发送者不想花费太多时间来处理特定站点(流量较大的站点除外),他们使用工具在很多站点上发布AD。 So make your FORM a little unusual, (eg give the user a image says '1.5+2.4=?' and let users to answer, this will block most of the spam tools :) ) 所以让你的FORM有点不寻常,(例如给用户一个图像说'1.5 + 2.4 =?'并让用户回答,这将阻止大多数垃圾邮件工具:))

The easiest thing I've done to stop spammers with (so far) 100% consistency is to validate the text that was submitted. 我为阻止垃圾邮件发送者(迄今为止)100%一致性所做的最简单的事情就是验证提交的文本。 If you use the php function strstr() to check for "a href" or even a non-clickable http or www, you can then just reroute the spammer elsewhere. 如果您使用php函数strstr()检查“a href”或甚至是不可点击的http或www,那么您可以在其他地方重新路由垃圾邮件发送者。 I actually have a script then write to my .htaccess file to deny the offending IP address. 我实际上有一个脚本然后写入我的.htaccess文件以拒绝违规的IP地址。 Not sure if there's any other kind of spam to be concerned about, but links are all I've seen so far. 不确定是否还有其他类型的垃圾邮件需要关注,但链接是我到目前为止所见过的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM