<?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>Skypher &#187; Security</title>
	<atom:link href="http://skypher.com/index.php/category/security/feed/" rel="self" type="application/rss+xml" />
	<link>http://skypher.com</link>
	<description>The blog for absolutely nothing!</description>
	<lastBuildDate>Sat, 25 Feb 2012 11:27:57 +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>w32 speaking shellcode &#8211; Pwn in style</title>
		<link>http://skypher.com/index.php/2010/12/31/w32-speaking-shellcode-pwn-in-style/</link>
		<comments>http://skypher.com/index.php/2010/12/31/w32-speaking-shellcode-pwn-in-style/#comments</comments>
		<pubDate>Fri, 31 Dec 2010 13:26:36 +0000</pubDate>
		<dc:creator>SkyLined</dc:creator>
				<category><![CDATA[Assembler]]></category>
		<category><![CDATA[Programming Languages]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Shellcode]]></category>

		<guid isPermaLink="false">http://skypher.com/?p=659</guid>
		<description><![CDATA[<br />
<b>Warning</b>:  preg_split() [<a href='function.preg-split'>function.preg-split</a>]: Compilation failed: lookbehind assertion is not fixed length at offset 14 in <b>/home/c3682jgn/domains/skypher.com/public_html/wp-content/themes/braille/options/plugins.php</b> on line <b>77</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home/c3682jgn/domains/skypher.com/public_html/wp-content/themes/braille/options/plugins.php</b> on line <b>78</b><br />
]]></description>
			<content:encoded><![CDATA[<p>Over the past few weeks I created a <a href="http://code.google.com/p/w32-speaking-shellcode/">new shellcode</a> that uses the <a href="http://msdn.microsoft.com/en-us/library/ee705648.aspx">Microsoft Speech API</a> to have the target computer say &#8220;You got pwned!&#8221; over the speakers. Needless to say, the practical applications are myriad, from impressing women in bars to expediting world peace. However, I expect that the most common application will be people impressing their friends with their 1337 hacker skills.</p>
<p>The size of the shellcode is 242 bytes (add 5 for stack alignment and 39 for EAT bypass). It has all the usual bells and whistles: OS/SP independent, null-free, optional stack alignment and EAT bypass and no register requires a specific value for it to run correctly. </p>
<p>Get the code <a href="http://code.google.com/p/w32-speaking-shellcode/downloads/detail?name=w32-speaking-shellcode.zip">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://skypher.com/index.php/2010/12/31/w32-speaking-shellcode-pwn-in-style/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Bypassing Export address table Address Filter (EAF)</title>
		<link>http://skypher.com/index.php/2010/11/17/bypassing-eaf/</link>
		<comments>http://skypher.com/index.php/2010/11/17/bypassing-eaf/#comments</comments>
		<pubDate>Wed, 17 Nov 2010 20:46:48 +0000</pubDate>
		<dc:creator>SkyLined</dc:creator>
				<category><![CDATA[Assembler]]></category>
		<category><![CDATA[PoC]]></category>
		<category><![CDATA[Programming Languages]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Shellcode]]></category>

		<guid isPermaLink="false">http://skypher.com/?p=605</guid>
		<description><![CDATA[<br />
<b>Warning</b>:  preg_split() [<a href='function.preg-split'>function.preg-split</a>]: Compilation failed: lookbehind assertion is not fixed length at offset 14 in <b>/home/c3682jgn/domains/skypher.com/public_html/wp-content/themes/braille/options/plugins.php</b> on line <b>77</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home/c3682jgn/domains/skypher.com/public_html/wp-content/themes/braille/options/plugins.php</b> on line <b>78</b><br />
]]></description>
			<content:encoded><![CDATA[<p>(An unfinished version of this blog post was accidentally published last week. In case you got a hold of a copy: I&#8217;ve made only small modifications, so no need to re-read the entire post. However, I did not released the source of my PoC shellcode earlier, so you may want to <a href="https://code.google.com/p/w32-msgbox-shellcode/source/diff?path=/trunk/w32-msgbox-shellcode.asm&#038;format=side&#038;r=4">check if out</a>).</p>
<p>In early September this year Microsoft released their <a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=c6f0a6ee-05ac-4eb6-acd0-362559fd2f04">Enhanced Mitigation Experience Toolkit v2.0</a> (EMET), which includes a new &#8220;pseudo&#8221;-mitigation called Export address table Address Filter (EAF). I decided to have a look at how this mitigation attempts to prevent exploits from succeeding and how an attacker might bypass it. For people that suffer from <a href="http://encyclopediadramatica.com/TL;DR">tl;dr</a> syndrome, I&#8217;ve put my conclusion up front:</p>
<p><strong>It is my conclusion that EAF should be effective at preventing most current shellcode from executing and therefore a useful mitigation. However, it is relatively simple to bypass. Proof of concept code to do this can be found <a href="https://code.google.com/p/w32-msgbox-shellcode/">here</a>. I expect that if EAF becomes a common mitigation, attackers will update their shellcodes to bypass it. I cannot think of any effective way in which EAF can be updated that would not be relatively simple to bypass as well.</strong></p>
<p>EAF works by setting a <a href="http://en.wikipedia.org/wiki/Breakpoint#Hardware_implementation">hardware breakpoint</a> on the <a href="http://www.microsoft.com/whdc/system/platform/firmware/PECOFF.mspx">export address tables</a> of the ntdll.dll and kernel32.dll modules in a process. When the breakpoint is triggered, EAF determines if the code that is trying to access the export address table is valid code for that process or malicious code injected into the process through an exploit. Most exploits will at some point inject and run shellcode into the target process. One of the first thing most shellcodes do is determine where certain functions are loaded in memory. This is commonly and easiest done by going through the list of loaded modules and reading their export address tables. When shellcode reads the export address tables of ntdll.dll and/or kernel32.dll, EAF detects the shellcode and terminates the process, preventing the exploit from running successfully.</p>
<p>I tested EAF with<a href="https://code.google.com/p/w32-msgbox-shellcode/">one of my shellcodes</a> that shows a message in a popup window when it runs successfully. <a href="http://code.google.com/hosting/search?q=SkyLined+shellcode+win32">All my shellcodes</a> scan the export address tables of loaded modules to find certain functions. This is a common technique used by almost all shellcodes that EAF is designed to detect. So, enabling EAF should prevent my shellcode, and most others, from working.</p>
<p>I use <a href="http://code.google.com/p/testival/">testival</a> to test my shellcode because it makes things easy to automate and I can copy+paste the output into this blog to show you what is going on. When my shellcode is run, it shows a popup dialog box and then triggers an int3 debugger breakpoint. Here&#8217;s the output of w32-testival.exe for a successful run of my shellcode:<br />
<code><br />
C:\Dev\Shellcode\w32-msgbox-shellcode&gt;w32-testival [$]=ascii:w32-msgbox-shellcode.bin eip=$ --verbose --eh --eh<br />
Allocating 0x1000 bytes of memory... ok. (address: 0x00030000)<br />
Setting data and registers:<br />
  [0x00030000]              = 8C bytes of data.<br />
  eax                       = 0xDEADBEEF (default)<br />
  ecx                       = 0xDEADBEEF (default)<br />
  edx                       = 0xDEADBEEF (default)<br />
  ebx                       = 0xDEADBEEF (default)<br />
  esp                       = ??? (unmodified)<br />
  ebp                       = 0xDEADBEEF (default)<br />
  esi                       = 0xDEADBEEF (default)<br />
  edi                       = 0xDEADBEEF (default)<br />
  eip                       = 0x00030000 ($)<br />
Registering Structured Exception Handler (SEH)...ok.<br />
Registering Vectored Exception Handler (VEH)...ok.<br />
Executing shellcode by jumping to 0x00030000...First chance debugger breakpoint exception at 0x0003008B.<br />
Second chance debugger breakpoint exception at 0x0003008B.<br />
&nbsp;<br />
C:\Dev\Shellcode\w32-msgbox-shellcode&gt;<br />
&nbsp;<br />
</code><br />
Of course, you cannot see the popup dialog box in this output, but you can see that the int3 debugger breakpoint at the end of the shellcode was executed. This means that it ran successfully.</p>
<p>After enabling EAF I tried executing the shellcode again and found that it still worked. So either EAF was not working or I was doing something wrong. I contacted my friends at MS who developed the tool and asked them to help me find out what was going on. They explained that in order to install the EAF mitigation, EMET needs to create a new thread in the process first, which means the mitigation is not enabled immediately on startup. To make sure that the mitigation is installed, you need to wait a bit before running your shellcode. So, I added a new switch to testival that allows it to wait a given number of milliseconds before executing the shellcode. Using this new feature, I tried again and this time EAF successfully blocked my shellcode, as you can see here:</p>
<p><code><br />
C:\Dev\Shellcode\w32-msgbox-shellcode&gt;w32-testival [$]=ascii:w32-msgbox-shellcode.bin eip=$ --verbose --eh --eh --delay=1000<br />
Allocating 0x1000 bytes of memory... ok. (address: 0x00030000)<br />
Setting data and registers:<br />
  [0x00030000]              = 8C bytes of data.<br />
  eax                       = 0xDEADBEEF (default)<br />
  ecx                       = 0xDEADBEEF (default)<br />
  edx                       = 0xDEADBEEF (default)<br />
  ebx                       = 0xDEADBEEF (default)<br />
  esp                       = ??? (unmodified)<br />
  ebp                       = 0xDEADBEEF (default)<br />
  esi                       = 0xDEADBEEF (default)<br />
  edi                       = 0xDEADBEEF (default)<br />
  eip                       = 0x00030000 ($)<br />
Registering Structured Exception Handler (SEH)...ok.<br />
Registering Vectored Exception Handler (VEH)...ok.<br />
Waiting for 1000 milliseconds...ok.<br />
Executing shellcode by jumping to 0x00030000...First chance single step exception at 0x00030054: A trace trap or other single-instruction mechanism signaled that one instruction has been executed.<br />
Second chance exception 0xC0000409 at 0x00030054.<br />
&nbsp;<br />
C:\Dev\Shellcode\w32-msgbox-shellcode&gt;<br />
&nbsp;<br />
</code><br />
This time the process is terminated early by a single step exception. This is because the EAF mitigation has detect that the shellcode accessed the export address table and decided to terminate the application rather than allow the shellcode to continue executing. This shows that EAF should be able to detect and protect against exploits that use most common shellcode.</p>
<p>I decided not to reverse EAF in order to find out how it works, but rather try to guess how it works and guess how it might by bypassed and try if it works. I assumed that EAF works by checking the location of the instruction that is accessing the export address table: if it is located inside the code segment of a loaded module, EAF assumes it is valid code and allowed it to continue. Otherwise, EAF assumes it is malicious code and terminates the process. If my hypothesis is correct, it might be possible to have the shellcode use a sequence of instructions inside the code segment of a loaded module that can be used to read memory. Because in this case, EAF will assumes that valid code is attempting to read the export address table rather than my shellcode and allow the code to continue.</p>
<p>To test this, I created a modified version of my shellcode that works like this:</p>
<ul>
<li>First, the shellcode finds out where ntdll.dll is loaded in memory as usual.</li>
<li>Second, it finds out where the code segment for ntdll.dll is located.</li>
<li>Third, it scans the code segment for a specific instruction sequence that can be used to read arbitrary memory.</li>
<li>Finally, it calls this instruction sequence to read the export address table, rather than read it directly.</li>
</ul>
<p>This is effectively the same as doing a ret-into-libc attack, something which EAF is not designed to block and this should therefore be able to bypass it. It turns out that the RtlGetCurrentPeb function has a useful instruction sequence. This sequence is static across Windows versions and SPs and exactly 4 bytes long, which means it is easy to write code to find it:<br />
<code><br />
 ntdll32!RtlGetCurrentPeb:<br />
     64a118000000    mov     eax,dword ptr fs:[00000018h]<br />
     8b4030          mov     eax,dword ptr [eax+30h]<br />
     c3              ret<br />
&nbsp;<br />
</code><br />
By setting EAX to the memory address you want to read (minus 0&#215;30) and calling the second instruction, you can read arbitrary memory into EAX.</p>
<p>The first time I tested my code, it was blocked by EAF while scanning for the instruction sequence in the code segment. It turns out that the export address table is located at the start of the code segment of ntdll.dll, so my scan for the instruction sequence was accessing it and triggering EAF.  Luckily, the RtlGetCurrentPeb function is not located anywhere near the start of the code segment in any version of ntdll.dll, so it was relatively easy to avoid this by skipping over the first 0&#215;1000 bytes of the code segment.</p>
<p>Here is the result for my modified shellcode, which is only 30 bytes larger than the original:<br />
<code><br />
C:\Dev\Shellcode\w32-msgbox-shellcode&gt;w32-testival [$]=ascii:w32-msgbox-shellcode-eaf.bin eip=$ --verbose --eh --eh --delay=1000<br />
Allocating 0x1000 bytes of memory... ok. (address: 0x00030000)<br />
Setting data and registers:<br />
  [0x00030000]              = AB bytes of data.<br />
  eax                       = 0xDEADBEEF (default)<br />
  ecx                       = 0xDEADBEEF (default)<br />
  edx                       = 0xDEADBEEF (default)<br />
  ebx                       = 0xDEADBEEF (default)<br />
  esp                       = ??? (unmodified)<br />
  ebp                       = 0xDEADBEEF (default)<br />
  esi                       = 0xDEADBEEF (default)<br />
  edi                       = 0xDEADBEEF (default)<br />
  eip                       = 0x00030000 ($)<br />
Registering Structured Exception Handler (SEH)...ok.<br />
Registering Vectored Exception Handler (VEH)...ok.<br />
Waiting for 1000 milliseconds...ok.<br />
Executing shellcode by jumping to 0x00030000...First chance single step exception at 0x76FBA045: A trace trap or other single-instruction mechanism signaled that one instruction has been executed.<br />
First chance single step exception at 0x76FAFFCE: A trace trap or other single-instruction mechanism signaled that one instruction has been executed.<br />
First chance single step exception at 0x76FAFFCE: A trace trap or other single-instruction mechanism signaled that one instruction has been executed.<br />
First chance single step exception at 0x76FAFFCE: A trace trap or other single-instruction mechanism signaled that one instruction has been executed.<br />
&lt;snip&gt;(Many more single step exceptions)&lt;snip&gt;<br />
First chance single step exception at 0x76FAFFCE: A trace trap or other single-instruction mechanism signaled that one instruction has been executed.<br />
First chance debugger breakpoint exception at 0x000300AA.<br />
Second chance debugger breakpoint exception at 0x000300AA.<br />
&nbsp;<br />
C:\Dev\Shellcode\w32-msgbox-shellcode&gt;<br />
&nbsp;<br />
</code><br />
Every time the export address table is accessed, the hardware breakpoint is triggered and EAF checks to see if shellcode is attempting to access it. This is why you are seeing so may first change single step exceptions. However, because I am using the instruction sequence in ntdll.dll to access the address table, EAF allows the code to continue. The shellcode runs successfully and the process terminates when the shellcode executes the int3 debugger breakpoint as before.</p>
<p>Have a look at <a href="https://code.google.com/p/w32-msgbox-shellcode/source/diff?path=/trunk/w32-msgbox-shellcode.asm&#038;format=side&#038;r=4">the changes</a> I made to my shellcode to make this work. They are relatively minor and it should be possible to apply this technique to any shellcode, which reduces the usefulness of EAF in the long run.</p>
<p>I thought about possibilities to prevent or detect this bypass.  Unfortunately, I could not think of anything that would be effective. Here are some of my ideas and why I think they won&#8217;t work:<br />
- EAF could check for this specific instruction sequence. However, shellcode could scan for other sequences in ntdll.dll (or even in other modules) that can be used to achieve the same.<br />
- EAF could &#8220;walk the stack&#8221; and check that all return addresses are valid. However, the shellcode could construct a ret-into-libc stack with only valid return addresses, where the first call reads the export address table and the next call modifies the return address for the third return address to point to the shellcode again.<br />
- EAF could set additional hardware breakpoints on structures that can be used to find the locations of modules, in an attempt to prevent the shellcode from finding an instruction sequence that it can use to read memory. However, there are a large number of ways in which the location of modules can be found and there are a <a href="http://en.wikipedia.org/wiki/X86_debug_register">limited number</a> of hardware breakpoints. There are not enough breakpoints available to protect all of locations that contain sensitive data.</p>
<p>I welcome your thoughts and ideas on this subject.</p>
]]></content:encoded>
			<wfw:commentRss>http://skypher.com/index.php/2010/11/17/bypassing-eaf/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Issue 32 &#8211; Oracle Java plugin2 non-exploitable memory corruption</title>
		<link>http://skypher.com/index.php/2010/10/13/issue-32-oracle-java-plugin2/</link>
		<comments>http://skypher.com/index.php/2010/10/13/issue-32-oracle-java-plugin2/#comments</comments>
		<pubDate>Wed, 13 Oct 2010 12:10:15 +0000</pubDate>
		<dc:creator>SkyLined</dc:creator>
				<category><![CDATA[Browsers]]></category>
		<category><![CDATA[Repro]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://skypher.com/?p=570</guid>
		<description><![CDATA[<br />
<b>Warning</b>:  preg_split() [<a href='function.preg-split'>function.preg-split</a>]: Compilation failed: lookbehind assertion is not fixed length at offset 14 in <b>/home/c3682jgn/domains/skypher.com/public_html/wp-content/themes/braille/options/plugins.php</b> on line <b>77</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home/c3682jgn/domains/skypher.com/public_html/wp-content/themes/braille/options/plugins.php</b> on line <b>78</b><br />
]]></description>
			<content:encoded><![CDATA[<p>About two years ago I found what appeared to be a memory corruption issue in SUN (now owned by Oracle) <a href="http://java.com">Java</a> Version 6 Update 10. I failed to find any evidence that the issue allows remote code execution and after investigating, SUN/Oracle reported that it was not a security issue that required immediate patching.</p>
<p>Oracle have released a fix for this issue, which can be found <a href="http://www.oracle.com/technetwork/topics/security/javacpuoct2010-176258.html">here</a>.</p>
<p>Details can be found <a href="http://code.google.com/p/skylined/issues/detail?id=32">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://skypher.com/index.php/2010/10/13/issue-32-oracle-java-plugin2/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Issue 18 &#8211; Oracle Java APPLET tag children property memory corruption</title>
		<link>http://skypher.com/index.php/2010/10/13/issue-18-oracle-java-applet-childre/</link>
		<comments>http://skypher.com/index.php/2010/10/13/issue-18-oracle-java-applet-childre/#comments</comments>
		<pubDate>Wed, 13 Oct 2010 12:04:17 +0000</pubDate>
		<dc:creator>SkyLined</dc:creator>
				<category><![CDATA[Browsers]]></category>
		<category><![CDATA[Repro]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://skypher.com/?p=572</guid>
		<description><![CDATA[<br />
<b>Warning</b>:  preg_split() [<a href='function.preg-split'>function.preg-split</a>]: Compilation failed: lookbehind assertion is not fixed length at offset 14 in <b>/home/c3682jgn/domains/skypher.com/public_html/wp-content/themes/braille/options/plugins.php</b> on line <b>77</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home/c3682jgn/domains/skypher.com/public_html/wp-content/themes/braille/options/plugins.php</b> on line <b>78</b><br />
]]></description>
			<content:encoded><![CDATA[<p>About half a year ago, I found a memory corruption issue in Oracle <a href="http://java.com">Java</a> Version 6 Update 20 which could be triggered by loading Java in <a href="http://www.microsoft.com/windows/internet-explorer/default.aspx">MSIE</a> through the &#8220;<a href="http://msdn.microsoft.com/en-us/library/ms535183(VS.85).aspx">APPLET</a>&#8221; tag and accessing the &#8220;<a href="http://msdn.microsoft.com/en-us/library/ms537446(v=VS.85).aspx">children</a>&#8221; property. It appears that the code suffers from some <a href="http://en.wikipedia.org/wiki/Race_condition">race condition</a> that may be exploited to <a href="http://en.wikipedia.org/wiki/Arbitrary_code_execution">execute arbitrary code</a> in the <a href="http://en.wikipedia.org/wiki/Access_token">context</a> of the user that the iexplore.exe process is running as.</p>
<p>Oracle have released a patch for this issue which can be found <a href="http://www.oracle.com/technetwork/topics/security/javacpuoct2010-176258.html">here</a>.</p>
<p>More details can be found <a href="http://code.google.com/p/skylined/issues/detail?id=18">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://skypher.com/index.php/2010/10/13/issue-18-oracle-java-applet-childre/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Issue 23 &#8211; Oracle Java OBJECT tag &#8220;launchjnlp&#8221;/&#8221;docbase&#8221; property stack buffer overflow</title>
		<link>http://skypher.com/index.php/2010/10/13/issue-2-oracle-java-object-launchjnlp-docbase/</link>
		<comments>http://skypher.com/index.php/2010/10/13/issue-2-oracle-java-object-launchjnlp-docbase/#comments</comments>
		<pubDate>Wed, 13 Oct 2010 09:34:09 +0000</pubDate>
		<dc:creator>SkyLined</dc:creator>
				<category><![CDATA[Browsers]]></category>
		<category><![CDATA[PoC]]></category>
		<category><![CDATA[Repro]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://skypher.com/?p=574</guid>
		<description><![CDATA[<br />
<b>Warning</b>:  preg_split() [<a href='function.preg-split'>function.preg-split</a>]: Compilation failed: lookbehind assertion is not fixed length at offset 14 in <b>/home/c3682jgn/domains/skypher.com/public_html/wp-content/themes/braille/options/plugins.php</b> on line <b>77</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home/c3682jgn/domains/skypher.com/public_html/wp-content/themes/braille/options/plugins.php</b> on line <b>78</b><br />
]]></description>
			<content:encoded><![CDATA[<p>About a month and a half ago, <a href="http://www.reversemode.com/index.php?option=com_content&#038;task=view&#038;id=69&#038;Itemid=1">information about an 0-day vulnerability</a> in the <a href="http://www.apple.com/quicktime/">Apple QuickTime</a> plugin was published. It reminded of a project I had planned to implement for a while (since 2004 to be precise): a fuzzer that extracted information about <a href="http://en.wikipedia.org/wiki/COM_object">COM objects</a> installed on a system from the <a href="http://en.wikipedia.org/wiki/Windows_registry">registry</a> and scanned the <a href="http://en.wikipedia.org/wiki/Executable">binaries</a> associated with each COM object for strings. The fuzzer would use the collected information to try to instantiate objects and attempt to fuzz it using the strings as properties, methods and &#8220;<a href="http://en.wikipedia.org/wiki/Magic_number_(programming)">magic</a>&#8221; argument values. As soon as I had hacked something together, it found a simple <a href="http://en.wikipedia.org/wiki/Executable">buffer overflow</a> in Oracle <a href="http://java.com">Java</a> 6 Update 21.</p>
<p>The buffer overflow allows easy control over <a href="http://en.wikipedia.org/wiki/Instruction_pointer">EIP</a> and creating a working <a href="http://en.wikipedia.org/wiki/Exploit_(computer_security)">exploit</a> for targets without <a href="http://en.wikipedia.org/wiki/Data_Execution_Prevention">DEP</a> is as easy as copy+pasting a <a href="http://en.wikipedia.org/wiki/Heap_spray">heap spray</a> into the repro file.</p>
<p>I reported the issue to Oracle, who were <a href="http://www.zerodayinitiative.com/advisories/ZDI-10-206/">already aware</a> of the issue because it had also been reported to them by Stephen Fewer of <a href="http://www.harmonysecurity.com">Harmony Security</a> through <a href="http://www.zerodayinitiative.com/">ZDI</a>. Oracle has release a patch for this issue, which is available <a href="http://www.oracle.com/technetwork/topics/security/javacpuoct2010-176258.html">here</a>.</p>
<p>More details can be found <a href="http://code.google.com/p/skylined/issues/detail?id=23">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://skypher.com/index.php/2010/10/13/issue-2-oracle-java-object-launchjnlp-docbase/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Issue 21 &#8211; Microsoft Windows Media Player memory corruption using popups</title>
		<link>http://skypher.com/index.php/2010/10/12/issue-21-wmp-memory-corruption-using-popups/</link>
		<comments>http://skypher.com/index.php/2010/10/12/issue-21-wmp-memory-corruption-using-popups/#comments</comments>
		<pubDate>Tue, 12 Oct 2010 21:02:55 +0000</pubDate>
		<dc:creator>SkyLined</dc:creator>
				<category><![CDATA[Browsers]]></category>
		<category><![CDATA[Repro]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://skypher.com/?p=579</guid>
		<description><![CDATA[<br />
<b>Warning</b>:  preg_split() [<a href='function.preg-split'>function.preg-split</a>]: Compilation failed: lookbehind assertion is not fixed length at offset 14 in <b>/home/c3682jgn/domains/skypher.com/public_html/wp-content/themes/braille/options/plugins.php</b> on line <b>77</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home/c3682jgn/domains/skypher.com/public_html/wp-content/themes/braille/options/plugins.php</b> on line <b>78</b><br />
]]></description>
			<content:encoded><![CDATA[<p>About 4 months ago I finally tracked down a memory corruption issue that my fuzzers had been hitting on occasion. It appeared that the root cause was some kind of memory corruption or stale pointer related to a Windows Media Player plugin popup. The MSRC team reported that further investigation had revealed the the issue was slightly more complex than I had originally assumed and that the root cause of the issue might be triggered through other attack vectors that require less user-interaction. However, neither MSRC nor I was able to find any additional attack vectors.</p>
<p>Microsoft has release a fix for this issue <a href="http://www.microsoft.com/technet/security/Bulletin/MS10-082.mspx">here</a>.</p>
<p>More details can be found <a href="http://code.google.com/p/skylined/issues/detail?id=21">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://skypher.com/index.php/2010/10/12/issue-21-wmp-memory-corruption-using-popups/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>w32 MessageBox shellcode</title>
		<link>http://skypher.com/index.php/2010/09/06/w32-messagebox-shellcode/</link>
		<comments>http://skypher.com/index.php/2010/09/06/w32-messagebox-shellcode/#comments</comments>
		<pubDate>Mon, 06 Sep 2010 14:22:59 +0000</pubDate>
		<dc:creator>SkyLined</dc:creator>
				<category><![CDATA[Assembler]]></category>
		<category><![CDATA[Programming Languages]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Shellcode]]></category>

		<guid isPermaLink="false">http://skypher.com/?p=566</guid>
		<description><![CDATA[<br />
<b>Warning</b>:  preg_split() [<a href='function.preg-split'>function.preg-split</a>]: Compilation failed: lookbehind assertion is not fixed length at offset 14 in <b>/home/c3682jgn/domains/skypher.com/public_html/wp-content/themes/braille/options/plugins.php</b> on line <b>77</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home/c3682jgn/domains/skypher.com/public_html/wp-content/themes/braille/options/plugins.php</b> on line <b>78</b><br />
]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve created and published various very small versions of often used shellcodes for 32-bit versions of Windows, such as a <a href="http://code.google.com/p/w32-bind-ngs-shellcode/">bindshell</a>, <a href="http://code.google.com/p/w32-dl-loadlib-shellcode/">download &#038; LoadLibrary shellcode</a> and <a href="http://code.google.com/p/w32-exec-calc-shellcode/">calc.exe executing shellcode</a>. One thing that was missing from the list until today is a <a href="http://code.google.com/p/w32-msgbox-shellcode/">MessageBox shellcode</a>.</p>
<p>I hacked the code together in 30 minutes based on my calc.exe shellcode, so it can probably be optimized a bit more. I haven&#8217;t tested it thoroughly, but it works on Windows 7 for me.</p>
]]></content:encoded>
			<wfw:commentRss>http://skypher.com/index.php/2010/09/06/w32-messagebox-shellcode/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Exploits, ASLR and randomness</title>
		<link>http://skypher.com/index.php/2010/09/03/exploit-aslr-randomness/</link>
		<comments>http://skypher.com/index.php/2010/09/03/exploit-aslr-randomness/#comments</comments>
		<pubDate>Fri, 03 Sep 2010 09:40:39 +0000</pubDate>
		<dc:creator>SkyLined</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://skypher.com/?p=538</guid>
		<description><![CDATA[<br />
<b>Warning</b>:  preg_split() [<a href='function.preg-split'>function.preg-split</a>]: Compilation failed: lookbehind assertion is not fixed length at offset 14 in <b>/home/c3682jgn/domains/skypher.com/public_html/wp-content/themes/braille/options/plugins.php</b> on line <b>77</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home/c3682jgn/domains/skypher.com/public_html/wp-content/themes/braille/options/plugins.php</b> on line <b>78</b><br />
]]></description>
			<content:encoded><![CDATA[<p>When trying to bypass <a href="https://secure.wikimedia.org/wikipedia/en/wiki/Data_Execution_Prevention">DEP</a>, I often use a <a href="https://secure.wikimedia.org/wikipedia/en/wiki/Heap_spray">heap spray</a> to get data (including my <a href="https://secure.wikimedia.org/wikipedia/en/wiki/Shellcode">shellcode</a>) in a predictable location first. Next, I use <a href="https://secure.wikimedia.org/wikipedia/en/wiki/Return-to-libc_attack">ret-into-libc</a> to call <a href="http://msdn.microsoft.com/en-us/library/aa366898(VS.85).aspx">VirtualProtect</a> in an attempt to give the chunk of the heap that contains my shellcode &#8220;RWE&#8221; permissions. Finally, I returning to my shellcode, which can now be executed without causing an exception. However, if <a href="https://secure.wikimedia.org/wikipedia/en/wiki/Address_space_layout_randomization">ASLR</a> is enabled, you must first bypass that to find out where VirtualProtect is located in memory.</p>
<p>I haven&#8217;t got as much time as I used to to write exploits for bugs I find, but when I write exploits, I usually do so in incremental steps: I first create a simple version that ignores ASLR/DEP and I make sure that works with ASLR/DEP disabled. I then add the code that uses ret-into-libc to bypass DEP, and provide it with the exact location of VirtualProtect to make sure that works as well before I add the code that automatically determines the location of VirtualProtect to bypass ASLR. Because I have ASLR enabled on most of my systems, I created a simple tool to extract its current location:</p>
<p><code style="color:silver; background-color: black;"><br />
C:\Sample&gt;type <a href="http://skypher.com/SkyLined/download/ASLR/vp.c">vp.c</a><br />
#define WINVER 0x0500<br />
#define _WIN32_WINNT 0x0500<br />
#include &lt;windows.h&gt;<br />
int main(int argc, char** argv) {<br />
  HMODULE hModule = 0;<br />
  FARPROC pFunction = 0;<br />
  if (argc &lt; 2 || argc &gt; 3) {<br />
    printf("Usage:\r\n  %s module_name [function_name]\r\n", argv[0]);<br />
  } else {<br />
    hModule = LoadLibraryEx(argv[1], NULL, DONT_RESOLVE_DLL_REFERENCES);<br />
    if (!hModule) {<br />
      printf("Module not found!\r\n");<br />
    } else {<br />
      printf("Module base     : %08X\r\n", (UINT)hModule);<br />
      if (argc == 3) {<br />
        pFunction = GetProcAddress(hModule, argv[2]);<br />
        if (!pFunction) {<br />
          printf("Function not found!\r\n");<br />
        } else {<br />
          printf("Function offset : %+8X\r\n", (UINT)pFunction - (UINT)hModule);<br />
        }<br />
      }<br />
    }<br />
  }<br />
}<br />
&nbsp;<br />
C:\Sample&gt;<a href="http://code.google.com/p/skybuild/">build</a><br />
== Sample ==<br />
  @ Generating build configuration.<br />
  @ Version 0.1 alpha, build 1, started at Fri, 03 Sep 2010 07:55:45 (UTC)<br />
  [Sample]<br />
    + Build: vp.obj<br />
    + Build: vp.exe<br />
      - Cleanup: vp.ilk<br />
    - Cleanup: vp.obj<br />
    @ Project built successfully.<br />
@ Build successful.<br />
&nbsp;<br />
C:\Sample&gt;vp %SystemRoot%\system32\kernel32.dll<br />
Module base     : 77000000<br />
&nbsp;<br />
C:\Sample&gt;vp %SystemRoot%\system32\kernel32.dll VirtualProtect<br />
Module base     : 77000000<br />
Function offset :    134EC<br />
&nbsp;<br />
C:\Sample&gt;<br />
&nbsp;<br />
</code><br />
As you can see, both times I ran the tool, the base address of kernel32.dll was the same. This is because ASLR is only re-randomized at boot time, so until you reboot your machine, you can hard-code the value obtained this way into your exploit.</p>
<p>So, how random is the base address of kernel32.dll in real life? One way to find out is to set up a Windows machine to automatically run a script at startup that extracts the base address of kernel32.dll using the code above and then reboots. If you let this run for a while, you get a number of different values. Here&#8217;s a script I created to do just that:</p>
<p><code><br />
@ECHO OFF<br />
vp.exe "%SystemRoot%\system32\kernel32.dll" >> %COMPUTERNAME%.txt<br />
IF EXIST continue.txt (<br />
  shutdown.exe -r -t 0<br />
)<br />
&nbsp;<br />
</code><br />
In addition to logging the base address of kernel32.dll in a file named after the machine it is running on, and rebooting the machine, it also checks for the existence of a file called &#8220;continue.txt&#8221;. That way, I can stop the machine from continuously rebooting by deleting that file (the script is loaded of a network share, so I can access the file from another machine). I used the &#8220;CONTROL USERPASSWORDS2&#8243; configuration panel to tell Windows to automatically log in as a local user account at startup, and put the script in the &#8220;startup&#8221; folder of that local user.</p>
<p>After running for a while on a 32-bit Vista sp2 en-us virtual machine, I used the following Python script to extract some useful data from the information I gathered:</p>
<p><code><br />
if __name__ == "__main__":<br />
  import sys;<br />
  file = open(sys.argv[1], 'rb');<br />
  try:<br />
    data = file.read();<br />
  finally:<br />
    file.close();<br />
  base_addresses_counts = {};<br />
  results_count = 0;<br />
  for line in data.split('\r\n'):<br />
    if not line:<br />
      continue;<br />
    results_count += 1;<br />
    base_address = int(line[18:], 16);<br />
    if base_address not in base_addresses_counts:<br />
      base_addresses_counts[base_address] = 1;<br />
    else:<br />
      base_addresses_counts[base_address] += 1;<br />
  base_addresses = base_addresses_counts.keys();<br />
  base_addresses.sort();<br />
  lowest_base_address = base_addresses[0];<br />
  highest_base_address = base_addresses[-1];<br />
  smallest_delta = highest_base_address - lowest_base_address;<br />
  previous_base_address = None;<br />
  print ' Base        | Offset      | Delta       | Count     ';<br />
  print '-------------|-------------|-------------|--------------';<br />
  for base_address in base_addresses:<br />
    offset = base_address - lowest_base_address;<br />
    if previous_base_address is not None:<br />
      delta = base_address - previous_base_address;<br />
      if delta &lt; smallest_delta:<br />
        smallest_delta = delta;<br />
    else:<br />
      delta = 0;<br />
    print ' %11s | %11s | %11s | %d' % ( \<br />
        '0x%08X' % base_address, '+0x%X' % offset, '+0x%X' % delta, \<br />
        base_addresses_counts[base_address]);<br />
    previous_base_address = base_address;<br />
  print '-------------\'-------------\'-------------\'--------------';<br />
  print ' Total runs: %d' % results_count;<br />
  print ' Total different values: %d' % len(base_addresses);<br />
  print ' Smallest delta: 0x%X' % smallest_delta;<br />
  print ' Total possible values: >= %(v)d (%(v)X)' % {'v': offset / smallest_delta};<br />
&nbsp;<br />
</code></p>
<p>Here&#8217;s part of the output of this script:<br />
<code style="color:silver; background-color: black;"><br />
C:\Sample&gt;<a href="http://skypher.com/SkyLined/download/ASLR/analyze.py">analyze.py</a> VM3-V32SP2-N.txt<br />
 Base        | Offset      | Delta       | Count<br />
-------------|-------------|-------------|--------------<br />
  0x75490000 |        +0x0 |        +0x0 | 1<br />
  0x75550000 |    +0xC0000 |    +0xC0000 | 1<br />
  0x75580000 |    +0xF0000 |    +0x30000 | 1<br />
  0x755A0000 |   +0x110000 |    +0x20000 | 2<br />
<span style="color:grey">&lt;snip&gt;</span><br />
  0x77E40000 |  +0x29B0000 |    +0x40000 | 1<br />
  0x77E80000 |  +0x29F0000 |    +0x40000 | 1<br />
  0x77EB0000 |  +0x2A20000 |    +0x30000 | 1<br />
  0x77ED0000 |  +0x2A40000 |    +0x20000 | 2<br />
-------------'-------------'-------------'--------------<br />
 Total runs: 807<br />
 Total different values: 460<br />
 Smallest delta: 0x10000<br />
 Total possible values: &gt;= 676 (2A4)<br />
&nbsp;<br />
C:\Sample&gt;<br />
</code></p>
<p>To clarify: the machine was rebooted to collect another base address 806 times, yielding 807 base addresses. The base addresses were distributed among 460 different values, some values occurring more than once. Because of the number of the tests I performed and the randomness at which the addresses get chosen, it is to be expected that some values occur more often than others and that some values do not occur at all. Based on the lowest and highest value (07549000 and 077ED0000) and the smallest difference between two addresses (10000), I calculate that there are at least 676 different possible values for the base address.</p>
<p>I was a bit surprised by the results. I haven&#8217;t kept up-to-date with ASLR randomness, but IIRC it was 8-bits (256 possible values) last time I checked. Microsoft appears to have increased the randomness of their ASLR implementation in Vista. This makes a brute force attack against ASLR, in which you try all possible values until you find the right one, take longer. This also decreases the chances of success for an attacker that only has one try at guessing the address: a 1/256 chance is bad, a 1/676 chance is worse.</p>
<p>Should you decide to run a similar test, let me know what OS you tested and what values you found!</p>
]]></content:encoded>
			<wfw:commentRss>http://skypher.com/index.php/2010/09/03/exploit-aslr-randomness/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Issue 17 &#8211; Msxml2.XMLHTTP.3.0 response handling memory corruption</title>
		<link>http://skypher.com/index.php/2010/08/10/ms10-051/</link>
		<comments>http://skypher.com/index.php/2010/08/10/ms10-051/#comments</comments>
		<pubDate>Tue, 10 Aug 2010 18:49:16 +0000</pubDate>
		<dc:creator>SkyLined</dc:creator>
				<category><![CDATA[Browsers]]></category>
		<category><![CDATA[Internet Explorer]]></category>
		<category><![CDATA[Repro]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://skypher.com/?p=487</guid>
		<description><![CDATA[<br />
<b>Warning</b>:  preg_split() [<a href='function.preg-split'>function.preg-split</a>]: Compilation failed: lookbehind assertion is not fixed length at offset 14 in <b>/home/c3682jgn/domains/skypher.com/public_html/wp-content/themes/braille/options/plugins.php</b> on line <b>77</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home/c3682jgn/domains/skypher.com/public_html/wp-content/themes/braille/options/plugins.php</b> on line <b>78</b><br />
]]></description>
			<content:encoded><![CDATA[<p>Today Microsoft released <a href="http://www.microsoft.com/technet/security/bulletin/ms10-051.mspx">MS10-051</a>; a fix for a vulnerability in MSXML 3.0 which I reported to them April 12th 2010.</p>
<p>Case details can be found <a href="http://code.google.com/p/skylined/issues/detail?id=17">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://skypher.com/index.php/2010/08/10/ms10-051/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JsSfx &#8211; JavaScript compression/obfuscation</title>
		<link>http://skypher.com/index.php/2010/08/10/jssfx/</link>
		<comments>http://skypher.com/index.php/2010/08/10/jssfx/#comments</comments>
		<pubDate>Tue, 10 Aug 2010 10:43:02 +0000</pubDate>
		<dc:creator>SkyLined</dc:creator>
				<category><![CDATA[Browsers]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Programming Languages]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://skypher.com/?p=483</guid>
		<description><![CDATA[<br />
<b>Warning</b>:  preg_split() [<a href='function.preg-split'>function.preg-split</a>]: Compilation failed: lookbehind assertion is not fixed length at offset 14 in <b>/home/c3682jgn/domains/skypher.com/public_html/wp-content/themes/braille/options/plugins.php</b> on line <b>77</b><br />
<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home/c3682jgn/domains/skypher.com/public_html/wp-content/themes/braille/options/plugins.php</b> on line <b>78</b><br />
]]></description>
			<content:encoded><![CDATA[<p>I revisited and released an old tool for compressing and obfuscating JavaScript. Given a JavaScript as input, it will generate and output self-extracting compressed JavaScript.</p>
<p><a href="http://code.google.com/p/jssfx/">http://code.google.com/p/jssfx/<br />
</a></p>
]]></content:encoded>
			<wfw:commentRss>http://skypher.com/index.php/2010/08/10/jssfx/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

