<?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; Crypter</title>
	<atom:link href="http://blog.reversinglabs.com/tag/crypter/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>Halloween reversing</title>
		<link>http://blog.reversinglabs.com/2009/10/halloween-reversing/</link>
		<comments>http://blog.reversinglabs.com/2009/10/halloween-reversing/#comments</comments>
		<pubDate>Sat, 31 Oct 2009 11:57:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Reversing]]></category>
		<category><![CDATA[TitanEngine]]></category>
		<category><![CDATA[Crypter]]></category>
		<category><![CDATA[LameCrypt]]></category>
		<category><![CDATA[Research]]></category>

		<guid isPermaLink="false">http://blog.reversinglabs.com/?p=118</guid>
		<description><![CDATA[Halloween is a special time of year and it deserves a special blog we might call "writing unpackers in reverse". But wait, writing unpackers in reverse... isn't that packer writing? We are going to do some TitanEngine coding in order to make it do a complete opposite of what it is meant for. We are [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Halloween is a special time of year and it deserves a special blog we might call "<em>writing unpackers in reverse</em>". But wait, writing unpackers in reverse... isn't that packer writing?</p>
<p style="text-align: justify;">We are going to do some <em>TitanEngine </em>coding in order to make it do a complete opposite of what it is meant for. We are going to force our good friend <em>Titan </em>to recreate a crypter we already made an unpacker for. Crypter we are recreating is called LameCrypt. So, what does LameCrypt do?</p>
<p style="text-align: justify;">Its a very very simple crypter designed only to crypt the first executable section by XORing with 0x90. Extremely simple protection mechanism which looks just like this:</p>
<blockquote>
<pre class="asm">  <span style="color: #EE4A02;">PUSHAD</span>
  PUSHFW
  <span style="color: #EE4A02;">MOV</span> <span style="color: #EE1802; font-weight:bold;">EBX</span>,4C000
L003:
  <span style="color: #EE4A02;">XOR</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>EBX<span style="color: #ff0000;">+401000</span><span style="color: #FFFFFF;">&#93;</span>,<span style="color: #ff0000;">90</span>
  <span style="color: #EE4A02;">DEC</span> <span style="color: #EE1802; font-weight:bold;">EBX</span>
  <span style="color: #EE4A02;">CMP</span> <span style="color: #EE1802; font-weight:bold;">EBX</span>,<span style="color: #ff0000;">-1</span>
  <span style="color: #EE4A02;">JNZ</span> L003
  POPFW
  <span style="color: #EE4A02;">POPAD</span>
  <span style="color: #EE4A02;">MOV</span> <span style="color: #EE1802; font-weight:bold;">EAX</span>,0044CF38
  <span style="color: #EE4A02;">JMP</span> <span style="color: #DEE002;">NEAR</span> <span style="color: #EE1802; font-weight:bold;">EAX</span></pre>
</blockquote>
<p style="text-align: justify;">That is the entire crypter code. To recreate it we will copy the binary for the code above and leave the constants blank. After processing that binary data looks like this:</p>
<blockquote>
<pre class="asm"><span style="color: #ff0000;">60</span> <span style="color: #ff0000;">66</span> 9C BB <span style="color: #ff0000;">00</span> <span style="color: #ff0000;">00</span> <span style="color: #ff0000;">00</span> <span style="color: #ff0000;">00</span> <span style="color: #ff0000;">80</span> B3 <span style="color: #ff0000;">00</span> <span style="color: #ff0000;">00</span> <span style="color: #ff0000;">00</span> <span style="color: #ff0000;">00</span> <span style="color: #ff0000;">90</span> 4B
<span style="color: #ff0000;">83</span> FB FF <span style="color: #ff0000;">75</span> F3 <span style="color: #ff0000;">66</span> 9D <span style="color: #ff0000;">61</span> B8 <span style="color: #ff0000;">00</span> <span style="color: #ff0000;">00</span> <span style="color: #ff0000;">00</span> <span style="color: #ff0000;">00</span> FF E0</pre>
</blockquote>
<p style="text-align: justify;">All the zeroes above will be filled with the following data: virtual size of the first section, virtual offset of the first section and the address of the original entry point. This data, once filled to code above, will be written to the new section. List of actions to perform for this would be:</p>
<blockquote>
<ul>
<li>Read necessary PE32 data</li>
<li>Fill the  binary data from above</li>
<li>Add new section to PE32 file</li>
<li>Fill written data to it</li>
<li>Encrypt the first section by XORing it with 0x90</li>
<li>Update PE header data</li>
</ul>
</blockquote>
<p style="text-align: justify;">Since this is a very simple crypter its code is very short. What makes this a Halloween post is the spooky fact that TE can be forced to create his own worst enemies, crypters! Until next time...</p>
<p><!-- 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/2009/10/LameCrypter.zip">LameCrypter</a><br />
(Package contains binary and source files)</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%2F2009%2F10%2Fhalloween-reversing%2F&amp;title=Halloween%20reversing" 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/2009/10/halloween-reversing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

