Created
April 25, 2018 18:08
-
-
Save dsebao/ab116daa1e416e5c2a7e56d6edbf75e3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #1: CODE | |
| Options +FollowSymLinks | |
| RewriteEngine On | |
| RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR] | |
| RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR] | |
| RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2}) | |
| RewriteRule ^(.*)$ index.php [F,L] | |
| #(last line means visitor is redirected to index with Forbidden message ([F)) | |
| #2: CODE | |
| # SQL Injection Protection | |
| RewriteEngine On | |
| RewriteRule ^.*EXEC\(@.*$ - [R=404,L,NC] | |
| RewriteRule ^.*CAST\(.*$ - [R=404,L,NC] | |
| RewriteRule ^.*DECLARE.*$ - [R=404,L,NC] | |
| RewriteRule ^.*DECLARE%20.*$ - [R=404,L,NC] | |
| RewriteRule ^.*NVARCHAR.*$ - [R=404,L,NC] | |
| RewriteRule ^.*sp_password.*$ - [R=404,L,NC] | |
| RewriteRule ^.*%20xp_.*$ - [R=404,L,NC] | |
| #(Above .htacess script used for SQL Injection Protection) | |
| #3: CODE | |
| # Block MySQL injections, RFI, base64, etc. | |
| RewriteEngine On | |
| RewriteCond %{QUERY_STRING} [a-zA-Z0-9_]=http:// [OR] | |
| RewriteCond %{QUERY_STRING} [a-zA-Z0-9_]=(\.\.//?)+ [OR] | |
| RewriteCond %{QUERY_STRING} [a-zA-Z0-9_]=/([a-z0-9_.]//?)+ [NC,OR] | |
| RewriteCond %{QUERY_STRING} \=PHP[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12} [NC,OR] | |
| RewriteCond %{QUERY_STRING} (\.\./|\.\.) [OR] | |
| RewriteCond %{QUERY_STRING} ftp\: [NC,OR] | |
| RewriteCond %{QUERY_STRING} http\: [NC,OR] | |
| RewriteCond %{QUERY_STRING} https\: [NC,OR] | |
| RewriteCond %{QUERY_STRING} \=\|w\| [NC,OR] | |
| RewriteCond %{QUERY_STRING} ^(.*)/self/(.*)$ [NC,OR] | |
| RewriteCond %{QUERY_STRING} ^(.*)cPath=http://(.*)$ [NC,OR] | |
| RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR] | |
| RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR] | |
| RewriteCond %{QUERY_STRING} (\<|%3C).*iframe.*(\>|%3E) [NC,OR] | |
| RewriteCond %{QUERY_STRING} (<|%3C)([^i]*i)+frame.*(>|%3E) [NC,OR] | |
| RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [NC,OR] | |
| RewriteCond %{QUERY_STRING} base64_(en|de)code[^(]*\([^)]*\) [NC,OR] | |
| RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR] | |
| RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2}) [OR] | |
| RewriteCond %{QUERY_STRING} ^.*(\[|\]|\(|\)|<|>).* [NC,OR] | |
| RewriteCond %{QUERY_STRING} (NULL|OUTFILE|LOAD_FILE) [OR] | |
| RewriteCond %{QUERY_STRING} (\./|\../|\.../)+(motd|etc|bin) [NC,OR] | |
| RewriteCond %{QUERY_STRING} (localhost|loopback|127\.0\.0\.1) [NC,OR] | |
| RewriteCond %{QUERY_STRING} (<|>|'|%0A|%0D|%27|%3C|%3E|%00) [NC,OR] | |
| RewriteCond %{QUERY_STRING} concat[^\(]*\( [NC,OR] | |
| RewriteCond %{QUERY_STRING} union([^s]*s)+elect [NC,OR] | |
| RewriteCond %{QUERY_STRING} union([^a]*a)+ll([^s]*s)+elect [NC,OR] | |
| RewriteCond %{QUERY_STRING} (;|<|>|'|"|\)|%0A|%0D|%22|%27|%3C|%3E|%00).*(/\*|union|select|insert|drop|delete|update|cast|create|char|convert|alter|declare|order|script|set|md5|benchmark|encode) [NC,OR] | |
| RewriteCond %{QUERY_STRING} (sp_executesql) [NC] | |
| RewriteRule ^(.*)$ - [F,L] | |
| #(Above .htacess script used for SQL Injection Protection) | |
| #4: CODE | |
| # File injection protection, by SigSiu.net | |
| RewriteCond %{REQUEST_METHOD} GET | |
| RewriteCond %{QUERY_STRING} [a-zA-Z0-9_]=http:// [OR] | |
| RewriteCond %{QUERY_STRING} [a-zA-Z0-9_]=(\.\.//?)+ [OR] | |
| RewriteCond %{QUERY_STRING} [a-zA-Z0-9_]=http%3A%2F%2F [OR] | |
| RewriteCond %{QUERY_STRING} [a-zA-Z0-9_]=/([a-z0-9_.]//?)+ [NC] | |
| RewriteRule .* - [F] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment