<?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>ReversingLabs &#124; Blog &#187; Analysis</title>
	<atom:link href="http://blog.reversinglabs.com/tag/analysis/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.reversinglabs.com</link>
	<description>Everything in reverse...</description>
	<lastBuildDate>Sat, 02 Jul 2011 10:53:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.4</generator>
		<item>
		<title>Analyzing layered protections</title>
		<link>http://blog.reversinglabs.com/2010/02/analyzing-layered-protections/</link>
		<comments>http://blog.reversinglabs.com/2010/02/analyzing-layered-protections/#comments</comments>
		<pubDate>Mon, 15 Feb 2010 15:38:49 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Reversing]]></category>
		<category><![CDATA[TitanEngine]]></category>
		<category><![CDATA[Analysis]]></category>
		<category><![CDATA[Protection]]></category>

		<guid isPermaLink="false">http://blog.reversinglabs.com/?p=313</guid>
		<description><![CDATA[There is hardly a software protection nowadays that has only a single layer of code containing the whole stub code. Even some software packers such as PeCompact implement multiple layers in the process of software decompression. It is common for these additional layers to do the most interesting protection operations, such as memory decompression, import [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">There is hardly a software protection nowadays that has only a single layer of code containing the whole stub code. Even some software packers such as <a href="http://www.bitsum.com/" target="_blank">PeCompact</a> implement multiple layers in the process of software decompression. It is common for these additional layers to do the most interesting protection operations, such as memory decompression, import table processing and entry point protection and redirection. Therefore in order to fully dynamically unpack these kinds of protections we need to move through the layers and collect the needed data along the way. The protection we have chosen to analyze is AlexProtector because it uses a multiple layer protection model along with other interesting protection features. During analysis of this protection, we will encounter: obfuscations, antidebugging, antitracing, antiemulation, checksum checks, import elimination and stolen bytes at the entry point. Quite an impressive list of protections found in software protection from 2004, which is why we at the <a href="http://www.reversinglabs.com/" target="_blank">ReversingLabs</a> commonly use it as an introduction to more complex protection solutions.</p>
<p style="text-align: justify;">The entry point of the packed file gives us a vague clue on how interesting this analysis will be. It looks like this:</p>
<blockquote>
<pre class="asm">  <span style="color: #EE4A02;">PUSHAD</span>
  <span style="color: #EE4A02;">CALL</span> L002
L002:
  <span style="color: #EE4A02;">POP</span> <span style="color: #EE1802; font-weight:bold;">EBP</span>
  <span style="color: #EE4A02;">SUB</span> <span style="color: #EE1802; font-weight:bold;">EBP</span>,<span style="color: #ff0000;">00401006</span>
  <span style="color: #EE4A02;">CALL</span> <span style="color: #ff0000;">00407036</span>
  <span style="color: #EE4A02;">JMP</span> L007
  <span style="color: #DEE002;">DB</span> E9
L007:
  <span style="color: #EE4A02;">MOV</span> <span style="color: #EE1802; font-weight:bold;">EAX</span>,<span style="color: #DEE002;">DWORD</span> <span style="color: #DEE002;">PTR</span> <span style="color: #EE1802; font-weight:bold;">SS</span>:<span style="color: #FFFFFF;">&#91;</span><span style="color: #EE1802; font-weight:bold;">ESP</span>+<span style="color: #DEE002;">C</span><span style="color: #FFFFFF;">&#93;</span>
  <span style="color: #EE4A02;">JMP</span> <span style="color: #DEE002;">SHORT</span> 0040701E</pre>
</blockquote>
<p style="text-align: justify;">The usual method of getting the code offset delta via CALL/POP, followed by simple obfuscations and the first packer controlled exception. Luckily for us the whole first protection layer is unprotected, so basic stub functions are accessible from start. They include antidebugging functions and more importantly, the decompression of the main protection layer and the transfer of control to it. This first layer's primary point of interest is the layer control transfer. To locate that part of the code we scroll down a bit and spot the <a href="http://www.ibsensoftware.com/products_aPLib.html" target="_blank">aplib</a> decompression code. That recognizable code:</p>
<blockquote>
<pre class="asm">  <span style="color: #EE4A02;">PUSHAD</span>
  <span style="color: #EE4A02;">MOV</span> <span style="color: #EE1802; font-weight:bold;">ESI</span>,<span style="color: #DEE002;">DWORD</span> <span style="color: #DEE002;">PTR</span> <span style="color: #EE1802; font-weight:bold;">SS</span>:<span style="color: #FFFFFF;">&#91;</span>ESP<span style="color: #ff0000;">+24</span><span style="color: #FFFFFF;">&#93;</span>
  <span style="color: #EE4A02;">MOV</span> <span style="color: #EE1802; font-weight:bold;">EDI</span>,<span style="color: #DEE002;">DWORD</span> <span style="color: #DEE002;">PTR</span> <span style="color: #EE1802; font-weight:bold;">SS</span>:<span style="color: #FFFFFF;">&#91;</span>ESP<span style="color: #ff0000;">+28</span><span style="color: #FFFFFF;">&#93;</span>
  <span style="color: #EE4A02;">CLD</span>
  <span style="color: #EE4A02;">MOV</span> <span style="color: #EE1802; font-weight:bold;">DL</span>,<span style="color: #ff0000;">80</span>
  <span style="color: #EE4A02;">XOR</span> <span style="color: #EE1802; font-weight:bold;">EBX</span>,<span style="color: #EE1802; font-weight:bold;">EBX</span>
  <span style="color: #EE4A02;">MOVS</span> <span style="color: #DEE002;">BYTE</span> <span style="color: #DEE002;">PTR</span> <span style="color: #EE1802; font-weight:bold;">ES</span>:<span style="color: #FFFFFF;">&#91;</span><span style="color: #EE1802; font-weight:bold;">EDI</span><span style="color: #FFFFFF;">&#93;</span>,<span style="color: #DEE002;">BYTE</span> <span style="color: #DEE002;">PTR</span> <span style="color: #EE1802; font-weight:bold;">DS</span>:<span style="color: #FFFFFF;">&#91;</span><span style="color: #EE1802; font-weight:bold;">ESI</span><span style="color: #FFFFFF;">&#93;</span>
...
  <span style="color: #EE4A02;">SUB</span> <span style="color: #EE1802; font-weight:bold;">EDI</span>,<span style="color: #DEE002;">DWORD</span> <span style="color: #DEE002;">PTR</span> <span style="color: #EE1802; font-weight:bold;">SS</span>:<span style="color: #FFFFFF;">&#91;</span>ESP<span style="color: #ff0000;">+28</span><span style="color: #FFFFFF;">&#93;</span>
  <span style="color: #EE4A02;">MOV</span> <span style="color: #DEE002;">DWORD</span> <span style="color: #DEE002;">PTR</span> <span style="color: #EE1802; font-weight:bold;">SS</span>:<span style="color: #FFFFFF;">&#91;</span><span style="color: #EE1802; font-weight:bold;">ESP</span>+1C<span style="color: #FFFFFF;">&#93;</span>,<span style="color: #EE1802; font-weight:bold;">EDI</span>
  <span style="color: #EE4A02;">POPAD</span>
  <span style="color: #EE4A02;">RET</span></pre>
</blockquote>
<p style="text-align: justify;">It is located at offset +0x108 relative to the entry point. Since it is common for protectors to compress and/or encrypt their layers, setting a hardware breakpoint here seems like a good place to start. After a few exceptions we finally hit it, and we can collect the needed data from this function's input parameters. If we take a look at the stack we can see these numbers:</p>
<blockquote>
<pre class="asm">0012FF50   00407AB9  RETURN to 00407AB9 from <span style="color: #ff0000;">00407108</span> <span style="color: #adadad; font-style: italic;">;Called from</span>
0012FF54   <span style="color: #ff0000;">00408531</span>  <span style="color: #ff0000;">00408531</span> <span style="color: #adadad; font-style: italic;">;Packed layer content</span>
0012FF58   <span style="color: #ff0000;">00330000</span>           <span style="color: #adadad; font-style: italic;">;Allocated layer buffe</span></pre>
</blockquote>
<p style="text-align: justify;">If we look at the address from which the layer decompression was called, we see:</p>
<blockquote>
<pre class="asm">  <span style="color: #EE4A02;">CALL</span> <span style="color: #ff0000;">00407108</span> <span style="color: #adadad; font-style: italic;">;aPLib decompression</span>
  <span style="color: #EE4A02;">ADD</span> <span style="color: #EE1802; font-weight:bold;">ESP</span>,<span style="color: #ff0000;">8</span>
  <span style="color: #EE4A02;">PUSHAD</span> <span style="color: #adadad; font-style: italic;">;AntiTracing via RDTSC</span>
 ...
  <span style="color: #EE4A02;">ADD</span> <span style="color: #EE1802; font-weight:bold;">ESP</span>,<span style="color: #ff0000;">4</span>
  RDTSC
  <span style="color: #EE4A02;">MOV</span> <span style="color: #EE1802; font-weight:bold;">EBX</span>,<span style="color: #EE1802; font-weight:bold;">EAX</span>
...
  <span style="color: #EE4A02;">ADD</span> <span style="color: #EE1802; font-weight:bold;">ESP</span>,<span style="color: #ff0000;">4</span>
  <span style="color: #EE4A02;">MOV</span> <span style="color: #EE1802; font-weight:bold;">ECX</span>,<span style="color: #EE1802; font-weight:bold;">EDX</span>
...
  <span style="color: #EE4A02;">ADD</span> <span style="color: #EE1802; font-weight:bold;">ESP</span>,<span style="color: #ff0000;">4</span>
  RDTSC
  <span style="color: #EE4A02;">SUB</span> <span style="color: #EE1802; font-weight:bold;">EAX</span>,<span style="color: #EE1802; font-weight:bold;">EBX</span>
...
  <span style="color: #EE4A02;">ADD</span> <span style="color: #EE1802; font-weight:bold;">ESP</span>,<span style="color: #ff0000;">4</span>
  <span style="color: #EE4A02;">SBB</span> <span style="color: #EE1802; font-weight:bold;">EDX</span>,<span style="color: #EE1802; font-weight:bold;">ECX</span>
  RDTSC
  <span style="color: #EE4A02;">ADD</span> <span style="color: #EE1802; font-weight:bold;">EAX</span>,<span style="color: #EE1802; font-weight:bold;">EBX</span>
...
  <span style="color: #EE4A02;">ADD</span> <span style="color: #EE1802; font-weight:bold;">ESP</span>,<span style="color: #ff0000;">4</span>
  <span style="color: #EE4A02;">ADC</span> <span style="color: #EE1802; font-weight:bold;">EDX</span>,<span style="color: #EE1802; font-weight:bold;">ECX</span>
  RDTSC
  <span style="color: #EE4A02;">SUB</span> <span style="color: #EE1802; font-weight:bold;">EAX</span>,<span style="color: #EE1802; font-weight:bold;">EBX</span>
...
  <span style="color: #EE4A02;">ADD</span> <span style="color: #EE1802; font-weight:bold;">ESP</span>,<span style="color: #ff0000;">4</span>
...
  <span style="color: #EE4A02;">ADD</span> <span style="color: #EE1802; font-weight:bold;">ESP</span>,<span style="color: #ff0000;">4</span>
  <span style="color: #EE4A02;">SBB</span> <span style="color: #EE1802; font-weight:bold;">EDX</span>,<span style="color: #EE1802; font-weight:bold;">ECX</span>
...
  <span style="color: #EE4A02;">ADD</span> <span style="color: #EE1802; font-weight:bold;">ESP</span>,<span style="color: #ff0000;">4</span>
  <span style="color: #EE4A02;">TEST</span> <span style="color: #EE1802; font-weight:bold;">EDX</span>,<span style="color: #EE1802; font-weight:bold;">EDX</span>
  <span style="color: #EE4A02;">JNZ</span> <span style="color: #DEE002;">SHORT</span> 00407B36 <span style="color: #adadad; font-style: italic;">;Executed if code is traced</span>
  <span style="color: #EE4A02;">POPAD</span></pre>
</blockquote>
<p style="text-align: justify;">This antitrace code is repeated throughout the code many times, and it is also present in all API redirections. Following this is a single exception that is executed just before control  is transferred to second protection layer. Instruction JMP EDI, which is located just above the custom memory checksum algorithm, transfers the control to the next layer. That next layer starts like this:</p>
<blockquote>
<pre class="asm">  <span style="color: #EE4A02;">JMP</span> L003
L001:
  <span style="color: #EE4A02;">JMP</span> L004
  ???
L003:
  <span style="color: #EE4A02;">JMP</span> L001
L004:
  <span style="color: #EE4A02;">CALL</span> L036
  <span style="color: #EE4A02;">TEST</span> <span style="color: #EE1802; font-weight:bold;">AL</span>,<span style="color: #ff0000;">83</span>
  <span style="color: #EE4A02;">LES</span> <span style="color: #EE1802; font-weight:bold;">EAX</span>,<span style="color: #DEE002;">FWORD</span> <span style="color: #DEE002;">PTR</span> <span style="color: #EE1802; font-weight:bold;">DS</span>:<span style="color: #FFFFFF;">&#91;</span><span style="color: #EE1802; font-weight:bold;">EAX</span>+<span style="color: #EE1802; font-weight:bold;">EDX</span>*<span style="color: #ff0000;">4</span><span style="color: #FFFFFF;">&#93;</span>
  <span style="color: #EE4A02;">NOP</span>
  <span style="color: #EE4A02;">NOP</span>
  <span style="color: #EE4A02;">NOP</span>
  <span style="color: #EE4A02;">NOP</span>
&nbsp;</pre>
</blockquote>
<p style="text-align: justify;">This protection layer holds all information necessary for unpacker coding in this layer. Imports are handled at these locations:</p>
<blockquote>
<pre class="asm">+0x9A5:  <span style="color: #EE4A02;">PUSH</span> <span style="color: #EE1802; font-weight:bold;">EBX</span>
  <span style="color: #EE4A02;">LEA</span> <span style="color: #EE1802; font-weight:bold;">EDX</span>,<span style="color: #DEE002;">DWORD</span> <span style="color: #DEE002;">PTR</span> <span style="color: #EE1802; font-weight:bold;">SS</span>:<span style="color: #FFFFFF;">&#91;</span>EBP<span style="color: #ff0000;">+401108</span><span style="color: #FFFFFF;">&#93;</span>
  <span style="color: #EE4A02;">CALL</span> <span style="color: #DEE002;">NEAR</span> <span style="color: #EE1802; font-weight:bold;">EDX</span>                       <span style="color: #adadad; font-style: italic;">;decompress IAT data</span>
  <span style="color: #EE4A02;">ADD</span> <span style="color: #EE1802; font-weight:bold;">ESP</span>,<span style="color: #ff0000;">8</span>
  <span style="color: #EE4A02;">MOV</span> <span style="color: #EE1802; font-weight:bold;">EDI</span>,<span style="color: #DEE002;">DWORD</span> <span style="color: #DEE002;">PTR</span> <span style="color: #EE1802; font-weight:bold;">SS</span>:<span style="color: #FFFFFF;">&#91;</span><span style="color: #EE1802; font-weight:bold;">EBP</span>+4023A9<span style="color: #FFFFFF;">&#93;</span>
+0x9B7:  <span style="color: #EE4A02;">CMP</span> <span style="color: #DEE002;">BYTE</span> <span style="color: #DEE002;">PTR</span> <span style="color: #EE1802; font-weight:bold;">DS</span>:<span style="color: #FFFFFF;">&#91;</span><span style="color: #EE1802; font-weight:bold;">EDI</span><span style="color: #FFFFFF;">&#93;</span>,0C3
  <span style="color: #EE4A02;">JNZ</span> 00330A8C
  <span style="color: #EE4A02;">ADD</span> <span style="color: #EE1802; font-weight:bold;">EDI</span>,<span style="color: #ff0000;">2</span>
  <span style="color: #EE4A02;">PUSH</span> <span style="color: #EE1802; font-weight:bold;">EDI</span>
  <span style="color: #EE4A02;">CALL</span> <span style="color: #DEE002;">NEAR</span> <span style="color: #DEE002;">DWORD</span> <span style="color: #DEE002;">PTR</span> <span style="color: #EE1802; font-weight:bold;">SS</span>:<span style="color: #FFFFFF;">&#91;</span><span style="color: #EE1802; font-weight:bold;">EBP</span>+4024C8<span style="color: #FFFFFF;">&#93;</span> <span style="color: #adadad; font-style: italic;">;GetModuleHandleA</span>
  <span style="color: #EE4A02;">TEST</span> <span style="color: #EE1802; font-weight:bold;">EAX</span>,<span style="color: #EE1802; font-weight:bold;">EAX</span>
...
+0xA95:  <span style="color: #EE4A02;">INC</span> <span style="color: #EE1802; font-weight:bold;">EDI</span>
  <span style="color: #EE4A02;">PUSH</span> <span style="color: #EE1802; font-weight:bold;">EDI</span>
  <span style="color: #EE4A02;">PUSH</span> <span style="color: #DEE002;">DWORD</span> <span style="color: #DEE002;">PTR</span> <span style="color: #EE1802; font-weight:bold;">SS</span>:<span style="color: #FFFFFF;">&#91;</span><span style="color: #EE1802; font-weight:bold;">EBP</span>+40247C<span style="color: #FFFFFF;">&#93;</span>
  <span style="color: #EE4A02;">CALL</span> <span style="color: #DEE002;">NEAR</span> <span style="color: #DEE002;">DWORD</span> <span style="color: #DEE002;">PTR</span> <span style="color: #EE1802; font-weight:bold;">SS</span>:<span style="color: #FFFFFF;">&#91;</span><span style="color: #EE1802; font-weight:bold;">EBP</span>+4024C4<span style="color: #FFFFFF;">&#93;</span> <span style="color: #adadad; font-style: italic;">;GetProcAddress</span>
  <span style="color: #EE4A02;">XOR</span> <span style="color: #EE1802; font-weight:bold;">EBX</span>,<span style="color: #EE1802; font-weight:bold;">EBX</span>
  <span style="color: #EE4A02;">PUSHAD</span>
&nbsp;</pre>
</blockquote>
<p style="text-align: justify;">And this is where we have a choice to either place breakpoints at these locations or analyze a memory buffer holding IAT data. That buffer is decompressed just before it is processed. If we examine it, we see the following pattern:</p>
<blockquote>
<pre class="cpp"><span style="">typedef</span> <span style="">struct</span> ALEX_IAT_DLL<span style="color: #FFFFFF;">&#123;</span>
       BYTE DLLSignature; <span style="color: #ff0000;">//0xC3</span>
       BYTE DLLNameLength;
       <span style="color: #ff0000;">// DLLName[DLLNameLength] followed by 0x00</span>
<span style="color: #FFFFFF;">&#125;</span>ALEX_IAT_DLL, *PALEX_IAT_DLL;
&nbsp;
<span style="">typedef</span> <span style="">struct</span> ALEX_IAT_APIENTRY<span style="color: #FFFFFF;">&#123;</span>
       BYTE APINameLength;
       <span style="color: #ff0000;">// APIName[APINameLength] followed by 0x00</span>
       BYTE RedirectionNumber; <span style="color: #ff0000;">//Number of redirections</span>
       DWORD RedirectionAddress<span style="color: #FFFFFF;">&#91;</span>RedirectionNumber<span style="color: #FFFFFF;">&#93;</span>;
<span style="color: #FFFFFF;">&#125;</span>ALEX_IAT_APIENTRY, *PALEX_IAT_APIENTRY;</pre>
</blockquote>
<p style="text-align: justify;">Either choice is a good one. However AlexProtector uses a protection technique called "import elimination" which means that parts of the code section which are used as call gates to Windows API are damaged and must be fixed. This data is stored in the import structure we just analyzed. However there is a problem with this since we don't know the original location of the import table and we must reserve some space for it. The solution to this problem is to reserve space in the new section but a detailed description on how to do this will be done next week in part two, when we create the unpacker for AlexProtector.</p>
<p style="text-align: justify;">Solving the problem of imports leaves us with just one more problem, the entry point. After some quick tracing we find this code part:</p>
<blockquote>
<pre class="asm">+0x107B:  <span style="color: #EE4A02;">MOV</span> <span style="color: #EE1802; font-weight:bold;">ESI</span>,<span style="color: #DEE002;">DWORD</span> <span style="color: #DEE002;">PTR</span> <span style="color: #EE1802; font-weight:bold;">SS</span>:<span style="color: #FFFFFF;">&#91;</span>EBP<span style="color: #ff0000;">+402385</span><span style="color: #FFFFFF;">&#93;</span> <span style="color: #adadad; font-style: italic;">;SS:[00408385]=004012E6</span>
  <span style="color: #EE4A02;">ADD</span> <span style="color: #EE1802; font-weight:bold;">EAX</span>,<span style="color: #EE1802; font-weight:bold;">EBX</span>
  <span style="color: #EE4A02;">MOV</span> <span style="color: #DEE002;">BYTE</span> <span style="color: #DEE002;">PTR</span> <span style="color: #EE1802; font-weight:bold;">DS</span>:<span style="color: #FFFFFF;">&#91;</span><span style="color: #EE1802; font-weight:bold;">EAX</span><span style="color: #FFFFFF;">&#93;</span>,0E9 <span style="color: #adadad; font-style: italic;">;Write jump to EP</span>
  <span style="color: #EE4A02;">INC</span> <span style="color: #EE1802; font-weight:bold;">EAX</span>
  <span style="color: #EE4A02;">MOV</span> <span style="color: #EE1802; font-weight:bold;">ECX</span>,<span style="color: #EE1802; font-weight:bold;">ESI</span>
...
+0x11E5:  <span style="color: #EE4A02;">MOV</span> <span style="color: #DEE002;">DWORD</span> <span style="color: #DEE002;">PTR</span> <span style="color: #EE1802; font-weight:bold;">SS</span>:<span style="color: #FFFFFF;">&#91;</span><span style="color: #EE1802; font-weight:bold;">ESP</span>+1C<span style="color: #FFFFFF;">&#93;</span>,<span style="color: #EE1802; font-weight:bold;">EAX</span>
  <span style="color: #EE4A02;">POPAD</span>
  <span style="color: #EE4A02;">JMP</span> <span style="color: #DEE002;">NEAR</span> <span style="color: #EE1802; font-weight:bold;">EAX</span>              <span style="color: #adadad; font-style: italic;">;Jump to stolen EP code</span>
...
  <span style="color: #EE4A02;">MOV</span> <span style="color: #EE1802; font-weight:bold;">EDI</span>,DFB4AF72
  <span style="color: #EE4A02;">LEA</span> <span style="color: #EE1802; font-weight:bold;">EDI</span>,<span style="color: #DEE002;">DWORD</span> <span style="color: #DEE002;">PTR</span> <span style="color: #EE1802; font-weight:bold;">DS</span>:<span style="color: #FFFFFF;">&#91;</span>1A58BA5F<span style="color: #FFFFFF;">&#93;</span>
  <span style="color: #EE4A02;">DEC</span> <span style="color: #EE1802; font-weight:bold;">EDI</span>
  <span style="color: #EE4A02;">SHRD</span> <span style="color: #EE1802; font-weight:bold;">EDI</span>,<span style="color: #EE1802; font-weight:bold;">ESI</span>,0F2
  <span style="color: #EE4A02;">BSR</span> <span style="color: #EE1802; font-weight:bold;">EDI</span>,<span style="color: #EE1802; font-weight:bold;">ESI</span>
  <span style="color: #EE4A02;">TEST</span> <span style="color: #EE1802; font-weight:bold;">EDI</span>,2730DC5C
  <span style="color: #EE4A02;">TEST</span> <span style="color: #EE1802; font-weight:bold;">EDI</span>,874CDC1C
  <span style="color: #EE4A02;">AND</span> <span style="color: #EE1802; font-weight:bold;">EDI</span>,9378C643
  <span style="color: #EE4A02;">JMP</span> 004012E6              <span style="color: #adadad; font-style: italic;">;True jump to EP</span>
&nbsp;</pre>
</blockquote>
<p style="text-align: justify;">The first part of this code at +0x107B writes the jump to entry point, more specifically the first instruction after a few instructions that have been stolen. Since those stolen instructions must be executed, the protector creates yet another layer which is executed just before the jump to entry point. That layer contains the stolen instructions, and a jump at the end of that code leads to the protected file code section. Stolen instructions are mixed with the junk instructions so its easiest to dump this layer to new sections and fix the jump to entry point. This was the last piece of information needed to create an unpacker for this protection, which is the topic for next week when we continue working on AlexProtector.</p>
<p>If you  only want to unpack AlexProtect protected files you can see how it is done in  our video tutorial which shows <em>ImportStudio </em>usage:</p>
<div style="text-align: center;"><a href="http://www.youtube.com/watch?v=dYyMcbqS8_g"><img src="http://blog.reversinglabs.com/wp-content/plugins/youtube-with-style/inc/img.php?v=dYyMcbqS8_g"></a></div>
<p>Writing  an unpacker for AlexProtector should be a nice exercise for any reverser. However we will do that next week, until <a href="http://blog.reversinglabs.com/2010/02/unpacking-layered-protections/">then</a>...<br />
<!-- Facebook Badge START --></p>
<table width="600" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="150" align="center" valign="middle"><a style="font-family: &amp;amp;quot; font-size: 11px; font-variant: normal; font-style: normal; font-weight: normal; color: #3b5998; text-decoration: none;" title="TitanEngine" href="http://www.facebook.com/pages/TitanEngine/136818796342291" target="_TOP">TitanEngine</a><br />
<a title="TitanEngine" href="http://www.facebook.com/pages/TitanEngine/136818796342291" target="_TOP"><img style="border: 0px;" src="http://badge.facebook.com/badge/136818796342291.1698.1945128657.png" alt="" width="120" height="144" /></a><br />
<a style="font-family: &amp;amp;quot; font-size: 11px; font-variant: normal; font-style: normal; font-weight: normal; color: #3b5998; text-decoration: none;" title="" href="http://www.reversinglabs.com" target="_TOP">ReversingLabs Corporation</a></td>
<td width="450" align="center" valign="middle">
<p><a href="http://blog.reversinglabs.com/wp-content/uploads/2010/02/alexprot.zip">Samples and Protector</a><br />
(package contains protector binary and samples used)</p>
</td>
</tr>
</table>
<p><!-- Facebook Badge END --></p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fblog.reversinglabs.com%2F2010%2F02%2Fanalyzing-layered-protections%2F&amp;title=Analyzing%20layered%20protections" id="wpa2a_2"><img src="http://blog.reversinglabs.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.reversinglabs.com/2010/02/analyzing-layered-protections/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

