









<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ring3 Circus &#187; Hacking</title>
	<atom:link href="http://www.ring3circus.com/category/hacking/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ring3circus.com</link>
	<description>Diary of a programmer, journal of a hacker.</description>
	<lastBuildDate>Fri, 25 Sep 2009 14:20:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>NAS Troubleshooting via the Back Door</title>
		<link>http://www.ring3circus.com/hacking/nas-troubleshooting-via-the-back-door/</link>
		<comments>http://www.ring3circus.com/hacking/nas-troubleshooting-via-the-back-door/#comments</comments>
		<pubDate>Sun, 05 Apr 2009 16:34:38 +0000</pubDate>
		<dc:creator>Greg</dc:creator>
				<category><![CDATA[Hacking]]></category>
		<category><![CDATA[nas]]></category>
		<category><![CDATA[path traversal]]></category>
		<category><![CDATA[samba]]></category>
		<category><![CDATA[smb]]></category>
		<category><![CDATA[smb.conf]]></category>
		<category><![CDATA[sumvision]]></category>

		<guid isPermaLink="false">http://www.ring3circus.com/?p=68</guid>
		<description><![CDATA[I recently bought a NAS enclosure with 1TB of storage for my humble home LAN. While I eventually managed to identify the manufacturer as a firm called &#8216;Sumvision&#8217;, the packaging didn&#8217;t make this obvious and upon opening it up I got that distinct and familiar feeling of &#8216;you&#8217;re on your own from here&#8217;. Of course, [...]]]></description>
			<content:encoded><![CDATA[<p>I recently bought a NAS enclosure with 1TB of storage for my humble home LAN. While I eventually managed to identify the manufacturer as a firm called &#8216;Sumvision&#8217;, the packaging didn&#8217;t make this obvious and upon opening it up I got that distinct and familiar feeling of &#8216;you&#8217;re on your own from here&#8217;. Of course, none of this came as a surprise (given the price I paid) and I was pleasantly surprised to find a fresh set of firmware available on the website (version 2.4.4-Jul 8 2008). What did upset me, though, was the awful performance I experienced when using it over my wireless connection. A short Google later it became apparent that this is a common problem with NAS devices, caused by the typically higher packet-loss experienced on wireless connections. Briefly put, SAMBA (and NFS) transmission units often default to 8192 bytes or more, whereas IPv4 networks without the relatively new jumbo frame support will fragment anything above the 1500-or-so-byte MTU. The suggested fix, for SAMBA devices such as mine, is to tweak this value in the server&#8217;s smb.conf:</p>
<p>
<pre>socket options = TCP_NODELAY IPTOS_LOWDELAY SO_KEEPALIVE SO_RCVBUF=1024 SO_SNDBUF=1024</pre>
</p>
<p>Alas, I found no obvious way to modify these values in the enclosure&#8217;s web interface. Furthermore, extracting the hard-drive and mounting it locally proved that it is used for content storage only &#8211; the OS sits on a ROM, away from the user&#8217;s grubby fingers. And so I was out of luck and was at the point of giving up, until curiosity got the better of me. Taking a look at the &#8216;shares&#8217; page of the admin interface it was pretty clear that this thing was running a Unix-based OS (disclosing local paths such as &#8216;/mnt/C/Media/Music&#8217;), and if their implementation was as flaky as their design there may be another way in.</p>
<p><a href="http://www.ring3circus.com/wp-content/uploads/shares.png"><img src="http://www.ring3circus.com/wp-content/uploads/shares-300x200.png" alt="Web interface &#039;shares&#039; page" title="shares" width="300" height="200" class="size-medium wp-image-66" /></a></p>
<p>So I tried what any hacker would have done faced with this input field, and tried to traverse the device-local path using some &#8216;../&#8217;s.</p>
<p><a href="http://www.ring3circus.com/wp-content/uploads/traversal.png"><img src="http://www.ring3circus.com/wp-content/uploads/traversal-300x200.png" alt="Path-traversal attack" title="traversal" width="300" height="200" class="size-medium wp-image-67" /></a></p>
<p>Now I won&#8217;t pretend that it was big, clever or original, but to my surprise it worked. Browsing to &#8216;\\nas\Root&#8217; from my computer landed me right in the device&#8217;s root, with admin read/write privileges. For those wondering, the OS is BusyBox.</p>
<p><a href="http://www.ring3circus.com/wp-content/uploads/samba.png"><img src="http://www.ring3circus.com/wp-content/uploads/samba-300x258.png" alt="The resulting SAMBA root share" title="samba" width="300" height="258" class="size-medium wp-image-65" /></a></p>
<p>And the rest is history. A couple of words of warning to anybody planning on doing the same:</p>
<ul>
<li>In order to access this root share, the device obviously needs to boot and mount successfully. As such I wouldn&#8217;t be the slightest bit surprised if any undue alterations to the OS or its configuration result in the device being rendered permanently unusable. I never did brick mine and so haven&#8217;t confirmed this, but be very careful what you touch.</li>
<li>/config/smb.conf is presumably kept open at all times, and so you&#8217;ll likely have trouble saving to it. I found that saving as a different file and then renaming them around works fine. Be aware that there is very little excess space to play with (I suspect it&#8217;s mounted as a ramdrive).</li>
<li>The smb.conf, at least, seems quite volatile, in that any changes via the web interface result in the [global] parameters being reset to their defaults. I have observed the alterations to persist across reboots but couldn&#8217;t offer a comprehensive list of actions that result in it being wiped clean, so don&#8217;t be surprised if you find that your fixes disappear when you&#8217;re not looking.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.ring3circus.com/hacking/nas-troubleshooting-via-the-back-door/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Shellcoding on Windows: Part II &#8211; Stack Overflow Problems</title>
		<link>http://www.ring3circus.com/rce/shellcoding-on-windows-part-ii-stack-overflow-problems/</link>
		<comments>http://www.ring3circus.com/rce/shellcoding-on-windows-part-ii-stack-overflow-problems/#comments</comments>
		<pubDate>Tue, 12 Feb 2008 00:00:24 +0000</pubDate>
		<dc:creator>Greg</dc:creator>
				<category><![CDATA[Hacking]]></category>
		<category><![CDATA[RCE]]></category>
		<category><![CDATA[shellcoding]]></category>
		<category><![CDATA[stack-overflow]]></category>

		<guid isPermaLink="false">http://www.ring3circus.com/rce/shellcoding-on-windows-part-ii-stack-overflow-problems/</guid>
		<description><![CDATA[The stack overflow has been discussed to death. If you don&#8217;t know the basic principle, then you should check out some of the the sixty-eight thousand hits on Google. Many of these descriptions would have you believe that any overflowable stack buffer will immediately allow the attacker to get root (or whatever the Windows equivalent [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://en.wikipedia.org/wiki/Stack_buffer_overflow">stack overflow</a> has been discussed to death. If you don&#8217;t know the basic principle, then you should check out some of the the <a href="http://www.google.com/search?&#038;hl=en&#038;q=Stack-Overflow&#038;btnG=Google+Search">sixty-eight thousand hits</a> on Google. Many of these descriptions would have you believe that any overflowable stack buffer will immediately allow the attacker to get root (or whatever the Windows equivalent might be), but if you&#8217;ve ever tried to exploit a real-world stack overflow vulnerability you&#8217;d realise that it&#8217;s a lot harder than it sounds. Here are some of the more common problems:</p>
<ul>
<li>A user-modifiable stack buffer is usually designed to hold string data, but even when this isn&#8217;t the case, it&#8217;s rare to find a situation where arbitrary input is accepted and blindly copied to the stack. It&#8217;s not infeasible that your shellcode will be restricted to null-terminated printable ASCII (that&#8217;s 0&#215;20-0x7E inclusive), and if you&#8217;ve ever tried to write code that assembles into this range you&#8217;ll realise that it&#8217;s no mean feat. Furthermore, not all strings are ASCII and even a seasoned hacker can have trouble crafting an executable Unicode string.</li>
<li>If you&#8217;re able to provide an arbitrary amount of data then overflowing a return-address is easy. But what&#8217;s not so straightforward is ensuring that the function actually gets a chance to return &#8211; after all, you have just corrupted every stack variable between the buffer and the return-address.</li>
<li>Suppose that your shellcode compiles okay, passes the input filters; no crashes occur and that you now own EIP after the vulnerable function returns. Just where should you make the target return to? Understand that the address from which to commence execution must be known at the time the shellcode is provided, and moreover that &#8211; in the paradigm case &#8211; your shellcode lies &#8216;somewhere&#8217; on the stack. Inherent in the nature of stack-based function architecture is the fact that the same function can execute many times without ever taking the same value of ESP. This problem of <strong>locating your shellcode after injection</strong> is one that never seems to go away and has become the bane of many hackers&#8217; lives.</li>
<li>If we weren&#8217;t already struggling enough, the recent shift in focus towards security has prompted the Windows kernel developers to take more and more precautions regarding the execution of data buffers. Windows XP SP2 introduced DEP (data-execution prevention) for Windows Services, and Vista/Server 2003 extended this to protect all processes by default. This means that as of Windows Vista, any attempts to execute code on the stack will fail with a warning dialog from the OS, provided the system&#8217;s processor supports the <a href="http://en.wikipedia.org/wiki/Nx_bit">NX/XD bit</a> (Intel and AMD couldn&#8217;t agree on nomenclature, apparently).</li>
<li>Because the OS can only do so much, many compilers now ship with support for automatic security code-generation. In particular, Visual Studio 2005 introduced the GS flag, which creates what Microsoft are calling a Security Cookie (but to everyone else, a <a href="http://en.wikipedia.org/wiki/Stack-smashing_protection#Random_canaries">stack canary</a>) within each function&#8217;s stack frame. With this option enabled, each function will push a pseudo-random dword onto the stack in its prologue, and check that it hasn&#8217;t been modified by the time the epilogue is reached. This way, any attempts to overflow into the return-address will corrupt the canary and alert the program before the RETN occurs.</li>
</ul>
<p>All of these problems can be appeased to a degree through a variety of techniques. Notably, the use of structured exception handling in the target application can make our job as an attacker considerably easier as we may be able to abuse the SEH records and sidestep several of these problems in one go. Details next time.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ring3circus.com/rce/shellcoding-on-windows-part-ii-stack-overflow-problems/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Shellcoding on Windows: Part I</title>
		<link>http://www.ring3circus.com/rce/shellcoding-on-windows-part-i/</link>
		<comments>http://www.ring3circus.com/rce/shellcoding-on-windows-part-i/#comments</comments>
		<pubDate>Tue, 29 Jan 2008 00:00:08 +0000</pubDate>
		<dc:creator>Greg</dc:creator>
				<category><![CDATA[Hacking]]></category>
		<category><![CDATA[RCE]]></category>
		<category><![CDATA[shellcoding]]></category>

		<guid isPermaLink="false">http://www.ring3circus.com/rce/shellcoding-on-windows-part-i/</guid>
		<description><![CDATA[If you were wondering why things have been so quiet for the past month, it&#8217;s because I&#8217;ve been spending my every waking hour learning to hack. This explains the presence of a new category here on the site, and the motivation behind some of the upcoming topics. It would be a shame to let January [...]]]></description>
			<content:encoded><![CDATA[<p>If you were wondering why things have been so quiet for the past month, it&#8217;s because I&#8217;ve been spending my every waking hour learning to hack. This explains the presence of a new category here on the site, and the motivation behind some of the upcoming topics. It would be a shame to let January pass us by, so here comes an introductory post on the exciting science of shellcoding. First, some formalities:</p>
<blockquote><p>
<strong>Shellcode</strong> (shĕl&#8217;kōd)<br />
<em>n.</em></p>
<p>A relocatable piece of executable code used as the payload in a software exploit, typically having the purpose of providing the attacker with unauthorised access to the system at which it is directed.</p>
<p><em>v.</em> [shellcod&bull;ing, shellcod&bull;er]</p>
<p>The process of developing shellcode and tailoring it to a particular target.
</p></blockquote>
<p>A piece of software is said to be <em>vulnerable</em> (to exploitation) if it contains a bug which allows a user to cause it to behave in a way unintended by the developers, by supplying appropriately crafted data to one of its normal input mechanisms. The faulty processing of this input is the <em>vulnerability</em>, and any operation that takes advantage of this is an <em>exploit</em>. The data used in such an exploit is the <em>payload</em>, and the executable component of this payload is the <em>shellcode</em>. While a distinction exists between an exploit&#8217;s <em>payload</em> and its <em>shellcode</em>, the two terms are often used interchangeably. The name &#8216;shellcode&#8217; derives from the fact that many Unix exploits would work toward the goal of delivering a shell to the attacker, but this is not a necessary criterion under today&#8217;s usage.</p>
<p>Not all exploits will require shellcode, as certain goals may be achieved without it, but we&#8217;ll primarily concern ourselves with vulnerabilities that lead to <em>execution of arbitrary code</em> (i.e. the shellcode), as that&#8217;s the holy grail of the hacker. While vulnerabilities can fall into many categories, there are a few of particular interest, and these are the ones I&#8217;ll concentrate on. Putting the theory into practice is the real stumbling-block, and so along the way I&#8217;ll discuss common problems the average Windows shellcoder will run into. Here&#8217;s the battle-plan:</p>
<ul>
<li>Stack overflows</li>
<li>Heap overflows</li>
<li>Format-string vulnerabilities</li>
<li>String filters, shellcode-location and other technical problems</li>
<li>Non-executable stacks and stack-canaries</li>
</ul>
<p>I appreciate that this is a lot of material to cover, and that you may be best off buying a book (<a href="http://eu.wiley.com/WileyCDA/WileyTitle/productCd-0764544683.html">The Shellcoder&#8217;s Handbook</a> handles this vast subject magnificently), but I aim to spend as little time as possible on the bread-and-butter material that can be found just about everywhere, while putting far more focus on the practical side of things. See you next week.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ring3circus.com/rce/shellcoding-on-windows-part-i/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.549 seconds -->

