wordpress-htaccess-ile-guvenlik-onlemleri

Hayat kurtaran 8 tane WordPress .htaccess güvenlik kodu sayesinde sitenizi hacklenmekten kurtarabilirsiniz.

.htaccess dosyasını nasıl düzenler veya oluştururum?

Bir FTP programı aracılığıyla sitenizin dosya dizinine giriş yapın ana dizinde bulunan public_html veya httpdocs klasörünü açın ve .htaccess klasörünün olup olmadığını kontrol edin eğer varsa düzenleyin yoksa oluşturun.

 01 – 6G Güvenlik Duvarını Uygulama

6G Güvenlik duvarı hiçbir yapılandırma gerektirmeden tak çalıştır mantığında apache ile çalışan tüm web sitelerinde güçlü bir koruma sağlar.

Wordpress Tema

Aşağıdaki kodu .htaccess dosyanızın sonuna ekleyerek aktif edebilirsiniz.

# 6G FIREWALL/BLACKLIST
# @ https://perishablepress.com/6g/

# 6G:[QUERY STRING]
</IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{QUERY_STRING} (eval\() [NC,OR]
    RewriteCond %{QUERY_STRING} (127\.0\.0\.1) [NC,OR]
    RewriteCond %{QUERY_STRING} ([a-z0-9]{2000,}) [NC,OR]
    RewriteCond %{QUERY_STRING} (javascript:)(.*)(;) [NC,OR]
    RewriteCond %{QUERY_STRING} (base64_encode)(.*)(\() [NC,OR]
    RewriteCond %{QUERY_STRING} (GLOBALS|REQUEST)(=|\[|%) [NC,OR]
    RewriteCond %{QUERY_STRING} (</|%3C)(.*)script(.*)(>|%3) [NC,OR]
    RewriteCond %{QUERY_STRING} (\\|\.\.\.|\.\./|~|`|</|>|\|) [NC,OR]
    RewriteCond %{QUERY_STRING} (boot\.ini|etc/passwd|self/environ) [NC,OR]
    RewriteCond %{QUERY_STRING} (thumbs?(_editor|open)?|tim(thumb)?)\.php [NC,OR]
    RewriteCond %{QUERY_STRING} (\'|\")(.*)(drop|insert|md5|select|union) [NC]
    RewriteRule .* - [F]
</IfModule>

# 6G:[REQUEST METHOD]
</IfModule mod_rewrite.c>
    RewriteCond %{REQUEST_METHOD} ^(connect|debug|move|put|trace|track) [NC]
    RewriteRule .* - [F]
</IfModule>

# 6G:[REFERRER]
</IfModule mod_rewrite.c>
    RewriteCond %{HTTP_REFERER} ([a-z0-9]{2000,}) [NC,OR]
    RewriteCond %{HTTP_REFERER} (semalt.com|todaperfeita) [NC]
    RewriteRule .* - [F]
</IfModule>

# 6G:[REQUEST STRING]
</IfModule mod_alias.c>
    RedirectMatch 403 (?i)([a-z0-9]{2000,})
    RedirectMatch 403 (?i)(https?|ftp|php):/
    RedirectMatch 403 (?i)(base64_encode)(.*)(\()
    RedirectMatch 403 (?i)(=\\\'|=\\%27|/\\\'/?)\.
    RedirectMatch 403 (?i)/(\$(\&)?|\*|\"|\.|,|&|&?)/?$
    RedirectMatch 403 (?i)(\{0\}|\(/\(|\.\.\.|\+\+\+|\\\"\\\")
    RedirectMatch 403 (?i)(~|`|</|>|:|;|,|%|\\|\{|\}|\[|\]|\|)
    RedirectMatch 403 (?i)/(=|\$&|_mm|cgi-|muieblack)
    RedirectMatch 403 (?i)(&pws=0|_vti_|\(null\)|\{\$itemURL\}|echo(.*)kae|etc/passwd|eval\(|self/environ)
    RedirectMatch 403 (?i)\.(aspx?|bash|bak?|cfg|cgi|dll|exe|git|hg|ini|jsp|log|mdb|out|sql|svn|swp|tar|rar|rdf)$
    RedirectMatch 403 (?i)/(^$|(wp-)?config|mobiquo|phpinfo|shell|sqlpatch|thumb|thumb_editor|thumbopen|timthumb|webshell)\.php
</IfModule>

# 6G:[USER AGENT]
</IfModule mod_setenvif.c>
    SetEnvIfNoCase User-Agent ([a-z0-9]{2000,}) bad_bot
    SetEnvIfNoCase User-Agent (archive.org|binlar|casper|checkpriv|choppy|clshttp|cmsworld|diavol|dotbot|extract|feedfinder|flicky|g00g1e|harvest|heritrix|httrack|kmccrew|loader|miner|nikto|nutch|planetwork|postrank|purebot|pycurl|python|seekerspider|siclab|skygrid|sqlmap|sucker|turnit|vikspider|winhttp|xxxyy|youda|zmeu|zune) bad_bot
    
    # Apache </ 2.3
    </IfModule !mod_authz_core.c>
        Order Allow,Deny
        Allow from all
        Deny from env=bad_bot
    </IfModule>

    # Apache >= 2.3
    </IfModule mod_authz_core.c>
        </RequireAll>
            Require all Granted
            Require not env bad_bot
        </RequireAll>
    </IfModule>
</IfModule>

02- Uploads klasöründe php kodlarının çalışmasını engelleyin

En yaygın tema/eklenti açıklarından bir tanesi dosya yükleme bölümlerinden güvenlik duvarı kandırılarak zararlı php kodu barındıran dosyanın sitenize yüklenmesi geliyor.

Bu açık olsa dahi paylaştığımız kod ile uploads klasöründe php dosyalarının çalışması engelleyecek dolayısıyla saldırı başarısız sonuçlanacak.

# Kill PHP Execution
<Files *.php>
deny from all
</Files>

03- Wp-config.php Dosyasının Güvenliğini Sağlayın

<files wp-config.php>
order allow,deny
deny from all
</files>

04- WordPress’te Dizin Taramayı Devre Dışı Bırak

Options -Indexes

05- Siteler arası komut dosyası çalıştırmayı engelleyin

Yaygın saldırı yöntemlerinden biri olan XSS ataklarına karşı sitenizi koruyacak bir kod parçacığı.

# Blocks some XSS attacks
<IfModule mod_rewrite.c>
RewriteCond %{QUERY_STRING} (\|%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]
</IfModule>

06 – WordPress Dosyalarına Erişimi Engelleyin

Wp-includes dosyası sitenizin beyni niteliğindedir. Bu klasöre kimsenin erişmesi gerekmez dolayısıyla bu dosyaya erişimi kısıtlamak yapılabilecek en doğru hareketlerden bir tanesi.

# Blocks all wp-includes folders and files
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^wp-admin/includes/ - [F,L]
RewriteRule !^wp-includes/ - [S=3]
RewriteRule ^wp-includes/[^/]+\.php$ - [F,L]
RewriteRule ^wp-includes/js/tinymce/langs/.+\.php - [F,L]
RewriteRule ^wp-includes/theme-compat/ - [F,L]
</IfModule>

07- Önemli WordPress Dosyalarını Güvenli Hale Getirin

<FilesMatch "^.*(error_log|wp-config\.php|php.ini|\.[hH][tT][aApP].*)$">
Order deny,allow
Deny from all
</FilesMatch>

08 – /wp-content/’i koruyun

Bunun için aşağıdaki kodları wp-content klasörünün içerisindeki .htaccess dosyasına ekleyin böyle bir dosya yoksa oluşturun.

Order deny,allow
Deny from all
<Files ~ ".(xml|css|jpe?g|png|gif|js)$">
Allow from all
</Files>

Yorum Yap
Bir Cevap Yaz

Wordpress Tema

kanews-wordpress-tema

Kanews — Wordpress Haber Teması

geoit-wordpress-tema

Geoit — Wordpress Blog&Magazine Teması

wordpress-e-ticaret-tema

Ticikan - E-Ticaret Wordpress Teması

spixer-wordpress-tema

Spixer — Wordpress Blog&Magazine Teması

dilhun-wordpress-tema

Dilhun - Çok Amaçlı Wordpress Kurumsal Teması

gmedia-wordpress-tema

Gmedia — Ücretsiz Wordpress Tema