|
4 | 4 | ## Begin - Rewrite rules to block out some common exploits.
|
5 | 5 | # If you experience problems on your site block out the operations listed below
|
6 | 6 | # This attempts to block the most common type of exploit `attempts` to Monstra
|
7 |
| - # |
| 7 | + # |
8 | 8 | # Block out any script trying to base64_encode data within the URL.
|
9 | 9 | RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
|
10 | 10 | # Block out any script that includes a <script> tag in URL.
|
|
14 | 14 | # Block out any script trying to modify a _REQUEST variable via URL.
|
15 | 15 | RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
|
16 | 16 | # Return 403 Forbidden header and show the content of the root homepage
|
17 |
| - RewriteRule .* index.php [F] |
| 17 | + RewriteRule .* index.php [F,L] |
18 | 18 | #
|
19 | 19 | RewriteCond %{REQUEST_FILENAME} !-f
|
20 |
| - RewriteCond %{REQUEST_FILENAME}/index.html !-f |
| 20 | + RewriteCond %{REQUEST_FILENAME} !-d |
| 21 | + # RewriteRule ^([^\.]+)$ $1.php [NC,L] |
| 22 | + # RewriteRule ^(.+)\.php$ /$1 [R,L] |
| 23 | + # RewriteCond %{REQUEST_FILENAME}/index.html !-f |
21 | 24 | RewriteCond %{REQUEST_FILENAME}/index.php !-f
|
22 |
| - RewriteRule . index.php [L] |
| 25 | + # |
| 26 | + # RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L] |
| 27 | + RewriteRule ^ index.php [QSA,L] |
| 28 | + # RewriteRule . index.php [L] |
23 | 29 | Redirect 301 "/home" "/"
|
24 | 30 | Redirect 301 "/inicio" "/"
|
25 | 31 | Redirect 301 "/system" "/admin"
|
26 | 32 | Redirect 301 "/login" "/signin"
|
27 | 33 | </IfModule>
|
| 34 | +<IfModule mod_headers.c> |
| 35 | + # Make sure proxies don't deliver the wrong content |
| 36 | + # Header always set Content-Security-Policy: upgrade-insecure-requests |
| 37 | + # This one can be a pain in the A** to set up, which is why I commented it out. |
| 38 | + Header set Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" |
| 39 | + Header append Vary User-Agent env=!dont-vary |
| 40 | + Header always append X-Frame-Options SAMEORIGIN |
| 41 | + Header always set Content-Security-Policy "upgrade-insecure-requests;" |
| 42 | + # // This is the Xss header you are looking for |
| 43 | + Header set X-XSS-Protection "1; mode=block" |
| 44 | + Header set X-Content-Type-Options nosniff |
| 45 | + Header set Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'" |
| 46 | + Header set Access-Control-Allow-Origin "*" |
| 47 | + IndexIgnore *.zip *.css *.js *.pyt |
| 48 | + Options -MultiViews -Indexes |
| 49 | + |
| 50 | +</IfModule> |
| 51 | +<IfModule mod_security.c> |
| 52 | + SecFilterEngine On |
| 53 | + # ^Turn the filtering engine On or Off |
| 54 | + SecFilterScanPOST On |
| 55 | + # ^Should mod_security inspect POST payloads |
| 56 | + SecFilterSelective "HTTP_USER_AGENT|HTTP_HOST" "^$" |
| 57 | + # ^Require HTTP_USER_AGENT and HTTP_HOST in all requests |
| 58 | + SecFilter "../" |
| 59 | + # ^Prevent path traversal (..) attacks |
| 60 | + SecFilter "<[[:space:]]*script" |
| 61 | + # ^Weaker XSS protection but allows common HTML tags |
| 62 | + SecFilter "<(.|n)+>" |
| 63 | + # ^Prevent XSS atacks (HTML/Javascript injection) |
| 64 | + SecFilter "delete[[:space:]]+from" |
| 65 | + SecFilter "insert[[:space:]]+into" |
| 66 | + SecFilter "select.+from" |
| 67 | + SecFilter "drop[[:space:]]table" |
| 68 | + # ^Very crude filters to prevent SQL injection attacks |
| 69 | + SecFilterSelective ARG_PHPSESSID "!^[0-9a-z]*$" |
| 70 | + SecFilterSelective COOKIE_PHPSESSID "!^[0-9a-z]*$" |
| 71 | + # ^Protecting from XSS attacks through the PHP session cookie |
| 72 | + SecFilterDefaultAction "deny,log,status:500" |
| 73 | + # ^Action to take by default |
| 74 | +</IfModule> |
| 75 | + # Block access to backup and source files. |
| 76 | + # These files may be left by some text editors and can pose a great security |
| 77 | + # danger when anyone has access to them. |
| 78 | + |
| 79 | +<FilesMatch "(^#.*#|.(bak|config|dist|fla|inc|ini|log|psd|sh|sql|sw[op])|~)$"> |
| 80 | + Order allow,deny |
| 81 | + Deny from all |
| 82 | + Satisfy All |
| 83 | +</FilesMatch> |
0 commit comments