Recovering from a WordPress Spam Injection attack is not fun, but you can regain your Google Search Results after being hacked by a spam injection attack.

The best policy with Google is to be specific in your explanations. You will need to make sure that you have removed all bad files from your server and then contact Google again explaining what actions you have taken to resolve the situation and submit your “request for reconsideration”. In most cases where a valid site has been hacked Google will restore their sites rankings within two weeks. However, don’t expect any notifications from Google on their progress of reevaluating your website or WordPress blog. I am writing this article in hopes that it will help anyone from having to go through that processs.

What should you look for if you suspect a WordPress Spam Injection Attack?

The first thing you should look for is a list of spammy keywords showing up in your list of keywords located in your Google Webmasters Tools. If you aren’t using Google Webmaster Tools then you should definitely look into this. When your site starts showing up in weird looking search results, which can also be seen in Google Webmaster Tools under search results for your site, you need to act fast because at this point Google will act fast to remove your site from SERPS in order to protect others who may be at risk from visiting your website.

The key to detection is awareness. Be vigilant in monitoring your website and your website’s stats. Spam injections are a clever, effective form of hacking and show no outward signs of infection. However, If you do a Google Site Search for spammy key words like; { viagra} you will be able to see if your site is referencing spam keywords. You will not be able to see spam showing up on your site. In order to physically see spam tags in your site you must go to the “cached” version of your web pages and view them in “text mode”. If you’ve been infected you will now be able to see spam keywords, usually appearing as a footer.

What does a Spam Injection Do?

Spam Injection software hides spam keyword links in code that is usually encoded with a PHP function that effectively scrambles html to be decoded once safely embedded on your server, database, etc. You won’t see these files decoded, but the Google Bot and other bots will when crawling your site! Once the Bots access the code the spam injection software has done it’s work, effectively stealing your search index to improve their own pagerank.

These spam injection hacks are very hard to detect software injections inserted into your site, usually on a database level, via templates or plugins. This is part of the reason WordPress is such a target for these attacks. Plugins are what make WordPress so dynamic and cool, but they are an open doorway for spam injection software. For obvious reasons we should all focus our attention on prevention so that you don’t have to deal with detection.

What can I do to prevent a WordPress Spam Injection Attack?

I’ll start with the simplest things you can do to protect your WordPress blog or site from spam attacks first. . .

First:  Update WordPress

Updating WordPress is the easiest thing to do, so why not do it? I usually wait a short period of time after a new release to make sure the bug fixes have been worked out. Please be aware that simply updating WordPress is NOT enough!

Second: Pick a good password

Pick a good password. Don’t use the same password on every site. If you’re really diligent  you can also change your password regularly.

Third: Change the admin user name

The default WordPress user name is “admin”. This is just a guess, but I suspect that the majority of people never change this. Don’t give any information away. Hackers are clever, but like burglars they would rather move on to the easy score. You can change your admin by creating a new user and then deleting the admin user. You’ll be given the option to migrate posts to another user.

Fourth: Hide your WordPress Version Number

David Kierznowski of lately released a simple plugin to hide your wordpress installation version number.  The no version plugin is a simple plugin that will replace the version number with blanks, so anyone doing a view “page source” from the browser on your site will not be able to see your wordpress version.

Fifth: Protect your plugins

Plugins are the easy gateway way for hackers to access your blog. All WordPress files begin with (wp-) by default so, hackers can quickly discover which plugins you’re using by going to /wp-content/plugins/, if you haven’t renamed your database files. A quick remedy to block  a blank index.html file in the wp-content/plugins/ folder.

More Complex Procedures:

First: Protecting your WP-Config file.

This file contains your database name, database username and database password. Obviously, you don’t want anyone to have access to something this valuable. If you don’t feel comfortable making changes to your config you may want to contact your hosting company for help otherwise you can add the following code to your .htaccess file:

1. # protect wpconfig.php
2. {files wp-config.php}
3. order allow,deny
4. deny from all
5. {/files}

Second: Change your database names

Note: do not attempt this unless you are comfortable with PHPMyAdmin and making changes to MySQL. If you are not comfortable with this you should hire a professional to assist you.

Begin by backing up your database!

Many people have problems with the database table name prefix changing functionality of WP Security Scan. You can manually change your database names following the instructions below.

1. BACKUP your WordPress database to a sql file – you can do this in “phpmyadmin”.
2. You should Deactivate your plugins as a precaution before proceeding. You can reactivate them after you have finished.
3. Make a copy of the .sql file you created, then you can open the .sql file and use a text editor to find and replace all “wp_” prefix to “rename_”.
4. Now, drop all tables of your WordPress databases, but DO NOT drop the database.
5. import the (.sql) file that you have just edited into your wordpress databases.
6. Finish by editing your wp-config.php file and change the $table_prefix = ‘wp_’; to $table_prefix = ’something_’;