This is a continuation of Detecting Comment Spam, Part 2
In the previous posts in this series, I've said that spammers habits allow us to detect their attempts to leave inappropriate comments. I use these techniques here and am able to send most spam comments directly to the bit-bucket without ever having to examine them myself. When I suspect spam but am not sure, I just send the comment to moderation. In practice, very few spam attempts get by the automatic filters.
The code I use is a hodgepodge I developed over many years of fighting spam comments. I need to rewrite it and my thought is to move toward a scoring system similar to that used by Spamassassin for mail spam: each "bad habit" increases an overall spam score and the final judgement is made based on the total score accumulated. To that end, I have been pulling out the various tests I use now and examining them. Some always cause the comment to be treated as spam; those would add enough points to ensure that would still happen. Other habits now cause moderation, but in my new design each of those will increase the spam score. Any spam score at all is cause for moderation, but if the post accumulates enough minor points, I can skip that and just throw it away.
By the way, there is an effort to create a BlogBlogSpamAssassin.
Seven (or more) habits of ineffective spammers
I'll be reviewing things covered in the previous two posts and will introduce some new ideas. Items covered in the previous posts are marked with a "*".
* Known spam links: Reusing links we already know are spam. This would carry enough points to always be spam.
* High link to text ratio: Sometimes nothing but links. This could be legitimate, but it's a strong indicator. In my current code, this always treats the comment as spam, but I think I will change it so that at least one other spam point is required.
* Nonsense words: The higher the ratio of nonsense to total word count, the more likely this is spam.
* Many quick posts: Legitimate commenters may post more than once per day, but there will be some time delay between comments as they read the articles they are commenting on. I simply enforce a "posting too frequently" policy.
* Direct posts: Some spammers bypass your forms and send direct POST requests. That's definite spam.
* Typed too fast: Legitimate commenters MAY use cut and paste, but moving from form load to POST too quickly needs to carry some weight.
Multiple posts to same article: Legitimate commenters almost never post more than one comment without some other comment intervening. Sure, someone may have an afterthought and add a second comment, but more usually this indicates a spammer, so we should add points.
Same comment at another article: As always, spammers are lazy. They sometimes post exactly the same text to different articles. The posts may not come from the same IP address, but the content is the same. This should probably carry enough points for flat rejection. It does mean that you need to maintain a database, but you only need to store 100 characters or so (spam comments are usually short) and you can clean it out after 24 or 48 hours.
Text and link have same word: This is a minor spam indicator, but if the word "Horrivea" appears as "Buy Horrivea: http://someaddress/horivea", it may be spam.
Failure to reload: I require clicking on a link to reload the original page after submitting a comment. A legitimate poster will almost always click, a spammer almost never will. Again, this is not an absolute indicator, but is worth a point or two.
Akismet is a popular comment checker. I have found it to be less effective than my own tests, but it can't hurt to have another opinion, can it?
Captcha tests: See Creating a blog... with anti-spam measures for an example of incorporating Captcha. As this technology is annoying, you might consider adding it as a confirmation only when some other conditions have raised suspicion. Similar tests involve solving simple math or providing answers to obvious questions. Spammers are in a hurry; they are usually using bots and if not they just don't want to spend time thinking, however small that time is.
Legitimate Commenters Habits
There are a few things that spammers don't usually do. Legitimate comments almost always use punctuation, so the presence of punctuation could decrease a spam count. Legitimate posters sometimes quote text from the article or from a previous comment; spammers almost never do that, so again we might decrease a spam score if we see this.
We can control spam comments. Not all of it, but we can limit the amount that has to be checked manually and we don't need to annoy our visitors with required registration or automatic "human reader" testing.
I'd love to hear your thoughts, comments and ideas.
(OLDER) <- More Stuff -> (NEWER) (NEWEST)
Printer Friendly Version