Что я уже сделал:
- фильтрацию данных из форм через htmlspecialchars() и проверку на соответствие регулярному выражению через preg_match();
- защищиту форм через генерацию ключа в поле hidden и запись в сессию;
- нагло своровал чей-то .htaccess и настроил для себя (изменял только mod_rewrite, в правильности сомневаюсь );
- запросы к бд через url не производятся;
- пароли пропускаются через md5();
- а xss на хостинге не срабатывает, уже проверял вводя <script>alert('xss');</script> в адресную строку... хотя на денвере работало. о_О
htaccess (Отобразить)
CODE (htmlphp):
скопировать код в буфер обмена
скопировать код в буфер обмена
- Options All -ExecCGI -Indexes -Includes +FollowSymLinks
- <IfModule mod_rewrite.c>
- RewriteEngine on
- RewriteBase /
- #редирект с www
- RewriteCond %{HTTP_HOST} ^www\.mysite\.ru$
- RewriteRule ^(.*)$ http://mysite.ru/$1 [L]
- #затирание index.php
- RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
- RewriteRule ^index\.php$ http://mysite.ru/ [L]
- #затирание index
- RewriteRule ^index$ http://mysite.ru/ [L]
- #редирект из папки с шаблонами
- RewriteRule ^templates.*$ http://mysite.ru/ [L]
- #редирект из папки с библиотеками
- RewriteRule ^lib.*$ http://mysite.ru/ [L]
- # Блокируем любой скрипт пытающийся получить значение mosConfig через URL
- RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|%3D) [OR]
- # Блокируем любой скрипт пытающийся отправить любое дерьмо через base64_encode по URL
- RewriteCond %{QUERY_STRING} base64_encode.*(.*) [OR]
- # Блокируем любой скрипт который содержит тег < script> в URL
- RewriteCond %{QUERY_STRING} (<|%3C).*script.*(>|%3E) [NC,OR]
- # Блокируем любой скрипт, который пытается установить глобальную переменную PHP через URL
- RewriteCond %{QUERY_STRING} GLOBALS(=|[|%[0-9A-Z]{0,2}) [OR]
- # Блокируем любой скрипт пытающийся изменить _REQUEST переменную через URL
- RewriteCond %{QUERY_STRING} _REQUEST(=|[|%[0-9A-Z]{0,2}) [OR]
- # Блокируем любой скрипт, который пытается установить CONFIG_EXT (баг в com_extcal2)
- #RewriteCond %{QUERY_STRING} CONFIG_EXT([|%20|%5B).*= [NC,OR]
- # Блокируем любой скрипт, который пытается установить sbp or sb_authorname через URL (баг simpleboard)
- RewriteCond %{QUERY_STRING} sbp(=|%20|%3D) [OR]
- RewriteCond %{QUERY_STRING} sb_authorname(=|%20|%3D)
- # Отправляем все заблокированный запросы на главную с ошибкой 403 Forbidden!
- RewriteRule ^(.*)$ index.php [F,L]
- #ЧПУ
- RewriteCond %{REQUEST_FILENAME} !-f
- RewriteCond %{REQUEST_FILENAME} !-d
- RewriteRule ^(.*)$ index.php?view=$1 [QSA,L]
- </IfModule>
- DirectoryIndex index.php
- <IfModule mod_setenvif.c>
- SetEnv TZ Europe/Moscow
- </IfModule>
- ServerSignature Off
- #AddDefaultCharset UTF-8
- <ifModule mod_php.c>
- php_value upload_max_filesize 0M
- php_value post_max_size 1M
- php_value default_charset utf-8
- php_value max_execution_time 200
- </ifModule>
- AddHandler application/x-httpd-php .html
- AddHandler cgi-script .pl .py .jsp .asp .htm .shtml .sh .cgi
- AddType application/x-javascript .js
- AddType text/css .css
- AddType text/xml .xml
- AddType application/octet-stream .doc .mov .avi .pdf .xls
- # ForceType application/x-httpd-php
- <ifModule mod_deflate.c>
- AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/css text/javascript application/javascript application/x-javascript
- </ifModule>
- <IfModule mod_gzip.c>
- mod_gzip_on Yes
- mod_gzip_dechunk Yes
- mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$
- mod_gzip_item_include mime ^text\.*
- mod_gzip_item_include mime ^application/x-javascript.*
- mod_gzip_item_exclude mime ^image\.*
- mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
- </IfModule>
- <ifModule mod_headers.c>
- #кэшировать html и htm файлы на один день
- <FilesMatch "\.(html|htm)$">
- Header set Cache-Control "max-age=43200"
- </FilesMatch>
- #кэшировать css, javascript и текстовые файлы на одну неделю
- <FilesMatch "\.(js|css|txt)$">
- Header set Cache-Control "max-age=604800"
- </FilesMatch>
- #кэшировать флэш и изображения на месяц
- <FilesMatch "\.(flv|swf|ico|gif|jpg|jpeg|png)$">
- Header set Cache-Control "max-age=2592000"
- </FilesMatch>
- #отключить кэширование
- <FilesMatch "\.(pl|php|cgi|spl|scgi|fcgi)$">
- Header unset Cache-Control
- </FilesMatch>
- </IfModule>
- <ifModule mod_expires.c>
- ExpiresActive On
- #по умолчанию кеш в 5 секунд
- ExpiresDefault "access plus 5 seconds"
- #кэшировать флэш и изображения на месяц
- ExpiresByType image/x-icon "access plus 2592000 seconds"
- ExpiresByType image/jpeg "access plus 2592000 seconds"
- ExpiresByType image/png "access plus 2592000 seconds"
- ExpiresByType image/gif "access plus 2592000 seconds"
- ExpiresByType application/x-shockwave-flash "access plus 2592000 seconds"
- #кэшировать css, javascript и текстовые файлы на одну неделю
- ExpiresByType text/css "access plus 604800 seconds"
- ExpiresByType text/javascript "access plus 604800 seconds"
- ExpiresByType application/javascript "access plus 604800 seconds"
- ExpiresByType application/x-javascript "access plus 604800 seconds"
- #кэшировать html и htm файлы на один день
- ExpiresByType text/html "access plus 43200 seconds"
- #кэшировать xml файлы на десять минут
- ExpiresByType application/xhtml+xml "access plus 600 seconds"
- </ifModule>
- # Bad Rquest
- ErrorDocument 400 /errors/400.html
- # Authorization Required
- ErrorDocument 401 /errors/401.html
- # Forbidden
- ErrorDocument 403 /errors/403.html
- # Not found
- ErrorDocument 404 /errors/404.html
- # Method Not Allowed
- ErrorDocument 405 /errors/405.html
- # Request Timed Out
- ErrorDocument 408 /errors/408.html
- # Request URI Too Long
- ErrorDocument 414 /errors/414.html
- # Internal Server Error
- ErrorDocument 500 /errors/500.html
- # Not Implemented
- ErrorDocument 501 /errors/501.html
- # Bad Gateway
- ErrorDocument 502 /errors/502.html
- # Service Unavailable
- ErrorDocument 503 /errors/503.html
- # Gateway Timeout
- ErrorDocument 504 /errors/504.html