Categories: Tips & Tricks

WordPress Security Hacks

Hi guys this is my first post on wpcult the great site Austin built.  Hope you guys find it usefull.

If you run a blog using the wordpress software then your blog is a target to hackers.  Below I will list some hacks and just how they can help you keep your business/site safe.

The following is  code to Block Bad Queries and protect your blog from malicious URL Requests.

Place the following code into a text file and name it what ever you like for example blockbadqueries.php upload it to your plugin folder and activate it in your wordpress admin just as you would any other Plugin

<?php
/*
Plugin Name: Block Bad Queries
Plugin URI:
http://perishablepress.com/press/2009/12/22/protect-wordpress-against-malicious-url-requests/
Description: Protect WordPress Against Malicious URL Requests
Author URI:
http://perishablepress.com/
Author: Perishable Press
Version: 1.0
*/
global $user_ID; if($user_ID) {
  if(!current_user_can(‘level_10’)) {
    if (strlen($_SERVER[‘REQUEST_URI’]) > 255 ||
      strpos($_SERVER[‘REQUEST_URI’], “eval(“) ||
      strpos($_SERVER[‘REQUEST_URI’], “CONCAT”) ||
      strpos($_SERVER[‘REQUEST_URI’], “UNION+SELECT”) ||
      strpos($_SERVER[‘REQUEST_URI’], “base64”)) {
        @header(“HTTP/1.1 414 Request-URI Too Long”);
 @header(“Status: 414 Request-URI Too Long”);
 @header(“Connection: Close”);
 @exit;
    }
  }
}
?>

 This Great plugin was made by Jeff Starr of Digging into WordPress

 

 

Protecting your blog with .htaccess 

.htaccess files have lots of possibilities. below is some code that will help protect your wordpress from modification of _REQUEST and/or GLOBALS and scripts injection.

 This is real simple just paste the following code into your .htaccess file. Always make a backup of your .htaccess before editing, better to be safe.

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]

 

Thanks to Oussama for this great hack

Miguel

Well been working with computers since the mid 80's and online since the late 80's early 90's so I am one of the older guys even though I am only in my early mid 30's ;) I feel alot older , I have worked in many different fields and am currently running companies in Mexico that both secure government contracts and Finance, have been involved in the finance part of many projects over the last few years and have so far been succesfull in all endevors, don't get much free time but when I do I would like to start rebuilding this site that I bought from Austin,since I am not a programer I will probably be writing about all kinds of things wordpress, security, seo, marketing, making money online, hosting, news, technology, bussiness, social networking and what ever comes to mind, when ever I get the chance to blog

View Comments

  • Didn't know about the security issues with WordPress. Will upload your code right now. Cool that I can just upload some php script and activate it like a plugin.

    Yeah congratz on your first post here I am sure you will do a great job too.

  • These are pretty good hack for the security of wordpress blogs. I will try it in my blog. Thanks for sharing

  • Congratulations on your first post, what a great article to start with, most useful for wannbe bloggers so thanks for sharing.

  • I've been using Wordpress for my blogs and knowing that there are possibilities that it could be hack by someone. Then, your post is such a big help for me to do some security with my blogs. I should be thankful for your useful information. ;-)

  • Great advice, Miguel. I recently transferred from Blogger to Wordpress because of the hacker and spamming problems that I was having.

  • Hey there Miguel, just want to ask if these codes will also work on joomla 1.5 platform, since it's in php? Congratulations on your first post here by the way.

  • the hack is fixed,
    I even got an email from Godaddy telling me to upgrade my WP.

Recent Posts

Creating a custom widget

Today let's learn a simple quick trick on how to create a custom widget. For…

47 minutes ago

Display custom url if comment authors url is blank

Here is a nifty trick for your comments.php template. If someone comes to your site…

13 hours ago

Complete bbPress integration with BuddyPress

Looking for a tutorial on how this can be done?

1 day ago

Twitter avatars inside your WordPress comments

Ricardo Sousa, who writes for Smashing Magazine created a great plugin called Twittar. This plugin…

2 days ago