Herself's Webtools

Scripts, HowTos, Templates, Plugins, Widgets, Tips

WordPress Security Plugin – block scrapers, hackers, and more





** 11/2011 Security patch

** 9/2011 Fixed problem with logs not being generated and fixed re-direct loop. Problem visitors now sent a 404 not found

** 8/2011 Added install and uninstall functions, cleaned up user interface and code Current version now 3.0

** 2/19/2011 Streamlined and sped up the security plugin. Current version now 2.6

** 12/20/2009 Two updates, the first one is a fix, the second makes some speed improvements and makes the plugin a bit more SEO friendly. Bots now get re-directed to main page of your site instead of an error page. Current version 2.5 And many thanks to Elites0ft.com who took the time to point out a flaw to me so I could get it rapidly patched and out the door. Check them out if you are looking for web security, seo or web development help.

** 2/1/2009 1.10 is the current version –

** 12/24/2008 Some IE users were having problems seeing log files in WP 2.7 so changed formatting

** 7/15/2008 Turn off the security script while you do the WP 2.6 update

** 7/25/2008 I added a white list how to blog entry for those of you wanting to white list some ip numbers.

This is part 2 of a 3 part security suite for WordPress. This part blocks cross-site script attempts, ip numbers of ill behaved people and bots and bans bad user agents. Since trouble is always changing this plugin allows you to adjust who you want to block. I’ve started you out with every bad bot I caught on my site this past month. You can remove bots, add bots and add and remove ips and requests.

Many internet websites list bad bots, or you can just watch your access-logs to see who is causing problems on your site. Several tools for finding weaknesses in your WP to hack are blocked and you can add more to the list as new ones appear on the net.

Cross site scripting attacks often contain .txt? .txt?? .txt??? or ?_wp_http_referer in the request. If new cross site scripts show up, you can easily add them to the list.

Anyone who’s bot or request shows up on your black list has his ip automatically added to your blacklisted ip list.

This plugin creates a page under ‘Manage’. On it you can blacklist ip numbers, user agents, and requests that you don’t want on your site.

If you have the TTC User Registration Bot Detector installed, both plugins will use the same bad ip list to make things easier for you.

The management page will also give you a list of all attempts at registration and if they were bounced and why.

I changed the ip checking part of the plugin so you can now block multiple ip numbers, not just individual ips.  Just add the ip blocks to your list like this:

to block 225.255.255.0 to 225.255.255.255

add
225.255.255.

You can also block everything from 225.255.0.0 to 225.255.225.225
225.225.

and
225. blocks everything beginning with 225.

It is good to end each number ( except the last ) with a dot like so:
225.

If you just put 150.15  you block every thing from 150.15.x.x to 150.151.x.x, 150.152.x.x. &c

There are directions in the plugin in case you’d rather direct bots to an error page.

Download TTC WP Security plugin

You should also add an email address to the error page. Do not use your main email address. Just set up an extra email address and change the error page like so:


print “<html>\n”;
print “<head><title>Banned</title></head>\n”;
print “<body>\n”;
print “<h2>Banned: $blacklisted: $code</h2>\n”;
print “<p> Contact: <a href=\”mailto:timestocome@gmail.com\”>timestocome@gmail.com</a> if you have questions.”;
print “<p> Be sure to include your ip number “;
print “</body>\n”;
print “</html>\n”;


Or you can just totally customize the two error pages. One starts at line 145, the second at line 171. Look for “// print error page”

If you use quotes in your page for a link you must escape them. Use \” where you would normally use a ”

Part 1 – Block bots from registering on your blog

Part III Tripwire tells you which files have been recently altered

See also:
Requests I’m blocking for a current list of things to block
Bots I’m blocking for a current list of bots we block
Per request I added directions to send an HTTP Error code instead of an error page How to send an HTTP error code with PHP

More information:
Know your enemy: Web application threats
Secunia: WordPress security vulnerabilites
SQL Injection Cheat Sheet
Google Online Security Blog

  •      
  •      
  •      

  •      
  •      
  •      
  •