<?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>LlamaLabs &#187; Linux</title>
	<atom:link href="http://llamalabs.com/category/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://llamalabs.com</link>
	<description>Wisdom of the llama</description>
	<lastBuildDate>Thu, 03 Feb 2011 09:54:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Monitoring Your WordPress Administrator User List</title>
		<link>http://llamalabs.com/2009/09/05/monitoring-your-wordpress-administrator-user-list/</link>
		<comments>http://llamalabs.com/2009/09/05/monitoring-your-wordpress-administrator-user-list/#comments</comments>
		<pubDate>Sun, 06 Sep 2009 07:23:47 +0000</pubDate>
		<dc:creator>kanske</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://llamalabs.com/?p=97</guid>
		<description><![CDATA[Overview Many WordPress attacks will create a backdoor WordPress account that has administrative privileges. One way to tell if your WordPress instance has been compromised is to check for the presence of an administrator account that you did not add. The latest WordPress worm, as described in Matt Mullenweg&#8217;s recent post titled How to Keep [...]]]></description>
			<content:encoded><![CDATA[<h1>Overview</h1>
<p>Many WordPress attacks will create a backdoor WordPress account that has administrative privileges. One way to tell if your WordPress instance has been compromised is to check for the presence of an administrator account that you did not add.</p>
<p>The latest WordPress worm, as described in Matt Mullenweg&#8217;s recent post titled <a href="http://wordpress.org/development/2009/09/keep-wordpress-secure/">How to Keep WordPress Secure</a>, uses javascript on the user page to hide the backdoor administrator account. It&#8217;s not enough to log in and check the list of users. You need to check the database itself.</p>
<p><a href="http://dougal.gunters.org/blog/">Dougal Campbell</a> had a good post, <a href="http://dougal.gunters.org/blog/2009/09/05/checking-your-wordpress-security">Checking Your WordPress Security</a>, that talks about how to find the current list of accounts having administrative privileges in your WordPress instance. He provided an SQL query that you could run to get the list.</p>
<p>I&#8217;d rather have an email sent to me if the list of administrators changes, rather than having to check manually. I created a simple setup that checks my database every 10 minutes and sends me an email if the list changes. It checks to see if new administrator accounts are added and also checks to see if one was removed and replaced.</p>
<h1>Security</h1>
<p>At first I thought I could use the WordPress environment itself to make database access easier, but I realized that by doing so I could potentially run compromised code. I chose to directly connect to the database using the credentials in wp-config.php and run my queries using the mysql_* PHP functions.</p>
<h1>Implementation</h1>
<h3>Directory Structure</h3>
<p>First I got the directory structure in place. As root:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">mkdir /root/etc
mkdir /root/bin</pre></div></div>

<h3>Files</h3>
<ul>
<li>admin_list_common.php &#8211; Common Code &#8211; This code is shared by the other two utilities.</li>
<li>check_admin_list.php &#8211; Admin List Checker &#8211; This checks to see if the current list of admins matches the known good list.</li>
<li>create_admin_list_file.php &#8211; Admin List Creator &#8211; This script will create the initial list of admin users.</li>
</ul>
<h3>Common Include File</h3>
<p><b>IMPORTANT NOTE: Make sure to update the database variables to match your setup. At a minimum, you will need to modify $wordpress_docroot and the database credentials.</b></p>
<p>In <b>/root/bin/admin_list_common.php</b> I put this:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #000088;">$wordpress_docroot</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;/www/llamalabs.com/content&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$admin_list_file</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;/root/etc/myblog.wp_admin_list&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// get these variables from wp-config.php, which is in the document root for your blog.</span>
<span style="color: #000088;">$db_host</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;localhost&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$db_user</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;user&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$db_pass</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;password&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$db_name</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;db_name&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$db</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_connect</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$db_host</span><span style="color: #339933;">,</span> <span style="color: #000088;">$db_user</span><span style="color: #339933;">,</span> <span style="color: #000088;">$db_pass</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span> <span style="color: #000088;">$db</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Unable to connect to DB: &quot;</span> <span style="color: #339933;">.</span> <span style="color: #990000;">mysql_error</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #990000;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span> <span style="color: #990000;">mysql_select_db</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$db_name</span><span style="color: #339933;">,</span> <span style="color: #000088;">$db</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Unable to select db: &quot;</span> <span style="color: #339933;">.</span> <span style="color: #990000;">mysql_error</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #990000;">exit</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// based off of get_users_of_blog in wp-includes/user.php</span>
<span style="color: #000000; font-weight: bold;">function</span> get_admin_users<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$db</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$sql</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT um.user_id AS ID, u.user_login &quot;</span>
         <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;FROM wp_users u, wp_usermeta um &quot;</span>
         <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;WHERE u.ID = um.user_id &quot;</span>
         <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;    AND um.meta_key = 'wp_capabilities' &quot;</span>
         <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;    AND um.meta_value LIKE '%administrator%' &quot;</span>
         <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;ORDER BY um.user_id&quot;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$res</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$sql</span><span style="color: #339933;">,</span> <span style="color: #000088;">$db</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span> <span style="color: #000088;">$res</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Could not execute query: &quot;</span> <span style="color: #339933;">.</span> <span style="color: #990000;">mysql_error</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #990000;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">mysql_num_rows</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$res</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000088;">$users</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$row</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_fetch_assoc</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$res</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$users</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$row</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$users</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> get_prev_admin_users<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$admin_list_file</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$fp</span> <span style="color: #339933;">=</span> <span style="color: #990000;">fopen</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$admin_list_file</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;r&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span> <span style="color: #000088;">$fp</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">echo</span>  <span style="color: #0000ff;">&quot;Error opening file.<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #990000;">exit</span><span style="color: #009900;">&#40;</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span> <span style="color: #990000;">feof</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$fp</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$data</span> <span style="color: #339933;">.=</span> <span style="color: #990000;">fgets</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$fp</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">4096</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #990000;">unserialize</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$data</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<h3>Check Admin List</h3>
<p>In <b>/root/bin/check_admin_list.php</b> I put this:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #b1b100;">require_once</span> <span style="color: #0000ff;">'admin_list_common.php'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$prev_admin_users</span> <span style="color: #339933;">=</span> get_prev_admin_users<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$admin_users</span> <span style="color: #339933;">=</span> get_admin_users<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$prev_admin_users</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$admin_users</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    show_warning_and_exit<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$prev_admin_users</span><span style="color: #339933;">,</span> <span style="color: #000088;">$admin_users</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000088;">$admin_count</span> <span style="color: #339933;">=</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$admins</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span> <span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$admin_count</span> <span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$admin_users</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;ID&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">!=</span> <span style="color: #000088;">$prev_admin_users</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;ID&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        show_warning_and_exit<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$prev_admin_users</span><span style="color: #339933;">,</span> <span style="color: #000088;">$admin_users</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> show_warning_and_exit<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$prev_admin_users</span><span style="color: #339933;">,</span> <span style="color: #000088;">$admin_users</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Warning! The list of admin users differs.<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Current Admin Users<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
    print_admin_users<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$admin_users</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Previous Admin Users<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
    print_admin_users<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$prev_admin_users</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #990000;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> print_admin_users<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$admin_users</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$admin_count</span> <span style="color: #339933;">=</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$admin_users</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;------------------------------------<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span> <span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$admin_count</span> <span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;ID({<span style="color: #006699; font-weight: bold;">$admin_users</span>[<span style="color: #006699; font-weight: bold;">$i</span>][&quot;</span>ID<span style="color: #0000ff;">&quot;]}) user_login({<span style="color: #006699; font-weight: bold;">$admin_users</span>[<span style="color: #006699; font-weight: bold;">$i</span>][&quot;</span>user_login<span style="color: #0000ff;">&quot;]})<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<h3>Create Admin List File</h3>
<p>In <b>create_admin_list_file.php</b> I put this:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #b1b100;">require_once</span> <span style="color: #0000ff;">'admin_list_common.php'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$fp</span> <span style="color: #339933;">=</span> <span style="color: #990000;">fopen</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$admin_list_file</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'w'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span> <span style="color: #000088;">$fp</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Error opening file .<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #990000;">exit</span><span style="color: #009900;">&#40;</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000088;">$admin_users</span> <span style="color: #339933;">=</span> get_admin_users<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">fwrite</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$fp</span><span style="color: #339933;">,</span> <span style="color: #990000;">serialize</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$admin_users</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">===</span> <span style="color: #009900; font-weight: bold;">FALSE</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Cannot write to file (<span style="color: #006699; font-weight: bold;">$admin_list_file</span>)&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #990000;">exit</span><span style="color: #009900;">&#40;</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #990000;">fclose</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fp</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h3>Setup and Testing</h3>
<p>Run the command to populate the known list of admin accounts. Then verify that the file was created:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">[root@host bin]# php create_admin_list_file.php 
[root@host bin]# cat /root/etc/myblog.wp_admin_list 
a:3:{i:0;a:2:{s:2:&quot;ID&quot;;s:1:&quot;1&quot;;s:10:&quot;user_login&quot;;s:5:&quot;admin&quot;;}i...&lt;snipped&gt;
[root@host bin]#</pre></div></div>

<p>Run the check script and make sure you get an exit status of 0.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">[root@host bin]# php check_admin_list.php 
[root@host bin]# echo $?
0
[root@host bin]#</pre></div></div>

<p>Now, check to make sure that the check works. To do this you can erase the contents of the known good list, test, and then restore. Make sure you get an exit status of 1 from your check scrpt. This will cause cron to mail you the report.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">[root@host bin]# php check_admin_list.php 
Warning! The list of admin users differs.
&nbsp;
Current Admin Users
------------------------------------
ID(1) user_login(admin)
ID(2) user_login(bob)
ID(3) user_login(harry)
&nbsp;
Previous Admin Users
------------------------------------
ID() user_login()
&nbsp;
[root@host bin]# echo $?
1
[root@host bin]# php create_admin_list_file.php 
[root@host bin]# php check_admin_list.php 
[root@host bin]# echo $?
0
[root@host bin]#</pre></div></div>

<h3>Set up the Recurring Check</h3>
<p>Set up the crontab entry using the crontab command:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">crontab -u root -e</pre></div></div>

<p>The contents of my entry are:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">*/10 * * * * php /root/bin/check_admin_list.php</pre></div></div>

<h3>Final Notes</h3>
<p>It&#8217;s important to test your setup. Make sure that when you add a new admin account you are alerted about the change.</p>
<p>Some people may not want to run the check as root. That&#8217;s fine, simply set it up under a different account.</p>
<p>Make sure that cron emails for the user running the cron job are making it to your inbox. Alternatively you could use the PHP mail functions to send yourself an email with the warning.</p>
<p>If you have nonstandard table prefixes you will need to update the SQL queries to reflect your custom table prefixes.</p>
<p>If I didn&#8217;t have full root access (ie: shared hosting, etc), I&#8217;d look into whether or not my hosting provider gave me the ability to create cron jobs. If so, I&#8217;d use whatever facilities were available, keeping the files out of the document root for the site. Yes, you could run these php scripts under your document root, but you should obfuscate them and understand that it&#8217;s not as safe to do so.</p>
<p>If you have PHP installed in a non-standard location, make sure to specify the path as well as the binary name when editing your crontab.</p>
<p>If you&#8217;re not getting cron emails, check out your system&#8217;s maillog and other log files to see what&#8217;s happening.</p>
<p>If you do need to add a new administrator account and you get emails about the difference, simply run the create_admin_list_file.php file again in order to update your list of known admin accounts.</p>
<h3>Related Links</h3>
<ul>
<li><a href="http://wordpress.org/development/2009/09/keep-wordpress-secure/">http://wordpress.org/development/2009/09/keep-wordpress-secure/</a></li>
<li><a href="http://dougal.gunters.org/blog/2009/09/05/checking-your-wordpress-security">http://dougal.gunters.org/blog/2009/09/05/checking-your-wordpress-security</a></li>
<li><a href="http://www.news-hub.eu/2009/09/wordpress-blogs-under-hack-attack/">http://www.news-hub.eu/2009/09/wordpress-blogs-under-hack-attack/</a></li>
<li><a href="http://lorelle.wordpress.com/2009/09/04/old-wordpress-versions-under-attack/">http://lorelle.wordpress.com/2009/09/04/old-wordpress-versions-under-attack/</a></li>
<li><a href="http://secunia.com/advisories/product/6745/?task=advisories_2008">http://secunia.com/advisories/product/6745/?task=advisories_2008</a></li>
<li><a href="http://scobleizer.com/2009/09/05/i-dont-feel-safe-with-wordpress-hackers-broke-in-and-took-things/">http://scobleizer.com/2009/09/05/i-dont-feel-safe-with-wordpress-hackers-broke-in-and-took-things/</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://llamalabs.com/2009/09/05/monitoring-your-wordpress-administrator-user-list/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Wiping hard drives &#8211; DBAN &#8211; Darik&#8217;s Boot And Nuke</title>
		<link>http://llamalabs.com/2008/11/29/wiping-hard-drives-dban-dariks-boot-and-nuke/</link>
		<comments>http://llamalabs.com/2008/11/29/wiping-hard-drives-dban-dariks-boot-and-nuke/#comments</comments>
		<pubDate>Sun, 30 Nov 2008 07:55:26 +0000</pubDate>
		<dc:creator>kanske</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://llamalabs.com/?p=24</guid>
		<description><![CDATA[I recently went on a quest to find a tool to wipe four hard drives in some machines at work. I hadn&#8217;t wiped a drive in years, and was pleasantly surprised to get more than one suggestion for DBAN, or Darik&#8217;s Boot and Nuke. From http://www.dban.org/: Darik&#8217;s Boot and Nuke (&#8220;DBAN&#8221;) is a self-contained boot [...]]]></description>
			<content:encoded><![CDATA[<p>I recently went on a quest to find a tool to wipe four hard drives in some machines at work. I hadn&#8217;t wiped a drive in years, and was pleasantly surprised to get more than one suggestion for DBAN, or Darik&#8217;s Boot and Nuke.</p>
<p>From <a href="http://www.dban.org/">http://www.dban.org/</a>:</p>
<blockquote><p>
Darik&#8217;s Boot and Nuke (&#8220;DBAN&#8221;) is a self-contained boot disk that securely wipes the hard disks of most computers. DBAN will automatically and completely delete the contents of any hard disk that it can detect, which makes it an appropriate utility for bulk or emergency data destruction.
</p></blockquote>
<p>I&#8217;d have to say, it has definitely lived up to its name. I downloaded the ISO image, burned it to a CD and several unattended hours later I had four clean machines. You boot one, remove the CD, and move on to the next machine.</p>
<p>Now I just need to find a new home for these machines.</p>
]]></content:encoded>
			<wfw:commentRss>http://llamalabs.com/2008/11/29/wiping-hard-drives-dban-dariks-boot-and-nuke/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

