<?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; Video</title>
	<atom:link href="http://blog.reversinglabs.com/tag/video/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>Everything in one go</title>
		<link>http://blog.reversinglabs.com/2010/07/everything-in-one-go/</link>
		<comments>http://blog.reversinglabs.com/2010/07/everything-in-one-go/#comments</comments>
		<pubDate>Sun, 04 Jul 2010 10:37:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Reversing]]></category>
		<category><![CDATA[TitanEngine]]></category>
		<category><![CDATA[Unpacker]]></category>
		<category><![CDATA[UPX]]></category>
		<category><![CDATA[Video]]></category>

		<guid isPermaLink="false">http://blog.reversinglabs.com/?p=710</guid>
		<description><![CDATA[When talking about new concepts, its always best to demonstrate them on something everyone is familiar with. In our case that's of-course UPX with which we are fairly familiar. It almost feels like we write one UPX unpacker each week, doesn't it? Today we are presenting an optimization concept that enables us to unpack everything [...]]]></description>
			<content:encoded><![CDATA[<div style="text-align: center;"><a href="http://www.youtube.com/watch?v=g_dQ1xp7AfE"><img src="http://blog.reversinglabs.com/wp-content/plugins/youtube-with-style/inc/img.php?v=g_dQ1xp7AfE"></a></div>
<p style="text-align: justify;">When talking about new concepts, its always best to demonstrate them on something everyone is familiar with. In our case that's of-course <a href="http://upx.sourceforge.net/" target="_blank">UPX</a> with which we are fairly familiar. It almost feels like we write one UPX unpacker each week, doesn't it?</p>
<p style="text-align: justify;">Today we are presenting an optimization concept that enables us to unpack everything in a single go. Now, when talking about file unpacking we always unpack everything in one go, but we never unpack both the main executable module and all of its packed dependencies in a single run. Normally, you wold do this by batching through individual files.  But from a speed perspective, the best optimization imaginable comes from unpacking the main module and all of its dependencies at once. Since <em>TitanEngine </em>wasn't really designed to do that out-of-the-box, it needs just a little bit of help to pull it off.</p>
<p style="text-align: justify;">The problem is the existence of multiple relocation tables, and more importantly multiple import tables. Since TitanEngine was designed to unpack files one at the time, we must do some additional coding around these boundaries to achieve our goal. Compared to a traditional TitanEngine dynamic unpacker, the only difference is the need to collect import table data for modules in one place, and use that data for any module that has reached its entry point jump. The UPX is a special case because it always imports packed file dependencies through the import table. This is, of course, a static way of importing libraries but our approach must be flexible enough to cover both dynamic and static importing.</p>
<p style="text-align: justify;">To achieve our goal we have to scan the main module and all loaded libraries and try to find  the appropriate patterns. Once the patterns are found, we set breakpoints and store info about them so we know which module triggered which callback event. Normally we have three callbacks for UPX unpackers (LoadLibrary, GetProcAddress and EP jump) but since we are doing transverse unpacking we need one more: the load library event custom handler, which determines whether the loaded dependencies are packed with UPX by trying to find the neccessary breakpoint patterns. Even though it is impossible to have more than one module loading at a time, we still need to store the import data because the import tables for the main executable and dependencies might overlap if the modules are loaded dynamically. Once stored, the import info for each module is retrieved when it hits its entry point callback. Relocations aren't really a problem since there is just one module loading at a time, so we can use our "snapshot and compare" model, provided that modules load on non-default image bases. This can be done in numerous ways - one of the easiest is to compile the sample files so that they do that by default (which is considered cheating in the unpacking game), alternatively, we can pre-allocate the memory so that the modules have no choice but to pick another base address. For the purpose of this blog we cheated, in a real world application of this approach you mustn't.</p>
<p style="text-align: justify;">In the real world you will hardly ever see this kind of case but if you do, you now know how to get everything in one go. Until next week...</p>
<p><!-- Facebook Badge START --></p>
<table border="0" cellspacing="0" cellpadding="0" width="600" align="center">
<tbody>
<tr>
<td width="150" align="center" valign="middle"><a style="font-family: &amp;amp;amp; 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;amp; font-size: 11px; font-variant: normal; font-style: normal; font-weight: normal; color: #3b5998; text-decoration: none;" href="http://www.reversinglabs.com" target="_TOP">ReversingLabs Corporation</a></td>
<td width="450" align="center" valign="middle"><a href="http://blog.reversinglabs.com/wp-content/uploads/2010/07/RL!deUPX_oneGo.rar">RL!deUPX</a><br />
(package contains the unpacker with source and the samples  used)</td>
</tr>
</tbody>
</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%2F07%2Feverything-in-one-go%2F&amp;title=Everything%20in%20one%20go" 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/07/everything-in-one-go/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>TitanEngine and LUA SDK</title>
		<link>http://blog.reversinglabs.com/2009/12/titanengine-on-lua/</link>
		<comments>http://blog.reversinglabs.com/2009/12/titanengine-on-lua/#comments</comments>
		<pubDate>Tue, 29 Dec 2009 14:57:06 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ReversingLabs]]></category>
		<category><![CDATA[LUA]]></category>
		<category><![CDATA[SDK]]></category>
		<category><![CDATA[TitanEngine]]></category>
		<category><![CDATA[Video]]></category>

		<guid isPermaLink="false">http://blog.reversinglabs.com/?p=238</guid>
		<description><![CDATA[As we said in the blog dedicated to our latest TitanEngine release we are continuously working on expanding our SDK to support as much programming languages as possible. That is why the next major version update for TitanEngine will feature a support for LUA scripting language. This is it from ReversingLabs for this year. Enjoy [...]]]></description>
			<content:encoded><![CDATA[<div style="text-align: center;"><a href="http://www.youtube.com/watch?v=_mRMf5eAqIo"><img src="http://blog.reversinglabs.com/wp-content/plugins/youtube-with-style/inc/img.php?v=_mRMf5eAqIo"></a></div>
<p style="text-align: justify;">
<p style="text-align: justify;">As we said in the blog dedicated to our latest <em><a href="http://blog.reversinglabs.com/2009/12/titanengine-202-update/" target="_blank">TitanEngine</a> </em>release we are continuously working on expanding our SDK to support as much programming languages as possible. That is why the next major version update for <em>TitanEngine </em>will feature a support for <a href="http://www.lua.org/" target="_blank">LUA</a> scripting language. This is it from ReversingLabs for this year. Enjoy the holidays!</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%2F12%2Ftitanengine-on-lua%2F&amp;title=TitanEngine%20and%20LUA%20SDK" id="wpa2a_4"><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/12/titanengine-on-lua/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>TitanEngine 2.0.2 on Ubuntu</title>
		<link>http://blog.reversinglabs.com/2009/10/titan-on-ubuntu/</link>
		<comments>http://blog.reversinglabs.com/2009/10/titan-on-ubuntu/#comments</comments>
		<pubDate>Tue, 27 Oct 2009 12:44:36 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ReversingLabs]]></category>
		<category><![CDATA[TitanEngine]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Video]]></category>

		<guid isPermaLink="false">http://blog.reversinglabs.com/?p=111</guid>
		<description><![CDATA[TitanEngine just became Linux friendly! Even though this framework was and is designed only for Microsoft Windows x86/x64 platforms it can work with no problems under Linux with the help of WINE. Small modifications were necessary in order to make this possible but from next release you will be able to execute all ReversingLabs unpackers [...]]]></description>
			<content:encoded><![CDATA[<div style="text-align: center;"><a href="http://www.youtube.com/watch?v=cBalPcqlUtw"><img src="http://blog.reversinglabs.com/wp-content/plugins/youtube-with-style/inc/img.php?v=cBalPcqlUtw"></a></div>
<p style="text-align: justify;">
<p style="text-align: justify;"><em>TitanEngine </em>just became <a href="http://www.linux.org/" target="_blank">Linux</a> friendly! Even though this framework was and is designed only for Microsoft <a href="http://www.microsoft.com/en/us/default.aspx" target="_blank">Windows</a> x86/x64 platforms it can work with no problems under Linux with the help of <a href="http://www.winehq.org/" target="_blank">WINE</a>. Small modifications were necessary in order to make this possible but from next release you will be able to execute all <em>ReversingLabs </em>unpackers under Linux distribution of your choice. We have chosen <a href="http://www.ubuntu.com/" target="_blank">Ubuntu</a>, what is your choice?</p>
<p style="text-align: justify;">This ensures maximum safe environment for live malware analysis for those reverse engineers that make Linux their platform of choice.</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%2Ftitan-on-ubuntu%2F&amp;title=TitanEngine%202.0.2%20on%20Ubuntu" id="wpa2a_6"><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/titan-on-ubuntu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Static unpackers, MEW5 story</title>
		<link>http://blog.reversinglabs.com/2009/09/static-unpackers-mew5-story/</link>
		<comments>http://blog.reversinglabs.com/2009/09/static-unpackers-mew5-story/#comments</comments>
		<pubDate>Mon, 21 Sep 2009 05:59:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Reversing]]></category>
		<category><![CDATA[TitanEngine]]></category>
		<category><![CDATA[MEW]]></category>
		<category><![CDATA[Unpacker]]></category>
		<category><![CDATA[Video]]></category>

		<guid isPermaLink="false">http://blog.reversinglabs.com/?p=54</guid>
		<description><![CDATA[This is our last blog about MEW, we promise. We intend to keep that promise since this is the last known version of MEW. Whats so special about MEW anyway? The reason we chose to do MEW (again) is that in its version 5 it is a simple crypter which can be used as a [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">This is our last blog about MEW, we promise. We intend to keep that promise since this is the last known version of MEW. Whats so special about MEW anyway?</p>
<p style="text-align: justify;">The reason we chose to do MEW (<em>again</em>) is that in its version 5 it is a simple crypter which can be used as a perfect example on how to write static unpackers for these kind of crypters. That kind would be the kind that doesn't do anything to imports but only encrypts the executable code section. Next time we revisit static unpackers we will be talking about such cases. We are going to leave that aside for now because this Monday is all about simple and fast unpacker writing. Start your timers we will do in under 10 minutes.</p>
<p style="text-align: justify;"><strong>Minute 1 - 2:</strong></p>
<p style="text-align: justify;">We load our sample into Olly and see the entire MEW5 code at the entry point.</p>
<blockquote>
<pre class="asm">  <span style="color: #EE4A02;">MOV</span> <span style="color: #EE1802; font-weight:bold;">ESI</span>,0040005B
  <span style="color: #EE4A02;">LODS</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><span style="color: #EE1802; font-weight:bold;">ESI</span><span style="color: #FFFFFF;">&#93;</span>
  <span style="color: #EE4A02;">XCHG</span> <span style="color: #EE1802; font-weight:bold;">EAX</span>,<span style="color: #EE1802; font-weight:bold;">ECX</span>
  <span style="color: #EE4A02;">LODS</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><span style="color: #EE1802; font-weight:bold;">ESI</span><span style="color: #FFFFFF;">&#93;</span>
  <span style="color: #EE4A02;">XCHG</span> <span style="color: #EE1802; font-weight:bold;">EAX</span>,<span style="color: #EE1802; font-weight:bold;">EBX</span>
  <span style="color: #EE4A02;">PUSH</span> <span style="color: #EE1802; font-weight:bold;">EBX</span>
  <span style="color: #EE4A02;">LODS</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><span style="color: #EE1802; font-weight:bold;">ESI</span><span style="color: #FFFFFF;">&#93;</span>
  <span style="color: #EE4A02;">XCHG</span> <span style="color: #EE1802; font-weight:bold;">EAX</span>,<span style="color: #EE1802; font-weight:bold;">ESI</span>
  <span style="color: #EE4A02;">PUSH</span> <span style="color: #EE1802; font-weight:bold;">ESI</span>
  <span style="color: #EE4A02;">POP</span> <span style="color: #EE1802; font-weight:bold;">EDI</span>
L010:
  <span style="color: #EE4A02;">LODS</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;">ROL</span> <span style="color: #EE1802; font-weight:bold;">AL</span>,<span style="color: #ff0000;">29</span>
  <span style="color: #EE4A02;">ADD</span> <span style="color: #EE1802; font-weight:bold;">AL</span>,BA
  <span style="color: #EE4A02;">ROR</span> <span style="color: #EE1802; font-weight:bold;">AL</span>,<span style="color: #ff0000;">50</span>
  <span style="color: #EE4A02;">STOS</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: #EE4A02;">LOOPD</span> L010
  <span style="color: #EE4A02;">RET</span></pre>
</blockquote>
<p style="text-align: justify;">Yes, that it. The whole code. So what does it do? First it loads a pointer to all internal information into ESI register. We follow ESI in the hex dump to find that there are 3 DWORDs that have the data necessary for unpacking. First DWORD is 0x3000 which is the size of the first section, second DWORD is 0x004012c0 which is the address of the original entry point and third DWORD is 0x00401000 which is the virtual address of the first section. Code following this loads 0x3000 bytes one by one and decrypts them with a custom decryption algorithm. Here instruction sequence ROL, ADD and ROR is used to decrypt data.</p>
<p style="text-align: justify;"><strong>Minute 3 - 4:</strong></p>
<p style="text-align: justify;">We make a copy of existing <em>TitanEngine </em>SDK sample for DEF and use that as a template for our unpacker. We are making a Delphi unpacker since,... well since TitanEngine is low on Delphi samples and this is a nice and quick exercise.</p>
<p style="text-align: justify;"><strong>Minute 5 - 9:</strong></p>
<p style="text-align: justify;">We code the unpacker. First we need to read the ESI pointer and read the data from the file. Once we make that we convert third DWORD to physical address inside mapped file and we also convert the original entry point address to relative one. Simple call to <em>StaticMemoryDecryptEx </em>makes sure that our <em>StaticCallBack</em> decrypts the data by executing this custom decryption algorithm. Lastly we add the code to store the new entry point to PE32 header and we're done.</p>
<p style="text-align: justify;"><strong>Minute 9:47 - 10:</strong></p>
<p>We run the compiled unpacker to test if it works... Success!<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/2009/09/RLdeMEW5.rar">Download RL!deMEW5 unpacker</a><br />
<span>(package contains unpacker binary, source and samples used)</span></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%2F09%2Fstatic-unpackers-mew5-story%2F&amp;title=Static%20unpackers%2C%20MEW5%20story" id="wpa2a_8"><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/09/static-unpackers-mew5-story/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

