<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Shellcode: finding the base address of kernel32 in Windows 7</title>
	<atom:link href="http://skypher.com/index.php/2009/07/22/shellcode-finding-kernel32-in-windows-7/feed/" rel="self" type="application/rss+xml" />
	<link>http://skypher.com/index.php/2009/07/22/shellcode-finding-kernel32-in-windows-7/</link>
	<description>The blog for absolutely nothing!</description>
	<lastBuildDate>Wed, 02 May 2012 00:54:08 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<item>
		<title>By: alu</title>
		<link>http://skypher.com/index.php/2009/07/22/shellcode-finding-kernel32-in-windows-7/comment-page-1/#comment-1364</link>
		<dc:creator>alu</dc:creator>
		<pubDate>Tue, 12 Jul 2011 10:25:12 +0000</pubDate>
		<guid isPermaLink="false">http://skypher.com/?p=153#comment-1364</guid>
		<description>old entry, but anyway.

The unicode string is actually a structure that looks like this:

struct UNICODE_STRING {
  USHORT Length;
  USHORT MaximumLength;
  PWSTR  Buffer;
}

So could do something like:

        mov ebx, [fs:0x30]      ; get PEB base address
        mov ebx, [ebx + 0xc]    ; get PEB.Ldr
        mov ebx, [ebx + 0x1c]   ; get PEB.Ldr.InInitOrder
.loop:
        mov eax, [ebx + 0x8]            ; get base dll addr
        movzx esi, word [ebx + 0x1c]    ; get length
        mov ebx, [ebx]                  ; get next entry
        cmp si, 0x18
        jne .loop</description>
		<content:encoded><![CDATA[<p>old entry, but anyway.</p>
<p>The unicode string is actually a structure that looks like this:</p>
<p>struct UNICODE_STRING {<br />
  USHORT Length;<br />
  USHORT MaximumLength;<br />
  PWSTR  Buffer;<br />
}</p>
<p>So could do something like:</p>
<p>        mov ebx, [fs:0x30]      ; get PEB base address<br />
        mov ebx, [ebx + 0xc]    ; get PEB.Ldr<br />
        mov ebx, [ebx + 0x1c]   ; get PEB.Ldr.InInitOrder<br />
.loop:<br />
        mov eax, [ebx + 0x8]            ; get base dll addr<br />
        movzx esi, word [ebx + 0x1c]    ; get length<br />
        mov ebx, [ebx]                  ; get next entry<br />
        cmp si, 0&#215;18<br />
        jne .loop</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Finding Kernel32 Base Address Shellcode &#171; Insanely Low-Level</title>
		<link>http://skypher.com/index.php/2009/07/22/shellcode-finding-kernel32-in-windows-7/comment-page-1/#comment-1363</link>
		<dc:creator>Finding Kernel32 Base Address Shellcode &#171; Insanely Low-Level</dc:creator>
		<pubDate>Thu, 07 Jul 2011 20:58:44 +0000</pubDate>
		<guid isPermaLink="false">http://skypher.com/?p=153#comment-1363</guid>
		<description>[...] based my code on: http://skypher.com/index.php/2009/07/22/shellcode-finding-kernel32-in-windows-7/ AFAIK, who based his post on: [...]</description>
		<content:encoded><![CDATA[<p>[...] based my code on: <a href="http://skypher.com/index.php/2009/07/22/shellcode-finding-kernel32-in-windows-7/" rel="nofollow">http://skypher.com/index.php/2009/07/22/shellcode-finding-kernel32-in-windows-7/</a> AFAIK, who based his post on: [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SkyLined</title>
		<link>http://skypher.com/index.php/2009/07/22/shellcode-finding-kernel32-in-windows-7/comment-page-1/#comment-1321</link>
		<dc:creator>SkyLined</dc:creator>
		<pubDate>Tue, 25 Jan 2011 20:06:09 +0000</pubDate>
		<guid isPermaLink="false">http://skypher.com/?p=153#comment-1321</guid>
		<description>I haven&#039;t got a copy to check your claims, but it used to work fine on my x64 Vista SP2 (in x86 WoW64 mode of course). The check does indeed make assumptions that do not NEED to be true for all OS/SPs, but you&#039;re the first to report issues. Did you run the code to make sure it fails? If not, could you give it a try and let me know if it does not, so I can consider other options?</description>
		<content:encoded><![CDATA[<p>I haven&#8217;t got a copy to check your claims, but it used to work fine on my x64 Vista SP2 (in x86 WoW64 mode of course). The check does indeed make assumptions that do not NEED to be true for all OS/SPs, but you&#8217;re the first to report issues. Did you run the code to make sure it fails? If not, could you give it a try and let me know if it does not, so I can consider other options?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SkyLined</title>
		<link>http://skypher.com/index.php/2009/07/22/shellcode-finding-kernel32-in-windows-7/comment-page-1/#comment-1320</link>
		<dc:creator>SkyLined</dc:creator>
		<pubDate>Tue, 25 Jan 2011 20:01:50 +0000</pubDate>
		<guid isPermaLink="false">http://skypher.com/?p=153#comment-1320</guid>
		<description>Not sure how to find the structure you&#039;re referring to, but I assume you&#039;ll need a few more instructions to do that. The above code is intended to be as small as possible and still work.</description>
		<content:encoded><![CDATA[<p>Not sure how to find the structure you&#8217;re referring to, but I assume you&#8217;ll need a few more instructions to do that. The above code is intended to be as small as possible and still work.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sippy</title>
		<link>http://skypher.com/index.php/2009/07/22/shellcode-finding-kernel32-in-windows-7/comment-page-1/#comment-1317</link>
		<dc:creator>sippy</dc:creator>
		<pubDate>Fri, 21 Jan 2011 23:58:05 +0000</pubDate>
		<guid isPermaLink="false">http://skypher.com/?p=153#comment-1317</guid>
		<description>Actually, Vista Ultimate SP1 x64 (maybe other versions) has a bunch of nulls after ntdll.dll, so this method doesn&#039;t work for all platforms mentioned.  I tried to post sample windbg output but wordpress hates me.</description>
		<content:encoded><![CDATA[<p>Actually, Vista Ultimate SP1 x64 (maybe other versions) has a bunch of nulls after ntdll.dll, so this method doesn&#8217;t work for all platforms mentioned.  I tried to post sample windbg output but wordpress hates me.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sippy</title>
		<link>http://skypher.com/index.php/2009/07/22/shellcode-finding-kernel32-in-windows-7/comment-page-1/#comment-1316</link>
		<dc:creator>sippy</dc:creator>
		<pubDate>Fri, 21 Jan 2011 23:49:09 +0000</pubDate>
		<guid isPermaLink="false">http://skypher.com/?p=153#comment-1316</guid>
		<description>Why not insure you have the right module by validating the .Length field of the UNICODE_STRING structure for module_name is 12?</description>
		<content:encoded><![CDATA[<p>Why not insure you have the right module by validating the .Length field of the UNICODE_STRING structure for module_name is 12?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Exploit writing tutorial part 9 : Introduction to Win32 shellcoding &#124; Peter Van Eeckhoutte&#39;s Blog</title>
		<link>http://skypher.com/index.php/2009/07/22/shellcode-finding-kernel32-in-windows-7/comment-page-1/#comment-813</link>
		<dc:creator>Exploit writing tutorial part 9 : Introduction to Win32 shellcoding &#124; Peter Van Eeckhoutte&#39;s Blog</dc:creator>
		<pubDate>Fri, 25 Jun 2010 07:02:27 +0000</pubDate>
		<guid isPermaLink="false">http://skypher.com/?p=153#comment-813</guid>
		<description>[...] This is what I meant with “think goal oriented”. The code does exactly what it needs to do, without imposing any restrictions. You can still use this code to execute something else, and the method to get the WinExec function address is generic. So my assumption that I needed to find 2 function addresses is wrong &#8211; all I really needed to focus on is getting calc executed.&#160; You can find more information on skylined’s approach to finding a function address here [...]</description>
		<content:encoded><![CDATA[<p>[...] This is what I meant with “think goal oriented”. The code does exactly what it needs to do, without imposing any restrictions. You can still use this code to execute something else, and the method to get the WinExec function address is generic. So my assumption that I needed to find 2 function addresses is wrong &#8211; all I really needed to focus on is getting calc executed.&#160; You can find more information on skylined’s approach to finding a function address here [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aniway</title>
		<link>http://skypher.com/index.php/2009/07/22/shellcode-finding-kernel32-in-windows-7/comment-page-1/#comment-634</link>
		<dc:creator>Aniway</dc:creator>
		<pubDate>Mon, 30 Nov 2009 15:26:30 +0000</pubDate>
		<guid isPermaLink="false">http://skypher.com/?p=153#comment-634</guid>
		<description>Cheers:)</description>
		<content:encoded><![CDATA[<p>Cheers:)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SkyLined</title>
		<link>http://skypher.com/index.php/2009/07/22/shellcode-finding-kernel32-in-windows-7/comment-page-1/#comment-633</link>
		<dc:creator>SkyLined</dc:creator>
		<pubDate>Mon, 30 Nov 2009 15:10:28 +0000</pubDate>
		<guid isPermaLink="false">http://skypher.com/?p=153#comment-633</guid>
		<description>Ah, that makes sense: the code assumes that the &quot;ntdll.dll&quot; string is followed by bytes that do not contain a NULL byte at offset +12 from the start of the string. It appears this is true for all versions of Windows after w2k (though I have not tested them all to confirm this). It seems that win2k happens to have a NULL byte at this offset after the string, causing the code to mistakenly assume it is kernel32.dll. Checking for a WORD NULL at that location solves this. Thanks for the feedback!</description>
		<content:encoded><![CDATA[<p>Ah, that makes sense: the code assumes that the &#8220;ntdll.dll&#8221; string is followed by bytes that do not contain a NULL byte at offset +12 from the start of the string. It appears this is true for all versions of Windows after w2k (though I have not tested them all to confirm this). It seems that win2k happens to have a NULL byte at this offset after the string, causing the code to mistakenly assume it is kernel32.dll. Checking for a WORD NULL at that location solves this. Thanks for the feedback!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: aniway</title>
		<link>http://skypher.com/index.php/2009/07/22/shellcode-finding-kernel32-in-windows-7/comment-page-1/#comment-628</link>
		<dc:creator>aniway</dc:creator>
		<pubDate>Fri, 27 Nov 2009 04:15:34 +0000</pubDate>
		<guid isPermaLink="false">http://skypher.com/?p=153#comment-628</guid>
		<description>Hi Skylined,

Just let you know that I figured it out.

As the first module name being checked is ntdll.dll, on win2k, the unicode name and the data following it is as below:

&lt;CODE&gt;
6e 00 74 00 64 00 6c 00 6c 00 2e 00 64 00 6c 00 ntdll.dl
6c 00 00 00 42 00 08 00 00 01 &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; l.B..
&#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; &#160;&#160; ^^
This is the byte we are checking.
&lt;/CODE&gt;
As you can see, if we only check one byte, the code will think ntdll.dll is kernel32.dll. Checking 2 bytes fixes that problem.

Cheers,

Aniway</description>
		<content:encoded><![CDATA[<p>Hi Skylined,</p>
<p>Just let you know that I figured it out.</p>
<p>As the first module name being checked is ntdll.dll, on win2k, the unicode name and the data following it is as below:</p>
<p><code><br />
6e 00 74 00 64 00 6c 00 6c 00 2e 00 64 00 6c 00 ntdll.dl<br />
6c 00 00 00 42 00 08 00 00 01 &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; l.B..<br />
&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; ^^<br />
This is the byte we are checking.<br />
</code><br />
As you can see, if we only check one byte, the code will think ntdll.dll is kernel32.dll. Checking 2 bytes fixes that problem.</p>
<p>Cheers,</p>
<p>Aniway</p>
]]></content:encoded>
	</item>
</channel>
</rss>

