<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>strottrot.com &#187; wordpress</title>
	<atom:link href="http://strottrot.com/topics/wordpress/feed/" rel="self" type="application/rss+xml" />
	<link>http://strottrot.com</link>
	<description>on user experience, usability, and access</description>
	<lastBuildDate>Fri, 06 Aug 2010 01:37:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>Recovering from a WordPress Spam Injection</title>
		<link>http://strottrot.com/2009/12/05/recovering-from-a-wordpress-spam-injection/</link>
		<comments>http://strottrot.com/2009/12/05/recovering-from-a-wordpress-spam-injection/#comments</comments>
		<pubDate>Sun, 06 Dec 2009 02:36:47 +0000</pubDate>
		<dc:creator>strottrot</dc:creator>
				<category><![CDATA[web development]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://strottrot.com/?p=226</guid>
		<description><![CDATA[I should have been relaxing and working on an inspirational side project, but instead spent much of Thanksgiving weekend trying to eliminate a senseless spam injection on a WordPress (wp) site. I was frustrated, to say the least, by how difficult it was to find a solution. There were many months-old unanswered pleas on the [...]]]></description>
			<content:encoded><![CDATA[<p>I should have been relaxing and working on an inspirational side project, but instead spent much of Thanksgiving weekend trying to eliminate a senseless spam injection on a WordPress (wp) site.</p>
<p>I was frustrated, to say the least, by how difficult it was to find a solution. There were many months-old unanswered pleas on the wp forums.</p>
<p>I cannot figure out the hackers&#8217; revenue model. Repeatedly over the course of two weeks, my husband’s site became unreliable to access. The symptoms were varied, including:</p>
<ol>
<li>The site never loads</li>
<li>Loading stalls and then redirects to a virus scanner software</li>
<li>The site is redirected to a Harry Potter related website</li>
<li>The site takes a long time to load and the source code shows approximately 30 links to enhancement-related drugs or movies. Each time the links are to a new single site, where the drug or movie is a variable at the end of the URL. The inserted code has a style of display:none; so it&#8217;s not visible to the naked eye. Nevertheless, it is available to search bots.</li>
</ol>
<p>For the first few days, the injection would take place in the form of #4 (invisible links) at the same time of day. Replacing the theme&#8217;s header.php erased the problematic code, returning the site to normal for the day. (I read of other situations where the injection is in the footer.) The ftp logs showed that /wp-content/themes/mytheme/header.php file was changed.<span id="more-226"></span></p>
<p>After the first few days, replacing header.php no longer solved the problem, and the injection switched over to being an evil redirect, taking our visitors elsewhere.</p>
<h3>Location of the Bad Code</h3>
<p>Eventually I found bad code in two files in /wp-content/uploads/2009/01/: topper.php and wp-pass.php. At least I think I did. It hasn’t come back in five days. The actual code was a base64-encoded 44,300+ character string starting with: &lt;?php $o=&#8221;QAE…(44,300 characters)…”  ==&#8221;));return;?&gt; This is apparently a variation on the ‘Goro’ hack, which <a href="http://robertogaloppini.net/2007/12/12/wordpress-spam-injection-goro-hacked-my-blog/">Roberto Galoppini explains</a> calls an external javascript code when decoded with base64_decode. My impression is that this bad code gets uploaded in any number of directories.</p>
<h3>Steps to Harden Off the WP install and Look for the Problem</h3>
<p>It took a while to eliminate the pernicious code. First steps included:</p>
<ol>
<li>Update WordPress. (I keep mine up-to-date, so this wasn’t the issue, but it’s a good first step if you’re facing this situation.)</li>
<li>Change the ftp password, the wp-admin password (strong passwords, different from each other)</li>
<li>Delete the wp-admin user ‘admin.’ (Create a new admin account and assign all of the posts, if needed, to this account.)</li>
<li>Disable any plugins that ping updates to sites like Google, Technorati, etc. until the problem is solved. (You don’t want to call their attention to the new spam.)</li>
<li>Remove any spammy looking registered users on the site. (They shouldn’t be able to do anything, but it seems like a good precaution.)</li>
<li>Move wp-config.php to the directory directly above WordPress install. (It will only work if it is a single directory above its original home.) This file stores the database username and password. [I assume this was the file that made the breach possible, but I don’t know for sure.]</li>
<li>Install the plugin <a href="http://www.seoegghead.com/software/wordpress-firewall.seo">SEO Egghead’s WordPress-firewall</a></li>
<li>Make sure there is a blank index.html file in the wp-content/plugins/ directory</li>
<li>Per <a href="http://www.articledashboard.com/Article/How-To-Detect-And-Prevent-A-Wordpress-Spam-Injection-Attack/1143555">Chris London’s spam injection advice</a>: Protect the wp-config.php file further by adding the following to your .htaccess file:
<ol>
<li># protect wpconfig.php</li>
<li>&lt;files wp-config.php&gt;</li>
<li>order allow,deny</li>
<li> deny from all</li>
<li> &lt;/files&gt;</li>
</ol>
</li>
<li>Hide your wordpress version number (<a href="http://www.wprecipes.com/how-to-hide-wordpress-version">instructions via WpRecipes</a>)<br />
In your theme’s functions.php file, add the following line:<br />
remove_action(&#8216;wp_head&#8217;, &#8216;wp_generator&#8217;);</li>
<li>I used the WordPress Admin upgrade tool to reinstall the current wp version. This removed the spam in the code, indicating that the script calling the code was showing up in a new location: a WordPress file and not a theme file.</li>
<li>I followed the steps at <a href="http://www.teohuiming.name/blog/wordpress-exploit">http://www.teohuiming.name/blog/wordpress-exploit</a> (reviewing db tables for potentially problematic entries in the options table, as well as *_(old|new).(php|giff|pngg) files in the directory structure). I could have had success in this step if I scoured through the wp-content/uploads/ folders for not just the file names and extensions listed but also for files that did looked suspect (topper.php and wp-pass.php, the culprits, definitely would have gotten my attention).</li>
<li>Finally, I did a fresh install of WordPress, and all plugins. A new database was created, as part of the process. I imported the old data. This potentially could bring the spam back in, but was worth at least a try to me. The site has a lot of photos managed through the wp plugin NextGEN Gallery. Reloading all of the photos would have been very time-consuming. The theme files and uploads were ftp’ed to the server. It was at this point that I scoured through the uploads folders and found the suspect files.</li>
</ol>
<p>It’s been almost two weeks now, with no sign of the injection. If you&#8217;re dealing with this: best wishes. If your site&#8217;s Google search ranking is suffering because of the spam links, see <a href="http://www.google.com/support/webmasters/bin/answer.py?answer=35843">instructions for requesting reconsideration</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://strottrot.com/2009/12/05/recovering-from-a-wordpress-spam-injection/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
