April 17, 2004

MT comment spam prevention

While I suppose that putting this here will teach certain lowlifes how to get around it, I suppose it's worth sharing the technique, so that other people can benefit from it. Seems that the spammers are idiots, and post the same comment repeatedly. So if you get a pattern early on, you can prevent a lot of other ones later.

The following goes in $MT/lib/MT/App/Comments.pm and assumes that you have some clue about Perl. I won't be providing tech support for this. Please contact your local Perl guru.

It should be somewhat obvious where these go. I've provided a few lines of context.

    if (!$q->param('text')) {
        return $app->handle_error($app->translate("Comment text is required."));
    }
    if ($q->param('text') =~ /I wish it true|see a later|cool amazing page/i) {
        return $app->handle_error($app->translate(
                        "An unexpected error has occured"));
    }   
    if ($q->param('author') =~ /hydrocodone|phentermine|gay f..king|valium/i) {
        return $app->handle_error($app->translate(
                        "An unexpected error has occured"));
    }
    if ($q->param('url') =~ /cheapdrug/i) {
        return $app->handle_error($app->translate(
                        "An unexpected error has occured"));
    }
    
    my $comment = MT::Comment->new;

And proceed with that same sort of thing. This will bit-bucket the most eggregious morons, and then you'll still have to deal with the others manually. Or migrate to WordPress, as I'm planning to do just as soon as I get a few spare moments.

Posted by rbowen at April 17, 2004 08:32 AM | TrackBack
Comments

I've been thinking that something like mod_dnsbl and using one of the proxy rbl's might prove very useful in blocking comment spam. From the number of open proxies found, I expect much of this type of spam to be going through it. A friend of mine tests the origin of all spam that SA catches (and that wasn't already denied by rbl's) and so far his numers find that one in ten of the originating hosts are open proxies!

Posted by: Mads Toftum on April 18, 2004 05:57 AM

Try MT-Blacklist (http://www.jayallen.org/comment_spam/), a MT plugin that works on the same principle, but has a nice web interface and the website hosts a consolidated list of regexps that you can periodically copy-and-paste to import so you stay up to date. It also has a nice de-spam interface to clean up after an attack. I have found it invaluable. And of course, it's free.

Posted by: Dave Brondsema on April 18, 2004 03:11 PM

More regex goodness...
http://www.jayallen.org/comment_spam/blacklist.txt
part of:
http://www.jayallen.org/comment_spam/

Posted by: Ben Hyde on April 18, 2004 04:04 PM
Post a comment