+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: .htaccess firewall

  1. #1
    galaxyAbstractor's Avatar
    galaxyAbstractor is offline Community Advocate galaxyAbstractor is on a distinguished road
    Join Date
    Oct 2007
    Location
    Land of Null and Insanity
    Posts
    5,495

    .htaccess firewall

    This is a small .htaccess firewall to protect your site from hackers:

    Code:
    RewriteEngine On
    
    Options +FollowSymLinks
    
    
    
    ServerSignature Off
    
    
    
    RewriteCond %{REQUEST_METHOD}  ^(HEAD|TRACE|DELETE|TRACK) [NC,OR]
    
    RewriteCond %{HTTP_REFERER}    ^(.*)(<|>|'|%0A|%0D|%27|%3C|%3E|%00).* [NC,OR]
    
    RewriteCond %{REQUEST_URI}     ^/(,|;|<|>|/{2,999}).* [NC,OR]
    
    
    
    RewriteCond %{HTTP_USER_AGENT} ^$ [OR]
    
    RewriteCond %{HTTP_USER_AGENT} ^(java|curl|wget).* [NC,OR]
    
    RewriteCond %{HTTP_USER_AGENT} ^.*(winhttp|HTTrack|clshttp|archiver|loader|email|harvest|extract|grab|miner).* [NC,OR]
    
    RewriteCond %{HTTP_USER_AGENT} ^.*(libwww|curl|wget|python|nikto|scan).* [NC,OR]
    
    RewriteCond %{HTTP_USER_AGENT} ^.*(<|>|'|%0A|%0D|%27|%3C|%3E|%00).* [NC,OR]
    
    
    
    RewriteCond %{HTTP_COOKIE}     ^.*(<|>|'|%0A|%0D|%27|%3C|%3E|%00).* [NC,OR]
    
    RewriteCond %{QUERY_STRING}    ^.*(;|'|").*(union|select|insert|declare|drop|update|md5|benchmark).* [NC,OR]
    
    RewriteCond %{QUERY_STRING}    ^.*(localhost|loopback|127\.0\.0\.1).* [NC,OR]
    
    
    
    RewriteCond %{QUERY_STRING}    ^.*\.[A-Za-z0-9].* [NC,OR] # prevents shell injection
    
    RewriteCond %{QUERY_STRING}    ^.*(<|>|'|%0A|%0D|%27|%3C|%3E|%00).* [NC]
    
    
    
    RewriteRule ^(.*)$ index.php # better yet: send them to a fail-safe page, like error.php
    Source:
    http://www.0x000000.com/?i=558

    http://jagf.net/blog/programming/website-firewall/

  2. #2
    bigjoe4 is offline x10 Elder bigjoe4 is an unknown quantity at this point
    Join Date
    Jan 2008
    Posts
    907

    Re: .htaccess firewall

    I am interrested in this, can I just replace my existing htaccess with this or will that mess stuff up? have you tried it yourself?
    Please visit my site: Circuit designer

  3. #3
    galaxyAbstractor's Avatar
    galaxyAbstractor is offline Community Advocate galaxyAbstractor is on a distinguished road
    Join Date
    Oct 2007
    Location
    Land of Null and Insanity
    Posts
    5,495

    Re: .htaccess firewall

    Quote Originally Posted by bigjoe4 View Post
    I am interrested in this, can I just replace my existing htaccess with this or will that mess stuff up? have you tried it yourself?
    Put it in the end of your .htaccess. No I haven't had time to try it

  4. #4
    LHVWB's Avatar
    LHVWB is offline Lord Of The Keys LHVWB is an unknown quantity at this point
    Join Date
    Jan 2008
    Location
    Australia
    Posts
    1,308

    Re: .htaccess firewall

    Maybe you should put this into the tutorials section? It would probably make a good tutorial. ;)

  5. #5
    TechAsh's Avatar
    TechAsh is offline Retired TechAsh is an unknown quantity at this point
    Join Date
    Oct 2007
    Location
    UK
    Posts
    5,853

    Re: .htaccess firewall

    I have tested it on my site. The only problem I've noticed is that it blocks "." in the query string, and this can cause problems with some scripts that use this. I just commented that bit out of the .htaccess file any it still works.

    I haven't tried to hack my site with this firewall in place to see how effective it is, and I'm not going to, but I think it will stop some attempts.
    Useful Links:
    Terms of Service | Server News | Buy a Domain
    Free Domains: co.cc | Dot.tk -- Free File Storage: Dropbox -- Website Monitoring: Service Uptime


    My Websites:
    Earthtime Games & TechAsh's Blog

  6. #6
    Sohail's Avatar
    Sohail is offline x10 Spammer Sohail is an unknown quantity at this point
    Join Date
    Sep 2007
    Location
    London, UK
    Posts
    3,052

    Re: .htaccess firewall

    Yeah i'll move this to the tuorials section now... This is a great script, but don't you have to place this in the .htaccess file of everyday directory as I think that if you were to put it in you main directory it would only work for that directory and not any subs?

  7. #7
    TechAsh's Avatar
    TechAsh is offline Retired TechAsh is an unknown quantity at this point
    Join Date
    Oct 2007
    Location
    UK
    Posts
    5,853

    Re: .htaccess firewall

    This is a great script, but don't you have to place this in the .htaccess file of everyday directory as I think that if you were to put it in you main directory it would only work for that directory and not any subs?
    No. If you place it in the main directory, it will work for all sub-directories as well.
    Useful Links:
    Terms of Service | Server News | Buy a Domain
    Free Domains: co.cc | Dot.tk -- Free File Storage: Dropbox -- Website Monitoring: Service Uptime


    My Websites:
    Earthtime Games & TechAsh's Blog

  8. #8
    LHVWB's Avatar
    LHVWB is offline Lord Of The Keys LHVWB is an unknown quantity at this point
    Join Date
    Jan 2008
    Location
    Australia
    Posts
    1,308

    Re: .htaccess firewall

    Just a question, I haven't done much working with securing websites, so how safe is this method when compared to other methods?
    Last edited by LHVWB; 05-28-2008 at 07:21 AM.

  9. #9
    sunils's Avatar
    sunils is offline x10 Spammer sunils is an unknown quantity at this point
    Join Date
    Jan 2008
    Location
    Chennai ,India
    Posts
    2,264

    Re: .htaccess firewall

    But i tried this. It just showed my pages cannot be displayed. I tried in my local server.
    [LEFT][B]Sunil Sankar
    -------------------------------------------------------------------------

  10. #10
    galaxyAbstractor's Avatar
    galaxyAbstractor is offline Community Advocate galaxyAbstractor is on a distinguished road
    Join Date
    Oct 2007
    Location
    Land of Null and Insanity
    Posts
    5,495

    Re: .htaccess firewall

    Quote Originally Posted by verbsite View Post
    Just a question, I haven't done much working with securing websites, so how safe is this method when compared to other methods?
    I don't belive it stops everything but I think it stops the n00b hackers that just learnt how to hack

+ Reply to Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. Best Firewall?
    By Twinkie in forum Crossfire
    Replies: 13
    Last Post: 04-13-2008, 12:34 PM
  2. Server firewall blocking countries?
    By clanuis in forum Free Hosting
    Replies: 14
    Last Post: 11-23-2007, 10:13 AM
  3. default .htaccess
    By Fedlerner in forum Computers & Technology
    Replies: 9
    Last Post: 09-05-2007, 09:10 PM
  4. What's your Antivirus & Firewall
    By stealth_thunder in forum Scripts & 3rd Party Apps
    Replies: 30
    Last Post: 04-28-2005, 02:56 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers