<?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>Drainbamage.nl</title>
	<atom:link href="http://drainbamage.nl/feed/" rel="self" type="application/rss+xml" />
	<link>http://drainbamage.nl</link>
	<description>blog of Christiaan Ottow</description>
	<lastBuildDate>Tue, 31 Aug 2010 08:56:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>The ELF file format</title>
		<link>http://drainbamage.nl/2010/08/the-elf-file-format/</link>
		<comments>http://drainbamage.nl/2010/08/the-elf-file-format/#comments</comments>
		<pubDate>Tue, 31 Aug 2010 08:56:27 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[UNIX/Security]]></category>

		<guid isPermaLink="false">http://drainbamage.nl/?p=260</guid>
		<description><![CDATA[I recently wrote a tutorial on the ELF format. It's in Dutch, and can be found here: http://hacking.certifiedsecure.com/showthread.php?63-Introductie-op-het-ELF-binary-format It deals with the structure inside an ELF file, the use of sections in binaries, and goes to show how one can disssect the /bin/ls binary using the tools readelf and objdump. Tweet This Post]]></description>
			<content:encoded><![CDATA[<p>I recently wrote a tutorial on the ELF format. It's in Dutch, and can be found here: </p>
<p><a href="http://hacking.certifiedsecure.com/showthread.php?63-Introductie-op-het-ELF-binary-format">http://hacking.certifiedsecure.com/showthread.php?63-Introductie-op-het-ELF-binary-format</a></p>
<p>It deals with the structure inside an ELF file, the use of sections in binaries, and goes to show how one can disssect the /bin/ls binary using the tools readelf and objdump. </p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=The+ELF+file+format+http://zrqcw.th8.us" title="Post to Twitter"><img class="nothumb" src="http://drainbamage.nl/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=The+ELF+file+format+http://zrqcw.th8.us" title="Post to Twitter">Tweet This Post</a></p>]]></content:encoded>
			<wfw:commentRss>http://drainbamage.nl/2010/08/the-elf-file-format/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DNS cache poisoning</title>
		<link>http://drainbamage.nl/2010/03/dns-cache-poisoning/</link>
		<comments>http://drainbamage.nl/2010/03/dns-cache-poisoning/#comments</comments>
		<pubDate>Wed, 31 Mar 2010 16:03:55 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[UNIX/Security]]></category>

		<guid isPermaLink="false">http://drainbamage.nl/?p=255</guid>
		<description><![CDATA[I recently gave a short presentation on DNS and cache poisoning. The slides can be found here. Enjoy. Dns Cache Poisoning View more presentations from Christiaan Ottow. Tweet This Post]]></description>
			<content:encoded><![CDATA[<p>I recently gave a short presentation on DNS and cache poisoning. The slides can be found <a href="http://www.slideshare.net/cottow/dns-cache-poisoning">here</a>. Enjoy.</p>
<div style="width:425px" id="__ss_3604257"><strong style="display:block;margin:12px 0 4px"><a href="http://www.slideshare.net/cottow/dns-cache-poisoning" title="Dns Cache Poisoning">Dns Cache Poisoning</a></strong><object width="425" height="355"><param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=dnscachepoisoning-100331105708-phpapp01&rel=0&stripped_title=dns-cache-poisoning" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=dnscachepoisoning-100331105708-phpapp01&rel=0&stripped_title=dns-cache-poisoning" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object>
<div style="padding:5px 0 12px">View more <a href="http://www.slideshare.net/">presentations</a> from <a href="http://www.slideshare.net/cottow">Christiaan Ottow</a>.</div>
</div>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=DNS+cache+poisoning+http://r98q4.th8.us" title="Post to Twitter"><img class="nothumb" src="http://drainbamage.nl/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=DNS+cache+poisoning+http://r98q4.th8.us" title="Post to Twitter">Tweet This Post</a></p>]]></content:encoded>
			<wfw:commentRss>http://drainbamage.nl/2010/03/dns-cache-poisoning/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pinta seems to be alive</title>
		<link>http://drainbamage.nl/2010/03/pinta-seems-to-be-alive/</link>
		<comments>http://drainbamage.nl/2010/03/pinta-seems-to-be-alive/#comments</comments>
		<pubDate>Thu, 25 Mar 2010 16:08:53 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[UNIX/Security]]></category>

		<guid isPermaLink="false">http://drainbamage.nl/?p=252</guid>
		<description><![CDATA[Last year, I wrote a tool called Pinta. It's an AMF debugging utility. One can use it the place calls to AMF (ActionScript Message Format) services, and observe the results. Normally, you'd need to create a Flash/Flex app to send these requests, but this is much quicker and easier for debugging your server-side service. I [...]]]></description>
			<content:encoded><![CDATA[<p>Last year, I wrote a tool called Pinta. It's an AMF debugging utility. One can use it the place calls to AMF (ActionScript Message Format) services, and observe the results. Normally, you'd need to create a Flash/Flex app to send these requests, but this is much quicker and easier for debugging your server-side service.</p>
<p>I didn't bother with the project after placing an initial version on <a href="http://code.google.com/p/pinta/">google code</a>, but this week I thought I might pick up development again. It occurred to me that few people writing AMF services will think through the security aspects of their service. You don't make service calls by hand, so it's easy for a developer to assume that only his app will be making calls. Wrong.</p>
<p>At least, that would be nice. As it turns out, the tool (which I've spent only 2 days on developing) is <a href="http://www.ivizsecurity.com/blog/web-application-security/testing-flash-applications-pen-tester-guide/comment-page-1/#comment-3364">already being recommended</a> for pentesting of AMF services. Which attests to the complete lack of tools, but still is nice <img src='http://drainbamage.nl/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>I'll be picking up development again and adding some fuzzing functionality. If you have any feedback, please leave it here or at the <a href="http://code.google.com/p/pinta/">google code project</a>!</p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=Pinta+seems+to+be+alive+http://4qfpt.th8.us" title="Post to Twitter"><img class="nothumb" src="http://drainbamage.nl/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Pinta+seems+to+be+alive+http://4qfpt.th8.us" title="Post to Twitter">Tweet This Post</a></p>]]></content:encoded>
			<wfw:commentRss>http://drainbamage.nl/2010/03/pinta-seems-to-be-alive/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Thumbnails too large with ImageMagick convert</title>
		<link>http://drainbamage.nl/2009/11/thumbnails-too-large-with-imagemagick-convert/</link>
		<comments>http://drainbamage.nl/2009/11/thumbnails-too-large-with-imagemagick-convert/#comments</comments>
		<pubDate>Thu, 19 Nov 2009 09:56:08 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[Web and Programming]]></category>

		<guid isPermaLink="false">http://drainbamage.nl/?p=244</guid>
		<description><![CDATA[Just a quick fix for a problem I ran into today. When using the ImageMagick "convert" command, my thumbnails were way to large. When resizing a large image to create a thumbnail, the thumbnail would be 41k while it should be around 4k. The input image was 1600x1200, 300DPI, 594k. After searching for a while, [...]]]></description>
			<content:encoded><![CDATA[<p>Just a quick fix for a problem I ran into today.</p>
<p>When using the ImageMagick "convert" command, my thumbnails were way to large. When resizing a large image to create a thumbnail, the thumbnail would be 41k while it should be around 4k. The input image was 1600x1200, 300DPI, 594k.</p>
<p>After searching for a while, I found that you shouldn't use the -scale or -resize option, but the -thumbnail option. This strips profile data from the image. Apparently, the image contains profile data which is left intact when resizing/scaling, but can be stripped with the thumbnail option.</p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=Thumbnails+too+large+with+ImageMagick+convert+http://596mm.th8.us" title="Post to Twitter"><img class="nothumb" src="http://drainbamage.nl/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Thumbnails+too+large+with+ImageMagick+convert+http://596mm.th8.us" title="Post to Twitter">Tweet This Post</a></p>]]></content:encoded>
			<wfw:commentRss>http://drainbamage.nl/2009/11/thumbnails-too-large-with-imagemagick-convert/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Compiling for AIR 1.5</title>
		<link>http://drainbamage.nl/2009/08/compiling-for-air-15/</link>
		<comments>http://drainbamage.nl/2009/08/compiling-for-air-15/#comments</comments>
		<pubDate>Mon, 24 Aug 2009 12:59:22 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[Web and Programming]]></category>

		<guid isPermaLink="false">http://drainbamage.nl/?p=231</guid>
		<description><![CDATA[When compiling an AIR application in Flex Builder for AIR 1.5, there are some pitfalls to reckon with. First, you need to install the Flex 3.3 SDK. If you're running an older Flex Builder, it will have 3.1 or 3.2 included. You can download the Flex SDK from Adobe here: http://www.adobe.com/cfusion/entitlement/index.cfm?e=flex3sdk. Be sure to also [...]]]></description>
			<content:encoded><![CDATA[<p>When compiling an AIR application in Flex Builder for AIR 1.5, there are some pitfalls to reckon with. </p>
<p>First, you need to install the Flex 3.3 SDK. If you're running an older Flex Builder, it will have 3.1 or 3.2 included. You can download the Flex SDK from Adobe here: <a href="http://www.adobe.com/cfusion/entitlement/index.cfm?e=flex3sdk">http://www.adobe.com/cfusion/entitlement/index.cfm?e=flex3sdk</a>. Be sure to also download the file labelled "ADOBE FLEX 3.3 DATA VISUALIZATION COMPONENTS FOR FLEX BUILDER".</p>
<p>After downloading, unzip the SDK somewhere and remember the location. Then, in Flex Builder, go to the preferences -> installed Flex SDKs -> Add. Enter the location of the SDK you unzipped.</p>
<p>Some of your apps might use classes that are no longer included with the SDK but bundled separately in the Flex Data Visualization Components you just downloaded. You will know this when you get an error like the following:</p>
<pre>1017: The definition of base class HierarchicalData was not found.</pre>
<p>Unzip the data visualization components zip, and move the swc and other files in it to the Flex 3 SDK dir in the fashion described in the readme. </p>
<p>Now, you need to change the namespace of the AIR app to 1.5. This is similar to setting the  target Flash Player version in a Flex project. It is done by editing the -app.xml file belonging to the project and changing the first line to:</p>
<pre>&lt;application xmlns="http://ns.adobe.com/air/application/1.5"&gt;</pre>
<p>If you get the following error: "error while loading initial content" when running an AIR app, you have upgraded your SDKs to 3.3 but not changed the namespace to 1.5.</p>
<p>Well, that's it, not so bad after all.</p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=Compiling+for+AIR+1.5+http://95man.th8.us" title="Post to Twitter"><img class="nothumb" src="http://drainbamage.nl/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Compiling+for+AIR+1.5+http://95man.th8.us" title="Post to Twitter">Tweet This Post</a></p>]]></content:encoded>
			<wfw:commentRss>http://drainbamage.nl/2009/08/compiling-for-air-15/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pinta &#8211; AMF debugger</title>
		<link>http://drainbamage.nl/2009/07/pinta-amf-debugger/</link>
		<comments>http://drainbamage.nl/2009/07/pinta-amf-debugger/#comments</comments>
		<pubDate>Thu, 23 Jul 2009 08:33:07 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[Web and Programming]]></category>
		<category><![CDATA[air]]></category>
		<category><![CDATA[amf]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[utility]]></category>

		<guid isPermaLink="false">http://drainbamage.nl/?p=229</guid>
		<description><![CDATA[I'm working on an AIR project that uses an AMF-service to get its data from. Writing such a service isn't difficult, but testing the AMF service functions isn't very straightforward. The way to do so now is to partially implement the client, and make it spit out debugging info. For this project however, since it [...]]]></description>
			<content:encoded><![CDATA[<p>I'm working on an AIR project that uses an AMF-service to get its data from. Writing such a service isn't difficult, but testing the AMF service functions isn't very straightforward. The way to do so now is to partially implement the client, and make it spit out debugging info. For this project however, since it relies heavily on AMF and there is no client-side app yet, I decided to write a debugging utility for it. It's called Pinta.</p>
<p>I suggested to the commissioner of the project (Axis.fm) that we release the tool under GNU/GPL, and they agreed. So, the tool can be found now on <a href="http://code.google.com/p/pinta">http://code.google.com/p/pinta</a>.</p>
<p>What the tool does: it allows the user to connect to an AMF service and make calls, and prints out the results in text and tree forms. So basically, it's a generic AMF client. Since AMF has no service discovery methods, the user needs to define what services are available on the server. When the AMFPHP browser, that comes with a default install, is present on the server, Pinta can use it do discover the available services for you.</p>
<p>In the future, the plan is to build unit testing support into Pinta, so that with one click you can see if your AMF service still responds as it should.</p>
<p>More info about the tool can be found on the Google Code page, <a href="http://code.google.com/p/pinta">http://code.google.com/p/pinta</a>. I hope the tool is useful to some, feel free to comment/request features/report issues.</p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=Pinta+%E2%80%93+AMF+debugger+http://mgob4.th8.us" title="Post to Twitter"><img class="nothumb" src="http://drainbamage.nl/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Pinta+%E2%80%93+AMF+debugger+http://mgob4.th8.us" title="Post to Twitter">Tweet This Post</a></p>]]></content:encoded>
			<wfw:commentRss>http://drainbamage.nl/2009/07/pinta-amf-debugger/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>AS3 object serialization pitfalls</title>
		<link>http://drainbamage.nl/2009/07/as3-object-serialization-pitfalls/</link>
		<comments>http://drainbamage.nl/2009/07/as3-object-serialization-pitfalls/#comments</comments>
		<pubDate>Fri, 17 Jul 2009 08:46:13 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[Web and Programming]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[actionscript 3]]></category>
		<category><![CDATA[serialization]]></category>
		<category><![CDATA[type coercion]]></category>

		<guid isPermaLink="false">http://drainbamage.nl/?p=224</guid>
		<description><![CDATA[I'm working on an AIR project now, and I wanted to save some user data locally. There are a few ways to do so, including SQLite, LSO, and plain file writing in the local datastore. I wanted to save an ArrayCollection containing connection profiles the user specified, and SQLite seemed like a bit of an [...]]]></description>
			<content:encoded><![CDATA[<p>I'm working on an AIR project now, and I wanted to save some user data locally. There are a few ways to do so, including SQLite, LSO, and plain file writing in the local datastore.<br />
I wanted to save an ArrayCollection containing connection profiles the user specified, and SQLite seemed like a bit of an overkill for this. Coming from a Java background, I just wanted to serialize and save my ArrayCollection so I wouldn't have to reconstruct it from SQL every time. </p>
<p>Fortunately, this is possible with ActionScript 3, using the FileStream class's readObject() and writeObject() methods. Here's the code I used to read and write the profiles:</p>
<pre>
private function loadProfiles():void
{
	var prefsFile:File = File.applicationStorageDirectory.resolvePath(fileName);
	var fs:FileStream = new FileStream();
	if( !prefsFile.exists )
	{
		profiles = new ArrayCollection();
	} else {
		try {
			fs.open( prefsFile, FileMode.READ );
			profiles = fs.readObject() as ArrayCollection;
			fs.close();
		} catch( e:Error ) {
			Alert.show( "Error while loading profiles: "+e.message, "Load error");
		}
	}
}

public function saveProfiles():void
{
	var prefsFile:File = File.applicationStorageDirectory.resolvePath(fileName);
	var fs:FileStream = new FileStream();
	try {
		fs.open( prefsFile, FileMode.WRITE );
		fs.writeObject(profiles);
		fs.close();
	} catch( e:Error ) {
		Alert.show("Failed to save profiles: "+e.message, "Save error");
	}
}
</pre>
<p>There are a few pitfalls however when loading the profiles. First, the player must be able to tell the class of the objects it is loading. For some reason, it cannot do so unless you specify it explicitly:</p>
<pre>
package nl.aboutcoding.servicebrowser.model
{
	import mx.collections.ArrayCollection;

	[RemoteClass(alias="nl.aboutcoding.servicebrowser.model.Profile")]
	public class Profile
	{
</pre>
<p>Secondly, the class MUST have a constructor, otherwise the objects are typed as Object and type casting will fail with a message concernin "Type coercion failed".  I often skip the constructor on ValueObjects, and it took some time to figure out.</p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=AS3+object+serialization+pitfalls+http://3ow2q.th8.us" title="Post to Twitter"><img class="nothumb" src="http://drainbamage.nl/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=AS3+object+serialization+pitfalls+http://3ow2q.th8.us" title="Post to Twitter">Tweet This Post</a></p>]]></content:encoded>
			<wfw:commentRss>http://drainbamage.nl/2009/07/as3-object-serialization-pitfalls/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Automatic uploading of SWF using FDT and Ant</title>
		<link>http://drainbamage.nl/2009/06/automatic-uploading-of-swf-using-fdt-and-ant/</link>
		<comments>http://drainbamage.nl/2009/06/automatic-uploading-of-swf-using-fdt-and-ant/#comments</comments>
		<pubDate>Sat, 06 Jun 2009 14:55:16 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[Web and Programming]]></category>

		<guid isPermaLink="false">http://drainbamage.nl/?p=216</guid>
		<description><![CDATA[FDT and Flex Builder 3 both feature the Ant builder (Flex Builder only via an addon). Ant is a project by Apache (http://ant.apache.org/), which does for the Java and AS3 worlds kind of the same thing as make does for the C world. It takes a build file as input, and calls the correct compilers [...]]]></description>
			<content:encoded><![CDATA[<p>FDT and Flex Builder 3 both feature the Ant builder (Flex Builder only via an addon). Ant is a project by Apache (<a href="http://ant.apache.org/">http://ant.apache.org/</a>), which does for the Java and AS3 worlds kind of the same thing as <code>make</code > does for the C world. It takes a build file as input, and calls the correct compilers and commands to produce meaningfull output.</p>
<p>Of course, you can compile your project directly with FDT or FB, but the way it handles its output (how it is generated, where it is placed, what to do after compilation) is much less under your control.</p>
<p>I wanted FDT to automatically upload the generated SWF and other resources after compilation, but only if they had been changed. My deployment folder consisted of these resources:<br />
<span id="more-216"></span></p>
<ul>
<li>preloader.swf</li>
<li>main.swf</li>
<li>index.php</li>
<li>style.css</li>
</ul>
<p>And an images directory which wasn't changed often. The answer to the problem is Ant. There are many tutorials on how to setup Ant building for your project, it's really quite simple (like <a href="http://www.boostworthy.com/blog/?p=194">this</a> one). I'll add my buildfile at the end of the post, it's self-explanatory. The addition that makes the whole thing upload the changed resource (and only those!) to the webserver is:</p>
<pre>
&lt;target name="upload"&gt;
		&lt;exec executable="rsync"&gt;
			&lt;arg line="-avP ${outputBaseDir} masteen.6core.net:www/www.aboutcoding.nl/webroot/"/&gt;
		&lt;/exec&gt;
&lt;/target&gt;
</pre>
<p>In this case, I'm creating <code>www.aboutcoding.nl</code>, which is on the server <code>masteen.6core.net</code> in the directory <code>www/www.aboutcoding.nl/webroot</code>. rsync is a utility that comes standard with Mac OS X and most Linux flavours. When it doesn't, it's easily installed.</p>
<p>That's not all though. For easy synchronisation, you don't want to have to enter your password for every upload. In fact, FDT/Ant doesn't handle it well at all if you need to give input during the build process. </p>
<p>Since rsync uses SSH, the solution is to uses public key authentication. You upload your public ssh key (found in ~/.ssh/id_rsa.pub, if you don't have one generate it with <code>ssh-keygen -t dsa</code>) to the server in question, and add it to the file ~/.ssh/authorized_keys there. The server has to support public key authentication though: </p>
<pre>
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile      %h/.ssh/authorized_keys
</pre>
<p>These options need to be in the config of the ssh daemon (usually /etc/ssh/sshd_config). </p>
<p>Then the last thing: your private SSH key is only unlocked with your password. On Mac OS X 10.5 ssh-agent runs in the background, keeping your key unlocked, but on Linux you'll probably have to set it up to do so.</p>
<p>Now you're good to go, automatic uploading with FDT and Ant <img src='http://drainbamage.nl/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=Automatic+uploading+of+SWF+using+FDT+and+Ant+http://cknm6.th8.us" title="Post to Twitter"><img class="nothumb" src="http://drainbamage.nl/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Automatic+uploading+of+SWF+using+FDT+and+Ant+http://cknm6.th8.us" title="Post to Twitter">Tweet This Post</a></p>]]></content:encoded>
			<wfw:commentRss>http://drainbamage.nl/2009/06/automatic-uploading-of-swf-using-fdt-and-ant/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>First AS3/Flash project</title>
		<link>http://drainbamage.nl/2009/06/first-as3flash-project/</link>
		<comments>http://drainbamage.nl/2009/06/first-as3flash-project/#comments</comments>
		<pubDate>Sat, 06 Jun 2009 12:59:26 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[Web and Programming]]></category>

		<guid isPermaLink="false">http://drainbamage.nl/?p=211</guid>
		<description><![CDATA[I started developing with AS3 and Flex some time ago. I really like AS3, Flex and AIR, but I decided it would be good for me to learn how to create Flash applications in AS3, without the Flex framework, and without the Flash CS3/4 authoring tool. So, I installed FDT, and set out to create [...]]]></description>
			<content:encoded><![CDATA[<p>I started developing with AS3 and Flex some time ago. I really like AS3, Flex and AIR, but I decided it would be good for me to learn how to create Flash applications in AS3, without the Flex framework, and without the Flash CS3/4 authoring tool. So, I installed <a href="http://fdt.powerflasher.com/" target="_blank">FDT</a>, and set out to create a website for my freelance activities.</p>
<p>The result can be found at <a href="http://www.aboutcoding.nl">www.aboutcoding.nl</a>. I embedded the following techniques I wanted to learn:</p>
<ul>
<li>Dynamic content through XML</li>
<li>Indexable by search engines</li>
<li>Deeplinking enabled</li>
<li>Embedded fonts with some visual effects</li>
<li>Full-window flash with graceful resizing</li>
</ul>
<p>I hope you enjoy it, I sure did creating it <img src='http://drainbamage.nl/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=First+AS3%2FFlash+project+http://i2rrn.th8.us" title="Post to Twitter"><img class="nothumb" src="http://drainbamage.nl/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=First+AS3%2FFlash+project+http://i2rrn.th8.us" title="Post to Twitter">Tweet This Post</a></p>]]></content:encoded>
			<wfw:commentRss>http://drainbamage.nl/2009/06/first-as3flash-project/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Xen benchmark</title>
		<link>http://drainbamage.nl/2009/04/xen-benchmark/</link>
		<comments>http://drainbamage.nl/2009/04/xen-benchmark/#comments</comments>
		<pubDate>Sun, 05 Apr 2009 19:05:37 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[UNIX/Security]]></category>

		<guid isPermaLink="false">http://drainbamage.nl/?p=182</guid>
		<description><![CDATA[This post discusses the performance of Linux context switches under the Xen hypervisor. Presence of the Xen hypervisor has an impact on the context switching performance, as is shown by benchmarks. I was interested in these benchmarks since I had the feeling a Xen-enabled machine is in general running slower than a non-Xen machine. It's quite large, so click the 'read more' link to see the whole thing.]]></description>
			<content:encoded><![CDATA[<h3>Contents</h3>
<ul>
<li><a href="#introduction">Introduction</a></li>
<li><a href="#setup">Benchmark setup</a></li>
<li><a href="#results">Results</a></li>
<li><a href="#discussion">Discussion</a></li>
<li><a href="#conclusion">Conclusion</a></li>
</ul>
<p><a name="introduction"><br />
<h3>Introduction</h3>
<p></a><br />
This post discusses the performance of Linux context switches under the Xen hypervisor. Presence of the Xen hypervisor has an impact on the context switching performance, as is shown by benchmarks. I was interested in these benchmarks since I had the feeling a Xen-enabled machine is in general running slower than a non-Xen machine.<br />
 <span id="more-182"></span><br />
So I decided to benchmark a server with and without Xen. I have a server running which isn't in production yet, so it's safe to experiment with. It is an IBM eServer xSeries 345 which I have blogged about <a href="http://drainbamage.nl/2009/03/09/server-setup-part-1/">before</a>. The relevant specs:</p>
<p><b>CPU</b> 2 x Intel Xeon 2.4GHz with 512K cache<br />
<b>Memory</b> 4 GB PC2100 DDR RAM, ECC & registered<br />
<b>Disks</b> 2x18G U320 SCSI, 2x36G U320 SCSI, 2x300G U320 SCSI</p>
<p><a name="setup"><br />
<h3>Benchmark setup</h3>
<p></a><br />
I ran the <a href="http://www.bitmover.com/lmbench/">lmbench</a> benchmark suite, which is in the Ubuntu package repository. The test cases:</p>
<ul>
<li><b>clean</b>: 4 runs with Ubuntu linux 2.6.24-23-server, no Xen at all</li>
<li><b>dom0-nodomU</b>: 4 runs with Xen 3.2 and Ubuntu linux 2.6.24-23-xen, from dom0, no domUs running</li>
<li><b>dom0-3domU</b>:4 runs with Xen 3.2 and Ubuntu linux 2.6.24-23-xen, from dom0, 3 domUs running</li>
<li><b>domU-3domU</b>4 runs with Xen 3.2 and Ubuntu linux 2.6.24-23-xen, from domU, 3 domUs running</li>
</ul>
<p>The domUs and dom0 were idle except for the benchmark. That is, regular cron jobs were running, but the systems weren't in use for any services. Each test took about 40 minutes, so the tests together are spread out over quite some time mitigating the effects of cron jobs.</p>
<p><a name="results"><br />
<h3>Results</h3>
<p></a></p>
<p>The results are too large to include in the post, but they are located here:<br />
<a href="http://drainbamage.nl/files/xen-benchmark-summary.txt">xen-benchmark-summary.txt</a></p>
<p>Below are some of the results where the Xen systems showed a significant difference from the Xen-less system:</p>
<pre>
Processor, Processes - times in microseconds - smaller is better
------------------------------------------------------------------------------
Host                 OS  Mhz null null      open slct sig  sig  fork exec sh
                             call  I/O stat clos TCP  inst hndl proc proc proc
--------- ------------- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
clean     Linux 2.6.24- 2400 0.49 0.70 2.97 4.82 5.24 1.15 2.78 280. 1006 2500
clean     Linux 2.6.24- 2400 0.49 0.69 2.98 4.89 5.37 1.14 2.84 279. 990. 2435
clean     Linux 2.6.24- 2400 0.49 0.68 2.97 4.77 5.13 1.15 2.80 280. 1011 2428
clean     Linux 2.6.24- 2400 0.49 0.68 2.96 4.74 5.44 1.15 2.85 280. 1013 2431
dom0-3dom Linux 2.6.24- 2400 0.51 0.70 2.93 4.50 5.16 1.16 2.77 1000 2937 7970
dom0-3dom Linux 2.6.24- 2400 0.50 0.69 2.92 4.80 5.23 1.15 2.70 993. 2902 6591
dom0-3dom Linux 2.6.24- 2400 0.52 0.68 2.94 4.78 5.13 1.16 2.71 972. 2890 6424
dom0-3dom Linux 2.6.24- 2400 0.49 0.69 2.92 4.94 5.09 1.17 2.74 959. 2908 6561
dom0-nodo Linux 2.6.24- 2400 0.49 0.69 2.92 4.55 5.14 1.16 2.70 969. 2786 6283
dom0-nodo Linux 2.6.24- 2400 0.49 0.69 2.91 4.54 5.13 1.15 2.74 961. 2806 6375
dom0-nodo Linux 2.6.24- 2400 0.50 0.68 2.92 4.77 5.14 1.15 2.75 985. 2835 6404
dom0-nodu Linux 2.6.24- 2400 0.50 0.68 2.92 4.77 5.16 1.15 2.79 970. 2779 6360
domU-3dom Linux 2.6.24- 2400 0.50 0.65 1.92 3.26 5.26 0.98 2.24 567. 1757 4108
domU-3dom Linux 2.6.24- 2400 0.52 0.67 1.95 3.26 5.22 0.98 2.29 578. 1742 4072
domU-3dom Linux 2.6.24- 2400 0.49 0.66 2.00 3.30 5.04 0.98 2.17 561. 1767 4127
domU-3dom Linux 2.6.24- 2400 0.51 0.66 1.93 3.27 5.21 0.98 2.25 634. 1880 4361
</pre>
<pre>
Context switching - times in microseconds - smaller is better
-------------------------------------------------------------------------
Host                 OS  2p/0K 2p/16K 2p/64K 8p/16K 8p/64K 16p/16K 16p/64K
                         ctxsw  ctxsw  ctxsw ctxsw  ctxsw   ctxsw   ctxsw
--------- ------------- ------ ------ ------ ------ ------ ------- -------
clean     Linux 2.6.24- 3.4500 3.7800 3.9700 5.2000   27.3 9.53000    38.0
clean     Linux 2.6.24- 3.5500 3.7600 4.0000 4.8000   30.9 9.19000    35.6
clean     Linux 2.6.24- 3.5000 3.8200 3.8200 5.0400   30.0 9.98000    38.6
clean     Linux 2.6.24- 3.6000 3.7600 4.1200 5.2100   28.3 9.40000    38.4
dom0-3dom Linux 2.6.24- 7.4700 7.6800 6.7000   10.8   35.1    18.4    38.9
dom0-3dom Linux 2.6.24- 7.6800 7.6200 8.9900   11.1   37.9    18.4    45.1
dom0-3dom Linux 2.6.24- 7.4800 7.6700 8.6300   10.6   38.9    18.2    45.8
dom0-3dom Linux 2.6.24- 7.5400 7.5800 7.5100   10.2   39.4    18.6    47.0
dom0-nodo Linux 2.6.24- 7.6000 7.6700 8.0000 9.3400   37.2    18.1    44.5
dom0-nodo Linux 2.6.24- 7.5600 7.6500 7.7400   11.0   37.1    18.1    44.3
dom0-nodo Linux 2.6.24- 7.4200 7.6900 8.6500   10.5   37.1    17.3    44.7
dom0-nodu Linux 2.6.24- 7.5800 7.7200   10.7   12.7   36.6    17.9    45.1
domU-3dom Linux 2.6.24- 7.1400 7.2800 8.2400 8.1900   35.3    16.8    43.6
domU-3dom Linux 2.6.24- 6.8900 7.2200 7.5500 9.3200   35.5    16.8    43.7
domU-3dom Linux 2.6.24- 7.1500 7.1300 8.3000 9.6700   36.8    16.9    43.7
domU-3dom Linux 2.6.24- 6.9300 7.0700 7.6500 9.1300   35.2    17.2    43.7</pre>
<pre>
File & VM system latencies in microseconds - smaller is better
-------------------------------------------------------------------------------
Host                 OS   0K File      10K File     Mmap    Prot   Page   100fd
                        Create Delete Create Delete Latency Fault  Fault  selct
--------- ------------- ------ ------ ------ ------ ------- ----- ------- -----
clean     Linux 2.6.24-   23.1   18.8   73.6   38.8  1490.0 1.265 3.22970 3.763
clean     Linux 2.6.24-   23.0   18.9   73.7   38.7  1488.0 1.171 3.29740 3.573
clean     Linux 2.6.24-   22.8   19.0   73.9   38.9  1484.0 1.113 3.25150 3.430
clean     Linux 2.6.24-   23.7   19.0   74.7   39.0  1497.0 1.086 3.23500 3.431
dom0-3dom Linux 2.6.24-   24.5   21.1   82.8   41.8  2900.0 1.401 6.54080 3.349
dom0-3dom Linux 2.6.24-   24.7   20.2   76.6   41.9  3000.0 1.533 6.64740 3.360
dom0-3dom Linux 2.6.24-   24.6   20.3   80.1   41.5  2971.0 1.603 6.60690 3.414
dom0-3dom Linux 2.6.24-   25.2   20.5   81.0   42.0  2924.0 1.383 6.65390 3.257
dom0-nodo Linux 2.6.24-   24.0   19.7   88.3   40.9  4551.0 1.421    10.6 3.330
dom0-nodo Linux 2.6.24-   25.0   20.2   87.4   41.6  4572.0 1.489    10.8 3.436
dom0-nodo Linux 2.6.24-   24.5   20.3   88.8   41.2  4627.0 1.539    10.7 3.454
dom0-nodu Linux 2.6.24-   25.4   20.3   88.1   41.6  4636.0 1.554    10.7 3.324
domU-3dom Linux 2.6.24-   20.3   12.9   61.8   25.0  2546.0 1.409 6.08420 3.310
domU-3dom Linux 2.6.24-   20.1   12.8   59.6   24.7  2592.0 1.376 6.06000 3.330
domU-3dom Linux 2.6.24-   19.7   12.9   60.8   24.7  2408.0 1.397 5.84500 3.295
domU-3dom Linux 2.6.24-   19.9   12.9   60.1   24.7  2493.0 1.311 5.89980 3.313</pre>
<p><a name="discussion"><br />
<h2>Discussion of the results</h2>
<p></a></p>
<p>As you can see, many measurements are the same for Xen and non-Xen machines alike, like basic integer operations and memory latency and bandwidth. However, a few categories stick out:</p>
<ul>
<li>Process creation (fork, exec, sh)</li>
<li>Context switching</li>
<li>Local communications latency</li>
<li>Virtual memory (mmap, page faults)</li>
</ul>
<p><b>Process creation</b><br />
lmbench mesasures process creation latency in three ways: <a href="http://en.wikipedia.org/wiki/Fork_(operating_system)">fork</a>, <a href="http://www.opengroup.org/onlinepubs/000095399/functions/exec.html">exec</a> and <a href="http://en.wikipedia.org/wiki/Bourne_shell">sh</a>. Fork is the simplest way for a UNIX system to create a process: it duplicates the currently running image. exec is a system call that loads a different binary image, and sh calls the shell to execute a binary. In the results we see that process creation of all three kinds is slower by factor 2.8 for systems running Xen. It doesn't matter if they run domUs or not. Strangely, measurements taken from a domU are still slower than no Xen but faster than a dom0.</p>
<p>Process creation implies context switching, which is slower on Xen machines. However, context switching is done in terms of 10 microseconds, while fork takes 1000 microseconds, and only 2 context switches are performed during the fork/exec test, so the context switching overhead is insignificant.</p>
<p><b>Local communication</b><br />
Processes on a UNIX system can communicate with each other through <a href="http://en.wikipedia.org/wiki/Named_pipe">pipes</a>. On both ends of the "pipe" a process is listening, and data travels through the pipe. lmbench tests both the bandwidth and the latency of the pipes.</p>
<p>Bandwidth is the same for Xen and non-Xen systems. However, the latency is considerably higher with pipes on Xen systems: 2 to 3 times.</p>
<p>Pipe communication implies context switches, and the context switches needed are significant to the total latency.</p>
<p><b>Context switching</b><br />
A multi-tasking operating system (all operating systems today) has many processes running at the same time. CPU time is divided among those processes. When the OS takes process A away from the CPU and puts process B on it, it must save that state that process A is in for when it will resume, and restore the saved state for B. This saved state is called context, and <a href="http://en.wikipedia.org/wiki/Context_switch">context switching</a> is the task of switching these contexts when a different process gets CPU time. The context is made up of at least CPU registers. A normal system will perform context switches many times per second: my web/mail server averages 400 times per second. Speed of context switches therefore is important.</p>
<p>In the results we see that all Xen systems have <b>twice the latency</b> the non-Xen system has in context switching.</p>
<p><b>Virtual Memory</b><br />
<a href="http://en.wikipedia.org/wiki/Virtual_memory">Virtual Memory</a> is the extension of memory to auxiliary storage (the swap space). To processes, it seems as if there is more memory present that there really is. Since this auxiliary storage (typically a harddisk) is much slower than real memory, the operating system keeps usage of this storage to a minimum. Memory is divided up into pages, and less-used pages are saved on the auxiliary storage and swapped back to memory when needed.</p>
<p>The <a href="http://en.wikipedia.org/wiki/Mmap">mmap</a> function maps I/O onto memory. When reading from this memory, the data is read from the I/O. Since the OS uses its memory so efficiently, data is cached in memory. lmbench uses this to test the caching speed: it only reads data using mmap that was read before (so it doesn't come from the real I/O device). When data is not present, a page fault arises and the data is read from the I/O device.</p>
<p>In the results we see that the Xen dom0 systems have about twice the mmap latency, and about twice the page fault latency. To my knowledge, mmap and page fault do not depend on context switching, but I'm no OS guru. Again we see that the domU system is doing better than the dom0 systems, but still worse than a no-Xen system.</p>
<p>Some more quirks:</p>
<ul>
<li>Bandwidth on local communication (pipes) was constantly higher once there were domU machines active</li>
<li>File creation and deletion was slightly slower with Xen active</li>
<li>With Xen running but no domUs, mmap was considerably slower than with domUs</li>
<li>With Xen enabled but no domUs, File Reread was considerably faster than with all other configurations</li>
<li>Many latencies were lower for domU systems than for dom0 systems</li>
</ul>
<p><a name="conclusions"><br />
<h3>Conclusions</h3>
<p></a></p>
<p>Xen systems are slower at:</p>
<ul>
<li>Process creation</li>
<li>Context switching (and therefore pipes)</li>
<li>mmap calls</li>
</ul>
<p>I will use my web/mail/dns server, which is a pretty typical linux server, to find out what these higher latencies mean in real life. I use <a href="http://munin.projects.linpro.no/">munin</a> to monitor this server, and it logs forks, context switches, and many other useful parameters. </p>
<p><b>Forks</b><br />
The Xen-less system has 4 measurements for forks, the average being 280 microseconds per fork. The Xen systems with and without domUs average 976 microsonds, the domU system averages 585 microseconds.</p>
<p><b>Context switches</b><br />
The Xen-less system does a context switch in 3.5 microseconds, so this takes 1568 microseconds per second. The Xen systems took 7.37 microseconds on average for a context switch.</p>
<p><b>mmap calls</b><br />
I don't have statistics for the number of mmap calls on my server. However, the Xen dom0 systems take about twice the time the Xen-less system does, and the domU systems add 1000 microseconds to the Xen-less latency. I imagine this would cost you for large amounts of I/O.</p>
<p><b>Wrapping up</b><br />
Running Xen impacts performance of some of the basic system calls, like fork(), exec() and mmap(). It also increases the overhead on context switches. Creating a process will take about twice the time with Xen. Process creation latency impacts the performance of networked daemons, since they tend to fork() for every new connection. Every process needs to be created however, so doubling the latency has an impact on general performance.</p>
<p>Context switchces happen on the webserver this website is hosted on about 450 times per second (measured average over last week). A doubled latency over context switches is also a pretty heavy performance impact.</p>
<p>Pipes also have higher latency, but I think this can be blamed on the context switches. Pipe performance therefore will depend on how often a context switch needs to take place between sending and receiving ends of the pipe, but the pipe bandwidth measurements were the same for Xen and non-Xen systems.</p>
<p>mmap also has twice the latency with Xen. I don't know the significance of this, since I'm not a ware of when mmap() is used on my system and when data is simply read() from file pointers. Maybe someone can comment on this <img src='http://drainbamage.nl/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=Xen+benchmark+http://3io6g.th8.us" title="Post to Twitter"><img class="nothumb" src="http://drainbamage.nl/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Xen+benchmark+http://3io6g.th8.us" title="Post to Twitter">Tweet This Post</a></p>]]></content:encoded>
			<wfw:commentRss>http://drainbamage.nl/2009/04/xen-benchmark/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>iPhone tethering in OS 3.0</title>
		<link>http://drainbamage.nl/2009/03/iphone-tethering-in-os-30/</link>
		<comments>http://drainbamage.nl/2009/03/iphone-tethering-in-os-30/#comments</comments>
		<pubDate>Wed, 25 Mar 2009 09:31:42 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[Life hacking]]></category>

		<guid isPermaLink="false">http://drainbamage.nl/?p=166</guid>
		<description><![CDATA[Yesterday I decided I would try out the new OS 3.0 beta 1. I've been looking forward to having tethering in my iPhone very much, since I'm often traveling and working at the same time. Buying an extra device for laptop internet (like a UMTS USB dongle) doesn't seem right, since I'm already paying for [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday I decided I would try out the new OS 3.0 beta 1. I've been looking forward to having tethering in my iPhone very much, since I'm often traveling and working at the same time. Buying an extra device for laptop internet (like a UMTS USB dongle) doesn't seem right, since I'm already paying for unlimited data access with my iPhone subscription. After having heard some reports of people in NL who got tethering to work with T-Mobile, I decided it was time.</p>
<p>To get to the tethering, one must go through these steps:</p>
<ul>
<li>Register your iPhone's UUID with apple</li>
<li>Get the OS 3.0 beta firmware image</li>
<li>Install the iPhone SDK or at least the USB System Components package that comes with it</li>
<li>Change the carrier information on you iPhone by uploading a modified IPCC file</li>
</ul>
<p>I'm registered as an Apple developer since the company where I work is starting to build iPhone apps. So, getting the device registered and downloading the OS 3.0 beta image and SDK was easy.</p>
<p>Upgrading to the new image is done by clicking the "Check for Update" button in iTunes while the Option key is pressed. This allows you to select a firmware image to update to. By selecting the 3.0 image, the device is upgraded. Then the SDK story. I already have the iPhone 2.2 SDK, since I've started writing iPhone apps. For tethering to work however, you need the 3.0 SDK or a part of it. I first installed the pkg that only contains the necessary drivers for USB tethering (the whole SDK is a 2.15 GB download). This file can be found <a href="http://www.mediafire.com/download.php?z2nombnzzzm">here</a>. Later, when tethering didn't work, I installed the whole SDK, and when it still didn't work, I installed the small PKG again. It finally worked <img src='http://drainbamage.nl/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Then, you need an IPCC file. For T-Mobile NL, you can find such a file in <a href="http://forum.onemorething.nl/viewtopic.php?t=145238">this</a> excellent post. It didn't work for me though, I downloaded <a href="http://drainbamage.nl/files/TMobile_nl.test.ipcc">this</a> file (thanks to Wiebel). </p>
<p>At first, iTunes and my iPhone would crash when I plugged the iPhone in with tethering enabled. After re-installing the PKG with drivers again, this problem was fixed. Tethering via bluetooth worked after using Wiebel's IPCC file. So, now it works both via bluetooth and USB!</p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=iPhone+tethering+in+OS+3.0+http://xzwtd.th8.us" title="Post to Twitter"><img class="nothumb" src="http://drainbamage.nl/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=iPhone+tethering+in+OS+3.0+http://xzwtd.th8.us" title="Post to Twitter">Tweet This Post</a></p>]]></content:encoded>
			<wfw:commentRss>http://drainbamage.nl/2009/03/iphone-tethering-in-os-30/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Visim &#8211; website visitor simulator</title>
		<link>http://drainbamage.nl/2009/03/visim-website-visitor-simulator/</link>
		<comments>http://drainbamage.nl/2009/03/visim-website-visitor-simulator/#comments</comments>
		<pubDate>Mon, 23 Mar 2009 11:02:32 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[Web and Programming]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[simulator]]></category>
		<category><![CDATA[tool]]></category>

		<guid isPermaLink="false">http://drainbamage.nl/?p=163</guid>
		<description><![CDATA[Today I uploaded some code I wrote for my bachelor thesis to Google Code as an open source project. My bachelor thesis was about creating a scalable architecture for heavy-duty web apps. I created such an architecture, and validated it on a prototype. To see what effect changes to the system had on its capacity, [...]]]></description>
			<content:encoded><![CDATA[<p>Today I uploaded some code I wrote for my bachelor thesis to Google Code as an open source project. My bachelor thesis was about creating a scalable architecture for heavy-duty web apps. I created such an architecture, and validated it on a prototype. To see what effect changes to the system had on its capacity, I wrote a tool that measures how many users can be served by the system. This tool is now public under the name "visim".</p>
<p>To measure how many users a system can serve, I used the following steps:</p>
<ul>
<li>Set requirements on response times (like 500ms for 90% of the requests, 1 sec for 98% of the request etc)</li>
<li>Run the tool with these requirements for a low number of users</li>
<li>Increase the number of users until the requirements aren't met anymore</li>
</ul>
<p>Then you can make changes to the system and re-run the tool to see if it still serves the same amount of users, or perhaps more.</p>
<p>The project is at <a href="http://code.google.com/p/visim">http://code.google.com/p/visim</a></p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=Visim+%E2%80%93+website+visitor+simulator+http://wbote.th8.us" title="Post to Twitter"><img class="nothumb" src="http://drainbamage.nl/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Visim+%E2%80%93+website+visitor+simulator+http://wbote.th8.us" title="Post to Twitter">Tweet This Post</a></p>]]></content:encoded>
			<wfw:commentRss>http://drainbamage.nl/2009/03/visim-website-visitor-simulator/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>nschaind updated</title>
		<link>http://drainbamage.nl/2009/03/nschaind-updated/</link>
		<comments>http://drainbamage.nl/2009/03/nschaind-updated/#comments</comments>
		<pubDate>Fri, 20 Mar 2009 16:12:35 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[UNIX/Security]]></category>

		<guid isPermaLink="false">http://drainbamage.nl/?p=161</guid>
		<description><![CDATA[In my previous post I wrote about my new tool, nschaind (http://code.google.com/p/nschaind). It detects if a querying dns resolver is vulnerable to cache poisoning according to VU#252735. It's now been updated to also include VU#927905, BIND 8 cache poisoning vulnerability. BIND 8 has the same kind of weakness in its PRNG, although it has a [...]]]></description>
			<content:encoded><![CDATA[<p>In my previous post I wrote about my new tool, nschaind (<a href="http://code.google.com/p/nschaind">http://code.google.com/p/nschaind</a>). It detects if a querying dns resolver is vulnerable to cache poisoning according to VU#252735. It's now been updated to also include VU#927905, BIND 8 cache poisoning vulnerability. BIND 8 has the same kind of weakness in its PRNG, although it has a different PRNG from BIND 9. Amit Klein discovered this vulnerability after discovering the one in BIND 9. These two vulnerabilities form the basis for Dan Kaminsky's now famous DNS flaw (VU#800113).</p>
<p>Anyway, the tool has been updated to detect weak BIND 8 and 9 resolvers, so <a href="http://code.google.com/p/nschaind">go and check it out!</a></p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=nschaind+updated+http://cs9qt.th8.us" title="Post to Twitter"><img class="nothumb" src="http://drainbamage.nl/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=nschaind+updated+http://cs9qt.th8.us" title="Post to Twitter">Tweet This Post</a></p>]]></content:encoded>
			<wfw:commentRss>http://drainbamage.nl/2009/03/nschaind-updated/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Bind cache poisoning scanner</title>
		<link>http://drainbamage.nl/2009/03/bind-cache-poisoning-scanner/</link>
		<comments>http://drainbamage.nl/2009/03/bind-cache-poisoning-scanner/#comments</comments>
		<pubDate>Thu, 12 Mar 2009 16:24:33 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[UNIX/Security]]></category>

		<guid isPermaLink="false">http://drainbamage.nl/?p=139</guid>
		<description><![CDATA[As a part of my master on computer security, I've written a tool that detects if a certain resolver is vulnerable to cache poisoning according to CVE-2007-2926. This vulnerability report from 2007 describes a bad practice of bind, that wasn't fixed until July 2008, when Dan Kaminsky came out with his famous DNS vulnerability. It [...]]]></description>
			<content:encoded><![CDATA[<p>As a part of my master on computer security, I've written a tool that detects if a certain resolver is vulnerable to cache poisoning according to <a href="http://www.securityfocus.com/bid/25037">CVE-2007-2926</a>. This vulnerability report from 2007 describes a bad practice of bind, that wasn't fixed until July 2008, when Dan Kaminsky came out with his famous <a href="http://www.kb.cert.org/vuls/id/800113">DNS vulnerability</a>.</p>
<p>It comes down to this: bind versions up to 9.4.1 use a fixed source port for queries. This source port is determined at startup. Furthermore, they employ a bad PRNG for query IDs. This leads to predictability of the next query ID. One can exploit these two vulnerabilities together to send a resolver false DNS information, since all of the packet can be constructed and sent before a real server could: cache poisoning.</p>
<p>I found this whole thing very interesting, and decided that it would be nice to write a tool that could detect if a certain resolver was vulnerable to this vulnerability or not. In order to be vulnerable, a server would have a) the same source port for multiple requests and b) have predictable query IDs. To detect this, I followed the path Amit Klein described in his path: CNAME chaining. The tool acts as a DNS server. When a resolver sends a request for an A or MX record, it answers with a CNAME record within the domain, triggering another query from the resolver. And then, it does that again and again, up to 10 times. In these 10 times, the tool can determine if the source port was the same all the time, and if any of the IDs was predictable. Only when a query ID is even can the tool predict a range of 10 possible next query IDs (again, Amit Klein's approach).</p>
<p>The tool accepts MX requests. This is because most resolvers do not accept queries from outside their own network. To make them query your domain, one of the possible tricks is interact with the website of your target to find and make it send you email. To send you email, the resolver will perform an MX lookup, exposing it's resolver IP to you, and creating a possibility for fingerprinting. If the resolver is open to the world, you can use a tool like <a href="http://code.google.com/p/fpdns/">fpdns</a> to fingerprint it further.</p>
<p>I used this project to learn C, so don't expect too much of the programming. The source is <a href="http://code.google.com/p/nschaind/">here</a>, as a Google Code project. Of course, it's intended for legal penetration testing and research only!</p>
<p>A sample of the output:</p>
<pre>
chris$ sudo ./nschaind -c lab2.6core.net -f masteen.6core.net -m mail
Chaining daemon listening on 0.0.0.0:53
------------------------------
A mail.lab2.6core.net.	?	192.168.1.2:45682,18216 chaining (1)
A chain00.lab2.6core.net.	?	192.168.1.2:45682,25421 chaining (2)
A chain01.lab2.6core.net.	?	192.168.1.2:45682,33129 chaining (3)
A chain02.lab2.6core.net.	?	192.168.1.2:45682,3140 chaining (4)
A chain03.lab2.6core.net.	?	192.168.1.2:45682,34338 (p) chaining (5)
A chain04.lab2.6core.net.	?	192.168.1.2:45682,41383 chaining (6)
A chain05.lab2.6core.net.	?	192.168.1.2:45682,63194 chaining (7)
A chain06.lab2.6core.net.	?	192.168.1.2:45682,31597 (p) chaining (8)
A chain07.lab2.6core.net.	?	192.168.1.2:45682,64114 chaining (9)
A chain08.lab2.6core.net.	?	192.168.1.2:45682,64825 (p) chaining (10)
A chain09.lab2.6core.net.	?	192.168.1.2:45682,51181 answering (10)
Target 192.168.1.2 correct prediction count: 3, different source ports: 1
TARGET IS VULNERABLE
</pre>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=Bind+cache+poisoning+scanner+http://cgkph.th8.us" title="Post to Twitter"><img class="nothumb" src="http://drainbamage.nl/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Bind+cache+poisoning+scanner+http://cgkph.th8.us" title="Post to Twitter">Tweet This Post</a></p>]]></content:encoded>
			<wfw:commentRss>http://drainbamage.nl/2009/03/bind-cache-poisoning-scanner/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Server setup part 4: Networking</title>
		<link>http://drainbamage.nl/2009/03/server-setup-part-4-networking/</link>
		<comments>http://drainbamage.nl/2009/03/server-setup-part-4-networking/#comments</comments>
		<pubDate>Tue, 10 Mar 2009 08:36:40 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[UNIX/Security]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[network-script]]></category>
		<category><![CDATA[networking]]></category>
		<category><![CDATA[routing]]></category>
		<category><![CDATA[xen]]></category>

		<guid isPermaLink="false">http://drainbamage.nl/?p=103</guid>
		<description><![CDATA[This is part 4 of the series on my new server setup with Ubuntu and Xen. Part 1: Overview and OS Part 2: Disk setup (RAID, LVM) Part 3: Xen and domU setup Part 4: Networking setup Part 5: Intrusion Detection (IDS) setup (coming soon) Networking and Xen As for networking, this is a bit [...]]]></description>
			<content:encoded><![CDATA[<p>This is part 4 of the series on my new server setup with Ubuntu and Xen.</p>
<ul>
<li><a href="http://drainbamage.nl/2009/03/09/server-setup-part-1/">Part 1: Overview and OS</a></li>
<li><a href="http://drainbamage.nl/2009/03/09/server-setup-part-2-raid-and-lvm/">Part 2: Disk setup (RAID, LVM)</a></li>
<li><a href="http://drainbamage.nl/2009/03/09/server-setup-part-3-xen-and-domus/">Part 3: Xen and domU setup</a></li>
<li><a href="http://drainbamage.nl/2009/03/10/server-setup-part-4-networking/">Part 4: Networking setup</a></li>
<li>Part 5: Intrusion Detection (IDS) setup (coming soon)</li>
</ul>
<h3>Networking and Xen</h3>
<p>As for networking, this is a bit different from the normal situation. My colo provider (<a href="http://www.coloclue.net">Coloclue</a>, great joint) is located in multiple datacenters in Amsterdam. They have an IP range for every datacenter, the machines in datacenter 1 will get IPs from a different range than those in datacenter 2. However, if one needs more than one IP address, as I do for my virtual machines, they will assign IP addresses from another range that is not datacenter specific. So, my dom0 has an IP address specific to the datacenter from range A, and the domUs will have IPs from range B. Furthermore, these IPs from range B are routed as /32s, so there is no loss due to network and broadcast addresses.</p>
<p>For dom0, there is no problem. I just configured eth0 with an IP address, the appropriate netmask for the datacenter range, and the default gateway. For domUs however, the story is different. Bridged networking, which is default in Xen, doesn't work now. We'll have to switch to routed mode. In bridged mode, Xen creates a bridge device on dom0, and a number of ethernet devices on top of that. The bridge forwards packets to the ethernet devices at layer 2. With routing however, packets are forwarded on IP level, layer 3. Dom0 will act as a router for the domUs.<br />
<span id="more-103"></span><br />
First, change the networking mode Xen uses in <code>/etc/xen/xend-config.sxp</code>:</p>
<pre>
#(network-script network-bridge)
(network-script network-route)

#(vif-script vif-bridge)
(vif-script vif-route)
</pre>
<p>Now, in the config file for the core domU, core.cfg:</p>
<pre>
vif  = [ 'ip=w.x.y.z,vifname=core-vif' ]
</pre>
<p>That's pretty straightforward. I had some problems with the file <code>/etc/xen/scripts/network-route</code>, xend gave a syntax error when restarting. The variable <code>netdev</code> wasn't properly initialized. It seems I'm the only one running in to this problem, must've done something wrong. To fix it, I manually set <code>netdev = "eth0"</code>. To make sure that the script has done its work, run this command:</p>
<pre>
cat /proc/net/ipv4/ip_forward
</pre>
<p>It should show "1", meaning that dom0 has enabled packet forwarding. Check your iptables setup for restrictions on forwarding, you don't want to become a router for everyone.</p>
<p>Now to configure the domUs. We'll refer to the dom0 IP as dom.0.ip.addr, and domU's IP as dom.U.ip.addr. The file /etc/network/interfaces in domU should look like this:</p>
<pre>
auto eth0
iface eth0 inet static
address dom.U.ip.addr
netmask 255.255.255.255
broadcast dom.U.ip.addr

pointopoint dom.0.ip.addr
gateway dom.0.ip.addr
</pre>
<p>And that's it. No strange hacks or obscure configs, but you do need to find out that you need to add the 'pointopoint' directive in /etc/network/interfaces... thanks to <a href="http://www.tonytee.nl">tony</a> for finding out!</p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=Server+setup+part+4%3A+Networking+http://rmm7m.th8.us" title="Post to Twitter"><img class="nothumb" src="http://drainbamage.nl/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Server+setup+part+4%3A+Networking+http://rmm7m.th8.us" title="Post to Twitter">Tweet This Post</a></p>]]></content:encoded>
			<wfw:commentRss>http://drainbamage.nl/2009/03/server-setup-part-4-networking/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Server setup part 3: Xen and DomU&#8217;s</title>
		<link>http://drainbamage.nl/2009/03/server-setup-part-3-xen-and-domus/</link>
		<comments>http://drainbamage.nl/2009/03/server-setup-part-3-xen-and-domus/#comments</comments>
		<pubDate>Mon, 09 Mar 2009 12:12:53 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[UNIX/Security]]></category>
		<category><![CDATA[dom0]]></category>
		<category><![CDATA[domU]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[lvm]]></category>
		<category><![CDATA[xen]]></category>

		<guid isPermaLink="false">http://drainbamage.nl/?p=102</guid>
		<description><![CDATA[This part talks about how to setup Xen on Ubuntu Server, and how to create domU's on top of LVM volumes. We don't use the xen-create-image tool, but show how to install a domU manually.]]></description>
			<content:encoded><![CDATA[<p>This is part 3 of the series on my new server setup with Ubuntu and Xen.</p>
<ul>
<li><a href="http://drainbamage.nl/2009/03/09/server-setup-part-1/">Part 1: Overview and OS</a></li>
<li><a href="http://drainbamage.nl/2009/03/09/server-setup-part-2-raid-and-lvm/">Part 2: Disk setup (RAID, LVM)</a></li>
<li><a href="http://drainbamage.nl/2009/03/09/server-setup-part-3-xen-and-domus/">Part 3: Xen and domU setup</a></li>
<li><a href="http://drainbamage.nl/2009/03/10/server-setup-part-4-networking/">Part 4: Networking setup</a></li>
<li>Part 5: Intrusion Detection (IDS) setup (coming soon)</li>
</ul>
<h3>Xen and domU's</h3>
<p>Setting up Xen on Ubuntu Server is pretty straightforward:</p>
<pre>aptitude install ubuntu-xen-server</pre>
<p>This meta-package will install all you need. After a reboot, you should be running Xen. Then, for the domU machines. They can be installed using xen-create-image, but I chose the manual setup since I had too much customization to do (in fact, I was too lazy to find out how to do this with xen-create-image). So:</p>
<pre>mount /dev/vg0/core-root /mnt
debootstrap hardy /mnt http://nl.archive.ubuntu.com/ubuntu</pre>
<p>This installes Ubuntu Hardy into the domU. After this initial setup, it is important to edit the following files to reflect your network settings:</p>
<pre>/mnt/etc/hostname
/mnt/etc/network/interfaces
/mnt/etc/resolv.conf
/mnt/etc/apt/sources.list</pre>
<p>And make the modules for the current kernel available to the domU:</p>
<pre>cp -R /lib/modules/`uname -r` /mnt/lib/modules/</pre>
<p>Now we can create a xen config file. Mine looks like this:<br />
<span id="more-102"></span></p>
<pre>kernel      = '/boot/vmlinuz-2.6.24-23-xen'
ramdisk     = '/boot/initrd.img-2.6.24-23-xen'
memory      = '1024'
root        = '/dev/sda1 ro'
disk        = [
                  'phy:vg0/core-root,sda1,w',
                  'phy:vg0/core-swap,sda2,w',
              ]
name        = 'core'
vif         = [ 'ip=94.142.241.53,vifname=vif-core' ]
on_poweroff = 'destroy'
on_reboot   = 'restart'
on_crash    = 'restart'</pre>
<p>We should be ready to start the domU now. After booting it, don't forget the following steps:</p>
<ol>
<li>Set a root password</li>
<li>Install ssh and libc6-xen</li>
<li>Disable root logins via ssh</li>
<li>Create a user and put him in the admin group</li>
<li>Grant the admin group sudo privileges</li>
<li>Setup some firewall rules</li>
<li>Move /lib/tls to /lib/tls.disabled</li>
<li>Enable swap: <code>swapon /dev/sda2</code></li>
<li>Create a /etc/fstab file containing proc, root and swap</li>
</ol>
<h2>Serial console</h2>
<p>There is one thing left: the serial console. Many server administrators will want to use a serial console in case things go wrong with the network. I do, anyway <img src='http://drainbamage.nl/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  For those who aren't familiar with the concept: a serial console is a login console on the serial port. Typically, you will have a console server in the rack with many serial ports, each one connected to a server. You can then login to the console server via TCP/IP and access the serial consoles of the servers. This way, you can manage the server when its network isn't functioning for some reason (for example, if you're blocked out by an overly eager IDS). Furthermore, the serial console functions as an attached keyboard/VGA: you can access the BIOS and the grub menu.</p>
<p>The serial console must be enabled in a few stages of the boot process in order to be fully functional:</p>
<ul>
<li>BIOS</li>
<li>Grub</li>
<li>Xen</li>
<li>Linux</li>
</ul>
<p>First, the BIOS. How serial console is enabled in the BIOS differs per BIOS, but yours should have an option for serial console somewhere. Then Grub. In order to tell Grub to send output to the serial console and accept input from it, add the following lines to /boot/grub/menu.lst:</p>
<pre>
serial --unit=0 --speed=9600 --word=8 --parity=no --stop=1
terminal --timeout=5 serial console
</pre>
<p>The <code>serial</code> defines a serial console at 9600 baud, no parity, 1 stopbit and a wordsize of 8. The parameters may be different for your serial console, make sure you have the same settings on both sides of the wire. 9600 is a pretty low speed, just to be safe.<br />
The <code>terminal</code> command instructs grub to use the 'serial' and 'console' interfaces for the menu. It will wait for 5 seconds for a keypress on either one, and than use that one.</p>
<p>Now, Xen must also send its output to the serial console. Here's a chunk from my menu.lst for the Xen boot:</p>
<pre>
title           Xen 3.2 / Ubuntu 8.04.2, kernel 2.6.24-23-xen
root            (hd0,0)
kernel          /boot/xen-3.2.gz com1=9600,8n1 console=com1,vga
module          /boot/vmlinuz-2.6.24-23-xen root=/dev/md0 ro console=tty0 console=xvc0
module          /boot/initrd.img-2.6.24-23-xen
</pre>
<p>The option <code>com1=9600,8n1</code> again initializes a serial console at 9600 baud, no parity, 1 stop bit. Then, <code>console=com1,vga</code> sends the output to both the VGA and serial interfaces. On the <code>module</code> line, Linux is instructed to use both its normal tty and the serial device <code>xvc0</code> for output. The device <code>xvc0</code> is created by Xen. I'm running Xen 3.2 and a xennified Linux 2.6.24, for some older versions of Xen and Linux the serial device is the usual linux serial device, ttyS0. For some even newer versions, the device is called <code>hvc0</code>. To find out which device you should use, boot the system without serial console and check which of the devices <code>ttyS0</code>, <code>xvc0</code> or <code>hvc0</code> exists in <code>/dev</code>.</p>
<p>Now, you'll have output of all the stages of the boot process on your serial console. One last thing: you'll probably want to be able to also login on the console. This requires that Linux spawns a <code>getty</code> process (the login process) attached to the serial interface, just as it does for the regular tty's. Under most Linux distro's, this is done by adding the following line to <code>/etc/inittab</code>:</p>
<pre>
T0:12345:respawn:/sbin/getty -L xvc0 9600 vt102
</pre>
<p>The <code>init</code> process will then start a getty process attached to /dev/xvc0. For Ubuntu 8.04 and newer, this has been replaced by <code>upstart</code>. The configuration for <code>upstart</code> resides in <code>/etc/event.d</code>, where you can see a config file for every console and the boot stages. Copy the file for <code>tty1</code> to <code>xvc0</code> (or, again, <code>hvc0</code> or <code>ttyS1</code>) and replace <code>tty1</code> with the appropriate serial device. Make sure to add the <code>-L 9600</code> option again. The file now looks lik this:</p>
<pre>
# xvc0 - getty
#
# This service maintains a getty on xvc0 from the point the system is
# started until it is shut down again.

start on stopped rc2
start on stopped rc3
start on stopped rc4
start on stopped rc5

stop on runlevel 0
stop on runlevel 1
stop on runlevel 6

respawn
exec /sbin/getty -L 9600 xvc0 vt100
</pre>
<p>And that's it, your serial console should be set to go!</p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=Server+setup+part+3%3A+Xen+and+DomU%E2%80%99s+http://gycfs.th8.us" title="Post to Twitter"><img class="nothumb" src="http://drainbamage.nl/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Server+setup+part+3%3A+Xen+and+DomU%E2%80%99s+http://gycfs.th8.us" title="Post to Twitter">Tweet This Post</a></p>]]></content:encoded>
			<wfw:commentRss>http://drainbamage.nl/2009/03/server-setup-part-3-xen-and-domus/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Server setup part 2: RAID and LVM</title>
		<link>http://drainbamage.nl/2009/03/server-setup-part-2-raid-and-lvm/</link>
		<comments>http://drainbamage.nl/2009/03/server-setup-part-2-raid-and-lvm/#comments</comments>
		<pubDate>Mon, 09 Mar 2009 12:12:00 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[UNIX/Security]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[lvm]]></category>
		<category><![CDATA[raid]]></category>
		<category><![CDATA[xen]]></category>

		<guid isPermaLink="false">http://drainbamage.nl/?p=100</guid>
		<description><![CDATA[This is part 2 of the series on my new server setup with Ubuntu and Xen. Part 1: Overview and OS Part 2: Disk setup (RAID, LVM) Part 3: Xen and domU setup Part 4: Networking setup Part 5: Intrusion Detection (IDS) setup (coming soon) Disk allocation with RAID and LVM The system has 6 [...]]]></description>
			<content:encoded><![CDATA[<p>This is part 2 of the series on my new server setup with Ubuntu and Xen.</p>
<ul>
<li><a href="http://drainbamage.nl/2009/03/09/server-setup-part-1/">Part 1: Overview and OS</a></li>
<li><a href="http://drainbamage.nl/2009/03/09/server-setup-part-2-raid-and-lvm/">Part 2: Disk setup (RAID, LVM)</a></li>
<li><a href="http://drainbamage.nl/2009/03/09/server-setup-part-3-xen-and-domus/">Part 3: Xen and domU setup</a></li>
<li><a href="http://drainbamage.nl/2009/03/10/server-setup-part-4-networking/">Part 4: Networking setup</a></li>
<li>Part 5: Intrusion Detection (IDS) setup (coming soon)</li>
</ul>
<h3>Disk allocation with RAID and LVM</h3>
<p>The system has 6 disks: 2 x 18G, 2 x 36G and 2 x 300G. It has a SCSI controller that supports RAID 1 only. However, I choose to use Linux software RAID instead. Using software RAID for RAID 1 doesn't really cause a performance penalty, since the data only has to be sent to 2 disks, no parities have to be calculated like with RAID 5. I want the disks to be fully redundant, so here's the setup. Click the image to see it in full size.<a href="http://drainbamage.nl/wp-content/uploads/disk-allocation.gif" target="_new"><br />
<img style="float: right;" title="disk-allocation" src="http://drainbamage.nl/wp-content/uploads/disk-allocation-300x217.gif" border="0" alt="disk-allocation" width="300" height="217" /></a>I've created three RAID-1 partitions from the 6 disks, grouping them in pairs. The 18G pair is for the dom0, since it won't have much to do this will be enough space. Then, I want all the remaining space to be available to the virtual machines. And I want to be able to re-allocate space without going through too much trouble. The way to do this is by using LVM: <a href="http://en.wikipedia.org/wiki/Logical_Volume_Manager_(Linux)" target="_blank">Logical Volume Manager</a>. What LVM does is roughly the following: you assign normal disk partitions which you've given the LVM type ("physical volume, PV") into so-called "volume groups" (VG's). From these VG's you create logical volumes: LVs. These logical volumes can be used as normal partitions again. So, I've created a PV out of both RAID 1 partitions on the 36G and 300G sets. These PV's are joined in one VG. In this VG I've created LV's for disk and swap of all the domU machines.<br />
<span id="more-100"></span><br />
During setup, I created md0 and md1, the root and swap for dom0. md2 and md3 were created with these commands:</p>
<pre>mdadm --create /dev/md2 --level 1 --raid-devices=2 /dev/sdc1 /dev/sdd1</pre>
<p>Then, to create PV's, use <code>pvcreate</code>:</p>
<pre>pvcreate /dev/md2</pre>
<p>The same for md3, and now the md's are ready to be put into a volume group:</p>
<pre>vgcreate vg0 /dev/md2
vgextend vg0 /dev/md3</pre>
<p>After this, the command <code>vgdisplay</code> gives roughly this output:</p>
<pre> --- Volume group ---
  VG Name               vg0
  System ID
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  8
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                0
  Open LV               0
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               313.28 GB
  PE Size               4.00 MB
  Total PE              80200
  Alloc PE / Size       78592 / 307.00 GB
  Free  PE / Size       1608 / 6.28 GB
  VG UUID               4r52aD-uRod-Bltc-PGMl-2o5g-ubeH-cIRHik</pre>
<p>Next, to create the logical volumes with<br />
<code>lvcreate</code>:</p>
<pre>lvcreate -L 40G -n core-root vg0</pre>
<p>This creates a 40G volume for the root filesystem of the core services domU. It is initialized with<br />
<code>mkfs.ext3</code>:</p>
<pre>mkfs.ext3 /dev/vg0/core-root</pre>
<p>And with mkswap for the swap partitions. Now, the system is ready to receive some domU's!</p>
<h3>Flexibility of LVM</h3>
<p>Say I want to replace the 36G drives with bigger ones, which probably will happen some day. If I have enough free space on the 300G's, this can be done without having to move the data to another system. <u>The free space must not be allocated to any LV!</u> You can tell LVM to move the data off a particular PV, then remove the PV from the VG, then create a PV on the new disk and add it to the VG. Also, <u>use the partitions in /dev/mapper instead of /dev/vg0!</u> Using those in /dev/vg0 caused my SCSI host to crash repeatedly.</p>
<p>In my case, I have all space in the VG allocated to LV's. So, first I'll shrink an LV (after halting the domU):</p>
<pre>
e2fsck -f /dev/mapper/vg0-masteen--root
resize2fs /dev/mapper/vg0-masteen--root
lvresize -L 201G vg0/masteen-root
</pre>
<p>Now <code>vgdisplay</code> shows the free space:</p>
<pre>
  --- Volume group ---
  VG Name               vg0
  System ID
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  9
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                6
  Open LV               6
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               313.28 GB
  PE Size               4.00 MB
  Total PE              80200
  Alloc PE / Size       68608 / 268.00 GB
  Free  PE / Size       11592 / 45.28 GB
  VG UUID               4r52aD-uRod-Bltc-PGMl-2o5g-ubeH-cIRHik
</pre>
<p>So we can remove the old disk (/dev/md2) from the VG:</p>
<pre>
pvmove /dev/md2
vgreduce vg0 /dev/md2
</pre>
<p>And the disk can be removed. Likewise for adding a disk:</p>
<pre>
pvcreate /dev/md2
vgextend vg0 /dev/md2
lvextend -L 230G vg0/masteen-root
</pre>
<p>And the disk's back in!</p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=Server+setup+part+2%3A+RAID+and+LVM+http://dhs3d.th8.us" title="Post to Twitter"><img class="nothumb" src="http://drainbamage.nl/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Server+setup+part+2%3A+RAID+and+LVM+http://dhs3d.th8.us" title="Post to Twitter">Tweet This Post</a></p>]]></content:encoded>
			<wfw:commentRss>http://drainbamage.nl/2009/03/server-setup-part-2-raid-and-lvm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Server setup part 1: Overview and OS</title>
		<link>http://drainbamage.nl/2009/03/server-setup-part-1/</link>
		<comments>http://drainbamage.nl/2009/03/server-setup-part-1/#comments</comments>
		<pubDate>Mon, 09 Mar 2009 12:10:46 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[UNIX/Security]]></category>
		<category><![CDATA[install]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[lvm]]></category>
		<category><![CDATA[raid]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[setup]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[x345]]></category>
		<category><![CDATA[xen]]></category>

		<guid isPermaLink="false">http://drainbamage.nl/?p=77</guid>
		<description><![CDATA[I've recently bought a new server. That is, a new second-hand server. It's an IBM eServer x345 with two Xeon 2.4GHz CPUs, 4GB of ECC reg memory, 6 U320 hot-swap SCSI disks and 2 hot-swap PSUs. A very nice machine, for a decent price. The only drawback is the price of hardware expansion: SCSI disks [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-91" title="ibm-x345" src="http://drainbamage.nl/wp-content/uploads/ibm-x345.gif" alt="ibm-x345" width="300" height="114" />I've recently bought a new server. That is, a new second-hand server. It's an IBM eServer x345 with two Xeon 2.4GHz CPUs, 4GB of ECC reg memory, 6 U320 hot-swap SCSI disks and 2 hot-swap PSUs. A very nice machine, for a decent price. The only drawback is the price of hardware expansion: SCSI disks are screamingly expensive, and ECC reg memory isn't cheap either. However, I thought I'd share with you the setup I've chosen on the machine. Maybe someone will benefit from it.<br />
I've spread this article across 5 different posts:</p>
<ul>
<li><a href="http://drainbamage.nl/2009/03/09/server-setup-part-1/">Part 1: Overview and OS</a></li>
<li><a href="http://drainbamage.nl/2009/03/09/server-setup-part-2-raid-and-lvm/">Part 2: Disk setup (RAID, LVM)</a></li>
<li><a href="http://drainbamage.nl/2009/03/09/server-setup-part-3-xen-and-domus/">Part 3: Xen and domU setup</a></li>
<li><a href="http://drainbamage.nl/2009/03/10/server-setup-part-4-networking/">Part 4: Networking setup</a></li>
<li>Part 5: Intrusion Detection (IDS) setup (coming soon)</li>
</ul>
<h3>Overview and OS</h3>
<p>First of all, I decided to use Ubuntu Server 8.04 LTS, since it has long support for security updates. Ubuntu also is more frequent with releases than Debian, which I've been using up till now. With Debian, I always needed lots of packages from the testing distro, making dependencies and upgrades more difficult. Hope it's better with Ubuntu, it feels just like Debian so far. I'm also going to use Xen for virtualization. On my previous server, I had all services and tasks in one root, and it quickly became a mess. Also, due to a leaky version of Mambo somewhere in a forgotten place on the system, the system was compromised once. By creating virtual machines for different tasks, I'm hoping to keep the system maintainable and more secure. The idea is to have three virtual machines:</p>
<ol>
<li>Hosting: websites, some shell accounts, irssi</li>
<li>Core services: DNS, SMTP, IMAP, POP3</li>
<li>Dev: a VM to test new stuff in without breaking anything</li>
</ol>
<p>All three servers will have their own Apache and MySQL daemons. For hosting, it's obvious why. For e-mail, I use MySQL to store domains, mailbox info, aliases and DNS records. I want this MySQL not to be bothered with anything else. For dev, it's obvious as well. </p>
<p>Then, there's the host system, or dom0 in Xen terminology. Dom0 will have as little tasks as possible: the less it does, the less can go wrong. The real work will take place in the domU's.<br />
As for networking, the colo provider where my server is at (Coloclue, <a href="http://www.coloclue.net" target="new">www.coloclue.net</a>) has a particular IP setup to maximize the use of IP addresses. Hosts are assigned IPs from different subnets, leading to some difficulties with Xen and bridging. In the networking post we take care of this problem.</p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=Server+setup+part+1%3A+Overview+and+OS+http://gdmb4.th8.us" title="Post to Twitter"><img class="nothumb" src="http://drainbamage.nl/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Server+setup+part+1%3A+Overview+and+OS+http://gdmb4.th8.us" title="Post to Twitter">Tweet This Post</a></p>]]></content:encoded>
			<wfw:commentRss>http://drainbamage.nl/2009/03/server-setup-part-1/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Snort and OSSEC &#8211; UNIX intrusion detection</title>
		<link>http://drainbamage.nl/2009/02/snort-and-ossec-unix-intrusion-detection/</link>
		<comments>http://drainbamage.nl/2009/02/snort-and-ossec-unix-intrusion-detection/#comments</comments>
		<pubDate>Thu, 12 Feb 2009 16:21:34 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[UNIX/Security]]></category>

		<guid isPermaLink="false">http://www.keol.nl/?p=29</guid>
		<description><![CDATA[Many of you have probably used snort for network intrusion detection. Snort is the most popular open-source NIDS, and features many detection plugins. For me, I haven't given much thought to what NIDS I'd use, and just installed snort on the system I maintain. The problem One problem with snort however is that it's only [...]]]></description>
			<content:encoded><![CDATA[<p>Many of you have probably used <a href="http://www.snort.org">snort</a> for network intrusion detection. Snort is the most popular open-source NIDS, and features many detection plugins. For me, I haven't given much thought to what NIDS I'd use, and just installed snort on the system I maintain.</p>
<p><strong>The problem</strong><br />
One problem with snort however is that it's only passive: it detects intrusion attempts, reports them to syslog, and sits back. This is not what I want, as I'm not always monitoring my syslog. At the least, I want email alerts when something strange happens. Even better, I'd like the IDS to perform soms actions to restrict malicious traffic once it starts. By blocking all packets from someone who is port scanning, for example.</p>
<p><strong>A solution</strong><br />
A solution to the first problem is to install <a href="http://swatch.sourceforge.net">swatch</a>: a tool that watches the syslog, and sends email alerts. Using regular expressions, you define about which log entries you want to be alerted. Nice, but requires a lot of configuration, probably doesn't catch all alerts you want to know about, and still doesn't solve the passivity of the system. There are solutions that both notify and implement counter-measures, turning snort into an Intrusion Prevention System (IPS) instead of just an IDS. Most well-known are SnortSam and Snort_inline.</p>
<p><strong>A better solution</strong><br />
However, three is also <a href="http://www.ossec.net">OSSEC</a>. OSSEC is a HIDS (Host-based Intrusion Detection System), and as such it does not watch the network traffic, but just the host. This means it checks the integrity of important files, and watches syslog. The good thing is, it knows about snort, and knows what its syslog messages look like. The better thing is, it is easily configured to perform actions, and by default adds firewall rules to drop traffic from IP addresses snort reports to be port scanning. OSSEC is configured by a large number of well-structured XML files, and operates in a distributed way. You can perform a standalone installation, or a server-agent setup. For my Xen machines, the dom0 is the server and the domUs are agents, reporting to the server. This works great, since when the domU machines report malicious traffic, the dom0 will drop all the traffic from the attacker's IP, protecting all domUs and dom0.</p>
<p>And, OSSEC sends email alerts to inform you about what's going on. What severity an alert must have for the admin to be emailed can be configured. One caveat however, some alerts ignore these settings and are emailed anyway (as can be configured in the alert's XML file).</p>
<p>I've attached two patches to the config to make OSSEC aware of denied AXFR requests by BIND (which it would otherwise email about), and to ignore unexpectedly terminated SSH sessions.</p>
<p><a href="http://www.keol.nl/wp-content/uploads/ossec_named_rules.patch">ossec_named_rules.patch</a><br />
<a href="http://www.keol.nl/wp-content/uploads/ossec_sshd_rules.patch">ossec_sshd_rules.patch</a></p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=Snort+and+OSSEC+%E2%80%93+UNIX+intrusion+detection+http://q5bx4.th8.us" title="Post to Twitter"><img class="nothumb" src="http://drainbamage.nl/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Snort+and+OSSEC+%E2%80%93+UNIX+intrusion+detection+http://q5bx4.th8.us" title="Post to Twitter">Tweet This Post</a></p>]]></content:encoded>
			<wfw:commentRss>http://drainbamage.nl/2009/02/snort-and-ossec-unix-intrusion-detection/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Xen on Debian Lenny</title>
		<link>http://drainbamage.nl/2009/02/xen-on-debian-lenny/</link>
		<comments>http://drainbamage.nl/2009/02/xen-on-debian-lenny/#comments</comments>
		<pubDate>Thu, 12 Feb 2009 16:00:32 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[UNIX/Security]]></category>

		<guid isPermaLink="false">http://www.keol.nl/?p=21</guid>
		<description><![CDATA[A few months ago, I tried to install Xen on Debian Lenny (testing). Xen is a hypervisor: it runs on the CPU in a lower ring than Linux, and regulates the resource access by virtual machines. These virtual machines aren't so virtual with Xen, as they have direct access to the CPU, memory, and any [...]]]></description>
			<content:encoded><![CDATA[<p>A few months ago, I tried to install Xen on Debian Lenny (testing). Xen is a hypervisor: it runs on the CPU in a lower ring than Linux, and regulates the resource access by virtual machines. These virtual machines aren't so virtual with Xen, as they have direct access to the CPU, memory, and any other devices you assign to them. With Xen, you run multiple OSs in parallel.</p>
<p><strong>The problem</strong><br />
Installation of the hypervisor and xend went fine, and I created a few domUs with debootstrap. However, I couldn't get them to boot. After some googling I found that the xennified kernels in Lenny are only dom0 kernels, not domU for some reason. So, I installed kernels from Etch (2.6.18), and everything worked. Sort of.</p>
<p>This week I have to install a new server with Xen however, and I wasn't happy with my mixed Lenny/Etch solution. Since Lenny is testing and a lot changes in the package base, I decided to try Xen with Lenny again. I installed Lenny on a test PC, installed the  xen-linux-system metapackage along with the xen-tools, and kernel 2.6.26-xen. I installed a domU machine with debootstrap/lenny, and tried to boot it. It wouldn't give me a console however. It went through the init scripts until the point where you'd expect a login prompt. Weird.</p>
<p><strong>A solution</strong><br />
Some googling again, and it seems that the udev package, which is required, isn't installed by debootstrap.</p>
<ol>
<li>Mount the harddisk image: <code>mount -o loop /var/xen/domains/[domain]/disk.img /mnt/tmp</code></li>
<li>Enter the mounted filesystem: <code>cd /mnt/tmp</code></li>
<li>Download udev and libvolume-id0: <code>aptitude  download udev libvolume-id0</code></li>
<li>chroot into the mounted filesystem: <code>chroot /mnt/tmp</code></li>
<li>Install the packages: <code>dpkg -i *.deb</code></li>
<li>Umount: <code>cd /; umount /mnt/tmp</code></li>
</ol>
<p><strong>A better solution</strong><br />
Now you have a working lenny image. The other way is much easier (with thanks to <a href="http://blog.debit.nl">Bernard</a>): when creating the image, pass the <code>--role=udev</code> option to <code>xen-create-image</code>.</p>
<p>[Note: as of this writing, Lenny is expected to be released as stable within 2-4 days. So, the xen behaviour could still change]</p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=Xen+on+Debian+Lenny+http://3iagk.th8.us" title="Post to Twitter"><img class="nothumb" src="http://drainbamage.nl/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Xen+on+Debian+Lenny+http://3iagk.th8.us" title="Post to Twitter">Tweet This Post</a></p>]]></content:encoded>
			<wfw:commentRss>http://drainbamage.nl/2009/02/xen-on-debian-lenny/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Leopards extended file attributes (Time Machine and Quarantine)</title>
		<link>http://drainbamage.nl/2008/01/leopards-extended-file-attributes-time-machine-and-quarantine/</link>
		<comments>http://drainbamage.nl/2008/01/leopards-extended-file-attributes-time-machine-and-quarantine/#comments</comments>
		<pubDate>Wed, 30 Jan 2008 13:52:44 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[Life hacking]]></category>

		<guid isPermaLink="false">http://www.keol.nl/2008/01/30/leopards-extended-file-attributes-time-machine-and-quarantine/</guid>
		<description><![CDATA[Recently, I discovered something interesting about the HFS+ filesystem features in Mac OS X 10.5 Leopard. I don't know whether these features were present in earlier versions of OS X, they weren't used in the way they are now however. I was wondering how Apple's new backup feature "Time Machine" works. When looking at a [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, I discovered something interesting about the HFS+ filesystem features in Mac OS X 10.5 Leopard. I don't know whether these features were present in earlier versions of OS X, they weren't used in the way they are now however.</p>
<p>I was wondering how Apple's new backup feature "Time Machine" works. When looking at a time machine partition with the terminal, all the files that haven't changed are simply hard links. However, when I listed them with 'ls -al', I saw a an attribute I haven't seen before:<br />
<code><br />
-rw-r--r--@  2 chris  staff    14M Jan 27 13:58 stoel.mov<br />
-rw-r--r--@  2 chris  staff    12M Aug  9 05:31 tony vs paul.flv<br />
-rw-r--r--@  1 chris  staff    59M Jan 28 20:40 visiting shoes.mov<br />
</code></p>
<p>Also, this '@' sign is present on other files sometimes. The man page of ls says:<br />
<code><br />
-@      Display extended attribute keys and sizes.<br />
</code></p>
<p>I also discovered this attribute on another bunch of files I recently downloaded. The strange thing about these files was that I couldn't modify or move them: the Finder (and 'mv') wouldn't allow me to. After some googling, I found <a href="http://blog.nanorails.com/articles/2007/12/12/removing-the-quarantine-attribute-on-your-application">this</a> link that explained why.</p>
<p>The '@' sign indicates that there are extended attributes in place on the file. You can list them with <code>ls -@</code>, and you can get and set them with 'xattr'. On the files I couldn't modify, I saw there was a 'com.apple.quarantine' attribute in effect. After removign it with 'xattr' I could move them again.</p>
<p>Back to Time Machine. The files in Time Machine have many attributes, for example:</p>
<p><code><br />
Appelflap:Stop Motion chris$ xattr -l stoel.mov<br />
com.apple.FinderInfo:<br />
0000   4D 6F 6F 56 69 53 74 6F 00 00 00 00 00 00 00 00    MooViSto........<br />
0010   00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................</p>
<p>com.apple.metadata:_kTimeMachineNewestSnapshot:<br />
0000   62 70 6C 69 73 74 30 30 33 42 2D 63 C3 7F 00 00    bplist003B-c....<br />
0010   00 08 00 00 00 00 00 00 01 01 00 00 00 00 00 00    ................<br />
0020   00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................<br />
0030   00 11                                              ..</p>
<p>com.apple.metadata:_kTimeMachineOldestSnapshot:<br />
0000   62 70 6C 69 73 74 30 30 33 41 AA 9B A8 BA 00 00    bplist003A......<br />
0010   00 08 00 00 00 00 00 00 01 01 00 00 00 00 00 00    ................<br />
0020   00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................<br />
0030   00 11                                              ..</p>
<p>Appelflap:Stop Motion chris$ xattr -l tony\ vs\ paul.flv<br />
com.apple.metadata:_kTimeMachineNewestSnapshot:<br />
0000   62 70 6C 69 73 74 30 30 33 42 2D 63 C3 7F 00 00    bplist003B-c....<br />
0010   00 08 00 00 00 00 00 00 01 01 00 00 00 00 00 00    ................<br />
0020   00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................<br />
0030   00 11                                              ..</p>
<p>com.apple.metadata:_kTimeMachineOldestSnapshot:<br />
0000   62 70 6C 69 73 74 30 30 33 41 AA 9B A8 BA 00 00    bplist003A......<br />
0010   00 08 00 00 00 00 00 00 01 01 00 00 00 00 00 00    ................<br />
0020   00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................<br />
0030   00 11                                              ..</p>
<p>com.apple.metadata:kMDItemWhereFroms:<br />
0000   62 70 6C 69 73 74 30 30 A2 01 02 5F 10 42 68 74    bplist00..._.Bht<br />
0010   74 70 3A 2F 2F 61 73 68 2D 76 31 30 30 2E 61 73    tp://ash-v100.as<br />
0020   68 2E 79 6F 75 74 75 62 65 2E 63 6F 6D 2F 67 65    h.youtube.com/ge<br />
0030   74 5F 76 69 64 65 6F 2E 66 6C 76 3F 76 69 64 65    t_video.flv?vide<br />
0040   6F 5F 69 64 3D 41 4A 7A 55 33 4E 6A 44 69 6B 59    o_id=AJzU3NjDikY<br />
0050   5F 10 21 68 74 74 70 3A 2F 2F 6D 65 67 61 75 70    _.!http://megaup<br />
0060   6C 6F 61 64 2E 6E 65 74 2F 6B 65 65 70 76 69 64    load.net/keepvid<br />
0070   2E 70 68 70 08 0B 50 00 00 00 00 00 00 01 01 00    .php..P.........<br />
0080   00 00 00 00 00 00 03 00 00 00 00 00 00 00 00 00    ................<br />
0090   00 00 00 00 00 00 74                               ......t</p>
<p>com.apple.quarantine: 0000;479afced;Safari;51D09ED4-1818-4136-A801-52237BD2E12E|com.apple.Safari<br />
Appelflap:Stop Motion chris$<br />
</code></p>
<p>While these attributes are binary, they reveal some information. The "com.apple.metadata:kMDItemWhereFroms" attribute shows the URL I downloaded the movie from, which is keepvid.com. The other properties have to do with version control in time machine. </p>
<p>Interesting stuff. I haven't found the time yet to dig deeper into time machine and see what it does with diffs and all, for now it seems like it just hardlinks unchanged files and uses these 'extended properties' for version management. Which explains why it only works on HFS+ <img src='http://drainbamage.nl/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=Leopards+extended+file+attributes+%28Time+Machine+and+Quarantine...+http://ypsww.th8.us" title="Post to Twitter"><img class="nothumb" src="http://drainbamage.nl/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Leopards+extended+file+attributes+%28Time+Machine+and+Quarantine...+http://ypsww.th8.us" title="Post to Twitter">Tweet This Post</a></p>]]></content:encoded>
			<wfw:commentRss>http://drainbamage.nl/2008/01/leopards-extended-file-attributes-time-machine-and-quarantine/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>My first youtube post</title>
		<link>http://drainbamage.nl/2008/01/my-first-youtube-post/</link>
		<comments>http://drainbamage.nl/2008/01/my-first-youtube-post/#comments</comments>
		<pubDate>Tue, 29 Jan 2008 14:27:41 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[Life hacking]]></category>

		<guid isPermaLink="false">http://www.keol.nl/2008/01/29/my-first-youtube-post/</guid>
		<description><![CDATA[Recently I figured that I cannot be a true student of Telematics, semi-geek or internet professional without actively participating in the Web 2.0 thing. I'm already on last.fm, linkedin, 43things and plaxo, but I have never posted a film to youtube! Combined with this great new app I bought, iStopMotion, and an evening with a [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I figured that I cannot be a true student of Telematics, semi-geek or internet professional without actively participating in the Web 2.0 thing. I'm already on last.fm, linkedin, 43things and plaxo, but I have never posted a film to youtube!<br />
Combined with this great new app I bought, iStopMotion, and an evening with a good friend, it resulted in a short stop-motion film. You can watch it at <a href="http://www.youtube.com/watch?v=CS6UmuZgSZU">youtube</a> or embedded here. It is about a pair of shoes visiting a friend and having a beer together <img src='http://drainbamage.nl/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Have fun!</p>
<p><object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/CS6UmuZgSZU&rel=1"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/CS6UmuZgSZU&rel=1" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed></object></p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=My+first+youtube+post+http://6qtye.th8.us" title="Post to Twitter"><img class="nothumb" src="http://drainbamage.nl/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=My+first+youtube+post+http://6qtye.th8.us" title="Post to Twitter">Tweet This Post</a></p>]]></content:encoded>
			<wfw:commentRss>http://drainbamage.nl/2008/01/my-first-youtube-post/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Spamassassin statistics per user in SQL</title>
		<link>http://drainbamage.nl/2007/09/spamassassin-statistics-per-user-in-sql/</link>
		<comments>http://drainbamage.nl/2007/09/spamassassin-statistics-per-user-in-sql/#comments</comments>
		<pubDate>Wed, 26 Sep 2007 13:39:04 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[UNIX/Security]]></category>

		<guid isPermaLink="false">http://www.keol.nl/2007/09/26/spamassassin-statistics-per-user-in-sql/</guid>
		<description><![CDATA[The last few days I've been busy reconfiguring my mailserver (postfix) and spamkiller (spamassasin). I wanted to have per-user controls over the spam filtering, and I wanted the spam to be placed in a spambox on the server (instead of clients having to filter and move spam). This was a bit difficult since I use [...]]]></description>
			<content:encoded><![CDATA[<p>The last few days I've been busy reconfiguring my mailserver (postfix) and spamkiller (spamassasin). I wanted to have per-user controls over the spam filtering, and I wanted the spam to be placed in a spambox on the server (instead of clients having to filter and move spam). This was a bit difficult since I use virtual mail users, not real system users.</p>
<p>Eventually I succeeded, using maildrop (<a href="http://www.courier-mta.org/maildrop/">http://www.courier-mta.org/maildrop/</a>) instead of the postfix virtual delivery agent. Maildrop now invokes spamassassin based on a per-user (virtual user) config file, and drops spam to INBOX.Spambox. Cool!</p>
<p>However, I also wanted some nice statistics of the filtering. It would be nice to see what percentage of the mail coming through the server is spam, and which users get the most spam. I couldn't find a nice solution for this however. The solution that came the closest was sa-stats.pl (<a href="http://0wned.it/view/2007/03/17/sastats_in_cvs/">http://0wned.it/view/2007/03/17/sastats_in_cvs/</a>). It prints out the statistics I want, based on logfile analysis. However, it doesn't collect statistics over a longer period.</p>
<p>So what I did is this: I modified sa-stats.pl to save the found statistics into a MySQL database. Using MySQLs aggregate functions (SUM, AVG, COUNT) it is very easy to get statistics of spam and ham, and totals. I wrote a PHP program to print these statistics.</p>
<p>So, <a href="http://www.keol.nl/~chris/weblog/sa-stats.pl">here</a> is the modified script, and <a href="http://www.keol.nl/~chris/weblog/sa-stats.sql">here</a> the SQL file that creates the tables it uses. Don't forget to change the database settings in the pl file around line 148!</p>
<p>And <a href="http://www.keol.nl/~chris/weblog/sa-stats.jpg">here</a> is a screenshot of what the output looks like.</p>
<p>Enjoy!</p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=Spamassassin+statistics+per+user+in+SQL+http://qc7d2.th8.us" title="Post to Twitter"><img class="nothumb" src="http://drainbamage.nl/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Spamassassin+statistics+per+user+in+SQL+http://qc7d2.th8.us" title="Post to Twitter">Tweet This Post</a></p>]]></content:encoded>
			<wfw:commentRss>http://drainbamage.nl/2007/09/spamassassin-statistics-per-user-in-sql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JavaScript Object Detection</title>
		<link>http://drainbamage.nl/2007/06/javascript-object-detection/</link>
		<comments>http://drainbamage.nl/2007/06/javascript-object-detection/#comments</comments>
		<pubDate>Sun, 03 Jun 2007 18:34:27 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[Web and Programming]]></category>

		<guid isPermaLink="false">http://www.keol.nl/2007/06/03/javascript-object-detection/</guid>
		<description><![CDATA[Even though the times of the browser wars are gone, browser incompatibilities remain. New features are added with every new browser version. Some are copied by the other vendors in their next version, some aren't. And of course there is the battle between the W3C standards and the Microsoft way, particularly in Javascript event handling. [...]]]></description>
			<content:encoded><![CDATA[<p>Even though the times of the browser wars are gone, browser incompatibilities remain. New features are added with every new browser version. Some are copied by the other vendors in their next version, some aren't. And of course there is the battle between the W3C standards and the Microsoft way, particularly in Javascript event handling.<br />
When creating a javascript-enhanced website, developers often run into these incompatibilities. The most obvious solution when encountering such a problem, is to detect which browser is being used. I'll illustrate this with an example.</p>
<p><code><br />
function changeText( )<br />
{<br />
&nbsp;&nbsp;var node = document.getElementById('nodeToChange');<br />
&nbsp;&nbsp;node.innerText = 'Hello, World!';<br />
}<br />
</code></p>
<p>This piece of code is pretty straightforward: the function <code>changeText</code> changes the text within the node with id="nodeToChange" into "Hello, World!".</p>
<p>This code won't work in Firefox. You'll see nothing change in the node. Firefox uses the <code>textContent</code> property to change the contents of a text node. So, one would expect the solution to be to detect the browser that the visitor is using, using some advanced browser detection script or your own routines. The name of the browser is available in the <code>navigator.userAgent</code> property. But most of the time, this is a very poor solution. Let me explain why.<br />
<span id="more-10"></span><br />
On the surface, it may seem that browser detection works. If the user agent is Firefox, you use the textContent property, otherwise you use innerText. But, who guarantees that Firefox is the only browser using textContent? Maybe there is some obscure browser for mobile devices using the same convention. Or, what if a new version of Firefox that will be released in two months will have switched to <code>innerText</code> for compatibility? Then you'd have to change all the scripts you've put online for your clients.</p>
<p>The better solution here is <strong>object detection</strong>. Instead of looking at the user agent, you look at what feature is supported. Thus, it doesn't matter anymore which browser is being used. In JavaScript, functions can be treated like objects. The following expression:</p>
<p><code><br />
document.getElementById;<br />
</code></p>
<p>Would evaluate to <code>true</code>, since there is a member of <code>document</code> called <code>getElementById</code>. It isn't until you put braces and optionally some arguments behind the name that the function is executed. So this;</p>
<p><code><br />
document.getElementById;<br />
</code><br />
Checks if the function exists, while this:</p>
<p><code><br />
document.getElementById('test');<br />
</code></p>
<p>Actually executes the function. In the same way, properties can be tested. This javascript feature lies at the heart of object detection. Using object detection, our solution to the <code>innerText</code> versus <code>textContent</code> would be:</p>
<p><code><br />
function changeText( )<br />
{<br />
&nbsp;&nbsp;var node = document.getElementById('nodeToChange');<br />
&nbsp;&nbsp;if( node.innerText )<br />
&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;node.innerText = 'Hello, World!';<br />
&nbsp;&nbsp;} else {<br />
&nbsp;&nbsp;&nbsp;&nbsp;node.textContent = 'Hello, World!';<br />
&nbsp;&nbsp;}<br />
}<br />
</code></p>
<p>This code will run nicely in all browsers that support one of both properties, current browsers and browsers yet to come.</p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=JavaScript+Object+Detection+http://7d23f.th8.us" title="Post to Twitter"><img class="nothumb" src="http://drainbamage.nl/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=JavaScript+Object+Detection+http://7d23f.th8.us" title="Post to Twitter">Tweet This Post</a></p>]]></content:encoded>
			<wfw:commentRss>http://drainbamage.nl/2007/06/javascript-object-detection/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Samsung D500 synchronization using iSync</title>
		<link>http://drainbamage.nl/2007/05/samsung-d500-synchronization-using-isync/</link>
		<comments>http://drainbamage.nl/2007/05/samsung-d500-synchronization-using-isync/#comments</comments>
		<pubDate>Tue, 22 May 2007 15:01:30 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[Life hacking]]></category>

		<guid isPermaLink="false">http://www.keol.nl/2007/05/22/samsung-d500-synchronization-using-isync/</guid>
		<description><![CDATA[Yes, it's possible! Recently (as in 'yesterday'), I obtained a Samsung SGH-D500 cellphone. A very nice phone, 1.3 megapixel camera and 96MB of memory. I was fairly happy with my Sony Ericsson Z520i, but after it suddenly died I had to find a replacement. Getting it to synchronize my contacts and agenda using iSync was [...]]]></description>
			<content:encoded><![CDATA[<p>Yes, it's possible! Recently (as in 'yesterday'), I obtained a Samsung SGH-D500 cellphone. A very nice phone, 1.3 megapixel camera and 96MB of memory. I was fairly happy with my Sony Ericsson Z520i, but after it suddenly died I had to find a replacement. Getting it to synchronize my contacts and agenda using iSync was a hassle, so here's the solution.</p>
<p>The Saumsung D500 officially doesn't have iSync support. Or the other way around, Apple iSync officially doesn't support the D500. However, after googling for a while, I found out that <a href="http://www.novamedia.de/index_e.html">Nova Media</a> has a set of <a href="http://www.novamedia.de/e_pages/e_produkte_software.html">iSync plugins</a> that adds additional phone support, including for the D500. I purchased the software (€10,-, not too bad) and gave it a try.<br />
<span id="more-8"></span><br />
However, this didn't seem to be enough. When attempting to synchronize, iSync would give me the following error:</p>
<p><code>There was an error getting data from the phone. The synchronization may have been cancelled on the phone.<br />
Device "chris" synchronization failed</code></p>
<p>I tried several things, including resetting the phone to default settings, but nothing really seemed to work. After a while, I e-mailed Nova Media requesting support. They were very quick to respond, and advised me to turn bluetooth on and off, remove some iSync, iCal and Address Book preference files, reset the D500, and try it again. I tried these and many other things, but nothing worked.</p>
<p>However, the <b>solution</b>. After clicking around for a while, I found what the problem was. Or rather, I found how to work around it. The synchronization would work if I selected 'Merge data on handheld device and computer' instead of 'Erase data on device then synchronize' as the first-time synchronization action. Perhaps it's a bug in the Nova Media D500 plugin or something like that, but now synchronization works fine.</p>
<p>I'm using Nova Media iSync phone plugins version <b>4.0.4</b>, perhaps this will be fixed in future releases.</p>
<p>Happy synching!</p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=Samsung+D500+synchronization+using+iSync+http://ynsi6.th8.us" title="Post to Twitter"><img class="nothumb" src="http://drainbamage.nl/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Samsung+D500+synchronization+using+iSync+http://ynsi6.th8.us" title="Post to Twitter">Tweet This Post</a></p>]]></content:encoded>
			<wfw:commentRss>http://drainbamage.nl/2007/05/samsung-d500-synchronization-using-isync/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
