Identifying user agents and stopping SPAM with mod-rewrite

I stumbled across an anti-spam resource today that SHOULD be of interest and helpful to anyone that runs a webserver. This resource is generic enough that the principles could be applied to any webserver but like any good webserver article; it is apache bent (dont get me started, apache is what to use, period).

First of all it is important to understand that as part of every HTTP request the client is at least informally required to identify itself with a user agent. The user agent identifies what software and rev the client is using so that the server can react accordingly if need be. User agents commonly look like : MSIE x, Netscape x, or Mozilla x, and so on (being very general here, but you get the idea).

The cool thing is that you can redirect or otherwise handle requests based on the user agent (yeah, that is repeating what I just said above, but it was worth it.) One of the main ways this comes in handy is to go after the low life scum sucking dirtbags that solicit anything and everything through unwanted and unrepentant email, aka SPAMMERS (hope I was not to obtuse there, I hate SPAM very very much, hows that).

You see many many programs have been written to hunt out the notation of email addresses anywhere on the net and "harvest" them to be fed to the spammers. Many of these programs (be they robots, spiders, ferns, ferry boats, whatever) actually do identify themselves with user agents that are known to be malicious (spam email harversters, yes spam is MALICIOUS.) Others still purposely do NOT identlfy themselves (which real browsers, robots, spiders and other legitimate index tools never do) or misrepresent themselves. OK, so the ones that misrepresent are tricky, beyond the scope of this little helpful hint article (and the linked resource), but the "low hanging fruit" so to speak of the known culprits is trivially easy to block and or even redirect to a fun little page that is full or erroneuos and offensive email addresses. (spamnomore@dumbass.net, repeated and varied hundreds of time, for example).

Using the apache mod-rewrite you can search for known spam user agents and then redirect as alluded to above, ie:

     
    RewriteEngine  on
    RewriteCond %{HTTP_USER_AGENT} ^EmailSiphon       [OR]
    RewriteCond %{HTTP_USER_AGENT} ^EmailWolf         [OR]
    RewriteCond %{HTTP_USER_AGENT} ^ExtractorPro      [OR]
    RewriteCond %{HTTP_USER_AGENT} ^Mozilla.*NEWT     [OR]
    RewriteCond %{HTTP_USER_AGENT} ^Crescent          [OR]
    RewriteCond %{HTTP_USER_AGENT} ^CherryPicker      [OR]
    RewriteCond %{HTTP_USER_AGENT} ^[Ww]eb[Bb]andit   [OR]
    RewriteCond %{HTTP_USER_AGENT} ^WebEMailExtrac.*  [OR]
    RewriteCond %{HTTP_USER_AGENT} ^NICErsPRO         [OR]
    RewriteCond %{HTTP_USER_AGENT} ^Telesoft          [OR]
    RewriteCond %{HTTP_USER_AGENT} ^Zeus.*Webster     [OR]
    RewriteCond %{HTTP_USER_AGENT} ^Microsoft.URL     [OR]
    RewriteCond %{HTTP_USER_AGENT} ^Mozilla/3.Mozilla/2.01 [OR]
    RewriteCond %{HTTP_USER_AGENT} ^EmailCollector
    RewriteRule ^.*$ /badspammer.html  [L]
    

    This is a very handy little thing to be aware of and it is the duty of everyone who runs a webserver to implement it. Eradication of SPAM is the mission, small and easy things like this can help a lot. The attached (linked -->) article delves further into which user agents are what and has more details on mod-rewrite (as does the apache documentation.

    Check the link and go after the spam.
      Protect Your Webserver from SPAM Harvesters:

    Comments

    Re: Identifying user agents and stopping SPAM with mod-rewrite

    How can you dismiss IIS out of hand like that? You can not tell me that IIS can't hang with Apache ANY DAY OF THE WEEK. I am offended and affronted.

    -mutt

    Re: Identifying user agents and stopping SPAM with mod-rewrite

    JACKASS!

    Re: Identifying user agents and stopping SPAM with mod-rewrite

    What a clever retort. You got me with that one, young man. Now I am off to go wither in shame and humiliation at being bested verbally by someone of your with and caliber.

    :P

    Re: Identifying user agents and stopping SPAM with mod-rewrite

    you will learn, JACKASS

    Comment viewing options

    Select your preferred way to display the comments and click "Save settings" to activate your changes.