Stopping Manual Spam on your Blog

I woke up this morning to a number of new comments on my blog. All of them utter crap from offshore SEO link builders.

I know they were posted by offshore link builders, because I happen to track referral URLs on all comments. These particular referral URLs all had search queries like web design "post comment" which is a pretty standard starting point for link builders looking for blogs to comment on.

Great post!

This got me thinking. When was the last time one of these link builders actually posted a useful comment? Their comments make it straight past the CAPTCHA because it's a human entering them, and because they don't usually contain spammy phrases such as 'WOW gold' or 'viagra' it's hard to algorithmically filter them too.

Does anyone else have problems with these 'low quality but not completely spam' posts? The ones where you have to stop and think for a bit before deleting?

Would it be so bad if I simply said no to all comments from visitors that arrived at the site from a search query such as web design "post comment"? Or any search query containing "add link", "submit url", "post comment" etc.

So, I thought I would put a bit of code together to put this theory into action.

Announcing...

So here is ManualSpamBlocker. It's a Wordpress plugin that closes comments for all posts if the visitor arrived via a dodgy looking search query. The link builder can still enjoy your quality blog posts, but they just won't be able to comment on them because they will think comments are closed.

Simple huh?

This is the first Wordpress plugin that I have released, so I would really welcome any feedback you might have on it. It's still to be considered Alpha quality code, so don't be rushing to install it on your high-traffic blog just yet. Once I'm happy with how it's looking, I'll submit it to the Wordpress plugin database and see what happens. Happy to give out SVN access to anyone who thinks they are able to contribute.
Digg StumbleUpon del.icio.us technorati blinklist furl reddit sphinn

Tags: link building spam captcha wordpress

24 Comments

- Jun 30, 2009

Heya,

Let's say someone searches for webdesign posts and finds page:

http://www.ragepank.com/webdesign-and-seo/

using the query

"add comment inurl:web inurl:design etc."

and then he simply types that url in another window or just copies and pastes it in google adding an extra site:http://ragepank.com/webdesign-and-seo/... what are you going to do after that ?

It might discourage the newbs but anyone with a bit of a brain can avoid this trick.

Overall I give it a 7/10 and i do think it's really a good plugin.

Cheers

- Jul 1, 2009

When they first enter the site and see "Comments are closed" it's pretty unlikely that they are going to think...

"Ahhh, this blog is using that antispam plugin from Ragepank.com - haaha, I'll just load a new browser window and thwart the system. Muhahaha..."

I think the vast majority of link builder spammers will simply move on when they see that comments are closed, but if genuine visitors return again (via a bookmark or directly), they will find comments are opened up for them. This is good.

- Jul 1, 2009

Sorry my bad... I thought the comment was gonna undergo verification from the site owner.
But still it can be avoided.

aidan - Jul 17, 2009

Great post ;P

- Aug 4, 2009

Err ... Great Post, Harvey :-)

I guess this works like a burglar alarm - they go somewhere else instead.

Is it working for you ?

- Aug 4, 2009

I haven't yet coded the Jojo CMS plugin for this yet, so I haven't been able to test it's effectiveness for myself yet.

Been busy dealing with a different kind of spam. Aarrggh.

- Aug 5, 2009

i think you can disable by just putting no follow in your blog because spammers dont like no -follow tag

- Aug 6, 2009

yeah. nice post about spammers and their interruption on valuable post. your cartoon images are too good than your content. lol..:>

- Aug 17, 2009

I guess this works like a burglar alarm - they go somewhere else instead.

- Aug 19, 2009

The link builder can still enjoy your quality blog posts, but they just won't be able to comment on them because they will think comments are closed.

- Aug 20, 2009

Harvey Kane. A fellow New Zealander :)

Anyway im trying to get guests to my forum but yeah ive got my site pretty much optimised as you can get - its second on google if you search "new zealand mobile forum" but still not many guests. Any ideas?

- Aug 20, 2009

The plugin for Jojo CMS is now available. Please visit http://snaps.jojocms.org for the dev version (you will need to upgrade jojo_article as well), or wait for the next release of Jojo which the team are trying to get out the door very soon.

- Sep 1, 2009

Hi there I have classifieds website .What is the best captcha i can use for it?Because The website is still under test mood and I am already getting spam.

- Sep 1, 2009

@q8daily:
Your current captcha looks pretty basic. Try somethign that adds either a more complex background, some colour, different fonts, or some distortion onto the letters. Preferably all of these.

ReCaptcha is a popular choice, though it's a slightly different approach to most. I use phpcaptcha which does an OK job, though I have had to boost the length recently as spam is becoming more of a problem (and I suspect it might be automated spam breaking the CAPTCHA).

@Darth:
I ran a successful forum a few years ago and it consumed me. It's really really hard work, and you need to offer something of value that is more than just a forum to get people in the door. Good luck.

- Sep 8, 2009

1. Install Akismet

This is the simple one that everyone does. Akismet comes bundled with WordPress by default and does a good job of picking up spam - for the average blogger, install Akismet and your spam problems will be sorted. The trouble is though, it just stops spam getting displayed, it doesn't get to the root of the problem. That's where this post comes in. We'll start with some simple methods of stopping spam being displayed and then we'll move onto stopping the spammers getting on your site in the first place.
2. reCAPTCHA

The reCAPTCHA plugin is one you've probably seen around on sites such as Facebook, Twitter and StumbleUpon. It isn't just your average CAPTCHA (an image containing some letters that are designed so only humans can read them), it uses words from old books, so every time you enter a reCAPTCHA, you're helping digitise books. At this point, you're probably thinking but if I'm telling it what the words mean, does that mean I can enter anything? How does that stop spammers? The answer is simple - there are two words, one of which the CAPTCHA knows. The second, it doesn't and you're helping digitise it.

The plugin is simple to install, in 2.7+, just do a search for WP-reCAPTCHA and click install. You'll need a key for the plugin to work, which you can get here. After you've done that, reCAPTCHA should appear on your comments' page.
3. Ask your readers to do 1+1

The second plugin that we're going to look at as a way of stopping spam being displaued is the 'Math Comment Spam Protection' plugin. Using it, you can add a field to your blog's comment box with a simple maths (or 'math' as they say in the States) question.

I'm not going to go into installing it here as there's a comprehensive installation guide on the plugin's website. You can see it in action on WordPress Hacks (image above).
4. Stop spam trackbacks

The final plugin that we're going to look at is one by the same author who made the plugin above. The 'Simple Trackback Validation' plugin checks if the IP address of the sender of the trackback is the same as the IP address that the trackback URL refers to, thus eliminating [lots]% of trackback spam as spammers won't use bots running on infected machines. As the plugin's page says, the plugin also "retrieves the web page located at the URL included in the trackback. If the page doesn’t a link to your blog, the trackback is considered to be spam. Since most trackback spammers do not set up custom web pages linking to the blogs they attack, this simple test will quickly reveal illegitimate trackbacks. Also, bloggers can be stopped abusing trackback by sending trackbacks with their blog software or webservices without having a link to the post."

Like the 'Math Comment Spam Protection' plugin, there's an installation guide on the plugin's homepage.
5. Make users login to comment

This is something that probably won't be a good idea for the majority of bloggers, but it will stop spam - make users login to be able to leave a comment and spammers will be stopped from commenting, but so will one time visitors. Just keep that in mind.

Under 'Settings'. click 'Discussion' and then tick the box 'Users must be registered and logged in to comment'. Then save changes and you're done.
6. Ban spammers by IP

Now that we've stopped spam being displayed with the tips above, we're going to move on to blocking spammers getting on your site in the first place. Something we're going to be using extensively is the .htaccess file. A basic introduction that you should read first is here, and remember the golden rule of .htaccess - always have a backup. Further .htaccess reading is available here on CatsWhoCode and my own blog, WPShout.

In most situations, this tip wouldn't be too much of a good idea; spammers will fake often their IP, but if there is one IP that is particularly bugging you, then the code below will block them from visiting your site - instert it into your .htaccess file in your blog's root, changing the second line to include the IP that you wish to ban.

Order allow,deny
Deny from 100.100.100.
Allow from all


7. Ban spammers by IP, on a massive scale

You've blocked a single spammer. Well done. Now, with help from Perishable Press, you can block thousands of spammers - Jeff from Perishable has compiled a number of blacklists, from which you can pick and choose which you want to implement into your .htaccess file. The latest blacklists, the 'fourth generation' can be accessed below:

* 'The Perishable Press 4G Blacklist'
* '4G Series: The Ultimate Referrer Blacklist, Featuring Over 8000 Banned Referrers'
* '4G Series: The Ultimate User-Agent Blacklist, Featuring Over 1200 Bad Bots'

8. Deny comment posting to no referrer requests

Another .htaccess trick and the final comment spam stopping technique we're going to look at is denying comment posting to no referrer requests - in other words, if the comment isn't actually coming from your site, then it gets blocked. Make sure you change the url in line four to your blog.

RewriteEngine On
RewriteCond %{REQUEST_METHOD} POST
RewriteCond %{REQUEST_URI} .wp-comments-post\.php*
RewriteCond %{HTTP_REFERER} !.*yourblog.com.* [OR]
RewriteCond %{HTTP_USER_AGENT} ^$
RewriteRule (.*) ^http://%{REMOTE_ADDR}/$ [R=301,L]

Source - WordPress Recipes.
9. Stop content theives

Spammers don't just limit themselves to spamming your comments - often they'll steal your content too. This next trick will stop spammers who steal your content via RSS. Once you've found a site stealing your content, first thing to do is find out the site's IP address. A search for 'ping [site name, ie catswhocode.com]' should give you a result. Once you've got that, head over to the offending site and find their RSS feed. Then, open up your .htaccess file and add the following lines:

RewriteEngine on
RewriteCond %{REMOTE_ADDR} ^69.16.226.12
RewriteRule ^(.*)$ http://newfeedurl.com/feed

Change the IP in line two with the IP of the offending site and the url in line three with the offending site's feed.

Source - WPShout/ SEO Black Hat
10. Stop spammers stealing your images

Now that we've stopped spammers from stealing your content via RSS, now it is time to combat those who just copy and paste your articles onto their site. Yes, this isn't technically stopping spam, but it is helping combat the spammers.

You've got two options if people are hotlinking your images - watermark or .htaccess. We'll look at both, and I'll leave you to decide which is better. First up, watermarking. The foolproof method is to watermark your images before you upload them, which you can do with some simple software - FastStone Photo Resizer is a great tool that I'd thoroughly recommend. What's more, it's free! The second option is to install phpThumb and create a shortcode that resizes and watermarks your image. Copy and paste the following code into your functions.php file, having uploaded phpThumb to your theme's folder, uploaded a watermark and changed the URLs. You can also change the width that images will be resized to (it's currently 590).

- Sep 15, 2009

What exactly is your idea to avoid spammers publishing the comments on your blog?
Please Elaborate in your next post. I will be folowing your posts for the reply.

Thanks,
Sam

Flemming Rasmussen - Oct 8, 2009

Look, whats all this paranoia really about? - I'm getting a bit tired of hearing all those SEO people complaining about spam - Who (not you) of all people was the worst of scum when it came to filling the web with garbage?

SEO people are not the victims here - u guys (still not you) started this mess and now you're all whining because some automated spammer passed your captcha?

The reason why people make the spam in the first place is because U guys directed the world into this style of mess? ;)

- Oct 8, 2009

Great comment Flemming.

It could also be argued that it's Google's fault for rewarding these spammy tactics with good rankings. Their algo is a lot better now, but in the past it was easier to place cheesy links all over the place than it was to create a great site and allow it to rank naturally.

For me though, I don't get paid by the hour to moderate comments so I need to find ways to minimise this as much as possible. This plugin helps.

Flemming Rasmussen - Oct 8, 2009

Right, and thanks for the reply Harvey ;)

<!--spam was supposed to be here, but I decided not to spam Harvey--> :)

One thing though - we could start thinking of a way that actually go back to basics and make the sites rank "naturally" .. Like how do we manage IRL and port this into the web-behaviour ;)

- Oct 10, 2009

Genius, that is exactly what I have been looking for - such a simple idea, but one that will really avoid all the really poor attempts to gain traffic with poorly written compliments posing as comments... Thanks for that!

- Nov 27, 2009

Soundz good but does it actually work if i might put it on my wordpress blog as I get a lot of useless comment being add on my articles.

- Jan 6, 2010

Great idea and one we'll definately add to our new comment function we're building into our CMS.

- Jan 8, 2010

Its true that various comments are written just to generate back links, but that comments are being deleted by webmasters of the site, but if genuine comments are posted by any user, they should be given priority and importance.

- Jan 26, 2010

There are a lot of ways to keep spammers from your blog site. You can install akismet or have your guests register before allowing them to post a comment. What I do is I don't allow comments at all :)


Post Comment

Post Comment

*
*


Visual CAPTCHA

*
Code is not case-sensitive
*

We welcome comments on this article, provided they have something to contribute. Please note that all links will be created using the nofollow attribute. This is a spam free zone. HTML is stripped from comments, but BBCode is allowed.