<?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>Checkmate</title>
	<atom:link href="http://niiconsulting.com/checkmate/feed/" rel="self" type="application/rss+xml" />
	<link>http://niiconsulting.com/checkmate</link>
	<description>An Information Security Blog by NII Consulting</description>
	<lastBuildDate>Fri, 02 Dec 2011 08:26:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Risk Analysis of Android Based Appliance</title>
		<link>http://niiconsulting.com/checkmate/2011/11/24/risk-analysis-of-android-based-appliance/</link>
		<comments>http://niiconsulting.com/checkmate/2011/11/24/risk-analysis-of-android-based-appliance/#comments</comments>
		<pubDate>Thu, 24 Nov 2011 10:40:16 +0000</pubDate>
		<dc:creator>Pralhad Chaskar</dc:creator>
				<category><![CDATA[Case Studies]]></category>
		<category><![CDATA[Forensics]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Secure Coding]]></category>
		<category><![CDATA[Adb]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[Android Debug Bridge (ADB)]]></category>
		<category><![CDATA[Android Reversing Toolkit]]></category>
		<category><![CDATA[ART]]></category>
		<category><![CDATA[Best Coding Practices Android]]></category>
		<category><![CDATA[jd-gui]]></category>
		<category><![CDATA[logcat]]></category>
		<category><![CDATA[Manitree]]></category>
		<category><![CDATA[non-rooted]]></category>
		<category><![CDATA[packages.xml]]></category>
		<category><![CDATA[ProGuard]]></category>
		<category><![CDATA[rooted]]></category>
		<category><![CDATA[USB Debugging]]></category>
		<category><![CDATA[z4root]]></category>

		<guid isPermaLink="false">http://niiconsulting.com/checkmate/?p=336</guid>
		<description><![CDATA[Overview I had to do the risk analysis of the Android 2.2 – Froyo based appliance and check for any security flaws exist in it before the XYZ Ltd. (just the example) company could launch that product in the market. Background How I get connected to appliance At start of my task I first assign [...]]]></description>
			<content:encoded><![CDATA[<h2><strong>Overview</strong></h2>
<p>I had to do the risk analysis of the Android 2.2 – Froyo based appliance and check for any security flaws exist in it before the XYZ Ltd. (just the example) company could launch that product in the market.</p>
<h2><strong>Background</strong></h2>
<p><strong>How I get connected to appliance</strong><br />
At start of my task I first assign an IP address (here 192.168.1.88) to the appliance, and ensure I have necessary connectivity to the appliance. The next obvious task is to run a port scan. I use NMAP and to my dismay I find no open ports. I now enabled USB debugging in android appliance by browsing this path of appliance.</p>
<p><strong>Settings &gt; Applications &gt; Development &gt; USB Debugging </strong></p>
<p>Again port scanning the device I found Port No. 5555 Open.</p>
<p><img class="alignnone" src="http://niiconsulting.com/checkmate/wp-content/uploads/2011/11/p3.jpg" alt="" width="263" height="40" /></p>
<p>Then I figured out that by Enabling USB debugging opens Port no. 5555 by default. Odd-numbered range of ports from 5555 to 5585 are usually used by emulators/devices (let Nmap to find&#8217;s it out for you).</p>
<h4>Intermediate between my machine and appliance: ADB</h4>
<p>My next step was to place the bridge between my machine and appliance. Here Google helped me by providing us the <a title="ADB" href="http://developer.android.com/guide/developing/tools/adb.html#logcat" target="_blank">Android Debug Bridge</a> (ADB) which is freely available <img src='http://niiconsulting.com/checkmate/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> .</p>
<p><strong>Android Debug Bridge</strong> (adb) is a versatile command line tool that lets you communicate with an emulator instance or connected Android-powered device. It is a client-server program that includes three components:<br />
1] A client, which runs on your development machine. You can invoke a client from a shell by issuing an adb command.<br />
2] A server, which runs as a background process on your development machine. The server manages communication between the client and the adb daemon running on an emulator or device.<br />
3] A daemon, which runs as a background process on each emulator or device instance.</p>
<p>Following is the snippet of ADB.</p>
<p><img class="alignnone" src="http://niiconsulting.com/checkmate/wp-content/uploads/2011/11/21.jpg" alt="" width="547" height="469" /></p>
<p>Commands of my interest were as follows:-<br />
1] adb connect device_ip:port_no – connects to attached device<br />
2] adb devices &#8211; List all connected devices/emulator<br />
3] adb push &lt;local_path&gt; &lt;remote_path&gt; &#8211; Copy file/dir to device/emulator<br />
4] adb pull &lt;remote_path&gt; [&lt;local_path&gt;] &#8211; Copy file/dir from device/emulator<br />
5] adb shell &#8211; Run remote shell interactively<br />
6] adb logcat &#8211; View device log<br />
7] adb install [-l] [-r] [-s] &lt;file&gt; &#8211; push this package file to the device<br />
8] adb uninstall [-k] &lt;package&gt; &#8211; remove this app package from the device<br />
9] adb help &#8211; Always helps to view all switches available <img src='http://niiconsulting.com/checkmate/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p><strong>What do you mean rooting the android appliance?</strong><br />
Android is basically a reworked Linux. Rooting means getting super user privilege to android device. Rooting thus provide you with access to system files and the ability to change things that normally are marked read only. This allows you to change all kinds of things that normally you wouldn&#8217;t be able to, along with install custom versions of Android.</p>
<p>There are multiple applications available for rooting the android eg: z4root, EasyRoot, SuperOneClick and many more.</p>
<p><img class="alignnone" src="http://niiconsulting.com/checkmate/wp-content/uploads/2011/11/p2.jpg" alt="" width="219" height="328" /></p>
<p>In my case <a href="http://forum.xda-developers.com/showthread.php?t=833953">z4root</a> helped me to become root user, it allows for temporary / permanent root using <a href="http://www.c-skills.blogspot.com/">Sebastian Krahmer&#8217;s RageAgainstTheCage</a> method.</p>
<p><strong>Tools help</strong><br />
<strong>Android Reversing Toolkit</strong> (ART) by Deurus which used to Compile, De-Compile, Re-compile the applications.</p>
<p><img class="alignnone" src="http://niiconsulting.com/checkmate/wp-content/uploads/2011/11/p9.jpg" alt="" width="440" height="329" /></p>
<p><a href="http://intrepidusgroup.com/insight/2011/11/manitree-androidmanifest-xml-auditor/">Manitree</a> (by IntrepidusGroup) is a tool that will review an AndroidManifest.xml file, APK package, or an entire device (or devices) for insecure values in the AndroidManifest.xml file. This is not the exact way to analyze the APK’s but this tool will help you want to analyze 100′s of APK’s in short span of time and pluck out low hanging fruits.</p>
<p><strong>dex2jar</strong> is a tool for converting Android&#8217;s .dex format to Java&#8217;s .class format which is readable by using Java Decompiler GUI utility.</p>
<p><strong>Let’s Get Started</strong><br />
Here our appliance [Target] IP address was 192.168.1.88. Then I connected to the appliance using ADB.</p>
<p><img class="alignnone" src="http://niiconsulting.com/checkmate/wp-content/uploads/2011/11/p4.jpg" alt="" width="400" height="53" /></p>
<p>Are we connected? Let’s verified the same</p>
<p><img class="alignnone" src="http://niiconsulting.com/checkmate/wp-content/uploads/2011/11/p5.jpg" alt="" width="272" height="39" /></p>
<p>Uhhh….Finally our appliance is talking to us <img src='http://niiconsulting.com/checkmate/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  and we are also able to talk. By using the ADB we get the shell access of the appliance by using the command as follows.</p>
<p><img class="alignnone" src="http://niiconsulting.com/checkmate/wp-content/uploads/2011/11/p6.jpg" alt="" width="154" height="235" /></p>
<p>Firstly I got the non-rooted (not able to browse all directories and files) appliance and want to pull out all the application (apk). Hence in order to get the path of each application’s installed, I need the packages.xml file. This file helped me to figure the exact path (codePath) of each apk located under /data/app directory (not available usually for non-rooted) of android. Following is the command for the same.</p>
<p><strong>adb pull /data/system/packages.xml</strong></p>
<p><img class="alignnone" src="http://niiconsulting.com/checkmate/wp-content/uploads/2011/11/p1.jpg" alt="" width="539" height="91" /></p>
<p>In my case the desired application was in /data/app directory, so i was able to pull APK file from the appliance even if my appliance was non-rooted. But suppose your desired application is located in /data/app-private directory, and then you cannot pull out applications (apk) from non-rooted appliance.</p>
<p>Then i thought of rooting the appliance using the z4Root to get deeper insight of appliance and underlying OS.</p>
<p>And following are the directories and files we could find under root directory. Here our ADB daemon is only running with privilege of root by default.</p>
<p>Under the <strong>/system/app</strong> we could find all the applications installed in the appliance.</p>
<p><img class="alignnone" src="http://niiconsulting.com/checkmate/wp-content/uploads/2011/11/p7.jpg" alt="" width="241" height="260" /></p>
<p>Then we can pull the respective *.apk file via ADB.</p>
<p><img class="alignnone" src="http://niiconsulting.com/checkmate/wp-content/uploads/2011/11/p8.jpg" alt="" width="490" height="26" /></p>
<p>An .apk file extension denotes an Android Package (APK) file. This file format, a variant of the JAR format, is used for distributing and installing bundled components onto the Android operating system.</p>
<p>After pulling the desired apk, I used ART (one method to look into apk) to decompile the apk can be used to Compile, De-Compile &amp; Re-Compile the applications. The steps involved in De-compilation are as follows:-</p>
<p><img class="alignnone" src="http://niiconsulting.com/checkmate/wp-content/uploads/2011/11/p10.jpg" alt="" width="600" height="109" /></p>
<p>Now my concern was to dig in this APK file. So just rename the *.apk to *.zip (it is another way to look into apk). Unzip the respective file. Following are the contents of the same.</p>
<p><img class="alignnone" src="http://niiconsulting.com/checkmate/wp-content/uploads/2011/11/p11.jpg" alt="" width="477" height="109" /></p>
<p><strong>AndroidManifest.xml</strong> is a required file for any application. It describes the name, version, access rights, referenced library files, and other information of the application. The AndroidManifest.xml contained in the .apk file has been compressed.<br />
<strong>META-INF</strong> Directory, where signature data is stored, is used to ensure the integrality of the .apk package and system security.<br />
<strong>Classes.dex</strong> is a java byte code file generated after the compilation using java source codes.<br />
<strong>Res</strong> directory is used to store resource files.<br />
<strong>resources.arsc</strong> is a binary resource file after compilation.</p>
<p>By just supplying the AndroidManifest.xml file to Manitree, it will generate the report mentioning the improper permissions granted to application with severity. Following is the usage for the same.</p>
<p><img class="alignnone" src="http://niiconsulting.com/checkmate/wp-content/uploads/2011/11/p12.jpg" alt="" width="623" height="114" /></p>
<p>So let’s check in the code of AndroidManifest.xml which is pointed out by the Manitree.</p>
<p><img class="alignnone" src="http://niiconsulting.com/checkmate/wp-content/uploads/2011/11/p13.jpg" alt="" width="795" height="155" /></p>
<p>In above image <strong>&lt;grant-uri-permission android:pathPrefix=”/” /&gt;</strong> means that anything that is located in a path that starts with “/” is able to access the content-provider of any other application. For better understanding ContentProvider are used to provide data from an application to another (eg: &#8211; Social networking app which could access the photos from Gallery, so here Social Networking app &amp; Gallery are sharing the common resource). ContentProvider do not store the data but provide the interface for other applications to access the data. Hence in our case instead of &lt;grant-uri-permission android:pathPrefix=”/” /&gt; it should be <strong>&lt;grant-uri-permission android:pathPrefix=”/&lt;specific_application_directory&gt;” /&gt;</strong></p>
<p>Now let’s concentrate on Classes.dex file. This file can be decompressed using the tool <strong>dex2jar</strong>.</p>
<p><img class="alignnone" src="http://niiconsulting.com/checkmate/wp-content/uploads/2011/11/p14.jpg" alt="" width="619" height="50" /></p>
<p>Now open generated classes.dex.dex2jar.jar file using Java Decompiler GUI [jd-gui].</p>
<p><img class="alignnone" src="http://niiconsulting.com/checkmate/wp-content/uploads/2011/11/p15.jpg" alt="" width="217" height="155" /></p>
<p>Expanding each tab we could actually read the code.</p>
<p><img class="alignnone" src="http://niiconsulting.com/checkmate/wp-content/uploads/2011/12/p16.jpg" alt="" width="624" height="372" /></p>
<p>Going through the non-obfuscated code we can understand the flow of code and working of Application. In order to prevent this we can use “<strong>ProGuard</strong>” tool which shrinks, optimizes and obfuscates your code and renaming classes, fields, and methods with semantically obscure names. The result is a smaller sized .apk file that is more difficult to reverse engineer. After usage of Proguard code looks as follows.</p>
<p><img class="alignnone" src="http://niiconsulting.com/checkmate/wp-content/uploads/2011/11/p17.jpg" alt="" width="624" height="264" /></p>
<p>Next step was is there any database in backend for application to store the data. This I could figure out in <strong>/data/data/&lt;package_name&gt;/databases/ folder</strong>. Then by using the ADB we can pull the desired database file on our machine.</p>
<p>Android as whole uses SQLite database to store the data for each application. We can view the contents of extracted database file of desired “package_name” using the addon in Mozilla Firefox named SQLite Manager 0.7.4 or tool named SQLite Maestro.</p>
<p><img class="alignnone" src="http://niiconsulting.com/checkmate/wp-content/uploads/2011/11/p18.jpg" alt="" width="442" height="240" /></p>
<p>Now I can read the un-encrypted database entries and also execute the SQL queries to refine your result.</p>
<p><img class="alignnone" src="http://niiconsulting.com/checkmate/wp-content/uploads/2011/11/p19.jpg" alt="" width="344" height="289" /></p>
<p>While this entire activity is running always keep “<strong>logcat</strong>” open in one of the terminal/command-prompt. Logcat has mechanism for collecting and viewing system debug output. Logs from various applications and portions of the system are collected in a series of circular buffers, which then can be viewed and filtered by the logcat command. Following is the command for the same.</p>
<p><strong> adb logcat [&lt;option&gt;] … [&lt;filter-spec&gt;] …</strong></p>
<p><img class="alignnone" src="http://niiconsulting.com/checkmate/wp-content/uploads/2011/11/p20.jpg" alt="" width="766" height="209" /></p>
<p><strong>Exercise ended with following Risks</strong><br />
1] Root-level Access to system<br />
2] Installation of 3rd-Party APKs<br />
3] No authentication to access to system<br />
4] Remote Connection/Management of Device<br />
5] Vulnerability in the underlying OS<br />
6] Insecure Coding Practices<br />
7] Unrestricted Browsing permissions<br />
8] Manual Vendor Updates<br />
9] Loss of the Device<br />
10] Database entries are not encrypted</p>
<p><strong>Best Coding Practices for building secure Android application</strong>  (Source: Google)<br />
1] Maintain a privacy policy<br />
2] Minimize permissions<br />
3] Give your users a choice regarding data collection<br />
4] Don’t collect unnecessary information<br />
5] Don’t send data off the device<br />
6] Use encryption and data minimization<br />
7] Don’t use code you don’t understand<br />
8] Don’t log device or user specific information<br />
9] Use Proguard- Code obfuscation mechanism<br />
10] Performing Input Validation</p>
]]></content:encoded>
			<wfw:commentRss>http://niiconsulting.com/checkmate/2011/11/24/risk-analysis-of-android-based-appliance/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Dump password of application pool user from IIS &gt;= 6.0</title>
		<link>http://niiconsulting.com/checkmate/2010/11/19/dump-password-of-application-pool-user-from-iis-6-0/</link>
		<comments>http://niiconsulting.com/checkmate/2010/11/19/dump-password-of-application-pool-user-from-iis-6-0/#comments</comments>
		<pubDate>Fri, 19 Nov 2010 13:07:15 +0000</pubDate>
		<dc:creator>Dhiraj Ranka</dc:creator>
				<category><![CDATA[Disk Forensics]]></category>
		<category><![CDATA[application pool]]></category>
		<category><![CDATA[dump password]]></category>
		<category><![CDATA[least privilege]]></category>
		<category><![CDATA[sharepoint]]></category>

		<guid isPermaLink="false">http://niiconsulting.com/checkmate/?p=292</guid>
		<description><![CDATA[IIS Application pools are used to separate sets of IIS worker processes that share the same configuration and application boundaries. Application pools used to isolate our web application for better security, reliability, and availability and performance and keep running with out impacting each other . The worker process serves as the process boundary that separates [...]]]></description>
			<content:encoded><![CDATA[<p>IIS Application pools are used to separate sets of IIS worker processes  that share the same configuration and application boundaries.  Application pools used to <strong>isolate </strong> our web application for better  security, reliability, and availability and performance and keep  running with out impacting each other . The worker process serves as the  process boundary that separates each application pool so that when one  worker process or application is having an issue or recycles, other  applications or worker processes are not affected.<br />
One Application Pool can have multiple worker process. (Ref:<a href="http://technet.microsoft.com/en-us/library/cc735247%28WS.10%29.aspx">http://technet.microsoft.com/en-us/library/cc735247%28WS.10%29.aspx</a>)</p>
<p><strong>Main Point to Remember: </strong><br />
1.  Isolation of Different Web Application<br />
2.  Individual worker process for different web application<br />
3. More reliably web application<br />
4. Better Performance</p>
<p>It may happen that while managing or testing multiple web applications we create many application pool(s) in the IIS. Thus, there is always the possibility that we may forget the password of an account that we have used for the some application pool. In order to retrieve the credentials we can use the utility called <strong>APPCMD</strong>.</p>
<p><span id="more-292"></span></p>
<p><span style="color: #a6a6a6; font-size: 18pt;">Let&#8217;s Start</span><strong><br />
</strong><br />
<strong> 1. </strong>Let us assume that we have forgotten the password of the account that is used by a &#8220;<strong>Demo User</strong>&#8221; application pool.</p>
<div id="attachment_299" class="wp-caption alignnone" style="width: 310px"><a href="http://niiconsulting.com/checkmate/wp-content/uploads/2010/11/AppPool.jpg"><img class="size-medium wp-image-299" src="http://niiconsulting.com/checkmate/wp-content/uploads/2010/11/AppPool-300x227.jpg" alt="" width="300" height="227" /></a><p class="wp-caption-text">Application Pool</p></div>
<p><strong>2.</strong> Open the command prompt by browsing Start menu -&gt; Accessories -&gt; Command Prompt. Right click on Command prompt and select &#8220;<strong>Run as Administrator</strong>&#8221; option from the context menu.</p>
<p><em>Tip: You can also select CMD and press <strong>CTRL + Shift + Enter </strong>to Start Command Prompt as Administrator or with Machine Administrator rights </em><strong> </strong></p>
<p><strong>3.</strong> Browse the following path on command prompt &#8220;<strong>%systemroot%\system32\inetsrv</strong>&#8221; and run <strong>APPCMD list apppool &#8220;Demo User&#8221; /text:*</strong></p>
<p>(The directory will most likely be<strong> C:\Windows\System32\inetsrv</strong>)</p>
<p><strong> </strong></p>
<p>Replace <strong>&#8220;Demo User&#8221; </strong>with the App Pool name of which you want to retrieve the password.</p>
<div id="attachment_300" class="wp-caption alignnone" style="width: 310px"><a href="http://niiconsulting.com/checkmate/wp-content/uploads/2010/11/Command.jpg"><img class="size-medium wp-image-300" src="http://niiconsulting.com/checkmate/wp-content/uploads/2010/11/Command-300x32.jpg" alt="" width="300" height="32" /></a><p class="wp-caption-text">Command</p></div>
<p><strong>4.</strong> Under the <strong>[processModel]</strong> section you will get the username and password which is in <strong>Clear Text</strong> .</p>
<div id="attachment_301" class="wp-caption alignnone" style="width: 242px"><a href="http://niiconsulting.com/checkmate/wp-content/uploads/2010/11/Output.jpg"><img class="size-medium wp-image-301" src="http://niiconsulting.com/checkmate/wp-content/uploads/2010/11/Output-232x300.jpg" alt="" width="232" height="300" /></a><p class="wp-caption-text">Output showing credentials</p></div>
<p><span style="color: #a6a6a6; font-size: 18pt;">Remediation &amp; POC<br />
</span><br />
The remediation for this is very simple; use service accounts like Network Service, Network, etc. So, even if someone has access to the system and tries same steps as above to retrieve the user account password, he wont be able to do that.</p>
<p><strong>1.</strong> Application pool &#8220;<strong>Dos</strong>&#8221; with Network Service account</p>
<div id="attachment_312" class="wp-caption alignnone" style="width: 310px"><a href="http://niiconsulting.com/checkmate/wp-content/uploads/2010/11/AppPoolNS.jpg"><img class="size-medium wp-image-312" title="AppPoolNS" src="http://niiconsulting.com/checkmate/wp-content/uploads/2010/11/AppPoolNS-300x227.jpg" alt="" width="300" height="227" /></a><p class="wp-caption-text">Application Pool for Network Service</p></div>
<p><strong>2.</strong> Running the same command as we ran in earlier in this post i.e. <strong>APPCMD list apppool &#8220;Dos&#8221; /text:*</strong></p>
<div id="attachment_313" class="wp-caption alignnone" style="width: 310px"><a href="http://niiconsulting.com/checkmate/wp-content/uploads/2010/11/CommandNS.jpg"><img class="size-medium wp-image-313" title="CommandNS" src="http://niiconsulting.com/checkmate/wp-content/uploads/2010/11/CommandNS-300x34.jpg" alt="" width="300" height="34" /></a><p class="wp-caption-text">Command</p></div>
<p><strong>3.</strong> Checking the output</p>
<div id="attachment_314" class="wp-caption alignnone" style="width: 235px"><a href="http://niiconsulting.com/checkmate/wp-content/uploads/2010/11/OutputNS.jpg"><img class="size-medium wp-image-314" title="OutputNS" src="http://niiconsulting.com/checkmate/wp-content/uploads/2010/11/OutputNS-225x300.jpg" alt="" width="225" height="300" /></a><p class="wp-caption-text">Output for Network Service</p></div>
<p><span style="color: #a6a6a6; font-size: 18pt;">Note<br />
</span></p>
<p>The above technique which we have tested against IIS 6.0 will also work with IIS 7.0 and IIS 7.5, as these versions also provide support for the utility for legacy reasons.</p>
<p>I guess this highlights why <strong>least-privilege</strong> is so important when assigning privileges to application services on servers. In a scenario where the server is compromised, the  Final word for IIS administrators, always use a least-privilege user account for SharePoint or any other web application installation or deployment, simply means that Application Pool account should not have more permissions than needed.</p>
<p>&#8211;</p>
<p>Dhiraj</p>
]]></content:encoded>
			<wfw:commentRss>http://niiconsulting.com/checkmate/2010/11/19/dump-password-of-application-pool-user-from-iis-6-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Info-Letter vol.2</title>
		<link>http://niiconsulting.com/checkmate/2010/11/19/info-letter-vol-2/</link>
		<comments>http://niiconsulting.com/checkmate/2010/11/19/info-letter-vol-2/#comments</comments>
		<pubDate>Fri, 19 Nov 2010 07:57:05 +0000</pubDate>
		<dc:creator>Wasim Halani</dc:creator>
				<category><![CDATA[Reading]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://niiconsulting.com/checkmate/?p=303</guid>
		<description><![CDATA[Hi all, This month’s reading list. Make sure to check out the tools sections. Traditional Pen-testing is Dead: A frank look at the state of affairs of our daily job http://www.secmaniac.com/october-2010/traditional-penetration-testing-is-dead-bsides-atlanta/ 10 Steps to creating your own IT Security Audit http://www.itsecurity.com/features/it-security-audit-010407/ Preparing for an ISO 27001 Audit http://searchsecurity.techtarget.in/tip/Preparing-for-ISO-27001-audit Dilbert on Identity Theft (Comic) http://dilbert.com/strips/comic/2010-10-14/ Hide your [...]]]></description>
			<content:encoded><![CDATA[<p>Hi all,</p>
<p>This month’s reading list. <strong>Make sure to check out the tools sections.</strong></p>
<p>Traditional Pen-testing is Dead: A frank look at the state of affairs of our daily job<br />
<a href="http://www.secmaniac.com/october-2010/traditional-penetration-testing-is-dead-bsides-atlanta/" target="_blank">http://www.secmaniac.com/october-2010/traditional-penetration-testing-is-dead-bsides-atlanta/</a></p>
<p><span id="more-303"></span></p>
<p>10 Steps to creating your own IT Security Audit<br />
<a href="http://www.itsecurity.com/features/it-security-audit-010407/" target="_blank">http://www.itsecurity.com/features/it-security-audit-010407/</a></p>
<p>Preparing for an ISO 27001 Audit<br />
<a href="http://searchsecurity.techtarget.in/tip/Preparing-for-ISO-27001-audit" target="_blank">http://searchsecurity.techtarget.in/tip/Preparing-for-ISO-27001-audit</a></p>
<p>Dilbert on Identity Theft (<strong>Comic</strong>)<br />
<a href="http://dilbert.com/strips/comic/2010-10-14/" target="_blank">http://dilbert.com/strips/comic/2010-10-14/</a></p>
<p>Hide your entire Operating System from prying eyes (Local System Security)<br />
<a href="http://lifehacker.com/5554136/hide-your-entire-operating-system-from-prying-eyes" target="_blank">http://lifehacker.com/5554136/hide-your-entire-operating-system-from-prying-eyes</a></p>
<p>Sys Admins Gone Rogue – Biggest Insider Threat<br />
<a href="http://www.pcworld.com/businesscenter/article/206362/biggest_insider_threat_sys_admin_gone_rogue.html" target="_blank">http://www.pcworld.com/businesscenter/article/206362/biggest_insider_threat_sys_admin_gone_rogue.html</a></p>
<p>Pentesting with Burpsuite – Taking the web back from Automated Scanners<br />
<a href="http://www.securityaegis.com/pentesting-with-burp-suite-taking-the-web-back-from-automated-scanners/" target="_blank">http://www.securityaegis.com/pentesting-with-burp-suite-taking-the-web-back-from-automated-scanners/</a></p>
<p>Google Offering Bounties for Bugs in Web services<br />
<a href="http://googleonlinesecurity.blogspot.com/2010/11/rewarding-web-application-security.html" target="_blank">http://googleonlinesecurity.blogspot.com/2010/11/rewarding-web-application-security.html</a></p>
<p>Real-time Phishing: A leap in phishing attack techniques<br />
<a href="http://www.darkreading.com/authentication/167901072/security/attacks-breaches/228200550/index.html" target="_blank">http://www.darkreading.com/authentication/167901072/security/attacks-breaches/228200550/index.html</a></p>
<p><em><strong>TOOLS:</strong></em></p>
<p><strong>Firesheep</strong>: Firefox addon to demonstrate the impact of browsing without HTTPS encrypted session.<br />
<a href="http://codebutler.com/firesheep" target="_blank">http://codebutler.com/firesheep</a></p>
<p><strong>EFF: HTTPS Everywhere</strong>- Firefox addon to force the browser to opt for HTTPS versions of the sites (Twitter, Google, Facebook, Paypal)<br />
<a href="https://www.eff.org/https-everywhere" target="_blank">https://www.eff.org/https-everywhere</a></p>
<p><strong>Social Engineering Toolkit (v1.0) – ‘Devolution’ release </strong>:<br />
(Version adds several key components including new attack vectors, a web GUI interface, a way to automate SET behavior)<br />
<a href="http://www.secmaniac.com/november-2010/the-social-engineer-toolkit-v1-0-devolution-release/" target="_blank">http://www.secmaniac.com/november-2010/the-social-engineer-toolkit-v1-0-devolution-release/</a></p>
<p>Be safe!!</p>
<p>&#8211;</p>
<p>Wasim</p>
]]></content:encoded>
			<wfw:commentRss>http://niiconsulting.com/checkmate/2010/11/19/info-letter-vol-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Info-Letter vol. 1</title>
		<link>http://niiconsulting.com/checkmate/2010/10/18/infoletter-vol1/</link>
		<comments>http://niiconsulting.com/checkmate/2010/10/18/infoletter-vol1/#comments</comments>
		<pubDate>Mon, 18 Oct 2010 07:50:40 +0000</pubDate>
		<dc:creator>Wasim Halani</dc:creator>
				<category><![CDATA[Reading]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://niiconsulting.com/checkmate/?p=283</guid>
		<description><![CDATA[Hi all, We are starting with a monthly reading-list for people who are unable to keep up with the latest in the field of IT Security. A few articles (like the ones below) may be informational to the non-technical readers as well to improve their tech know-how and security posture The What And The Why [...]]]></description>
			<content:encoded><![CDATA[<p>Hi all,</p>
<p>We are starting with a monthly reading-list for people who are unable to keep up with the latest in the field of IT Security.<br />
A few articles (like the ones below) may be informational to the non-technical readers as well to improve their tech know-how and security posture <img src='http://niiconsulting.com/checkmate/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p><span id="more-283"></span></p>
<p>The What And The Why Of Professional Penetration Testing<br />
<a href="http://www.darkreading.com/blog/archives/2010/09/professional_pe.html">http://www.darkreading.com/blog/archives/2010/09/professional_pe.html</a></p>
<p>The Case of Zero-Day Penetration Testing<br />
<a href="http://www.darkreading.com/blog/archives/2010/08/the_case_for_ze.html">http://www.darkreading.com/blog/archives/2010/08/the_case_for_ze.html</a></p>
<p>Zero-Day Pentesting Under Fire<br />
<a href="http://www.darkreading.com/blog/archives/2010/10/i_wrote_a_blog.html">http://www.darkreading.com/blog/archives/2010/10/i_wrote_a_blog.html</a></p>
<p>Stuxnet: FAQ – F-Secure Blog<br />
<a href="http://www.f-secure.com/weblog/archives/00002040.html">http://www.f-secure.com/weblog/archives/00002040.html</a></p>
<p>TOOLS:</p>
<p>OracleEnumerator<br />
<a href="http://www.woany.co.uk/oracleenumerator-v1-1-1/">http://www.woany.co.uk/oracleenumerator-v1-1-1/</a></p>
<p>SQL Server 2005 Baseline Analyzer<br />
<a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyId=da0531e4-e94c-4991-82fa-f0e3fbd05e63&amp;displaylang=en">http://www.microsoft.com/downloads/en/details.aspx?FamilyId=da0531e4-e94c-4991-82fa-f0e3fbd05e63&amp;displaylang=en</a><br />
<a href="http://blog.sqlauthority.com/2007/07/05/sql-server-2005-best-practices-analyzer-tutorial-sample-example/">http://blog.sqlauthority.com/2007/07/05/sql-server-2005-best-practices-analyzer-tutorial-sample-example/</a></p>
<p>USBSploit –  USB Exploitation using Metasploit<br />
<a href="http://secuobs.com/news/12102010-usbsploit_v0.3b_meterpreter_msf_3.shtml">http://secuobs.com/news/12102010-usbsploit_v0.3b_meterpreter_msf_3.shtml</a></p>
<p>DriveSploit – Drive-by-Download using Metasploit<br />
<a href="http://www.drivesploit.org/home">http://www.drivesploit.org/home</a></p>
<p>If you have any links/articles/tools etc. which you would like to share with others, then send it along and I’ll include it in the next release of the newsletter.</p>
]]></content:encoded>
			<wfw:commentRss>http://niiconsulting.com/checkmate/2010/10/18/infoletter-vol1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Social Engineering &amp; &#8220;Influence&#8221;, by Dr. Cialdini</title>
		<link>http://niiconsulting.com/checkmate/2010/06/03/social-engineering-influence-by-dr-cialdini/</link>
		<comments>http://niiconsulting.com/checkmate/2010/06/03/social-engineering-influence-by-dr-cialdini/#comments</comments>
		<pubDate>Thu, 03 Jun 2010 07:10:40 +0000</pubDate>
		<dc:creator>K K Mookhey</dc:creator>
				<category><![CDATA[Case Studies]]></category>
		<category><![CDATA[Hacks]]></category>
		<category><![CDATA[Social Engineering]]></category>
		<category><![CDATA[Cialdini]]></category>

		<guid isPermaLink="false">http://niiconsulting.com/checkmate/?p=253</guid>
		<description><![CDATA[Over the past few years, we have completed a number of social engineering tests as part of advanced penetration testing at various organizations. Coincidentally, I recently read an excellent book called “Influence – the Psychology of Persuasion” by Dr. Robert Cialdini.and realized that it has some excellent lessons for anyone wanting to guard themselves from [...]]]></description>
			<content:encoded><![CDATA[<p>Over the past few years, we have completed a number of social engineering tests as part of advanced penetration testing at various organizations. Coincidentally, I recently read an excellent book called “Influence – the Psychology of Persuasion” by <a href="http://en.wikipedia.org/wiki/Robert_Cialdini" target="_blank">Dr. Robert Cialdini.</a>and realized that it has some excellent lessons for anyone wanting to guard themselves from social engineering attacks.</p>
<p>Dr. Cialdini’s book is an excellent coverage of what he calls “compliance professionals” – people engaged in hard-core door-to-door selling such as second-hand car salesman, multi-level marketing (read Amway) professionals, etc. He talks about the following 6 techniques adopted by these professionals to convince people to buy things they were never going to buy in the first place. The same techniques can also afford the social engineer easy access to information, and it is worthwhile for information security professionals to examine what the other breed of “compliance professionals” is up to!</p>
<p><span id="more-253"></span></p>
<p><strong> 1. Reciprocation: </strong>We are hard-wired to respond to a favor, often not in direct proportion to the size of the favor done to us. One such example given by Cialdini is the aid given in 1985 by Ethiopian Red Cross to earthquake victims in Mexico as repayment of aid given by Mexico when Ethiopia was invaded by Italy, way back in 1935! For the original <a href="http://news.google.com/newspapers?id=6aAmAAAAIBAJ&amp;sjid=xgEGAAAAIBAJ&amp;pg=5597,2603767&amp;hl=en" target="_blank">news article click here</a>.<br />
<span style="text-decoration: underline;">Practical exploitation:</span> <span style="text-decoration: underline;"><br />
</span>We used this technique to deadly effect by inducing a systems administrator to disclose highly confidential information about their set up after providing him with lots of study material for the upcoming CISA exam.</p>
<p><strong>2. Commitment and Consistency: </strong>Once we have made a choice or taken a stand, we will encounter personal and inter-personal pressures to behave consistently with that commitment.<br />
<span style="text-decoration: underline;">Practical exploitation:</span> <span style="text-decoration: underline;"><br />
</span>During one such test, we posed as auditors and started interviewing the system administrators. After a couple of days of helping us out with information, they led us to the other departments in the organization and further facilitated our “audit”. It was only on the 5th day that someone raised an alarm, but during the first few days once the personnel had hard-wired themselves into co-operating with us, they just went all the way, without even checking our credentials!</p>
<p><strong>3. Social Proof: </strong>One means we use to determine what is correct is to find out what other people think is correct. The principle applies especially to the way we decide what constitutes correct behavior.<br />
<span style="text-decoration: underline;">Practical exploitation:</span> <span style="text-decoration: underline;"><br />
</span>This is most simply exploited during a social engineering test by leveraging the power of social networking sites such as LinkedIn and Facebook. An attractive enough profile with other members of your organization linked to it is highly likely to make you add it to your network as well, with no clue as to the profile&#8217;s veracity.</p>
<p><strong>4. Liking: </strong>Few people would be surprised to learn that, as a rule, we most prefer to say yes to the requests of someone we know and like.<br />
<span style="text-decoration: underline;">Practical exploitation:</span> <span style="text-decoration: underline;"><br />
</span>Our most successful attempts have involved sending our more likeable people across asking for help or requesting for information to complete a “college project”. These individuals are usually well-groomed, smart, personable, and possess decent levels of charm or naivete to get the other person to comply.</p>
<p><strong>5. Authority: </strong>The famous <a href="http://en.wikipedia.org/wiki/Milgram_experiment" target="_blank">Milgram experiments</a> show the power of authority in comparison to all the other factors listed here. The real culprit is our inability to resist the psychological power wielded by the person in authority.<br />
<span style="text-decoration: underline;">Practical exploitation:</span> <span style="text-decoration: underline;"><br />
</span>We have seen this work in numerous ways by faking authority letters purporting to come from some government agency or from the managing director of the company. A lot of the times the recipient will simply comply with the request. The same effect is seen when depending on which car one is in, and how one is dressed, the security guard at the gate will adjust his level of obsequiousness.</p>
<p><strong>6. Scarcity: </strong>Collectors of everything from baseball cards to antiques are keenly aware of the influence of the scarcity principle in determining the worth of an item.<br />
<span style="text-decoration: underline;">Practical exploitation:</span> <span style="text-decoration: underline;"><br />
</span>One of the most common tactics is to build time pressure. The scarcity of time often makes people comply with requests in violation of their policies and their own common sense. We have used this on numerous occasions be it with a security guard or with a system or network administrator.</p>
<p>For other interesting social engineering experiments, search for “the real hustle” on YouTube for the BBC program that shows how as humans we easily fall prey to the smart hustler who sweet-talks his or her way into social engineering us.</p>
]]></content:encoded>
			<wfw:commentRss>http://niiconsulting.com/checkmate/2010/06/03/social-engineering-influence-by-dr-cialdini/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Format Preserving Encryption &#8211; In the guise yet retrievable as it is</title>
		<link>http://niiconsulting.com/checkmate/2010/02/09/format-preserving-encryption-in-the-guise-yet-retreivsble-as-it-is/</link>
		<comments>http://niiconsulting.com/checkmate/2010/02/09/format-preserving-encryption-in-the-guise-yet-retreivsble-as-it-is/#comments</comments>
		<pubDate>Tue, 09 Feb 2010 11:11:02 +0000</pubDate>
		<dc:creator>Khushbu Jithra</dc:creator>
				<category><![CDATA[Research]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Encrypt with format intact]]></category>
		<category><![CDATA[Encryption]]></category>
		<category><![CDATA[Format Preserving Encryption]]></category>
		<category><![CDATA[German Data Privacy Law]]></category>
		<category><![CDATA[PCI DSS]]></category>
		<category><![CDATA[UK Data Privacy Act]]></category>

		<guid isPermaLink="false">http://niiconsulting.com/checkmate/?p=239</guid>
		<description><![CDATA[A recent dive into challenges faced from privacy compliance requirements unearthed an interesting patent. The unearthing of this new patent on the block came from the need of anonymizing data for several reasons including compliance (PCI DSS, German Data Privacy Law [BDSG], UK Data Privacy Act).]]></description>
			<content:encoded><![CDATA[<p>A recent dive into challenges faced from privacy compliance requirements unearthed an interesting patent. The unearthing of this new patent on the block came from the need of anonymizing data for several reasons including compliance (PCI DSS, German Data Privacy Law [BDSG], UK Data Privacy Act).<span id="more-239"></span></p>
<p>With inputs from experts in the domain here is an overview of this unique encryption technology.</p>
<p><strong>The challenge:</strong><br />
Simply randomizing the data won&#8217;t help if the data drives a process like indexing in a database &#8211; the introduction of database indexing problems, or destruction of the integrity of the data in the de-identification process may render it useless as far as a business application or statistical analysis is concerned even if the process should not access specific identifiable fields. So, if you need to de-identify or depersonalize yet still use the data, there needs to be a more thought put into it to ensure the process cannot be reversed and to ensure that the use of the de-identified data can be preserved.</p>
<p>For example, if we have two databases, both indexed on a national ID number containing e.g. health records but we need to de-identify the personal data, yet retain the referential integrity across internal database tables in addition to preserving record relationships across two independent databases, and replace the personal data with data that is still meaningful for analysis but truly de-identified, then we need to preserve referential integrity across all the de-identified databases.</p>
<p>What if we need this process to be selectively reversible for e.g. a e-discovery request or specific analysis where real data is needed? Traditionally, data owners would have to keep some kind of mapping table &#8211; an ugly solution as it simple moves the problem of de-identification to another place.</p>
<p><strong>The solution:</strong><br />
There are some new techniques that permit de-identification of data &#8211; in a secure fashion. Specifically Format Preserving Encryption (FFX/FFSEM mode AES) which can:</p>
<p>* Encrypt/De-identify data without changing length, structure, type, format, referential integrity of data (again optional if this is essential or if de-association of record relationships is actually required) on the fly</p>
<p>* Provide the dual purpose &#8211; de-identification or data protection in place (no database schema changes) or protection of data in live systems with a single technique</p>
<p>* reversible or non reversible by policy</p>
<p>* Supports native mainframe, open systems and legacy out of production systems.</p>
<p>In <a href="http://csrc.nist.gov/groups/ST/toolkit/BCM/documents/proposedmodes/ffsem/ffsem-spec.pdf">this</a> paper on Fiestal Finite Set Encryption (FFSEM), the author elaborates on the Pseudo-Random Permutation used in this mode and the security of the construction. The author is quoted, &#8220;In many applications, such as encryption of credit card numbers, it is desirable to encrypt items from an arbitrarily sized set onto that same set. Unfortunately, conventional cipher modes such as ECB, CBC, or CTR are unsuitable for this purpose. Feistel Finite Set Encryption Mode (FFSEM) allows encryption of a value ranging from 0..n with resultant ciphertext in that same range. This mode can be used to encrypt fields where the expansion associated with a block cipher is undesirable or the format of the data must be preserved.&#8221;</p>
<p>An <a href="http://eprint.iacr.org/2009/251">academic paper</a> on the subject summarizes &#8211; &#8220;Format-preserving encryption (FPE) encrypts a plaintext of some specified format into a ciphertext of identical format—for example, encrypting a valid credit-card number into a valid creditcard number. The problem has been known for some time, but it has lacked a fully general and rigorous treatment.We provide one, starting off by formally defining FPE and security goals for it.We investigate the natural approach for achieving FPE on complex domains, the “rank-then-encipher” approach, and explore what it can and cannot do. We describe two flavors of unbalanced Feistel networks that can be used for achieving FPE, and we prove new security results for each. We revisit the cycle-walking approach for enciphering on a non-sparse subset of an encipherable domain, showing that the timing information that may be divulged by cycle walking is not a damaging thing to leak.&#8221;</p>
<p>Now the interesting bit&#8230;.is it implemented and is it commercial?<br />
Yes. <a href="http://www.voltage.com/technology/format-preserving-encryption.htm">http://www.voltage.com/technology/format-preserving-encryption.htm</a></p>
<p>Full patent description is available here<br />
<a href="http://www.freshpatents.com/Format-preserving-cryptographic-systems-dt20080717ptan20080170693.php?type=description">http://www.freshpatents.com/Format-preserving-cryptographic-systems-dt20080717ptan20080170693.php?type=description</a></p>
<p>And of course, at the first look, Wikipedia also did not help understanding it much unless I read the background and the two papers</p>
<p><a href="http://en.wikipedia.org/wiki/Format-Preserving_Encryption">http://en.wikipedia.org/wiki/Format-Preserving_Encryption</a></p>
]]></content:encoded>
			<wfw:commentRss>http://niiconsulting.com/checkmate/2010/02/09/format-preserving-encryption-in-the-guise-yet-retreivsble-as-it-is/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GeoEdge &#8211; IP Address Locator</title>
		<link>http://niiconsulting.com/checkmate/2010/01/06/geoedge-ip-address-locator/</link>
		<comments>http://niiconsulting.com/checkmate/2010/01/06/geoedge-ip-address-locator/#comments</comments>
		<pubDate>Wed, 06 Jan 2010 12:02:28 +0000</pubDate>
		<dc:creator>Nikhil Wagholikar</dc:creator>
				<category><![CDATA[Fundamentals]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[geoedge]]></category>
		<category><![CDATA[geotools]]></category>
		<category><![CDATA[ip locator]]></category>
		<category><![CDATA[MAP-Quest]]></category>
		<category><![CDATA[maxmind]]></category>
		<category><![CDATA[wikimapia]]></category>

		<guid isPermaLink="false">http://niiconsulting.com/checkmate/?p=192</guid>
		<description><![CDATA[From forensics point of view, investigating “which user did what on the application/server that lead to its compromise” is of the most importance. Similar scenario applies to Email investigation. It’s quite simple now to find out the IP Address of the person who is sending out fishy or threatening emails to the victim(s).]]></description>
			<content:encoded><![CDATA[<p><strong>Introduction</strong></p>
<p>Log analysis, is one of the very basic but crucial exercise of any Forensics Analyst. It includes many aspects for analysis; some of the important ones being:</p>
<ul>
<li>Determine actions/requests performed by User/Host/IP Address</li>
<li>The application’s or Server’s reactions towards user’s requests</li>
<li>Finding more information about a particular User/Host/IP Address who may be performing some extra-ordinary transactions with the application/server</li>
<li>Application/Server performance</li>
<li>Application/Server traffic monitoring to calculate business growth etc</li>
</ul>
<p>However from forensics point of view, investigating “which user did what on the application/server that lead to its compromise” is of the most importance. Similar scenario applies to Email investigation. It’s quite simple now to find out the IP Address of the person who is sending out fishy or threatening emails to the victim(s).</p>
<p>Here we are discussing a post investigation aspect of above and similar scenarios i.e. what after once the source IP Address (of the attacker) is identified? In this article we are going to discuss about a simple tool/script, which helps forensic analyst to get the exact location of the source IP Address on this very beautiful earth.<br />
<span id="more-192"></span><br />
<strong>Geo-Edge</strong></p>
<p>“geoedge.py” is a small Python utility/tool/script developed by Laramies from “<a href="http://www.edge-security.com/soft/geoedge.py">edge-security.com</a>” to get the exact location of the target host/IP Address on earth. This directly helps in finding the attacker’s physical location from where he carried out the attack.</p>
<p>However, those who don’t have a Python compiler/interpreter need not to worry, since NII Consulting have put in some more efforts and made this python script available in EXE format.</p>
<p>This tool can be downloaded as:</p>
<p>Original Python Version: Download <a href="http://www.edge-security.com/soft/geoedge.py">here</a></p>
<p>EXE Version: Download <a title="GeoEdge EXE version" href="http://www.niiconsulting.com/tools/geoedge.exe" target="_self">here</a></p>
<p>The beauty of this tool is that it queries two sources – <a href="http://www.maxmind.com/">Maxmind</a> and <a href="http://www.geoiptool.com/">geoiptool</a>, to extract information about given target host or IP Address. Hence possibility of availability and correctness of information about host or IP Address is high.</p>
<p><strong>Example</strong></p>
<p>Let’s first have a look how to use this tool:<br />
<a href="http://niiconsulting.com/checkmate/wp-content/uploads/2010/02/Pic1-Usage.jpg" target="_blank"><img src="http://niiconsulting.com/checkmate/wp-content/uploads/2010/02/Pic1-Usage.jpg" alt="" width="593" height="206" /></a></p>
<p>Now we’ll try to locate physical location of IP Address 64.246.16.151.</p>
<p>So for this, we’ll issue:</p>
<p><a href="http://niiconsulting.com/checkmate/wp-content/uploads/2010/02/Pic2-Sample.jpg" target="_blank"><br />
<img src="http://niiconsulting.com/checkmate/wp-content/uploads/2010/02/Pic2-Sample.jpg" alt="" width="593" height="371" /></a></p>
<p>As we can see, both the sources provided us with correct information about Latitude and Longitude of the target IP Address.</p>
<p>Now what? We have Latitude and Longitude information with us, but which country, which lane, which area this belongs to on earth?</p>
<p>So for this, we’ll refer to online world map available on <a href="http://www.mapquest.com/maps/latlong.adp">MAP-Quest</a> website.</p>
<p>We provide this obtained/derived information about Latitude and Longitude to this website, and find the exact location of this IP Address on earth.</p>
<p><img src="http://niiconsulting.com/checkmate/wp-content/uploads/2010/01/Pic3.jpg" alt="" width="586" height="612" /></p>
<p>The physical location of the target host/IP Address is shown using a red star marked on the map. Two kinds of views are available for getting the Latitude and Longitude information.</p>
<p>First view is the “Street View” in which we get the nearby street information about the target.</p>
<p><a href="http://niiconsulting.com/checkmate/wp-content/uploads/2010/01/Pic4.jpg" target="_blank"><img src="http://niiconsulting.com/checkmate/wp-content/uploads/2010/01/Pic4.jpg" alt="" width="461" height="277" /></a></p>
<p>A little further zoom can help us to get more information about the target host/IP Address.</p>
<p><a href="http://niiconsulting.com/checkmate/wp-content/uploads/2010/01/Pic5.jpg" target="_blank"><img src="http://niiconsulting.com/checkmate/wp-content/uploads/2010/01/Pic5.jpg" alt="" width="461" height="277" /></a></p>
<p>The second view is the “Aeriel view”, in which we get to see the exact satellite view of the target host/IP Address.</p>
<p><a href="http://niiconsulting.com/checkmate/wp-content/uploads/2010/01/Pic6.jpg" target="_blank"><img src="http://niiconsulting.com/checkmate/wp-content/uploads/2010/01/Pic6.jpg" alt="" width="461" height="277" /></a></p>
<p>Further zoom is available subject to the database availability of MapQuest website.</p>
<p><strong>Conclusion</strong></p>
<p>So from this, we learn that it’s not at all difficult for any forensics analyst to find out the exact physical location of the attacker.</p>
<p>Besides this technique, “GeoTools” available at <a href="http://wikimapia.org/">WikiMapia</a> is also very handy and useful.</p>
]]></content:encoded>
			<wfw:commentRss>http://niiconsulting.com/checkmate/2010/01/06/geoedge-ip-address-locator/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Hacking Microsoft Windows 2003 Server with Microsoft SQL Server 2005</title>
		<link>http://niiconsulting.com/checkmate/2009/12/08/hacking-microsoft-windows-2003-server-with-microsoft-sql-server-2005/</link>
		<comments>http://niiconsulting.com/checkmate/2009/12/08/hacking-microsoft-windows-2003-server-with-microsoft-sql-server-2005/#comments</comments>
		<pubDate>Tue, 08 Dec 2009 05:30:53 +0000</pubDate>
		<dc:creator>TAS</dc:creator>
				<category><![CDATA[Case Studies]]></category>
		<category><![CDATA[Hacks]]></category>

		<guid isPermaLink="false">http://niiconsulting.com/checkmate/?p=119</guid>
		<description><![CDATA[This post is a complete switch over from my previous post on phishing modus operandi. A little background on the hack. I was doing an assessment of a financial application; the objective was to evaluate the security of the complete infrastructure on which the application will be hosted once it goes live. As oppose to [...]]]></description>
			<content:encoded><![CDATA[<p>This post is a complete switch over from my previous post on phishing modus operandi. A little background on the hack. I was doing an assessment of a financial application; the objective was to evaluate the security of the complete infrastructure on which the application will be hosted once it goes live. As oppose to the routine list of findings this particular hack took the limelight. It was system compromise with Administrator access to the system. Yeah! </p>
<p><span id="more-119"></span></p>
<p>It was last day of our assessment; I had little time on hand before I could wind up for the day. So I thought why not bash the ‘sa’ account. I open the Microsoft SQL Server 2005 Management Studio and try some brute forcing for ‘sa’ account with common passwords, I get errors and disappointments. But this was short lived, it dint take me more than 7 tries to get the combination right. And that opens my way into the system. </p>
<p>Once I was inside, the next step was to use the stored procedure xp_cmdshell. The &#8220;xp_cmdshell&#8221; extended stored procedure runs operating system commands from within the database engine. You can use the query analyzer or T-SQL code to run the command. Back to the hack, I than open the query analyzer and type the following command</p>
<blockquote><p>
<em>exec xp_cmdshell &#8216;dir C:\&#8217;</em></p></blockquote>
<p>Though I was logged in &#8216;sa&#8217; account (the highest privilege account in SQL server), as expected I get this long error message.</p>
<blockquote><p><em>Msg 15281, Level 16, State 1, Procedure xp_cmdshell, Line 1<br />
SQL Server blocked access to procedure &#8216;sys.xp_cmdshell&#8217; of component &#8216;xp_cmdshell&#8217; because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of &#8216;xp_cmdshell&#8217; by using sp_configure. For more information about enabling &#8216;xp_cmdshell&#8217;, see &#8220;Surface Area Configuration&#8221; in SQL Server Books Online</em></p></blockquote>
<p>In short the error means, I cannot use the xp_cmdshell stored procedure to do my hack. Microsoft (MS) has turned this stored procedure OFF in the version above SQL 2000 as a part of the security configuration. The previous versions of SQL Server 2005 had full access to xp_cmdshell turned ON in the default setup. And hence it was easy to do the system compromise. One obvious advantage of disabling the xp_cmdshell is, once a hacker gets access to the SQL server, the system compromise would not become a cake walk. But let’s check out how you can still do cake walk on version above Microsoft SQL Server 2000. Just a little tricky but easy <img src='http://niiconsulting.com/checkmate/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>If you read the error carefully it gives out a lot more than it should. Check the last line of the error message. It says xp_cmdshell can be enabled using the &#8220;Surface Area Configuration&#8221;. I further Google and get plenty of articles that tell me how to use Surface Area Configuration wizard to enable the stored procedure. They would ideally work but it dint work for me for whatever reason. If you want to enable xp_cmdshell with Surface Area Configuration method on your own system, try the following</p>
<blockquote><p>
<em>Goto Microsoft SQL Server 2005<br />
Configuration Tools &gt; SQL Server Surface Area Configuration &gt; Surface Area Configuration for Feature &gt; Expand the SQL server Instance name &gt; Under Database engine goto xp_cmdshell &gt; Check &#8220;Enable xp_cmdshell&#8221; and Apply</em></p></blockquote>
<p>That&#8217;s it, you can have now enabled xp_cmdshell for your own box. You can again run the command mentioned above. You should not get any error now. The image below summarizes this</p>
<p><img src="http://niiconsulting.com/checkmate/wp-content/uploads/2009/12/Enable_xp-cmdshell_local_sys" alt="Enabling xp_cmdshell with 'Surface Area Configuration Wizard' on your own box" /><br />
Fig: Enabling xp_cmdshell using the Surface Area Configuration Wizard</p>
<p>I had to enable xp_cmdshell on the remote system. I open my SQL Server Surface Area Configuration wizard and click on &#8220;Change computer&#8221; and specify the remote system SQL server instance name (or IP). It popped me with some error. I tried a few time but phew! It does not work for me. It was time, I try something else. I go back and start to find if there was some a command line to do the same thing. Again a few searches and I get my results. You can enable the xp_cmdshell in 4 simple steps.</p>
<blockquote><p><em>1) EXEC master.dbo.sp_configure &#8216;show advanced options&#8217;, 1 (ONE means ON, ZERO means OFF)<br />
2) RECONFIGURE<br />
3) EXEC master.dbo.sp_configure &#8216;xp_cmdshell&#8217;, 1<br />
4) RECONFIGURE</em></p></blockquote>
<p>sp_configure displays or changes global configuration settings for the current server. And the ‘sa’ account has privileges on this stored procedure. Eh! sp_configure is my key inside the system. So I first enable all the advance options than enable the xp_cmdshell. The image below shows my ‘xp_cmdshell’ in action on the remote system.</p>
<p><img src="http://niiconsulting.com/checkmate/wp-content/uploads/2009/12/enable_xp_cmdshell.png" alt="xp_cmdshell in action on victim system" /><br />
Fig: xp_cmdshell in action on victim system</p>
<p>Once I enabled xp_cmdshell, it was time for me to add user. So I type the following commands at the query analyzer console,</p>
<blockquote><p><em>1) EXEC xp_cmdshell &#8216;net user pwnsauc3 h3ll0w0rld$ /ADD&#8217;<br />
2) EXEC xp_cmdshell &#8216;net group Administrators pwnsauc3 /ADD&#8217;</em></p></blockquote>
<p>In case the remote terminal service is not ON, goto to Start &gt; Run and type service.msc. Right click on the parent node and connect to remote services and use the above username and password. Start the Terminal Services. You can now sit and relax; you are a step away from administrator access to the system. Fire up your remote terminal client and type in the IP and login with the user name and password we created. The images below conclude my hack. </p>
<p><img src="http://niiconsulting.com/checkmate/wp-content/uploads/2009/12/connecting_to_remote_system.png" alt="Verify the user addition from command line" /><br />
Fig: Verify the user addition from command line</p>
<p><img src="http://niiconsulting.com/checkmate/wp-content/uploads/2009/12/verifying_user_addition_to_sys.png" alt="Remote terminal to the victim system" /><br />
Fig: Remote terminal to the victim system</p>
<p><img src="http://niiconsulting.com/checkmate/wp-content/uploads/2009/12/user_added_to_administrators group.png" alt="verifying the user added to Administrators group" /><br />
Fig: Verifying the user added to Administrators group</p>
<p>Adios!<br />
Taufiq Ali</p>
]]></content:encoded>
			<wfw:commentRss>http://niiconsulting.com/checkmate/2009/12/08/hacking-microsoft-windows-2003-server-with-microsoft-sql-server-2005/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Phishy Story</title>
		<link>http://niiconsulting.com/checkmate/2009/11/05/a-phishy-story/</link>
		<comments>http://niiconsulting.com/checkmate/2009/11/05/a-phishy-story/#comments</comments>
		<pubDate>Thu, 05 Nov 2009 12:17:40 +0000</pubDate>
		<dc:creator>TAS</dc:creator>
				<category><![CDATA[Case Studies]]></category>
		<category><![CDATA[Hacks]]></category>
		<category><![CDATA[Incident Response]]></category>
		<category><![CDATA[Research]]></category>

		<guid isPermaLink="false">http://niiconsulting.com/checkmate/?p=80</guid>
		<description><![CDATA[Phishing sounds similar to fishing. Fishes are to the volume of internet users today much like fishermen are to phishers. Zillions of fishes falling prey the nets is nothing less compared to internet users being phished through their own in boxes and messengers. Phishers tend to have some personal favorites &#8211; personal information, credit cards [...]]]></description>
			<content:encoded><![CDATA[<p>Phishing sounds similar to fishing. Fishes are to the volume of internet users today much like fishermen are to phishers. Zillions of fishes falling prey the nets is nothing less compared to internet users being phished through their own in boxes and messengers.  Phishers tend to have some personal favorites &#8211; personal information, credit cards numbers, debit cards numbers with ATM pins, etc. Though phishing has been around for a long time, it became more prominent back in 2003. You can read more here on the big scams <a href="http://www.washingtonpost.com/wp-dyn/articles/A59350-2004Nov18.html">here</a>.</p>
<p>How does it all work?</p>
<p><span id="more-80"></span></p>
<p>
A typical modus operandi:</p>
<p>1)	The Phisher would either go out and buy a phishing kit from the underground channels or create a look alike page himself.</p>
<p>2)	 He would then need hacked websites or a server where the pages can be hosted. This can also be easily made available. He would pay or trade for a list of hacked websites on IRC channels, underground forums etc. These are some very common sources for such deals. He could also target systems that are vulnerable to a particular vulnerability or weakness in the website &#8211; vulnerability in the hosting providers control panel software, exploit for popular CMS like Joomla, 0day vulnerability in web server, etc. A zero-day (or zero-hour) attack or threat is a computer threat that tries to exploit computer application vulnerabilities that are unknown to others, undisclosed to the software vendor, or for which no security fix is available. (ref : <a href="http://en.wikipedia.org/wiki/Zero_day_vulnerability">http://en.wikipedia.org/wiki/Zero_day_vulnerability</a>)</p>
<p>3)	Once the hacked infrastructure is ready it’s time to spam. They would ideally send out emails in large volumes. These emails are crafted to perfection. They would have the company logo, an appealing message in the email; use the CSS as the company that is phished, etc. All this together make it look perfect. It’s like decorating the devils face with cosmetics to make it look innocent. But not to forget the devil under a thin layer of cosmetics. They will have a crafted link and the hyperlink actually pointing to some website where the pages are hosted.</p>
<p>However, the entire process is a gamble. Some may fall prey to their phish nets while others may not. Over the years, phishing scams have grown from simply stealing accounts into much more dangerous criminal intention. Assuming the user is a prey of the phish net, let us understand the ways in which a phisher can harvest the data of the victim. There are various ways in which this can be done.</p>
<p>1)	The attacker here uses services of websites that let you send HTML forms embedded in your email. On submit of this HTML form the phished page will redirect you to the legitimate website. This often tricks the user. They don’t realize what just happened. The details entered on the form are then emailed to the phisher’s inbox that is supposed to collect the details. The most common examples where you can see them are when advertising on the internet.</p>
<p>2)	Second, the email is scripted in a way that a user is tempted or forced to visit the copied website. The attacker can also use the tactic mentioned above and use services like www.emailmeform.com. Attacker creates an account here and links his entire phished page to use their service to capture the details and then email it to them. This is the most common method used by phishers. Also the pages are scripted in server side programming languages like PHP, .NET, JSP etc. Doing so it does not expose the modus operandi or the attacker’s identity in any way or other details in any way.</p>
<p>3)	The third type is where the phishers use nothing like above and instead writes all the output to a predefined file. In this way he needs no email address or anything mentioned above to capture the user details. This is what I am exactly going to write about.</p>
<p>Since I had some time off before I could start with the next takedown, I decided to dig further. Before we begin let me give you a brief about our service and the client. We offer take down services to a large public sector bank. We have a strict timeline defined of 24 hrs for every takedown. Every time a customer or their monitoring reports a phished page we have to takedown the site to protect the loss of financial and other details. While doing takedowns I also get a chance to research on understanding the modus operandi behind the operation. It is very interesting.</p>
<p>I have just started my day checking my email over a cup of coffee. I receive a new email on Tue 11/3/2009 10:22 AM about a phished link being up with the URL and we need to immediately start the takedown. He also sends me a sample email. We did the usual process and the link was down by noon. Have a look at a sample phishing email. </p>
<p><img src="http://niiconsulting.com/checkmate/wp-content/uploads/2009/11/fraudlent-email-sample1.jpg" alt="" /></p>
<p><br/><br/></p>
<p>The email looks so real. It has the logo of the customer and perfect login URL. On hover I found it was actually pointing to some server in Russia. The page &#8216;retails.html&#8217; simply redirects to the next URL where the phished page is hosted. Have a look at the closing lines of the email below. The phisher uses pressure tactic that will force the user to browse the URL.</p>
<p><img src="http://niiconsulting.com/checkmate/wp-content/uploads/2009/11/2009-11-04_151209.jpg" alt="" /></p>
<p>Ok I now click and I am now redirected to the URL http://200.119.X.X/retail/login.php. The page looks like this</p>
<p><img src="http://niiconsulting.com/checkmate/wp-content/uploads/2009/11/login-page.jpg" alt="" /></p>
<p>I then enter some fake details on this page and press the Enter key. I am now redirected to another page called &#8216;accounts.php&#8217; on the same domain. I quickly check the html source code (view source) of the page to check for the</p>
<form> tag. This is where I would see where the page is going on hitting &#8216;submit&#8217;. I am now redirected to another page hosted on a hacked domain called hxxp://stirileprotv.fnhost.org/bi/ib.php</p>
<p><img src="http://niiconsulting.com/checkmate/wp-content/uploads/2009/11/2009-11-04_151925.jpg" alt="" /></p>
<p>I go a level up in the URL hxxp://200.119.X.X/retail/login.php and now I see the directory listing. I see 2 files under the retail folder namely &#8216;login.php&#8217; and &#8216;accounts.php&#8217;. Directory Listing has been common in all my takedowns. They don’t really care for the directory listings. What I also observed, at the bottom of the &#8216;account.php&#8217; page is more interesting. The page is has an IFRAME with src pointing to <a href="http://statanalyze.cn/lib/index.php">http://statanalyze.cn/lib/index.php</a>. This is some malware getting downloaded on victim system. </p>
<p><img src="http://niiconsulting.com/checkmate/wp-content/uploads/2009/11/2009-11-04_124018_malware.jpg" alt="" /></p>
<p>My anti virus immediately pops up an alert that a malware is getting downloaded. And it immediately blocks it. Coming back to &#8216;accounts.php&#8217; it asks for my Name, email address, credit card number, ATM pin and expiration date. On entering some fake details I am now redirected to a third domain hxxp://stirileprotv.fnhost.org/bi/ib.php. And from &#8216;ib.php&#8217; it redirects me to the legitimate page of my client website. I have changed that to hxxp://www.google.com in the code snippet. Aren’t these guys sick of so many re directions? Not really they have a smart modus operandi. They don’t use one domain to complete their operation.</p>
<p>I again go a level up on the <a href="http://stirileprotv.fnhost.org/bi/ib.php">http://stirileprotv.fnhost.org/bi/ib.php</a>. What I happen to find is something even more interesting. It had a page &#8216;ib.php&#8217; under the ib folder and a .txt file. When I tried accessing the file what I find is the actual account details of the people who have fallen prey to the trick with their usernames, credit card numbers, internet banking IDs and passwords. Check file snippet below</p>
<p><img src="http://niiconsulting.com/checkmate/wp-content/uploads/2009/11/2009-11-05_113230.jpg" alt="" /> </p>
<p>I then contact the client to freeze the accounts and get in touch with the hosting providers. I make sure I ask the hosting providers to provide me with the pages as they aid to my research in understanding various modus operandi out on pr0wl. Most of the time they don’t give the pages but this time I was lucky. The tech support guys actually emailed me the contents of the ib folder. Have a look at the php code</p>
<p><img src="http://niiconsulting.com/checkmate/wp-content/uploads/2009/11/the-actual-code.jpg" alt="" /></p>
<p>Let me explain the code in brief. It opens a stream to a file called x-account-all.txt and then captures the post variables from the URL http://200.119.X.X/retail/accounts.php. The following table explains what each variable means</p>
<p><img src="http://niiconsulting.com/checkmate/wp-content/uploads/2009/11/table.jpg" alt="" /></p>
<p>I thought that was it. I was done with my research. I relaxed a bit and stretched my arms. But hold on readers I recollect that the website was also vulnerable to IFRAME injection. No more research on this malware guys I have colleagues who enjoys this. I will send this to him. Till he comes up with his analysis there are some who have already done it. Check the link below</p>
<p><a href="http://wepawet.iseclab.org/view.php?hash=363c95666cf1e80072656c7b562c4dbb&amp;type=js">http://wepawet.iseclab.org/view.php?hash=363c95666cf1e80072656c7b562c4dbb&amp;type=js</a> </p>
<p><a href="http://anubis.iseclab.org/?action=result&amp;task_id=1c109b3e2cc07d1f49168943cc884e1d2">http://anubis.iseclab.org/?action=result&amp;task_id=1c109b3e2cc07d1f49168943cc884e1d2</a></p>
<p><a href="http://www.virustotal.com/analisis/837508d65acc78ec684c0d7a907bea7f49ce223052a18a076240018fc61a0d7f-1257141946">http://www.virustotal.com/analisis/837508d65acc78ec684c0d7a907bea7f49ce223052a18a076240018fc61a0d7f-1257141946</a></p>
<p>I was still way too itchy to pull down a full stop. I picked some arbitrary entries from the file and picked the &#8216;ea&#8217; and &#8216;bb&#8217; field. Why only them? (I got this particular combination after trying out a few) I was able to login to the Yahoo accounts of the victim since the password used was the same for both the accounts. I then checked the spam box and found the email that the victim had received. There were similar emails and to my surprise I found another URL hosting the phished page. Ok guys that’s it, I need to get back to my next takedown immediately  Oh! By the way, this time it is some Windows 2003 server behind some ADSL router running the phished page on a XAMP server. I did RDP to the box, 3389 was found open. I will come back if I find something more interesting.</p>
<p>All the details in this post have being changed or rename to protect real identity of our client. </p>
<p>Adios!<br />
Taufiq Ali</p>
]]></content:encoded>
			<wfw:commentRss>http://niiconsulting.com/checkmate/2009/11/05/a-phishy-story/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Deobfuscating Javascript Malware</title>
		<link>http://niiconsulting.com/checkmate/2009/10/01/deobfuscating-javascript-malware/</link>
		<comments>http://niiconsulting.com/checkmate/2009/10/01/deobfuscating-javascript-malware/#comments</comments>
		<pubDate>Thu, 01 Oct 2009 11:20:32 +0000</pubDate>
		<dc:creator>Wasim Halani</dc:creator>
				<category><![CDATA[Case Studies]]></category>
		<category><![CDATA[Malware Analysis]]></category>
		<category><![CDATA[Research]]></category>
		<category><![CDATA[javascript deobfuscation]]></category>
		<category><![CDATA[javascript malware]]></category>

		<guid isPermaLink="false">http://niiconsulting.com/checkmate/?p=62</guid>
		<description><![CDATA[Some days back I was greeted by a Google Safe browsing warning when I tried visiting a &#8216;known&#8217; site. As I was sure it was supposed to be clean and harmless site, I thought it would be good to dig further into this problem. The trail led to interesting amounts of codes, concepts and techniques. [...]]]></description>
			<content:encoded><![CDATA[<p>Some days back I was greeted by a Google Safe browsing warning when I tried visiting a &#8216;known&#8217; site. As I was sure it was supposed to be clean and harmless site, I thought it would be good to dig further into this problem. The trail led to interesting amounts of codes, concepts and techniques.</p>
<p>Malware writers are very smart nowadays (haven&#8217;t they always been ?). They know that once their code is understood it most likely to be detected by anti-malware applications. To delay detection by such applications, they resort to a wide range of techniques. In this blog post I&#8217;ll be discussing the most potent and easily created malware.</p>
<p>Javascript has become the boon and bane of the Internet. It provides greater interactivity with the user but can also be used by malware writers to infect innocent users. Javascript is a client-side scripting technology which means the processing of the script is handled by the user&#8217;s browser.</p>
<blockquote><p><strong><em>Obfuscation is the concealment of intended meaning in communication, making communication confusing, intentionally ambiguous, and more difficult to interpret.</em></strong></p></blockquote>
<p><span id="more-62"></span></p>
<p>JavaScript is sometimes obfuscated to prevent users from easily understanding their functionality. ( Legitimate uses are to prevent stealing of code)</p>
<p>There may be many ways to obfuscate a code and similarly there may be multiple ways to de-obfuscate a code. What I&#8217;ve presented below is very raw and cannot be used to analyze many malicious JS. But since this is the beginning for me, I thought it may help others too.</p>
<p><strong>Disclaimer: Links presented below are live at the time of writing this blog post. Please do not visit them if you do not know what you are getting into.<br />
</strong></p>
<p>First thing first, we need to get the HTML source the malicious page. We can either use wget/curl or <a href="http://malzilla.sourceforge.net/">Malzilla</a>, which is what I used. It was observed that this page is dependent on the HTTP referrer. So if the domain receives a request for the page without a &#8216;valid&#8217; HTTP referrer page, the page is not returned.<br />
We get the &#8216;bad&#8217; HTML at http://mybetorwager.cn:8080/index.php with a valid HTTP referrer.</p>
<p>The complete HTML source can be viewed <a href="http://docs.google.com/View?id=dctvmpj6_28f9pwcrhd"><strong>here</strong></a> </p>
<p>The code starts off with the following in the SCRIPT tag.</p>
<blockquote><p><strong>Vhotzdq(function(p,a,c,k,e,d)</strong></p></blockquote>
<p>This section of the code shows that the javascript has been packed by the popular <a href="http://dean.edwards.name/packer/">Dean Edword JS Packer</a>. This packer is available online as well as in <a href="http://dean.edwards.name/download/#packer">download-able formats</a>. We use a GreaseMonkey script &#8220;<a href="http://userscripts.org/scripts/show/25935">Decode It!</a>&#8221; to enable the online &#8216; <em>Decoder</em>&#8216; on the webpage.<br />
</br><br />
We paste the code from Vhotzdq(function(p,a,c,k,e,d) onwards till the end and <strong>rename the function name Vhotzdq to eval</strong>. This will help us decode and evaluate the result. The output of which can be found <a href="http://docs.google.com/View?id=dctvmpj6_29hgzk3tdr"><strong>here</strong></a></p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p><strong>Update</strong><em><br />
Seems like Dean Edwards had coded an UNPACKER as well. It can be accessed at <a href="http://dean.edwards.name/unpacker/">http://dean.edwards.name/unpacker/</a>. If using this tool, simply <strong>replace the Vhotzdq to eval</strong> and run the script. No additional GreaseMonkey scripts are necessary <img src='http://niiconsulting.com/checkmate/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /><br />
</em></p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<div id="attachment_82" class="wp-caption alignnone" style="width: 610px"><img src="http://niiconsulting.com/checkmate/wp-content/uploads/2009/10/js_unpack_1.jpg" alt="Fig: Unpacked Javascript using Dean Edwards Packer" title="Unpacked Javascript using Dean Edwards Packer" width="600" height="178" class="size-full wp-image-82" /><p class="wp-caption-text">Fig: Unpacked Javascript using Dean Edwards Packer</p></div>
<p>As can be seen above, we need to unescape the code to get the decoded output. This can be done in multiple ways:</p>
<ul>
<li>Replace <em>Vhotzdq </em>as <em>eval</em>, and execute the script</li>
<li>Use the Malzilla decoder feature &#8220;Decode UCS2 (%u)&#8221;</li>
<li>Use an online encoder/decoder like <a href="http://www.yehg.net/encoding/">PHP Charset Encoder/PHP String Encrypter</a></li>
</ul>
<p></br><br />
<div id="attachment_83" class="wp-caption aligncenter" style="width: 610px"><img src="http://niiconsulting.com/checkmate/wp-content/uploads/2009/10/js_decoded-php-charset-1.jpg?w=600" alt="Fig: Using the &#39;unescape&#39; feature provided by PHP Charset Encoder" title="Using the &#39;unescape&#39; feature provided by PHP Charset Encoder" width="600" height="315" class="size-full wp-image-83" /><p class="wp-caption-text">Fig: Using the 'unescape' feature provided by PHP Charset Encoder</p></div></p>
<p>The decoded output of the above step can be found <a href="http://docs.google.com/View?id=dctvmpj6_30dd9nvgdk"><strong>here</strong></a></p>
<p>Now the code is in a more human readable format. To further complicate analysis, the malware authors have implemented small amounts of string manipulations on the code. Also, the variables used have been obfuscated or mangled. This will not pose a problem to us as the variables can be given any names.</p>
<blockquote><p><em>Note that there exists a certain amount of code-block which is still encoded. Another <a href="http://wepawet.iseclab.org/view.php?hash=835f950f74bbdaebab4e91a28c73d1d8&amp;t=1250389682&amp;type=js">malware analysis</a> shows this section as the Shellcode. I will update this as I get more information on how to decode it.</em></p></blockquote>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p><strong>Update</strong><em><br />
OK, it turns out that the segment was indeed the shellcode. Using the Malzilla tool we concatenate the variable &#8220;<strong>var unf57UBnT</strong>&#8221;<br />
This presents us with an encoding which seems to be UCS2. Next, we can either use Malzilla to convert UCS2 to Hex (which does not provide reliable results) or use a shellcode to EXE converter available at <a href="http://sandsprite.com/shellcode_2_exe.php">http://sandsprite.com/shellcode_2_exe.php</a>.</em><br />
</br><div id="attachment_96" class="wp-caption aligncenter" style="width: 463px"><a href="http://sandsprite.com/shellcode_2_exe.php"><img src="http://niiconsulting.com/checkmate/wp-content/uploads/2009/10/shellcode-2-exe_2.jpg" alt="Fig: ShellCode 2 EXE" title="ShellCode 2 EXE" width="453" height="518" class="size-full wp-image-96" /></a><p class="wp-caption-text">Fig: ShellCode 2 EXE</p></div><br />
</br><br />
<em>Once we obtain the EXE from the shellcode, we can analyze this executable in a tool called <a href="http://www.webwasher.de/download/fileinsight/"><strong>FileInsight </strong>developed by Mcafee Labs</a>. Below is a snapshot of FileInsight analysis output which shows the malicious URL.</em><br />
</br><br />
<div id="attachment_97" class="wp-caption aligncenter" style="width: 610px"><img src="http://niiconsulting.com/checkmate/wp-content/uploads/2009/10/fileinsight-2.jpg" alt="Fig: FileInsight - Shellcode.exe analysis" title="FileInsight - Shellcode.exe analysis" width="600" height="420" class="size-full wp-image-97" /><p class="wp-caption-text">Fig: FileInsight - Shellcode.exe analysis</p></div> </br></p>
<p><em>URLMON.DLL is a system DLL generally used by malwares to download files from online locations</em></p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
The next step is to execute the &#8216;replace&#8217; functions which involve Regular Expressions to clean out the manipulated code.<br />
As an example below is the line of code that we currently have in our decoded output.</p>
<blockquote><p>rqeqG6Spq.setAttribute(&#8216;i#)@d!&#8217;.replace(/\(|\!|&amp;|\$|@|\^|\)|#/ig, &#8221;),rqeqG6Spq);</p></blockquote>
<p>Let&#8217;s take this code in detail:</p>
<table>
<tr>
<td><strong>rqeqG6Spq</strong></td>
<td>&#8211;&gt;</td>
<td>declared variable</td>
</tr>
<tr>
<td><strong>setAttribute</strong></td>
<td>&#8211;&gt;</td>
<td>the property of the variable rqeqG6Spq</td>
</tr>
<tr>
<td><strong>/\(|\!|&amp;|\$|@|\^|\)|#/ig</strong></td>
<td>&#8211;&gt;</td>
<td>Regular Expression</td>
<tr>
<td colspan="3">
(In JavaScript, to define a regex pattern, we define it between <strong>/&#8230;../</strong> .<br />
&#8216;<strong>g</strong>&#8216; indicates <em>Global Match</em> and &#8216;<strong>i</strong>&#8216; is for <em>Case-Insensitive</em> search)
</td>
<tr>
<td><strong>.replace()</strong></td>
<td>&#8211;&gt;</td>
<td>is a JavaScript string manipulation function, which runs the regex on the &#8216;object&#8217; <strong>i#)@d!</strong></td>
</tr>
</table>
<p>After executing the replace() function, the output would look like this </p>
<blockquote><p><em>rqeqG6Spq.setAttribute(&#8216;id&#8217;,rqeqG6Spq);</em></p></blockquote>
<p>Similar replace operations are performed at all other places, till we get the final output as shown <a href="http://docs.google.com/View?id=dctvmpj6_32fhwmwdfz">here</a></p>
<p><strong>NOTE: Your Anti-Malware may issue an alert when you try to visit the above link. I have modified the malicious URL a bit so the script won&#8217;t move ahead.</strong></p>
<p>We are now at a stage where we can make a few observations on what the JavaScript does and how it works.<br />
The original malicious domain is found to be <strong>http://3c8.ru:8080/welcome.php</strong> .This domain serves the malware payload.<br />
The script tries to exploit a vulnerability in ActiveX which allows it to download and execute a malicious binary.<br />
I haven&#8217;t had the chance to go deeper into the execution of the malware But once I get the time, I&#8217;ll look into analyzing the binary as well.</p>
<p>Before I end this long post, just a quick note that to automate this entire process, we can use an online tool called <strong><em><a href="http://wepawet.iseclab.org/index.php">wepawet</a></em></strong>, which is a service for detecting and analyzing web-based malware. It currently handles Flash and JavaScript files.<br />
You can find the result of the analysis of our malicious page at <a href="http://wepawet.iseclab.org/view.php?hash=07fc283602731721a97f196c3ab19092&amp;type=js">http://wepawet.iseclab.org/view.php?hash=07fc283602731721a97f196c3ab19092&amp;type=js</a><br />
It provides for a comprehensive analysis. </p>
<p>Also, do check out the VirusTotal scan results for the obfuscated and deobfuscated Javascript<br />
<a href="http://www.virustotal.com/analisis/2cd3069c412cac7b1159d20070503ee91238f1e4682a5b90b003b29a569c9291-1251527312">Obfuscated Detection rate is 2/41</a><br />
<a href="http://www.virustotal.com/analisis/218209456d7c0dc654596eab91b8cf0127dbbe1642eef9f56a3366021835d504-1251527404">De-obfuscated Detection rate is 14/41</a></p>
<p>I  guess that&#8217;s it. Hope you liked this basic tutorial. Do leave your feedback in the comments section below</p>
]]></content:encoded>
			<wfw:commentRss>http://niiconsulting.com/checkmate/2009/10/01/deobfuscating-javascript-malware/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

