<?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>Unintended Results &#187; pyew</title>
	<atom:link href="http://joxeankoret.com/blog/category/pyew/feed/" rel="self" type="application/rss+xml" />
	<link>http://joxeankoret.com/blog</link>
	<description>Or maybe not</description>
	<lastBuildDate>Sun, 04 Dec 2011 17:55:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Analyzing PDF exploits with Pyew</title>
		<link>http://joxeankoret.com/blog/2010/02/21/analyzing-pdf-exploits-with-pyew/</link>
		<comments>http://joxeankoret.com/blog/2010/02/21/analyzing-pdf-exploits-with-pyew/#comments</comments>
		<pubDate>Sun, 21 Feb 2010 14:46:23 +0000</pubDate>
		<dc:creator>joxean</dc:creator>
				<category><![CDATA[Malware]]></category>
		<category><![CDATA[pyew]]></category>
		<category><![CDATA[Research]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[obfuscated]]></category>
		<category><![CDATA[pdf]]></category>

		<guid isPermaLink="false">http://joxeankoret.com/blog/?p=95</guid>
		<description><![CDATA[Something I really hate to do when analyzing PDF malware exploits is to manually extract the streams and manually decode them to see the, typically, hidden JavaScript code, so I decided to extend the PDF plugin for Pyew to automatically see them. Now, with the new version of the plugin (download it from the Mercurial [...]]]></description>
			<content:encoded><![CDATA[<p>Something I really hate to do when analyzing PDF malware  exploits is to manually extract the streams and manually decode them to see the, typically, hidden JavaScript code, so I decided to extend the PDF plugin for <a title="Pyew" href="http://code.google.com/p/pyew" target="_blank">Pyew</a> to automatically see them. Now, with the new version of the plugin (download it from the <a href="http://code.google.com/p/pyew/source/checkout" target="_blank">Mercurial repository</a>) we can see what filters are used in the exploit and, the most important thing, we can see the decoded streams, independently of how many filters are being used.<br />
<span id="more-95"></span><br />
<strong>Example</strong></p>
<p>For example, I will take one obfuscated PDF exploit (SHA256 6a8204ee7b703f96f811f32f903ac9df4045b05910d633fc34fed89e2e0a7576). I will open it in Pyew to see what is inside so, simply, run the command "pyew pdf.file":</p>
<blockquote><p>$ pyew sample.pdf<br />
PDF File</p>
<p>PDFiD 0.0.9_PL 6a8204ee7b703f96f811f32f903ac9df4045b05910d633fc34fed89e2e0a7576<br />
PDF Header: %PDF-1.1<br />
obj                    4<br />
endobj                 4<br />
stream                 1<br />
endstream              1<br />
xref                   1<br />
trailer                1<br />
startxref              1<br />
/Page                  1<br />
/Encrypt               0<br />
/ObjStm                0<br />
/JS                    1<br />
/JavaScript            1<br />
/AA                    0<br />
/OpenAction            1<br />
/AcroForm              0<br />
/JBIG2Decode           0<br />
/RichMedia             0<br />
/Colors &gt; 2^24         0<br />
%%EOF                  1<br />
After last %%EOF       0<br />
Total entropy:           4.293999 (      5547 bytes)<br />
Entropy inside streams:  3.669587 (      4773 bytes)<br />
Entropy outside streams: 5.132696 (       774 bytes)</p>
<p>(...)</p>
<p>[0x00000000]&gt; p<br />
%PDF-1.1<br />
%&amp;#1074;&amp;#1075;&amp;#1055;&amp;#1059;<br />
1 0 obj<br />
&lt;&lt;<br />
/Type /Catalog<br />
/OpenAction &lt;&lt;<br />
/JS 4 0 R<br />
/S /JavaScript<br />
&gt;&gt;<br />
/Pages 2 0 R<br />
&gt;&gt;<br />
endobj<br />
2 0 obj<br />
&lt;&lt;<br />
/Type /Pages<br />
/Kids [ 3 0 R ]<br />
/Count 1<br />
&gt;&gt;<br />
endobj<br />
3 0 obj<br />
&lt;&lt;<br />
/Type /Page<br />
/Parent 2 0 R<br />
/Resources &lt;&lt;<br />
/Font &lt;&lt;<br />
/F1 &lt;&lt;<br />
/Type /Font<br />
/Name /F1<br />
/Subtype /Type1<br />
/BaseFont /Helvetica<br />
&gt;&gt;<br />
&gt;&gt;<br />
&gt;&gt;<br />
/MediaBox [ 0 0 795 842 ]<br />
&gt;&gt;<br />
endobj<br />
4 0 obj<br />
&lt;&lt;<br />
/Length 4769<br />
/Filter [/ASCIIHexDecode /ASCII85Decode /#4c</p></blockquote>
<p>What we see in Pyew? The output of <a href="http://blog.didierstevens.com/programs/pdf-tools/" target="_blank">PDFId</a> (a great tool by Didier Stevens) as well as the hexadecimal output of the first block (512 bytes). Taking a brief look to the 1st block of data we see one "OpenAction" to execute JavaScript. Surprise. The code "/JS 4 0 R" specifies that the JavaScript code to be executed is the object number 4. Seeking to the offset where the object #4 is and printing the buffer (in ASCII) we will find the following:</p>
<blockquote>
<pre>[0x000001b7]&gt; s 0x1b7
[0x000001b7]&gt; p
4 0 obj
&lt;&lt;
        /Length 4769
        /Filter [/ASCIIHexDecode /ASCII85Decode /#4c#5a#57De#63#6fde /R#75nLen#67t#68#44ecod#65 /FlateDecode ]
&gt;&gt;stream
4A2E3539605651222D714E634326304C5A47725A236A63494B26682C323A4E532...</pre>
</blockquote>
<p>The object is multiple times encoded and, which is more, the strings to specify what filters must be used in order to decode the stream are encoded too. It's perfectly legal according to the PDF specifications, although pretty suspicious. Pyew does a good job decoding both the encoded strings and the multiple times encoded stream. To see the streams just type "pdfvi" to see the encoded streams in the console:</p>
<blockquote>
<pre>eval(unescape("%76%61%72%20%56%68%4C%66%4E%20%3D..."))</pre>
</blockquote>
<p>Wow! it's a <em>small</em> chunk of JavaScript data <img src='http://joxeankoret.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  Pyew <em>automagically</em> applied all the filters needed (ASCIIHexDecode, ASCII85Decode, LZWDecode, RunLengthDecode and FlateDecode) and printed out the obfuscated code. We can see it, too, in a graphical user interface. Instead of typing "pdfvi" execute the command "pdfview". You will see the following screen:</p>
<div id="attachment_96" class="wp-caption aligncenter" style="width: 310px"><a href="http://joxeankoret.com/blog/wp-content/uploads/2010/02/pdf1.png"><img class="size-medium wp-image-96" title="Obfuscated Stream View" src="http://joxeankoret.com/blog/wp-content/uploads/2010/02/pdf1-300x156.png" alt="Obfuscated Stream View" width="300" height="156" /></a><p class="wp-caption-text">Obfuscated Stream View</p></div>
<p><strong>More Examples</strong></p>
<p>OK, so we can see now the encoded stream but, what if there are a lot of encoded streams and we must check them all or if we want to see just one of them? For this purpose, and also to show the Pyew's APIs, I created an example usage of the PDF API. The example reads all the streams and shows a list of all the encoded streams as you may see in the following snapshot:</p>
<div id="attachment_97" class="wp-caption aligncenter" style="width: 310px"><a href="http://joxeankoret.com/blog/wp-content/uploads/2010/02/pdf2.png"><img class="size-medium wp-image-97" title="Usage example of the PDF API" src="http://joxeankoret.com/blog/wp-content/uploads/2010/02/pdf2-300x156.png" alt="Usage example of the PDF API" width="300" height="156" /></a><p class="wp-caption-text">Usage example of the PDF API</p></div>
<p>Using this simple screen we can see all the streams or just one specific (encoded) stream. This is the code of this example usage of the Pyew's API for the PDF format:</p>
<div class="geshi no python">
<div class="head">#!/usr/bin/env python</div>
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">import</span> <span class="kw3">os</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">import</span> <span class="kw3">sys</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">from</span> pyew_core <span class="kw1">import</span> CPyew</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">from</span> easygui <span class="kw1">import</span> choicebox, fileopenbox, msgbox</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">def</span> main<span class="br0">&#40;</span>filename=<span class="kw2">None</span><span class="br0">&#41;</span>:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">if</span> filename <span class="kw1">is</span> <span class="kw2">None</span>:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; filename = fileopenbox<span class="br0">&#40;</span>msg=<span class="st0">&quot;Select PDF file&quot;</span>, default=<span class="st0">&quot;*.pdf&quot;</span>, filetypes=<span class="br0">&#91;</span><span class="st0">&quot;*.pdf&quot;</span><span class="br0">&#93;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> filename <span class="kw1">is</span> <span class="kw2">None</span>:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; pyew = CPyew<span class="br0">&#40;</span>batch=<span class="kw2">True</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; pyew.<span class="me1">loadFile</span><span class="br0">&#40;</span>filename<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; streams = pyew.<span class="me1">plugins</span><span class="br0">&#91;</span><span class="st0">&quot;pdfilter&quot;</span><span class="br0">&#93;</span><span class="br0">&#40;</span>pyew, doprint=<span class="kw2">True</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">if</span> <span class="kw2">len</span><span class="br0">&#40;</span>streams<span class="br0">&#41;</span> == <span class="nu0">0</span>:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; msgbox<span class="br0">&#40;</span>title=<span class="st0">&quot;PDF Streams&quot;</span>,msg=<span class="st0">&quot;No encoded streams found&quot;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; l = <span class="br0">&#91;</span><span class="br0">&#93;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; l.<span class="me1">append</span><span class="br0">&#40;</span><span class="st0">&quot;About PDF Streams Viewer&quot;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; l.<span class="me1">append</span><span class="br0">&#40;</span><span class="st0">&quot;See all streams (both encoded and unencoded)&quot;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">for</span> x <span class="kw1">in</span> streams:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; l.<span class="me1">append</span><span class="br0">&#40;</span><span class="st0">&quot;Stream %d encoded with %s&quot;</span> <span class="sy0">%</span> <span class="br0">&#40;</span>x, streams<span class="br0">&#91;</span>x<span class="br0">&#93;</span><span class="br0">&#41;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; l.<span class="me1">append</span><span class="br0">&#40;</span><span class="st0">&quot;Quit&quot;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">while</span> <span class="nu0">1</span>:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; c = choicebox<span class="br0">&#40;</span>msg=<span class="st0">&quot;Select one stream to view it decoded&quot;</span>, title=<span class="st0">&quot;Stream Viewer&quot;</span>, choices=l<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> c <span class="kw1">is</span> <span class="kw2">None</span>:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">break</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">elif</span> c.<span class="me1">lower</span><span class="br0">&#40;</span><span class="br0">&#41;</span> == <span class="st0">&quot;quit&quot;</span>:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">break</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">elif</span> c.<span class="me1">lower</span><span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">startswith</span><span class="br0">&#40;</span><span class="st0">&quot;about&quot;</span><span class="br0">&#41;</span>:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; msgbox<span class="br0">&#40;</span>title=<span class="st0">&quot;About PDF Streams Viewer&quot;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;msg=<span class="st0">&quot;Example usage of the Pyew APIs to see PDF streams. Written by Joxean Koret&quot;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">elif</span> c.<span class="me1">lower</span><span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">startswith</span><span class="br0">&#40;</span><span class="st0">&quot;see all&quot;</span><span class="br0">&#41;</span>:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pyew.<span class="me1">plugins</span><span class="br0">&#91;</span><span class="st0">&quot;pdfview&quot;</span><span class="br0">&#93;</span><span class="br0">&#40;</span>pyew, doprint=<span class="kw2">False</span>, stream_id=<span class="nu0">-1</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">else</span>:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; stream_id = <span class="kw2">int</span><span class="br0">&#40;</span>c.<span class="me1">split</span><span class="br0">&#40;</span><span class="st0">&quot; &quot;</span><span class="br0">&#41;</span><span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pyew.<span class="me1">plugins</span><span class="br0">&#91;</span><span class="st0">&quot;pdfview&quot;</span><span class="br0">&#93;</span><span class="br0">&#40;</span>pyew, stream_id=stream_id<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">if</span> __name__ == <span class="st0">&quot;__main__&quot;</span>:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">if</span> <span class="kw2">len</span><span class="br0">&#40;</span><span class="kw3">sys</span>.<span class="me1">argv</span><span class="br0">&#41;</span> == <span class="nu0">1</span>:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; main<span class="br0">&#40;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">else</span>:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; main<span class="br0">&#40;</span><span class="kw3">sys</span>.<span class="me1">argv</span><span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span><span class="br0">&#41;</span></div>
</li>
</ol>
</div>
<p>And, that's all for the moment. I hope you like the new Pyew's features <img src='http://joxeankoret.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://joxeankoret.com/blog/2010/02/21/analyzing-pdf-exploits-with-pyew/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Malware Tricks I</title>
		<link>http://joxeankoret.com/blog/2009/12/02/malware-tricks-i/</link>
		<comments>http://joxeankoret.com/blog/2009/12/02/malware-tricks-i/#comments</comments>
		<pubDate>Wed, 02 Dec 2009 21:57:42 +0000</pubDate>
		<dc:creator>joxean</dc:creator>
				<category><![CDATA[Malware]]></category>
		<category><![CDATA[pyew]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://joxeankoret.com/blog/?p=76</guid>
		<description><![CDATA[Today, while analyzing a family of malwares (the familiy called by some vendors as "Krap") I noticed a good and new, at least for me, antiemulation technique. What do you think this sample code does? some_func: &#160; ; Do stuff... &#160; start: &#160; &#160;push offset some_func &#160; &#160;jmp edx What is this? We're pushing the [...]]]></description>
			<content:encoded><![CDATA[<p>Today, while analyzing a family of malwares (the familiy called by some vendors as "Krap") I noticed a good and new, at least for me, antiemulation technique. What do you think this sample code does?</p>
<div class="geshi no asm">
<div class="head">some_func:</div>
<ol>
<li class="li1">
<div class="de1">&nbsp; <span class="co1">; Do stuff...</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">start:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;<span class="kw1">push</span> <span class="kw4">offset</span> some_func</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;<span class="kw1">jmp</span> <span class="kw3">edx</span></div>
</li>
</ol>
</div>
<p><span id="more-76"></span><br />
What is this? We're pushing the address of the function some_func in the stack and, after this, jumping unconditionally to the address contained at EDX. The question here is: What value has the EDX register before executing your first line of assembly code? You have the address of ntdll!KiFastSystemCallRet:</p>
<p style="text-align: center;">
<a href="http://joxeankoret.com/blog/wp-content/uploads/2009/12/anal_edx.png"><img class="size-medium wp-image-77 aligncenter" title="Value of EDX at the very first program\'s instruction" src="http://joxeankoret.com/blog/wp-content/uploads/2009/12/anal_edx-300x178.png" alt="" width="300" height="178" /></a></p>
<p>So, basically, we're jumping to a return only function (see a detailed description of <a href="http://www.dumpanalysis.org/blog/index.php/2008/01/10/what-is-kifastsystemcallret/">KiFastSystemCallRet</a>) efectively returning into the "some_func" function. The emulators I tested, as in example, the Bochs Debugger module that comes with IDA Pro, initialize all the registers to 0: a cool trick! And the first time I see this.</p>
<p>The tricks I typically find in malware are undocumented (or non typical) API calls mixed with junk code, as the following example extracted from a Mebroot downloader:</p>
<div class="geshi no asm">
<ol>
<li class="li1">
<div class="de1">000013a7 <span class="kw1">PUSH</span> 0x74327ebc</div>
</li>
<li class="li1">
<div class="de1">000013ac <span class="kw1">CALL</span> KERNEL32.dll!WriteFile</div>
</li>
<li class="li1">
<div class="de1">000013b2 <span class="kw1">TEST</span> <span class="kw3">EAX</span>, <span class="kw3">EAX</span></div>
</li>
<li class="li1">
<div class="de1">000013b4 <span class="kw1">JZ</span> 0x000013bb &nbsp; &nbsp; &nbsp;<span class="co1">; 1</span></div>
</li>
<li class="li1">
<div class="de1">000013b6 <span class="kw1">JMP</span> 0x0000108e &nbsp; &nbsp; <span class="co1">; 2</span></div>
</li>
<li class="li1">
<div class="de1">000013bb <span class="kw1">PUSH</span> 0x0</div>
</li>
<li class="li1">
<div class="de1">000013bd <span class="kw1">CALL</span> KERNEL32.dll!DisconnectNamedPipe</div>
</li>
</ol>
</div>
<p>Junk code using APIs relatively commons:</p>
<div class="geshi no asm">
<ol>
<li class="li1">
<div class="de1">00001c1f <span class="kw1">PUSH</span> 0x0</div>
</li>
<li class="li1">
<div class="de1">00001c21 <span class="kw1">PUSH</span> 0x0</div>
</li>
<li class="li1">
<div class="de1">00001c23 <span class="kw1">CALL</span> SHLWAPI.dll!SHDeleteKeyA</div>
</li>
<li class="li1">
<div class="de1">00001c29 <span class="kw1">PUSH</span> 0x100</div>
</li>
<li class="li1">
<div class="de1">00001c2e <span class="kw1">CALL</span> msvcrt.dll!malloc</div>
</li>
<li class="li1">
<div class="de1">00001c34 <span class="kw1">ADD</span> <span class="kw3">ESP</span>, 0x4</div>
</li>
<li class="li1">
<div class="de1">00001c37 <span class="kw1">PUSH</span> <span class="kw3">EAX</span></div>
</li>
<li class="li1">
<div class="de1">00001c38 <span class="kw1">CALL</span> msvcrt.dll!free</div>
</li>
<li class="li1">
<div class="de1">00001c3e <span class="kw1">ADD</span> <span class="kw3">ESP</span>, 0x4</div>
</li>
<li class="li1">
<div class="de1">00001c41 <span class="kw1">PUSH</span> 0x0</div>
</li>
<li class="li1">
<div class="de1">00001c43 <span class="kw1">CALL</span> WINMM.dll!timeKillEvent</div>
</li>
<li class="li1">
<div class="de1">00001c49 <span class="kw1">PUSH</span> 0x10005129</div>
</li>
<li class="li1">
<div class="de1">00001c4e <span class="kw1">LEA</span> <span class="kw3">EAX</span>, <span class="br0">&#91;</span>EBP-0x20<span class="br0">&#93;</span></div>
</li>
<li class="li1">
<div class="de1">00001c51 <span class="kw1">PUSH</span> <span class="kw3">EAX</span></div>
</li>
<li class="li1">
<div class="de1">00001c52 <span class="kw1">CALL</span> USER32.dll!wsprintfA</div>
</li>
<li class="li1">
<div class="de1">00001c58 <span class="kw1">ADD</span> <span class="kw3">ESP</span>, 0x8</div>
</li>
<li class="li1">
<div class="de1">00001c5b <span class="kw1">PUSH</span> 0x0</div>
</li>
<li class="li1">
<div class="de1">00001c5d <span class="kw1">CALL</span> ADVAPI32.dll!RegCloseKey</div>
</li>
<li class="li1">
<div class="de1">00001c63 <span class="kw1">CALL</span> ole32.dll!OleUninitialize</div>
</li>
</ol>
</div>
<p>Very simple API calls not commonly emulated (extracted from the dropper of the rootkit TDSS):</p>
<div class="geshi no asm">
<ol>
<li class="li1">
<div class="de1"><span class="nu0">00000813</span> <span class="kw1">XOR</span> <span class="kw3">ESI</span>, <span class="kw3">ESI</span></div>
</li>
<li class="li1">
<div class="de1"><span class="nu0">00000815</span> <span class="kw1">PUSH</span> <span class="kw3">ESI</span></div>
</li>
<li class="li1">
<div class="de1"><span class="nu0">00000816</span> <span class="kw1">MOV</span> <span class="kw3">EAX</span>, <span class="br0">&#91;</span>0x40600c<span class="br0">&#93;</span> &nbsp; &nbsp; &nbsp; &nbsp;<span class="co1">; kernel32.dll!GetModuleHandleA</span></div>
</li>
<li class="li1">
<div class="de1">0000081d <span class="kw1">CALL</span> <span class="kw3">EAX</span></div>
</li>
<li class="li1">
<div class="de1">0000081f <span class="br0">&#40;</span><span class="kw1">PUSH</span> 0x74</div>
</li>
<li class="li1">
<div class="de1"><span class="nu0">00000821</span> <span class="kw1">MOV</span> <span class="kw3">EAX</span>, <span class="br0">&#91;</span>0x406080<span class="br0">&#93;</span> &nbsp; &nbsp; &nbsp; &nbsp;<span class="co1">; msvcrt.dll!iscntrl</span></div>
</li>
<li class="li1">
<div class="de1"><span class="nu0">00000827</span> <span class="kw1">CALL</span> <span class="kw3">EAX</span></div>
</li>
<li class="li1">
<div class="de1"><span class="nu0">00000829</span> <span class="kw1">POP</span> <span class="kw3">ECX</span></div>
</li>
<li class="li1">
<div class="de1">0000082a <span class="kw1">TEST</span> <span class="kw3">EAX</span>, <span class="kw3">EAX</span></div>
</li>
<li class="li1">
<div class="de1">0000082c <span class="kw1">JNZ</span> 0x000008ad &nbsp; &nbsp; <span class="co1">; 1</span></div>
</li>
<li class="li1">
<div class="de1"><span class="nu0">00000832</span> <span class="kw1">PUSH</span> 0x6d</div>
</li>
<li class="li1">
<div class="de1"><span class="nu0">00000834</span> <span class="kw1">PUSH</span> 0x68</div>
</li>
<li class="li1">
<div class="de1"><span class="nu0">00000836</span> <span class="kw1">MOV</span> <span class="kw3">EAX</span>, <span class="br0">&#91;</span>0x40607c<span class="br0">&#93;</span> &nbsp; &nbsp; &nbsp; &nbsp;<span class="co1">; msvcrt.dll!is_wctype</span></div>
</li>
<li class="li1">
<div class="de1">0000083d <span class="kw1">CALL</span> <span class="kw3">EAX</span></div>
</li>
</ol>
</div>
<p>Or strange x86 assembly instructions like multibyte NOPs with redundant prefixes and so on (found in some variants of Sality): </p>
<div class="geshi no asm">
<ol>
<li class="li1">
<div class="de1">f30f1f90909090. <span class="kw1">rep</span> <span class="kw1">nop</span> <span class="br0">&#91;</span><span class="kw3">eax</span>+0x66909090<span class="br0">&#93;</span></div>
</li>
</ol>
</div>
<p>I know it's just one antiemulation trick and there are thousands of them but this trick is new (at least for me), special and cool!</p>
]]></content:encoded>
			<wfw:commentRss>http://joxeankoret.com/blog/2009/12/02/malware-tricks-i/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

