<?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>Cosu</title>
	<atom:link href="http://cosu.ro/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://cosu.ro/blog</link>
	<description>"I'm even greater than I thought I was", Bender Bending Rodríguez , Futurama, S05E01</description>
	<lastBuildDate>Wed, 12 Oct 2011 13:35:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>ipv6: Neighbour table overflow</title>
		<link>http://cosu.ro/blog/2011/09/26/ipv6-neighbour-table-overflow/</link>
		<comments>http://cosu.ro/blog/2011/09/26/ipv6-neighbour-table-overflow/#comments</comments>
		<pubDate>Mon, 26 Sep 2011 08:17:53 +0000</pubDate>
		<dc:creator>Cosu</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://cosu.ro/blog/?p=1040</guid>
		<description><![CDATA[If syslog starts complaining about neighbor table overflow  then some limits need to be increased. Current values: grep . /proc/sys/net/ipv6/neigh/default/gc_thresh* /proc/sys/net/ipv6/neigh/default/gc_thresh1:128 /proc/sys/net/ipv6/neigh/default/gc_thresh2:512 /proc/sys/net/ipv6/neigh/default/gc_thresh3:1024 Add to sysctl.conf net.ipv6.neigh.default.gc_thresh1 = 512 net.ipv6.neigh.default.gc_thresh2 = 2048 net.ipv6.neigh.default.gc_thresh3 = 4096 Reload sysctl parameters sysctl -p]]></description>
			<content:encoded><![CDATA[<p>If syslog starts complaining about neighbor table overflow  then some limits need to be increased.</p>
<p>Current values:</p>
<pre>grep . /proc/sys/net/ipv6/neigh/default/gc_thresh*</pre>
<pre>/proc/sys/net/ipv6/neigh/default/gc_thresh1:128
/proc/sys/net/ipv6/neigh/default/gc_thresh2:512
/proc/sys/net/ipv6/neigh/default/gc_thresh3:1024</pre>
<p>Add to sysctl.conf</p>
<pre>net.ipv6.neigh.default.gc_thresh1 = 512
net.ipv6.neigh.default.gc_thresh2 = 2048
net.ipv6.neigh.default.gc_thresh3 = 4096</pre>
<p>Reload sysctl parameters</p>
<pre>sysctl -p</pre>
<pre></pre>
]]></content:encoded>
			<wfw:commentRss>http://cosu.ro/blog/2011/09/26/ipv6-neighbour-table-overflow/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How I fixed my google contacts phone numbers</title>
		<link>http://cosu.ro/blog/2011/05/02/how-i-fixed-my-google-contacts-phone-numbers/</link>
		<comments>http://cosu.ro/blog/2011/05/02/how-i-fixed-my-google-contacts-phone-numbers/#comments</comments>
		<pubDate>Mon, 02 May 2011 15:04:43 +0000</pubDate>
		<dc:creator>Cosu</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://cosu.ro/blog/?p=1035</guid>
		<description><![CDATA[With this handy thing: http://splitbrain.github.com/googlephonefix/ It connects to Google Accounts and adds  a default prefix to the phone numbers which don&#8217;t have one yet. Very handy if you moved abroad and you don&#8217;t want to add that damn country prefix by hand.  Privacy wise it&#8217;s fine, opensource and it runs only in the browser.]]></description>
			<content:encoded><![CDATA[<p>With this handy thing: <a href="http://splitbrain.github.com/googlephonefix/" target="_blank">http://splitbrain.github.com/googlephonefix/</a></p>
<p>It connects to Google Accounts and adds  a default prefix to the phone numbers which don&#8217;t have one yet. Very handy if you moved abroad and you don&#8217;t want to add that damn country prefix by hand.  Privacy wise it&#8217;s fine, opensource and it runs only in the browser.</p>
]]></content:encoded>
			<wfw:commentRss>http://cosu.ro/blog/2011/05/02/how-i-fixed-my-google-contacts-phone-numbers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Running Traffic over SSH easy peasy</title>
		<link>http://cosu.ro/blog/2011/04/04/running-traffic-over-ssh-easy-peasy/</link>
		<comments>http://cosu.ro/blog/2011/04/04/running-traffic-over-ssh-easy-peasy/#comments</comments>
		<pubDate>Mon, 04 Apr 2011 20:51:37 +0000</pubDate>
		<dc:creator>Cosu</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://cosu.ro/blog/?p=1030</guid>
		<description><![CDATA[Last week I was stuck in a hotel located in the middle of a forest with crappy GPRS signal so my mobile internet wasn&#8217;t any good. On top of this the &#8216;free&#8217; wifi at the hotel provided only web traffic connectivity ( ports 80 and 443). Sure, a smart guy would run a VPN over [...]]]></description>
			<content:encoded><![CDATA[<p>Last week I was stuck in a hotel located in the middle of a forest with crappy GPRS signal so my mobile internet wasn&#8217;t any good. On top of this the &#8216;free&#8217; wifi at the hotel provided only web traffic connectivity ( ports 80 and 443). Sure, a smart guy would run a VPN over port 443 and would be on his way. Unfortunately I&#8217;m not that guy. I struggled getting some remote ssh server listening on port 80 and in the end managed to do my thing.</p>
<p>Reading Hacker news today I stumbled upon a cool piece of softare: sshuttle. Acording to the developer, it allows you to seamlessly run traffic over ssh in a VPN kinda way, but without the vpn hassle. All you need is a working ssh connection and sudo rights on your machine. Traffic gets somehow redirected via ipfw or iptables to the &#8216;tunnel&#8217; and out it goes to the remote ssh endpoint. I just tested this with a couple of remove ssh servers and it works pretty good. Ah yes, and it&#8217;s open source so you can inspect the code for funny stuff..</p>
<p><a href="https://github.com/apenwarr/sshuttle">https://github.com/apenwarr/sshuttle</a></p>
]]></content:encoded>
			<wfw:commentRss>http://cosu.ro/blog/2011/04/04/running-traffic-over-ssh-easy-peasy/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Bash and Template Files</title>
		<link>http://cosu.ro/blog/2010/05/23/bash-and-template-files/</link>
		<comments>http://cosu.ro/blog/2010/05/23/bash-and-template-files/#comments</comments>
		<pubDate>Sun, 23 May 2010 17:29:50 +0000</pubDate>
		<dc:creator>Cosu</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://cosu.ro/blog/?p=987</guid>
		<description><![CDATA[Last week I had to migrate my dns server and to do stuff properly I also added a couple of slave DNS servers just to make sure. Problem: ~15 domain names that need to be added to a fresh bind installation. The zone files didn&#8217;t change too much so that was fine, sed helped me [...]]]></description>
			<content:encoded><![CDATA[<p>Last week I had to migrate my dns server and to do stuff properly I also added a couple of slave DNS servers just to make sure. Problem: ~15 domain names that need to be added to a fresh bind installation. The zone files didn&#8217;t change too much so that was fine, sed helped me out with the replacing of old IPs. But what about the bind configuration ? I had to add add the following declaration for all the 15 domains and on each of the slave dns server the &#8220;slave&#8221; equivalent:</p>
<pre>zone "example.com" {
        type master;
        file "/etc/bind/zones/example.ro/zone.db";
};
</pre>
<p>I was in the mood form automation but I wanted something light and quick to setup. Obvious answer: bash.</p>
<p>I created a &#8220;template&#8221; file where and I replaced the domain name with a place holder:</p>
<pre>zone \"$domain\" {
        type master;
        file \"/etc/bind/zones/$domain/zone.db\";
};
</pre>
<p>I then wrote a small bash loop that walks the array of domains and feeds them one by one to the template file. The end result was a nice config file with all of the domain names.</p>
<p><code>#!/bin/sh<br /> for i in `find * -prune -type d`; do<br /> domain=$i<br /> eval "echo \"$(cat db.zones.tmpl)\""<br /> done<br /> </code></p>
<p>The essence here is that the eval function forces bash to do  parsing and variable replacement once more on the argument.</p>
]]></content:encoded>
			<wfw:commentRss>http://cosu.ro/blog/2010/05/23/bash-and-template-files/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Yakuake</title>
		<link>http://cosu.ro/blog/2010/04/21/yakuake/</link>
		<comments>http://cosu.ro/blog/2010/04/21/yakuake/#comments</comments>
		<pubDate>Wed, 21 Apr 2010 16:46:01 +0000</pubDate>
		<dc:creator>Cosu</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://cosu.ro/blog/2010/04/21/yakuake/</guid>
		<description><![CDATA[I&#8217;m going to start a series of blog posts about linux apps that I can&#8217;t live without. After a fresh system install these are the first installed. The more and more I use Linux the more I find myself stuck into some console. While the default terminal app shipped with Gnome is just fine for [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m going to start a series of blog posts about linux apps that I can&#8217;t live without. After a fresh system install these are the first installed.</p>
<p>The more and more I use Linux the more I find myself stuck into some console. While the default terminal app shipped with Gnome is just fine for small jobs it gets annoying when I accidentally close it and or when it&#8217;s not on the right desktop. Alt-tab-ing all the time is painful.</p>
<p>This is where the geek in me comes in. Remember the times of Quake and the &#8220;console&#8221;, when you pressed the &#8217;tilda&#8217; key (~) and a nice console dropped down from the top of the screen allowing you to type game commands ? Well that nifty little concept  made its way to the modern desktop!</p>
<p>Enter Yakuake or &#8220;A drop-down terminal emulator based on KDE Konsole technology&#8221; as the About menu says. I install it even if I use gnome  and although it ads some tens of megs of libraries and breaks the &#8220;pure gnome install&#8221;. It&#8217;s so damn worth it! Pressing a magic key (default F12) instantly pops out the Yakuake window. Do your thing in the console and press the magic key again and the console disappears making way for your other apps. It&#8217;s simply brilliant. Yakuake has support for multiple terminal tabs so you can have multiple sessions opened. Using short cut keys you can quickly change the tabs. I consider that Yakuake improves my productivity just as much as the &#8216;screen&#8217; utility, even tough it has nothing to do with &#8216;screen&#8217;  <img src='http://cosu.ro/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Yakuake is not the only app that offers this type of functionality. Tilda is another &#8216;quake console clone&#8217; and it&#8217;s based on GTK instead of QT.</p>
<p>Another alternative is &#8216;guake&#8217;, a younger app that aims at the same goal: quake style terminal emulator. It is also GTK based , hence the &#8216;g&#8217;, and it feels more snappy than tilda. With a bit of customizing it comes close to yakuake but I find it a bit unpolished.</p>
<p>Personally I find Yakuake faster and more friendly but it&#8217;s all about habits. Give them all a chance!</p>
<p>If you are using a Mac and want the same thing take a look at Visor ( Quake3 anyone? ). It is roughly the same thing.</p>
<p>The same thing goes for you  Windoes Powershell lovers out there. You can have the amazing Powershell in a quake console: <a href="http://poshconsole.codeplex.com/">http://poshconsole.codeplex.com/</a></p>
<p>Nice pic goes here.</p>
<p><a href="http://cosu.ro/blog/wp-content/uploads/2010/04/Screenshot.png" rel="lightbox[975]"><img class="alignleft size-medium wp-image-976" title="Yakuake Terminal emulator" src="http://cosu.ro/blog/wp-content/uploads/2010/04/Screenshot-300x225.png" alt="" width="300" height="225" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://cosu.ro/blog/2010/04/21/yakuake/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Hardware Keylogger Detection</title>
		<link>http://cosu.ro/blog/2010/04/18/hardware-keylogger-detection/</link>
		<comments>http://cosu.ro/blog/2010/04/18/hardware-keylogger-detection/#comments</comments>
		<pubDate>Sun, 18 Apr 2010 19:43:37 +0000</pubDate>
		<dc:creator>Cosu</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://cosu.ro/blog/?p=965</guid>
		<description><![CDATA[Intro Keyloggers are nifty things used to grab keyboard input for later analysis and use. The most common type of keylogger is the software keylogger as it is just some program that records key presses. Running it usually requires administrator privileges and this limits the attack surface as one must first gain this type of [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Intro</strong></p>
<p>Keyloggers are nifty things used to grab keyboard input for later analysis and use. </p>
<p>The most common type of keylogger is the software keylogger as it is just some program that records key presses. Running it usually requires administrator privileges and this limits the attack surface as one must first gain this type of privileges.</p>
<p>Hardware keyloggers on the other hand are just small devices that sit between the keyboard and PC and listen and record all the keystrokes.</p>
<p>This article refers to the KeyDaemon USB, a hardware keylogger produced by the Polish company KeeLog.  <a href="http://www.keelog.com/usb_hardware_keylogger.html">Official website</a></p>
<p>The device is pretty small: on one end there&#8217;s an USB A plug (this goes to the PC) and on the other end there&#8217;s an USB A receptacle (here the keyboard is plugged). The plastic casing contains a microcontroller that listens in to the USB traffic. A 2GB storage module is also embedded in the small casing and is used to store the sniffed key presses. </p>
<p>The default mode is the &#8220;record mode&#8221; where the device silently records data. When a magic 3-key combination is pressed ( KBS is the default) the keylogger goes into &#8220;playback mode&#8221; and it makes visible the embedded flash storage. The keyboard is disabled and in place a flash storage device is detected by the operating system. Inside the flash disk there are two important files: log.txt which contains all the key presses captured by the keylogger and config.txt, which contains configuration settings for the device. By editing config.txt one can change the magic key combination (more on this later). </p>
<p>The keylogger is transparent and does not change the USB vendor ID or product ID. One can not tell that the device is plugged in just by looking at the USB device enumeration ( lsusb for example). This makes the detection of the device quite difficult at first sight.</p>
<p><strong>Detection </strong></p>
<p>The initial approach was to see if the current drain on the USB port was higher with the keylogger in place, but this turned out to be too impractical as it&#8217;s hard to do an accurate measurement. The OS support for this is also limited and I felt that this was a dead end.</p>
<p>Next I wanted to see how the keylogger handled unexpected flows of commands. The ioctl interface in linux permits changing the leds on the keyboard from user space. This nifty python script makes your keyboard flash the leds like a Las Vegas Casino billboard:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
</pre></td><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">fcntl</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">os</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">time</span>
&nbsp;
KDSETLED = 0x4B32
SCR_LED  = 0x01
NUM_LED  = 0x02
CAP_LED  = 0x04
&nbsp;
console_fd = <span style="color: #dc143c;">os</span>.<span style="color: #008000;">open</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'/dev/console'</span>, <span style="color: #dc143c;">os</span>.<span style="color: black;">O_NOCTTY</span><span style="color: black;">&#41;</span>
&nbsp;
all_on = SCR_LED | NUM_LED | CAP_LED
all_off = <span style="color: #ff4500;">0</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">while</span> <span style="color: #ff4500;">1</span>:
	<span style="color: #dc143c;">fcntl</span>.<span style="color: black;">ioctl</span><span style="color: black;">&#40;</span>console_fd, KDSETLED, all_on<span style="color: black;">&#41;</span>
	<span style="color: #dc143c;">fcntl</span>.<span style="color: black;">ioctl</span><span style="color: black;">&#40;</span>console_fd, KDSETLED, all_off<span style="color: black;">&#41;</span></pre></td></tr></table></div>

<p>Unfortunately the keylogger had no trouble in handling this type of data. </p>
<p>The next step was to see how the device handles traffic sent from the PC to the keyboard and not the other way around. One would expect that a properly designed keylogger would also take into consideration the direction of the traffic flow. As you will see this is not the case&#8230;</p>
<p>The USB keyboard uses the HID protocol to send and receive data to and from the PC. The basic data packet (or report) has 8 bytes. The first byte contains keycodes for the modifier keys (ALT, SHIFT, CTRL), the second byte is reserved for OEM and the remaining 6 bytes are used to send the keycodes for the pressed keys. So one can simultaneous press the modifier keys and 6 other keys.</p>
<p>Using libusb I wrote a very small application that sends the magic 3-key combination out to the keyboard. I didn&#8217;t think that this would work as I was expecting a propper design but to my surprise the device flash storage opened like a Christmas present from the first run. One interesting detail is that the keylogger needs to &#8220;warm up&#8221; since it was first plugged in. Sending the magic key combination immediately after plugging it in does not open the flash storage.</p>
<p>The next logical step was to further extend the app to brute force all the 3-key combinations. If no data can be written to the device then the flash storage has just popped up and a keylogger has been detected. </p>
<p>The device does not take into account the order in which the magic keys are pressed so KBS is also KSB or BKS. Also due to the fact that one can press a key only once a key combination of AAA for example would be invalid. This makes the number of key combinations very small and the brute force takes less than 1 second!  While the code needs some polishing and some bugfixes (the USB handle is not cleanly released and this makes the keyboard unusable after execution &#8211; it needs to be replugged) it clearly proves that hardware keyloggers can be detected. This is a design flaw it will take a while until it will be fixed. </p>
<p>The PS2 variant  of the keylogger has the same flaw and can be detected in the same manner : send all 3 key combinations out the ps2 port and the device will be detected at some point.</p>
<p>My proof-of-concept code uses a small library written by Paul J Stoffregen and Robin Coon of pjrc.com.</p>
<p>Given the fact that this device is so weak (less than 1s to detect) a script or service could be executed at boot time. Maybe companies that write security software could use this to implement a hardware keylogger detection function. </p>
<p>Other devices use a passphrase instead of a key combination. This is harder to brute force and as stated above it all depends on the way the keyloger snoops the traffic. If it does take into account the source of the traffic then the above method is useless and the keylogger is still invisible. </p>
<p>Tar file with the code : <a href='http://cosu.ro/blog/wp-content/uploads/2010/04/keelogdetect.tar.gz'>keelogdetect.tar</a><br />
Source code available via SVN : <a href="http://code.google.com/p/cdumitru/source/browse/#svn/trunk/keelogdetect">http://code.google.com/p/cdumitru/source/browse/#svn/trunk/keelogdetect</a></p>
]]></content:encoded>
			<wfw:commentRss>http://cosu.ro/blog/2010/04/18/hardware-keylogger-detection/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Parsing XML data using bash and standard Unix tools</title>
		<link>http://cosu.ro/blog/2010/02/13/parsing-xml-data-using-bash-and-standard-unix-tools/</link>
		<comments>http://cosu.ro/blog/2010/02/13/parsing-xml-data-using-bash-and-standard-unix-tools/#comments</comments>
		<pubDate>Fri, 12 Feb 2010 23:53:24 +0000</pubDate>
		<dc:creator>Cosu</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Unix]]></category>

		<guid isPermaLink="false">http://cosu.ro/blog/2010/02/13/parsing-xml-data-using-bash-and-standard-unix-tools/</guid>
		<description><![CDATA[Parsing XML can be a tedious and unpleasant job if you insist on using just standard Unix tools like sed, awk, cut, grep and so on. One might say that it&#8217;s better to use python/perl/ruby/other language that ships with a full blown XML parser and use the standard Unix utilites for what they were meant [...]]]></description>
			<content:encoded><![CDATA[<p>Parsing XML can be a tedious and unpleasant job if you insist on using just standard Unix tools like sed, awk, cut, grep and so on. One might say that it&#8217;s better to use python/perl/ruby/other language that ships with a full blown XML parser and use the standard Unix utilites for what they were meant for, plain old text files and not pesky XML. The problem with those nice programming languages is that they take away the one liners. You need to import stuff, have variables, flow control and so on.</p>
<p>A nice tool that makes one&#8217;s life easier when it comes to XML is XML2. It can convert a normal xml file to a more line oriented file format. The standard debian distribution has this neat tool in the repos so you are one apt-get away from using it.</p>
<p> </p>
<p>One simple example. Take this XML file:</p>
<p><code><br />
&lt;xml&gt;<br />
&lt;fruits&gt;<br />
        &lt;fruit name=&quot;apple&quot; type=&quot;royal gala&quot; quantity=&quot;2&quot; price=&quot;1&quot;/&gt;<br />
        &lt;fruit name=&quot;orange&quot; type=&quot;tasty&quot; quantity=&quot;4&quot; price=&quot;1.5&quot;/&gt;<br />
        &lt;fruit name=&quot;banana&quot; type=&quot;green&quot; quantity=&quot;3&quot; price=&quot;1&quot;/&gt;<br />
&lt;/fruits&gt;<br />
&lt;/xml&gt;<br />
</code></p>
<p>We run xml2 against it:<br /> <code><br /> cosu@roadwarrior:/tmp$ xml2 &lt; fruits.xml<br /> /xml/fruits/fruit/@name=apple<br /> /xml/fruits/fruit/@type=royal gala<br /> /xml/fruits/fruit/@quantity=2<br /> /xml/fruits/fruit/@price=1<br /> /xml/fruits/fruit<br /> /xml/fruits/fruit/@name=orange<br /> /xml/fruits/fruit/@type=tasty<br /> /xml/fruits/fruit/@quantity=4<br /> /xml/fruits/fruit/@price=1.5<br /> /xml/fruits/fruit<br /> /xml/fruits/fruit/@name=banana<br /> /xml/fruits/fruit/@type=green<br /> /xml/fruits/fruit/@quantity=3<br /> /xml/fruits/fruit/@price=1<br /> </code><br /> And now we extract all the fruit names:<br /> <code><br /> cosu@roadwarrior:/tmp$ xml2 &lt; fruits.xml |grep name |cut -d"=" -f2<br /> apple<br /> orange<br /> banana<br /> </code></p>
<p>There you go! A fruit salad! Of course for more complicated stuff use other tools <img src='http://cosu.ro/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p> </p>
]]></content:encoded>
			<wfw:commentRss>http://cosu.ro/blog/2010/02/13/parsing-xml-data-using-bash-and-standard-unix-tools/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Internet Exchange Points</title>
		<link>http://cosu.ro/blog/2010/02/10/ixps/</link>
		<comments>http://cosu.ro/blog/2010/02/10/ixps/#comments</comments>
		<pubDate>Wed, 10 Feb 2010 01:48:59 +0000</pubDate>
		<dc:creator>Cosu</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[internet]]></category>
		<category><![CDATA[Politehnica]]></category>

		<guid isPermaLink="false">http://cosu.ro/blog/?p=956</guid>
		<description><![CDATA[The largest Romanian IXP is Interlan . Funny enough, Interlan is a response of the smaller ISPs  to the other big Romanian IXP, Ronix. Because 3 years ago joining Ronix was a complicated affair, a few small companies decided to take matters into their own hands. Currently,  Interlan has 3 times more traffic than Ronix.]]></description>
			<content:encoded><![CDATA[<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="560" height="340" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/a5837LcDHfE&amp;hl=en_US&amp;fs=1&amp;" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="560" height="340" src="http://www.youtube.com/v/a5837LcDHfE&amp;hl=en_US&amp;fs=1&amp;" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p>The largest Romanian IXP is <a href="http://interlan.ro/" target="_blank">Interlan</a> . Funny enough, Interlan is a response of the smaller ISPs  to the other big Romanian IXP, <a href="http://www.ronix.ro/" target="_blank">Ronix</a>. Because 3 years ago joining Ronix was a complicated affair, a few small companies decided to take matters into their own hands. Currently,  Interlan has 3 times more traffic than Ronix.</p>
]]></content:encoded>
			<wfw:commentRss>http://cosu.ro/blog/2010/02/10/ixps/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Joining pdf files</title>
		<link>http://cosu.ro/blog/2009/11/24/joining-pdf-files/</link>
		<comments>http://cosu.ro/blog/2009/11/24/joining-pdf-files/#comments</comments>
		<pubDate>Tue, 24 Nov 2009 08:27:02 +0000</pubDate>
		<dc:creator>Cosu</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://cosu.ro/blog/2009/11/24/joining-pdf-files/</guid>
		<description><![CDATA[Combining multiple pdfs into a single file can be handy for putting together one big final report or for submitting a single print job instead of multiple smaller ones. Joining pdfs in a Debian based Linux distribution can be easily done by using the pdfjoin utility. It is provided by the pdfjam package. One only [...]]]></description>
			<content:encoded><![CDATA[<p>Combining multiple pdfs into a single file can be handy for putting together one big final report or for submitting a single print job instead of multiple smaller ones. Joining pdfs in a Debian based Linux distribution can be easily done by using the <strong>pdfjoin</strong> utility. It is provided by the <strong>pdfjam</strong> package. One only needs to</p>
<p><strong>sudo aptitude install pdfjam</strong></p>
<p>Then all that needs to be done is cd-ing into the folder containing the large number of pdfs and running:</p>
<p><strong>pdfjoin *.pdf &#8211;outfile out.pdf</strong></p>
<p>There you go, instant pdf!</p>
]]></content:encoded>
			<wfw:commentRss>http://cosu.ro/blog/2009/11/24/joining-pdf-files/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Choosing random entries from a group</title>
		<link>http://cosu.ro/blog/2009/11/23/choosing-random-entries-from-a-group/</link>
		<comments>http://cosu.ro/blog/2009/11/23/choosing-random-entries-from-a-group/#comments</comments>
		<pubDate>Mon, 23 Nov 2009 21:31:11 +0000</pubDate>
		<dc:creator>Cosu</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[RGC]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://cosu.ro/blog/2009/11/23/choosing-random-entries-from-a-group/</guid>
		<description><![CDATA[In the past two weeks we had a lottery-type thing on RGC.ro (Romanian Guitarist Community). Proguitar, the official importer of Fender products in Romania, wanted to give-away a custom made Fender Stratocaster electric guitar. To register, the community users had to fill out a form and choose from a series of custom options for the [...]]]></description>
			<content:encoded><![CDATA[<p>In the past two weeks we had a lottery-type thing on <a href="http://www.rgc.ro">RGC.ro</a> (Romanian Guitarist Community). Proguitar, the official importer of Fender products in Romania, wanted to give-away a custom made Fender Stratocaster electric guitar. To register, the community users had to fill out a form and choose from a series of custom options for the guitar.</p>
<p>As organizers we had  to pick out the lucky winner of the raffle.  Usually this is done by someone who is impartial. Due to the fact that we had about 1600 entries and that we are geeks we wanted to do something that geeks would do. Therefore we ditched the &#8220;extract the name of the lucky winner from a bowl&#8221;. The geek version of this is described in<a href="http://www.ietf.org/rfc/rfc2777.txt"> RFC2777 &#8211;  Publicly Verifiable Nomcom Random Selection</a></p>
<p>In short RFC2777 describes a simple publicly verifiable algorithm to pick out a set of entries from a group as random as possible. The keywords here are public &#8211; anyone can see how the entries are picked &#8211; and as random as possible. To have random values a thing called <a href="http://en.wikipedia.org/wiki/Information_entropy">information entropy</a> is needed. To get that initial random value full of juicy entropy we used, as suggested in the RFC, the results from three international lotteries. This initial random value was slightly modified for each &#8220;extracted&#8221; entry and then transformed into a MD5 hash. Due to the nature of a hash when slightly modifying  the original the resulting hash differs heavily from the original hash.</p>
<p>Below you can find a naive python implementation that can be freely used for any purpose. Just make sure you fill in the entropySource with a good initial random value.</p>
<pre>
import md5                                                 

if __name__ == '__main__':

    entropySource = "9.24.30.32.36.40./18.25.35.43.46.47./1.3.4.8.23.31./"

    numberOfEntries = 1655
    numberOfWinners = 10  

    numbers = map( lambda x: x + 1, range( numberOfEntries ) )

    i = 0
    entries = numberOfEntries
    print "index \t hex value of MD5 \t div \t selected"
    while ( i < numberOfWinners ) :
        md5hash = md5.new()
        md5hash.update( chr( i ) + entropySource + chr( i ) )
        val = int( md5hash.hexdigest(), 16 )
        modulo = val % entries
        print str( i + 1 ) + "\t" + md5hash.hexdigest() + "\t" + str( entries ) + "\t" + str( numbers[modulo] )
        del numbers[modulo]
        i += 1
        entries -= 1
</pre>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://cosu.ro/blog/2009/11/23/choosing-random-entries-from-a-group/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

