<?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>[blog.rayfoo] &#187; server administration</title>
	<atom:link href="http://blog.rayfoo.info/tag/server-administration/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.rayfoo.info</link>
	<description>Infosec, DFIR, tech geekery, thoughts and whatnot</description>
	<lastBuildDate>Wed, 25 Jan 2012 00:36:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>More automation needed</title>
		<link>http://blog.rayfoo.info/2010/07/more-automation-needed</link>
		<comments>http://blog.rayfoo.info/2010/07/more-automation-needed#comments</comments>
		<pubDate>Wed, 14 Jul 2010 15:25:04 +0000</pubDate>
		<dc:creator>ray</dc:creator>
				<category><![CDATA[Everything]]></category>
		<category><![CDATA[automation]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[server administration]]></category>
		<category><![CDATA[TODO]]></category>

		<guid isPermaLink="false">http://blog.rayfoo.info/?p=641</guid>
		<description><![CDATA[Although I've managed to configure the server such that there's a fair amount of automation for appropriate tasks (phone homes, automated monitoring and basic defenses), the time needed daily to monitor/maintain it still adds up...and is unreasonable collectively. Looks like I'll have to look into further automating some of the tasks...]]></description>
			<content:encoded><![CDATA[<p>Although I've managed to configure the server such that there's a fair amount of automation for appropriate tasks (phone homes, automated monitoring and basic defenses), the time needed daily to monitor/maintain it still adds up...and is unreasonable collectively.</p>
<p>Looks like I'll have to look into further automating some of the tasks...</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rayfoo.info/2010/07/more-automation-needed/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DNS rebinding defense with Nginx</title>
		<link>http://blog.rayfoo.info/2010/02/dns-rebinding-defense-with-nginx</link>
		<comments>http://blog.rayfoo.info/2010/02/dns-rebinding-defense-with-nginx#comments</comments>
		<pubDate>Fri, 26 Feb 2010 16:47:58 +0000</pubDate>
		<dc:creator>ray</dc:creator>
				<category><![CDATA[Everything]]></category>
		<category><![CDATA[DNS rebinding]]></category>
		<category><![CDATA[hardening]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[server administration]]></category>
		<category><![CDATA[web server]]></category>

		<guid isPermaLink="false">http://blog.rayfoo.info/?p=461</guid>
		<description><![CDATA[DNS rebinding's a particularly nasty attack, having similar characteristics as CSRF attacks where the user's browser can be used to access/attack sites on behalf of the attacker. I'm not going to describe how it works here, there's plenty of literature out there that talks about it.  And if that's not enough, Google Is Your Friend. [...]]]></description>
			<content:encoded><![CDATA[<p>DNS rebinding's a particularly nasty attack, having similar characteristics as CSRF attacks where the user's browser can be used to access/attack sites on behalf of the attacker.</p>
<p>I'm not going to describe how it works here, there's <a href="http://en.wikipedia.org/wiki/DNS_rebinding">plenty</a> of <a href="http://ha.ckers.org/blog/20091201/dns-rebinding-video/">literature</a> out there that talks about it.  And if that's not enough, <a href="http://www.google.com/search?q=dns+rebinding">Google Is Your Friend</a>.</p>
<p>One of the simpler ways to defend against it is to have the server only serve requests with legit Host headers, which is what <a href="http://en.wikipedia.org/wiki/DNS_rebinding#Protection">Wikipedia says</a> anyway.  (No I didn't edit that portion myself)  This can be simply done with virtual hosts (HTTP/1.1), and can work for servers serving one domain, or two, or three, or many many many.</p>
<p>For nginx, a default catchall virtual host might look like this:</p>
<pre><span style="color: #00ff00;">server {
    listen 80 default;
    server_name can-be-anything-not-served;

    access_log /path/to/log/weird/access.log;
    error_log /path/to/log/weird/error.log;

    root /path/with/only/an/empty/index/html/file;
    index index.html;
}</span></pre>
<p>Note that this is configured to be the default listener on port 80 for this virtual host.  Make sure your actual virtual host(s) configuration does <strong><em>not</em></strong> have the 'default' option.</p>
<p>The server_name can be anything other than the actual virtual host(s) that the server is serving on port 80.</p>
<p>I usually put nothing (only empty index.html files) in that root folder for this catchall virtual host,but you're free to put other files to serve indicators to your users, or just to taunt them when they get subjected to DNS rebinding attacks unknowingly.  Just kidding about the taunting.</p>
<p>With this default catchall virtual host in place, you have a simple yet effective defense against DNS rebinding attacks!  Now watch the attacks get thwarted like eggs against a steel wall.</p>
<p>Note that this is helpful in situations where you don't expect HTTP/1.0 requests, which is usually the case in today's world.  If you have a case where you have  work with HTTP/1.0 requests, then you really shouldn't use this defense method in the exact same manner.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rayfoo.info/2010/02/dns-rebinding-defense-with-nginx/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Restoration</title>
		<link>http://blog.rayfoo.info/2010/01/restoration</link>
		<comments>http://blog.rayfoo.info/2010/01/restoration#comments</comments>
		<pubDate>Mon, 11 Jan 2010 15:32:47 +0000</pubDate>
		<dc:creator>ray</dc:creator>
				<category><![CDATA[Everything]]></category>
		<category><![CDATA[server administration]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://blog.rayfoo.info/?p=389</guid>
		<description><![CDATA[Finally restored the blog in 2.5 hrs, after a stupid mistake following a botched WordPress install. Lesson learnt: even if tools like WordPress Automatic Upgrade helps you to perform backups, make sure you know everything is backed up before you do a delete! Even though all the posts have been restored, I think I will [...]]]></description>
			<content:encoded><![CDATA[<p>Finally restored the blog in 2.5 hrs, after a stupid mistake following a botched WordPress install.</p>
<p>Lesson learnt: even if tools like WordPress Automatic Upgrade helps you to perform backups, make sure you know everything is backed up before you do a delete!</p>
<p>Even though all the posts have been restored, I think I will not restore any more of the lost images, so there.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rayfoo.info/2010/01/restoration/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Verifying rkhunter file warnings</title>
		<link>http://blog.rayfoo.info/2009/10/verifying-rkhunter-file-warnings</link>
		<comments>http://blog.rayfoo.info/2009/10/verifying-rkhunter-file-warnings#comments</comments>
		<pubDate>Mon, 12 Oct 2009 06:46:26 +0000</pubDate>
		<dc:creator>ray</dc:creator>
				<category><![CDATA[Everything]]></category>
		<category><![CDATA[detection]]></category>
		<category><![CDATA[Finnix]]></category>
		<category><![CDATA[hardening]]></category>
		<category><![CDATA[rkhunter]]></category>
		<category><![CDATA[rootkit]]></category>
		<category><![CDATA[scripts]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[server administration]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://blog.rayfoo.info/?p=250</guid>
		<description><![CDATA[I got this problem as my rkhunter installation detected changed files (due to updates), so I encountered this solution by steve as I was searching for a solution. Of course, as there could be a root kit/trojan/malicious stuff running in your system as rkhunter's meant to detect, you should NOT fully trust anything running from [...]]]></description>
			<content:encoded><![CDATA[<p>I got this problem as my <a href="http://www.rootkit.nl/projects/rootkit_hunter.html">rkhunter</a> installation detected changed files (due to updates), so I encountered this <a href="http://www.shuningbian.net/2009/06/dealing-with-rkhunter-warnings.php">solution</a> by <a href="http://www.shuningbian.net/">steve</a> as I was searching for a solution.</p>
<p>Of course, as there could be a root kit/trojan/malicious stuff running in your system as rkhunter's meant to detect, you should NOT fully trust anything running from the machine.  But I had to rely on this solution temporarily until I can get it (rebooted and) checked out proper using a tool like <a href="http://www.finnix.org/">Finnix</a>.<br />
Am reposting the script here for reference, but you can get the most recent copy of the script <a href="http://git.pictorii.com/?p=scripts.git;a=blob_plain;f=verify.sh;hb=rei">here</a> .<br />
<span id="more-250"></span></p>
<p>
<pre style="color:green">#!/bin/bash
desc="
This script will verify whether files for which rkhunter has logged a
warning for is still valid. It does this by finding which debian package
it came out of, and downloads them, unpacks them, then checks
the checksums.

Run it by supplying a rkhunter log file as first argument
"

HASHER="sha256sum"

IFS="
"
function find_suspect_files
{
	echo "parsing $1 for suspect files" 1>&#038;2
	grep -1 Warning "$1"| grep File | sed 's|.*File: ||'
}

function find_packages
{
	echo "finding packages" 1>&#038;2
	for suspect_file in $1
	do
		package=$(dpkg -S $suspect_file|awk '{print $1}'|sed 's/.$//')
		echo "suspect file $suspect_file found in $package" 1>&#038;2
		echo $package
	done

}

function make_aptitude_args
{
	echo "generating aptitude arguments" 1>&#038;2
	for package in $1
	do
		version=$(dpkg -p $package | grep Version | awk '{print $2}')
		echo $package=$version
	done
}

function cleanup
{
	echo "cleaning up"
	popd
	rm -rf tmp
	exit $1
}

function setup
{
	echo "setting up"
	rm -rf tmp
	mkdir tmp
	pushd tmp
}

if [ $# -ne 1 ];
then
	echo "$desc"
	exit 1
fi

suspect_files=$(find_suspect_files "$1")

packages=$(find_packages "$suspect_files" | sort | uniq)

if [ -z "$packages" ];
then
	echo "***WARNING****"
	echo "No packages contain any of the suspect files!"
	cleanup 1
fi

aptitude_args=$(make_aptitude_args "$packages")

setup

echo "downloading packages"
aptitude download $aptitude_args 1>/dev/null
if [ $? -ne 0 ];
then
	echo "aptitude download failed!"
	echo "args=$aptitude_args"
	cleanup 1
fi

echo "unpacking"
for deb_file in *.deb
do
	ar -x $deb_file
	tar zxf data.tar.gz
	rm -rf data.tar.gz control.tar.gz
done

for suspect_file in $suspect_files
do
	if [ ! -f ".$suspect_file" ]
	then
		echo "***WARNING****"
		echo "For some reason .$suspect_file does not exis!"
		continue
	fi
	echo -n "verifying $suspect_file... "
	suspect_sum=$($HASHER $suspect_file | awk '{print $1}')
	clean_sum=$($HASHER ".$suspect_file" | awk '{print $1}')
	if [ $suspect_sum == $clean_sum ];
	then
		echo "OK"
	else
		echo
		echo "***WARNING****"
		echo "Checksum mistmatch for $suspect_file!!!"
		echo "Should be: $clean_sum"
		echo "Is: $suspect_sum"
	fi
done
cleanup</pre></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rayfoo.info/2009/10/verifying-rkhunter-file-warnings/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting your server to send an email whenever anyone logs in</title>
		<link>http://blog.rayfoo.info/2009/09/getting-your-server-to-send-an-email-whenever-anyone-logs-in</link>
		<comments>http://blog.rayfoo.info/2009/09/getting-your-server-to-send-an-email-whenever-anyone-logs-in#comments</comments>
		<pubDate>Tue, 29 Sep 2009 16:32:18 +0000</pubDate>
		<dc:creator>ray</dc:creator>
				<category><![CDATA[Everything]]></category>
		<category><![CDATA[CLI]]></category>
		<category><![CDATA[email notification]]></category>
		<category><![CDATA[hardening]]></category>
		<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[Linode]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[server administration]]></category>

		<guid isPermaLink="false">http://blog.rayfoo.info/?p=141</guid>
		<description><![CDATA[Running on a VPS like Linode give me plenty of control over what is run, and also plenty of chances to learn more about network administration (along with the heartaches). The code that I used was based from this forum post. This one presumes that your MTA has been setup properly. The original code was [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.linode.com/?r=b1394ed1dfb7ce948e9dadb668234b2e69a2c274"><img class="alignright size-full wp-image-142" title="Linode" src="http://blog.rayfoo.info/wp-content/uploads/2009/09/rubyinside-ad1-310x90.png" alt="rubyinside-ad1-310x90" width="310" height="90" /></a>Running on a VPS like <a href="http://www.linode.com/?r=b1394ed1dfb7ce948e9dadb668234b2e69a2c274">Linode</a> give me plenty of control over what is run, and also plenty of chances to learn more about network administration (along with the heartaches). <img src='http://blog.rayfoo.info/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<p>The code that I used was based from this <a href="http://www.linode.com/forums/archive/o_t/t_1358/securing_your_linode.html">forum post</a>.  This one presumes that your MTA has been setup properly.  The original code was for protecting your root account (i.e. when anyone logs into your server's root account, you get the notification).</p>
<p>(Note: it is usually not advisable to login as root.  Create a user account and give it sudoer rights instead.  I'd say that's advisable even for servers where there is only one person expected to login, which is you.)<br />
<span id="more-141"></span><br />
&nbsp;</p>
<h1>Protect only the root account</h1>
<p>If you want to protect only the root account, edit the file <code>/root/.bash_profile</code> or <code>/root/.profile</code> (the bash profile file takes precedence)</p>
<p>Add this line at the end:<br />
<code>echo 'ALERT - Root Shell Access on:' `date` `who` | mail -s "Alert: Root Login from `who | awk '{print $6}'`" youremailaddresshere</code><br />
&nbsp;</p>
<h1>Protect all accounts</h1>
<p>If you want to protect ALL accounts, which is better for high security requirements, or for paranoid people like me, you edit the <code>/etc/profile</code> file instead. (you will need root priviledges for this)</p>
<p>For me, I used this instead of the previous command:<br />
<code>echo 'ALERT - Shell Access:' `date` `who` | mail -s "Alert: Shell Access from `who | cut -d"(" -f2 | cut -d")" -f1`" youremailaddresshere</code></p>
<p>With this, you'll get a notification whenever anyone logs in.  The downside to this is that you may get too many emails on a server that has plenty of people logging in.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rayfoo.info/2009/09/getting-your-server-to-send-an-email-whenever-anyone-logs-in/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

