|
|
 |
|
 |
|
I love the internet
Join Date: Oct 2007
Posts: 2,704
Credits:
8,753
Location: Göteborg, Sweden
|
|
05-03-2008, 12:05 PM
|
|
.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/
|
|
|
|
VIP User
Join Date: Jan 2008
Posts: 907
Credits:
478
|
|
05-26-2008, 10:12 AM
|
|
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?
|
|
|
|
I love the internet
Join Date: Oct 2007
Posts: 2,704
Credits:
8,753
Location: Göteborg, Sweden
|
|
05-26-2008, 10:21 AM
|
|
Re: .htaccess firewall
Quote:
Originally Posted by bigjoe4
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
|
|
|
|
Lord Of The Keys
Join Date: Jan 2008
Posts: 1,280
Credits:
9,231
Location: Australia
|
|
05-28-2008, 12:44 AM
|
|
Re: .htaccess firewall
Maybe you should put this into the tutorials section? It would probably make a good tutorial. 
|
|
|
|
Senior Account Manager
Join Date: Oct 2007
Posts: 5,237
Credits:
22,315
Location: UK
|
|
05-28-2008, 03:27 AM
|
|
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.
|
|
|
|
Account Manager
Join Date: Sep 2007
Posts: 2,796
Credits:
1,301
Location: Dubai, UAE
|
|
05-28-2008, 03:49 AM
|
|
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?
|
|
|
|
Senior Account Manager
Join Date: Oct 2007
Posts: 5,237
Credits:
22,315
Location: UK
|
|
05-28-2008, 03:52 AM
|
|
Re: .htaccess firewall
Quote:
|
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.
|
|
|
|
Lord Of The Keys
Join Date: Jan 2008
Posts: 1,280
Credits:
9,231
Location: Australia
|
|
05-28-2008, 08:18 AM
|
|
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 08:21 AM.
|
|
|
|
Account Manager
Join Date: Jan 2008
Posts: 2,033
Credits:
30,567
Location: Chennai ,India
|
|
05-28-2008, 10:39 AM
|
|
Re: .htaccess firewall
But i tried this. It just showed my pages cannot be displayed. I tried in my local server.
__________________
Sunil Sankar
-------------------------------------------------------------------------
Account Manager
|
|
|
|
I love the internet
Join Date: Oct 2007
Posts: 2,704
Credits:
8,753
Location: Göteborg, Sweden
|
|
05-28-2008, 10:49 AM
|
|
Re: .htaccess firewall
Quote:
Originally Posted by verbsite
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
|
|
|
|
 |
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 03:06 PM.
Powered by vBulletin® Version 3.7.3 Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.2.0 RC7
Credit Cards | Anime Forum | Bad Credit Mortgages | Internet Advertising | Diamond Rings
| |