Blokace spammerů

Jednoduchý skript Spammer Blocker vám pomůže s blokací spammerů a jiných nepohodlných návštěvníků. Ač to může znít absurdně, k jeho slátání mě donutila nehorázná lenost, která mě do jisté míry ovládá a ovlivňuje mé rozhodování. Už mě přestalo bavit manuálně blokovat IP adresy drzých spammerů, kteří […]

WordPress plugin Extra Security

Zhruba měsíc po vydání pluginu Validation Helper přináším další kousek. Extra Security slouží k lepšímu zabezpečení vašeho blogu. Tentokrát jsem si s ním dal trochu více práce a neodbyl jsem jej.
Plugin je v podstatě velmi jednoduchý. Do souboru .htaccess v rootovském adresáři a zdrojových kódů aktivní šablony přidává různé kódy, které znemožňují […]

Vyladění nové instalace WordPressu

Nastavení .htaccess

Zabezpeční souboru wp-config.php


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

Adresa vždy bez www


RewriteEngine on
Options +FollowSymlinks
RewriteCond %{HTTP_HOST} ^www.domena.cz
RewriteRule (.*) http://domena.cz/$1 [R=301,QSA,L]

Adresa vždy s www


RewriteEngine on
Options +FollowSymlinks
RewriteCond %{HTTP_HOST} ^domena.cz
RewriteRule (.*) http://www.domena.cz/$1 [R=301,QSA,L]

Zákaz výpisu obsahu adresářů


Options -Indexes

Odstranění „rubriky“ z url


RewriteRule ^category/(.+)$ http://www.domena.cz/$1 [R=301,L]

(ev. použijeme plugin „No category base“:45)

Robots.txt

Zákaz přístupu do adresářů WordPressu robotům a uvedení odkazu na sitemap


User-agent: *
Disallow: /cgi-bin/
Disallow: /wp-admin/
Disallow: /wp-includes/
Disallow: /wp-content/
Disallow: /trackback/
Disallow: /xmlrpc.php
Disallow: /wp-

Sitemap: http://domena.cz/sitemap.xml

Pro vytvoření sitemapy použijeme plugin „Google XML Sitemaps“:219

Nastavení „user-friendly“ odkazů

Nastavení > Trvalé odkazy > Vlastní struktura: /%postname%/

Vytvoření a odkaz na favicon

1. Vytvoříme *favicon.ico* (např. zde nebo zde
3. Zkopírujeme ho do rootu našeho blogu
2. Umístíme do hlavičky v souboru *header.php*


<link rel="shortcut icon" href="<?php bloginfo('url'); ?>/favicon.ico" />

Blocks script injections

The following code blocks script injections and any attempts to modify the PHP GLOBALS and _REQUEST variables.


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]

Hot-linking protection


RewriteEngine On
#Replace ?mysite\.com/ with your blog url
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?mysite\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
#Replace /images/nohotlink.jpg with your "don't hotlink" image url
RewriteRule .*\.(jpe?g|gif|bmp|png)$ /images/nohotlink.jpg [L]

Odstranění verze WordPressu

Paste the following lines of code in the functions.php file of your theme:


function wp_remove_version() {
return '';
}
add_filter('the_generator', 'wp_remove_version');

Disable eval:

This can be done with a PHP Extension called Suhosin; the Suhosin configuration can be edited within your php.ini file.


suhosin.executor.disable_eval = On

Další doporučená nastavení souboru .htacess
6 .htaccess Tricks for Better WordPress SEO & Security

Firewall – prevence před napadením

WordPress Firewall
http://www.seoegghead.com/software/wordpress-firewall.seo

This WordPress plugin investigates web requests with simple WordPress-specific heuristics to identify and stop most obvious attacks. There exist a few powerful generic modules that do this; but they’re not always installed on web servers, and difficult to configure.

It intelligently whitelists and blacklists pathological-looking phrases based on which field they appear within in a page request (unknown/numeric parameters vs. known post bodies, comment bodies, etc.). Its purpose is not to replace prompt and responsible upgrading, but rather to mitigate 0-day attacks and let bloggers sleep better at night.

* Detect, intecept, and log suspicious-looking parameters — and prevent them compromising WordPress.
* Also protect most WordPress plugins from the same attacks.
* Optionally configure as the first plugin to load for maximum security.
* Respond with an innocuous-looking 404, or a home page redirect.
* Optionally send an email to you with a useful dump of information upon blocking a potential attack.
* Turn on or off directory traversal attack detection.
* Turn on or off SQL injection attack detection.
* Turn on or off WordPress-specific SQL injection attack detection.
* Turn on or off blocking executable file uploads.
* Turn on or off remote arbitrary code injection detection.
* Add whitelisted IPs.
* Add additional whitelisted pages and/or fields within such pages to allow above to get through when desirable.

Změna defaultního wp_ prefixu tabulek

Table Prefix Rename
http://www.seoegghead.com/software/wordpress-table-rename.seo

This WordPress plugin facilitates renaming all WordPress tables with a custom prefix. Why do that?

Well, it turns out that the majority of exploits we’ve seen against WordPress-based web sites (this one and those for clients) have a very simple signature — they attempt SQL injection attacks with the assumption that the table prefix is set to „wp_.“ So why not just change the prefix?

Now this is nothing new, and other people have written it up or made plugins. But they require that one make the changes manually and/or live. Our version does the following in 2 easy steps with a button-click for each:

1. Creates a duplicate set of tables with the same structure/schema.
1a. Copies a coherent version of the old tables to the new tables.
1b. Makes a few changes to the data in the new tables with regard to the new table names.
(all the while showing all executed queries to keep you informed).

2. Swaps to the newly-created set of tables.