From 2bfb1188f2051cc23a9be4ab5c603890567f8601 Mon Sep 17 00:00:00 2001 From: DariusIII Date: Wed, 2 Aug 2017 00:57:09 +0200 Subject: [PATCH] Update .htaccess with XSS blocking --- public/.htaccess | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/public/.htaccess b/public/.htaccess index 48f1ac296..d2805dda2 100644 --- a/public/.htaccess +++ b/public/.htaccess @@ -10,4 +10,36 @@ RewriteRule ^(admin|install).*$ - [L] # Rewrite web pages to one master page RewriteRule ^([^/\.]+)/?$ index.php?page=$1 [QSA,L] RewriteRule ^([^/\.]+)/([^/]+)/?$ index.php?page=$1&id=$2 [QSA,L] -RewriteRule ^([^/\.]+)/([^/]+)/([^/]+)/? index.php?page=$1&id=$2&subpage=$3 [QSA,L] \ No newline at end of file +RewriteRule ^([^/\.]+)/([^/]+)/([^/]+)/? index.php?page=$1&id=$2&subpage=$3 [QSA,L] + +# Block MySQL injections, RFI, base64, etc. +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] \ No newline at end of file