O NOES!!!1!

In the interests of full disclosure, I’d like to announce that my blog was cracked into in the wee hours of the morning (PDT) two Saturdays ago (9/21/2007). I have yet to figure out the vector the crackers used to compromise my blog, but I will repost the details that I have found out so that others may be on their guard against such attacks.

Here’s how I figured out I’d been cracked.

As you may already know, the theme that I am currently running is one that I developed myself (and even plan to release some day…) and so I constantly tinker with its innards. I keep all of the code in a Subversion repository and make semi-regular check-ins in the interests of keeping myself honest and making sure that I don’t lose old changes.

Last Saturday (9/28), I noticed that my copyright statement in footer.php was still referring to 2007, so I quickly edited the file and then did an `svn status` prior to committing my revision. I usually execute a status before committing so that I can recall which files I’ve touched and thus present more meaningful commit log messages. When I executed the status, I noticed something a little funny:

$ svn status
?      functions2.php
?      2590.php
?      styles/phskyline
?      styles/move
?      styles/index.html
?      styles/phskyline.css
?      styles/default/phillyskyline.jpg
M      footer.php
?      layouts/index.php
?      images/o.txt
?      images/faq.php

Note the last two lines — I certainly did. (For you svn newbs out there: the “?” means that Subversion doesn’t know about the files, the “M” means that the file is locally modified) The other files I expected to see there, as I have a couple of page-/post-specific files (2590.php, functions2.php) that I use as templates for my blog alone and thus would be of no use to others and the others were either abandoned or nowhere near complete custom templates. I was 100% certain, however, that I had not created anything in the images directory in a long time. My curiosity aroused, I issued an `svn diff` and noted the following output (pay attention to line 10):

$ svn diff 
Index: footer.php 
--- footer.php (revision 131) 
+++ footer.php (working copy) 
@@ -63,6 +63,7 @@ 
	<div id="footercredits"> 
	<p><a href="<?php bloginfo('url'); ?>"><?php bloginfo('name'); ?></a> is powered by <a href="http://wordpress.org">WordPress</a> <?php bloginfo('version'); ?> and <a href="http://literalbarrage.org/blog/code/elbee-elgee">Elbee Elgee</a></p><p>&copy; 2006 Doug Stewart</p> 
	+<?php include('images/faq.php'); ?> 
	<?php /* Try. to understand */ ?>

Now I knew something fishy was afoot. I generally don’t just include() files willy-nilly and I was certain that I hadn’t thrown a “faq.php” into my images directory.

So I fired up vi and took a look at faq.php:

$gg_subnets = array ("" => 16, "" => 28, "" => 26, "" => 25, "" => 29, "" => 28, "" => 29, "" => 17, "" => 19, "" => 29, "" => 29, "" => 27, "" => 27, "" => 29, "" => 24, "" => 28, "" => 24, "" => 28, "" => 19, "" => 21, "" => 28, "" => 26, "" => 28, "" => 28, "" => 29, "" => 24, "" => 28, "" => 28, "" => 28, "" => 28, "" => 29, "" => 28, "" => 24, "" => 28, "" => 29, "" => 20, "" => 28, "" => 19, "" => 29, "" => 29, "" => 24, "" => 29, "" => 24, "" => 29, "" => 29, "" => 24, "" => 29, "" => 29, "" => 24, "" => 24, "" => 29, "" => 18, "" => 29, "" => 29, "" => 24, "" => 29, "" => 24, "" => 24, "" => 24, "" => 21, "" => 29, "" => 29, "" => 21, "" => 24); 
$gg_cip = ip2long($_SERVER['REMOTE_ADDR']); 
$gg_show = 0; 
foreach ($gg_subnets as $gg_cnet => $gg_mask) { 
	if ($gg_cip>>(32-$gg_mask) == ip2long($gg_cnet)>>(32-$gg_mask)) { 
		$gg_show = 1; 
if ($gg_show) { 

Aha! Now we’re on to something! The above script appears to check incoming requests to the webpage for a known set of IPs/IP ranges and, if a known one is detected, it displays the contents of o.txt in-line. I will not reprint the contents of said file here, as that would give the dirty spammers the Google Juice they so obviously desire. Suffice it to say that there were links to 1) illegal MP3 sites 2) cigarette-vending sites and 3) sites offering cut-rate Viagra. If you’re really all that interested in the contents, drop me a line and I’ll send it along.

So we’ve got the what (two new files and an alteration of one of mine) and the why (propagation of spam links, potential markers for other blog spammers to note that my blog was compromisable) but I’m still without the how. In response to this breach, I’ve recently updated a lot of the security settings in my hosting environment to hopefully minimize any server-side cracks, I’ve upgraded WordPress to 2.3 (there’s a post in the works on that one…) and I’ve begun looking at my theme code in the hopes of removing any potentially dangerous bits from my own codebase. The offending code never made it into my code (r134 effectively nuked the issue), but I am heartily glad that I was using Subversion to keep track of my files, otherwise it could have been months before I noticed anything out of sorts.

If anyone out there has any further information on this particular scam operation (the Google search results I managed to find were very thin gruel indeed, revealing only two potentially compromised sites, one of which apparently already took care of the issue, as the flaw only shows up in the cached version of the page), please contact me ASAP. I’d like to get to the bottom of what’s going on here. Oh, and if your IP address shows up in that list, you got some ‘splainin’ to do, Lucy.


I’ve just discovered I’ve been hit by the same exact problem on several of my domains. I found one instance of the include-to-.txt and removed it. But spam links are still showing up. I’ve grepp’d my entire account for everything possible, and can’t find the culprit. Really really frustrating. Would love to know if this is a WP issue, or just general hackery (I’ve updated to WP2.5).

What version of WP were you running previously?

I’ve been operating under the assumption that the vector was WP’s XML-RPC interface, as that’s the only real point of entry for my setup (I also altered my admin password in an attempt to narrow down exploit holes).

It almost seemed as if the spammers in question got ahold of my login credentials somehow and used the Theme Editor to add the offending code.

Do either of you happen to use a plugin to stop multiple login attempts?

If not, it could be that they brute forced your password.

Blocking multiple logins is a bad idea, as some malefactor could well block you from your own blog simply by repeatedly attempting to log in as “admin”, thus denying you access.

coffee2code’s Last Logins plugin may be something to look into, as it at least logs all attempted logins, thus giving you an idea as to whether someone is attempting to get in and react in time (by changing passwords, etc.).

Literal Barrage is Stephen Fry proof thanks to caching by WP Super Cache