Skip to main content

Block Unwanted Bots Agent and Proxys

Comments

11 comments

  • cPanelMichael
    Hello :) Have you considered using Mod_Security instead of Mod_Rewrite to block user agents? Thank you.
    0
  • quizknows
    Hello :) Have you considered using Mod_Security instead of Mod_Rewrite to block user agents? Thank you.

    This would be my recommendation. There are a couple good ways to do this with ModSecurity. One would be individual rules like:
    SecRule REQUEST_HEADERS:User-Agent "^NetSeer" "deny,id:12345"
    Or, you could make a list of user agents in a file like /usr/local/apache/conf/my_custom_list.conf and then make a modsec rule like:
    SecRule REQUEST_HEADERS:User-Agent "@pmFromFile /usr/local/apache/conf/my_custom_list.conf" "deny,id:12346"
    This method is detailed in the modsecurity manual here Reference Manual " SpiderLabs/ModSecurity Wiki " GitHub
    0
  • Bidi
    i will try to make mod_sec way :) i hope not braking to many thinks, but there is another one, witch drives me crazy is this (on the pic) and i dont know what agent to write to block them, if no agent or sompting like this. They ar some sort of proxys, or mirc bots i think. [Removed]
    0
  • cPanelMichael
    Please ensure you attach images directly to the post, instead of linking to a third-party image hosting website. This is listed at: Guide To Opening An Effective Forums Thread Thank you.
    0
  • Bidi
    I fix it, i made all the thinks in mod_sec rules, even for proxys, bad agents, fake hits ...etc thank you, works like a charm :D
    0
  • cPanelMichael
    I am happy to see you were able to address the issue. Thank you for updating us with the outcome.
    0
  • Bidi
    Whell i`m back :( cuz of this rulls witch brakes my websites and i dont understand whant i`m doing bad, dose anyone got any ideas ?
    # Block empty User-Agents. SecRule REQUEST_HEADERS:User-Agent "@eq 0" \ "id:'13009',phase:2,t:none,deny,status:406,log,msg:'Fake Agent - Detectat'" and SecRule REQUEST_HEADERS:User-Agent "^$" \ "id:'13006',phase:2,t:none,deny,status:406,log,msg:'Fake Agent - Detectat'"
    0
  • quizknows
    Try this instead of those two:
    # Block empty User-Agents. SecRule &REQUEST_HEADERS:User-Agent "@eq 0" \ "id:'13009',phase:2,t:none,deny,status:406,log,msg:'Fake Agent - Detectat'"
    If you're using an operator like @eq sometimes you need to add the & before the matched var.
    0
  • Bidi
    Hy i forget to mention :( i had like theath before but the problem is when i had theath rule enabled and on WHM i go to Apache Status i got this error. Do i have to whitelist sompting ? Apache server status for ************ Failed to receive status information from Apache. And i dont understand why. Thank you for your reply
    0
  • quizknows
    That is the correct syntax (with the &) however I don't think WHM provides a User Agent when it queries server status. The log looks like this:
    127.0.0.1 - - [17/Feb/2016:21:20:01 -0500] "GET /whm-server-status HTTP/1.0" 200 6153
    Try this:
    # Block empty User-Agents. SecRule &REQUEST_HEADERS:User-Agent "@eq 0" \ "id:'13009',phase:2,t:none,deny,chain,status:406,log,msg:'Fake Agent - Detectat'" SecRule REMOTE_ADDR "!@ipMatch 127.0.0.1"
    This will allow 127.0.0.1 to query the server without a user agent specified but other IPs will not be allowed to. That should fix WHM server status for you.
    0
  • Bidi
    I had added lest see how it works :D thank you
    0

Please sign in to leave a comment.