Code to block user agents please?

Discussion in 'C#' started by Paz, Apr 13, 2007.

  1. #1
    Hi,

    I have a Snitz forum that's getting hit hard by automated posters. I've looked at my logs and amazingly they are all using a unique user agent and I can eliminate 99.9% of this spam by blocking it or redirecting to a 404 or something.

    Is there any chance someone can post some suitable code for this? It doesn't have to completely accurate, I know a little asp, I just don't know where/how to start coding this. Green given for all answers...

    Cheers,
    Paz.
     
    Paz, Apr 13, 2007 IP
  2. briansol

    briansol Well-Known Member

    Messages:
    221
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    110
    #2
    if request.server("HTTP_REFERER") = "thespam.com" then
    response.redirect "404.asp"
    end if
     
    briansol, Apr 13, 2007 IP
    Paz likes this.
  3. Paz

    Paz Well-Known Member

    Messages:
    587
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    170
    #3
    Thanks for that, I'll get to work!
     
    Paz, Apr 13, 2007 IP
  4. Paz

    Paz Well-Known Member

    Messages:
    587
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    170
    #4
    Just in case anyone's interested, here's the code that seems to work OK;
     
    Paz, Apr 14, 2007 IP
  5. weppos

    weppos Well-Known Member

    Messages:
    99
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    125
    #5
    Are you sure about the ServerVariable syntax?
    It should be

    RefAGENT = Request.ServerVariables("HTTP_User_Agent")
    Code (markup):
    instead of

    RefAGENT = Request.ServerVariables("HTTP_User-Agent")
    Code (markup):
    :)
     
    weppos, Apr 16, 2007 IP
    Paz likes this.
  6. Paz

    Paz Well-Known Member

    Messages:
    587
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    170
    #6
    Yes, thanks for that, I thought it worked but I obviously didn't test it properly. I've been racking my brains trying to get it working, there was another problem with the other anti-spam code, so here's something tested with a custom user agent using a Firefox extension;

     
    Paz, Apr 17, 2007 IP