blog.sat0ri.com

Command-line Argument Handling in Standard Windows Binaries

by sharpe on Jun.02, 2010, under Security, Vulnerabilities

Looking at some of the components present within the %systemroot%\system32 directory can be fun when attempting to identify low-hanging-fruit-vulnerabilities. I made a simple fuzzer that enumerated all executables within a given directory and attempted to execute them with user-defined arguments. A more advanced method also supported by the tool, is to specify the arguments for a given executable in the fuzzer’s configuration file and allow it to run the programme based on the configuration options.

A sample configuration might resemble the following:

<?xml version="1.0" encoding="iso-8859-1"?>
<configuration>
<session>
<top><![CDATA[C:/]]></top>
<denyrules>
<rule><![CDATA[Documents]]></rule>
<rule><![CDATA[Unencrypted]]></rule>
<rule><![CDATA[ie7updates]]></rule>
<rule><![CDATA[Installer]]></rule>
<rule><![CDATA[cmd.exe]]></rule>
</denyrules>
<extensions>
<extension value="exe" />
</extensions>
<!-- Add specific programmes and their arguments below -->
<!-- Arguments with values are followed with a "+" -->
<!-- Arguments that must be present are followed with a "!" -->
<!-- The first byte is the char that is used when giving arguments. -->
<!-- Some will be a forward slash and others a hyphen -->
<programmes enabled="0">
<programme name="C:/path/to/executable.exe" arguments="/l:+;/s:!;" />
</programmes>
</session>
<files>
<output>db.xml</output>
<errors>errors.xml</errors>
</files>
</configuration>

After a few practice, fine-tuning runs, I ran the tool in the %systemroot%\system32 directory and went to make myself a cup of tea. About five or ten minutes later I came back to find the debugger attached to the following 6 processes:

  • mrinfo.exe
  • locator.exe
  • eventvwr.exe
  • netsetup.exe
  • odbcconf.exe
  • sdbinst.exe

what does this mean? Well it means that the tool caused some kind of exception in the programmes to occur. Looking at the debugger, if we have a closer look at the contents of the registers and state of the stack (which was the cause of the exceptions) we can see that the data passed to the programme via the command-line is the culprit here. For the sake of illustration, lets have a look at some screen-dumps of some of the exceptions and the executables in which they occured.

mrinfo.exe:

locator.exe:

eventvwr.exe:

netsetup.exe:

sdbinst.exe:

If we have a closer look at the vulnerabilities mentioned above, we can see that they are all a result of improper bounds checking when reading command-line arguments. This is quite a common error, not only in the components mentioned above, but also in many other applications, which take arguments/data and/or options via the command-line.

Can this type of vulnerability be exploited to introduce a remote code execution vulnerability? The answer is, some will and some will not. All of the issues presented above, will require that the vulnerable programme is executed with a malicious command-line argument in order to cause any damage, and this is just not a realistic scenario. This could be done by sending a maliciously constructed scripting file to the user and attempting to trick him/her into executing it but again, this is highly unlikely, as scripting files are considered un-safe and will not likely make it to the user, due to restrictions within the software packages (e.g. e-mail and instant messaging clients, etc.) via which the attacker will possibly try to send the malicious scripting file. In other words, there is not vector.

Some of you may be asking how long the vulnerabilities mentioned above have been common knowledge and the answer is, a very long time. Most of these vulnerabilities are well known and date back to as far as 2002 and 2003. The only recent issue is the one identified in the Rpc locator executable, which I reported to Microsoft on the 24th of May 2010. You can expect no fixes for any of these issues as the likelihood of them being exploited is very low due to the previously mentioned, non-existing attack vector.

While fuzzing is fun, it’s just not good enough when attemtping to identify more complex vulnerabilities. Specially crafted payloads required to reach a specific branch of code-execution will require an in-depth analysis of the functionality. This in-depth analysis will enable you to construct just the right composition of data that will ensure your data’s contact with the vulnerable code, and this is when things really start to happen.

For fun, I have written a small PoC, which calls the Rpc locator executable with a long command-line argument. It can be downloaded here: Rpc Locator PoC (38)

  • Share/Bookmark
Leave a Comment :, more...

WinAsm *.WAP File Buffer Overflow Vulnerability

by sharpe on May.28, 2010, under Security, Vulnerabilities

Summary

A vulnerability has been discovered in WinAsm Studio, which can be exploited by malicious, anonymous individuals to compromise a vulnerable system.

The vulnerability is caused as a result of improper bounds checking when reading *.WAP files. This can be exploited to cause a stack-based buffer overflow by tricking a user into opening a maliciously constructed WinAsm project.

Successful exploitation of this vulnerability enables execution of arbitrary code.

Affected Versions

This vulnerability is confirmed in the following versions:

  • WinAsm Studio 5.1.8.0

Other versions may also be affected.

Screen Dumps

The following screen dump illustrates this issue:

Resolution

There is currently no fix for this issue.

Time-line

  • Vulnerability identified: 20.05.10
  • Vendor informed: 27.05.10
  • Vendor fix: Currently unavailable

References

  • Share/Bookmark
Leave a Comment :, , more...

Enter Spy Eye – The Rise of Another Botnet

by sharpe on May.27, 2010, under Malware, Security

Originally posted on opensc.ws the 2nd of January 2010, the Spy Eye information theif appears to be a very promising info-stealer with much functionality, similar to that of the notourius ZBot. Spy Eye, which could originally be purchased for 500 USD, currently costs 1000 USD and contains much functionality including the following:

  • Form-grabbing
  • Password stealing
  • API-hooking
  • PHP/MySQL cpmtrol panel
  • Daily back-ups sent via e-mail
  • Multiple protocol grabbing
  • Hides it in other processes
  • Creates invisible files/autorun keys
  • Operates in ring 3
  • Works on Windows 2000 -> 2007

What do you get for your money? You get a promising way to help earn you a quick buck. And with the proper choice of pay-per-install in place, your chances go up even more. Spy Eye is comprised of two main components; the builder, which builds the individual Spy Eye servers, and the drop-site/command and the control server, which is the PHP/MySQL web-application where harvested information is posted/bots are controlled.

The builder is a Win32 application, programmed in C++, which can be used to create server components. The builder provides the possibility for the user to specify settings, used by generated servers. Here is a list of the options:

  • Path to the main control panel
  • Alternative path to the main control panel
  • Path to the formgrabber control panel
  • Encryption key
  • Connector interval (in seconds)
  • UPX compression option
  • Kill Zeus option

The Spy Eye server, when executed on a system, injects itself into explorer.exe and creates a new section within the process with read, write, and execute permissions. Spy Eye then calls a LPTHREAD_START_ROUTINE routine, which resides within the injected section located in explorer.exe’s memory space. This is done using the CreateRemoteThread() API. Shortly after, the Spy Eye server termimates execution by calling ExitProcess(). Spy Eye, from within explorer.exe, then begins writing files to disk including the following:

  1. C:\cleansweep.exe\
  2. C:\cleansweep.exe\cleansweep.exe
  3. C:\cleansweep.exe\cleansweepupd.exe
  4. C:\cleansweep.exe\config.bin

The Spy Eye payload is executed every time the system boots by adding the path to the payload (2) to the Run Registry Key. Configuration data is stored in encrypted form within the Spy Eye binary and is read using the LoadResource(). This configuration data includes the information defined in the builder as previously mentioned.

While Spy Eye boasts of being able to kill Zeus, the current implementation of this functionality is limited to Zbot versions 1.4 and prior, as it appears only to monitor two Zbot mutexes, illustrated below:


<snip>

if (strstr((LPSTR)name, "__SYSTEM__") || strstr((LPSTR)name, "_AVIRA_")) {

...

}

</snip>

If you’re interested in viewing the entire source code, search the web for the following: C++ Zeus Killer [SOURCE].

Will this spark the beginning of yet another bot war? Let’s watch and see.

Based on the Insight-article entitled: Technical Analysis of the Spy Eye Trojan (CSIS).

  • Share/Bookmark
Leave a Comment :, , , more...

DNA FAT – DNA Frequency Analysis Tool

by sharpe on May.20, 2010, under Molecular Biology, Utilities

DNA-FAT performs a very rapid indexation of the uniqueness and repetitative buildup of fasta format DNA sequences using user assigned window sizes.

The two output files contain the following:

  1. The number of unique sequences with the preset window size and the number of sequences present, any number of multiple times.
  2. Output of the actual sequences themselves and their number of repetitions in the input DNA sequence.

One of the possible uses of the program is to evaluate the required DNA sequencing length of the new next-generation sequencing technologies such as Illumina’s Genome Analyzer and ABI’s SOLiD platform, to predict a high number of unique matches when performing techniques such as RNAseq.

Here is a screen-dump of dnafat in action:

Below is an example of an output file using the genome sequences Staphylococcus Aureus USA300 (NC_007793):

DNA-FAT can be downloaded here: dnafat (42)

Progamme idea by Marc Stegger (SSI), written by sharpe.

  • Share/Bookmark
Leave a Comment :, , , more...

The Very Capable Win32.Silon Information Thief

by sharpe on May.12, 2010, under Malware, Security

The Win32.Silon information thief  (hereafter referenced as Silon) is a relitively new information stealer, which surfaced early 2009. It has the ability to steal log-in information and commit financial fraud via many popular online banks. Currently it has been seen it the following two versions (dubbed by CSIS):

  • Win32/Silon.A (SA)
  • Win32/Silon.B (SB)

Due to the fact that the malware doesn’t have its own installation functionality, it relies on installers and other pay-per-install services to set up an infected environment. In order for Silon to properly be able to function, the installer must do the following:

  • Create the registry key: HKEY_CLASSES_ROOT\CLSID\{<value calculated based on the vol ID>}\InprocServer32
  • Add required values to the above key (presented below)
  • Drop the Silon payload to %systemroot%\system32\msjet51.dll (SA) or %systemroot%\system32\msls50.dll (SB)
  • Alter the predefined value specified in HKEY_CLASSES_ROOT\CLSID\{50D5107A-D278-4871-8989-F4CEAAF59CFC}\InprocServer32\(Default) so it points to the Silon payload (originally set to C:\WINDOWS\system32\msimtf.dll)

The above information can of course also be used when attempting to identify the presence of Silon. That’s more or less it. When Internet Explorer is run, the Silon module will be executed instead of the previously defined module, and will run within the context of the Internet Explorer process. Upon execution, the Silon module throws more than 28000 exceptions in an attempt to cause analysis confusion via the lock xor eax,eax instruction. The exception handler is responsible for decrementing the counter, initially set to 6E00h/28160d (the number of exceptions) until it is equal to zero.

I have implemented a simplified version of the mentioned exception joy in challenge nine, so if you’re curious about how it works, debug challenge nine (58).

Eventually, RtlAllocateHeap is called to allocate heap space to which the encrypted instructions are written. This encrypted data is then xor’ed with the static dword key DC887163h and then rolled to the right (ror) by the hex value 39h. If you step into and follow this loop for a few interations, you will be able to see the decrypted executable (MZ…) beginning to take form. The code is then copied to the original entry point of the executable. After the copying is done, the module is unprotected.

Silon has some nice functionality including API patching, which enable it to handle calls to wininet.dll specific APIs prior to the actual called API itself. Application data is then at the disposal of the malwware until code execution returns to the called API. Silon patches the following APIs:

  • InternetCloseHandle
  • HttpQueryInfoA
  • InternetReadFile
  • InternetQueryDataAvailable
  • HttpSendRequestA
  • InternetSetStatusCallBackA
  • InternetQueryOptionA
  • HttpSendRequestW
  • InternetReadFileExW
  • InternetReadFileExA

Data intercepted via the patched APIs is logged locally prior to being sent to drop-servers in the %systemroot%\Temp directory, the file name equal to the current computers volume id, hyphen not included. All configuration and drop-site information is stored in the registry under the previously mentioned key in encrypted (RC4) form, and is illusrated in the screen-dump below (truncated due to file size):

The following provides an explanation for the above mentioned encrypted data written to the registry by the installer:

  • 0: Injected HTML data (e.g. fields and forms)
  • 1: Command & Control
  • 3: Control data
  • 4: Control data

The Silon gang mean business, so we can expect to see some new versions in the future.

  • Share/Bookmark
Leave a Comment :, , more...

WinAsm *.RC File Buffer Overflow Vulnerability

by sharpe on Apr.12, 2010, under Security, Vulnerabilities

Summary

A vulnerability has been discovered in WinAsm Studio, which can be exploited by malicious, anonymous individuals to compromise a vulnerable system.

The vulnerability is caused as a result of improper bounds checking when reading *.RC files. This can be exploited to cause a stack-based buffer overflow by tricking a user into opening a maliciously constructed WinAsm project.

Successful exploitation of this vulnerability enables execution of arbitrary code.

Affected Versions

This vulnerability is confirmed in the following versions:

  • WinAsm Studio 5.1.8.0

Other versions may also be affected.

Screen Dumps

The following screen dump illustrates this issue:

Resolution

There is currently no fix for this issue.

Time-line

  • Vulnerability identified: 01.04.10
  • Vendor informed: 06.04.10
  • Vendor fix: Currently unavailable

References

  • Share/Bookmark
Leave a Comment :, , more...

Crimson Editor Dictionary File Buffer Overflow Vulnerability

by sharpe on Apr.03, 2010, under Security, Vulnerabilities

Summary

A vulnerability has been discovered in Crimson Editor, which can be exploited by malicious, anonymous individuals to compromise a vulnerable system.

The vulnerability is caused as a result of improper bounds checking when reading words from dictionary files. This can be exploited to cause a stack-based buffer overflow by tricking a user into using a maliciously constructed dictionary file.

Successful exploitation of this vulnerability enables execution of arbitrary code.

Affected Versions

This vulnerability is confirmed in the following versions:

  • Crimson Editor SVN263 English
  • Crimson Editor 3.70 Release (Freeware)

Other versions may also be affected.

Screen Dumps

The following screen dump illustrates this issue:

Resolution

Update to Crimson Editor SVN286 English:

  • http://sourceforge.net/projects/emeraldeditor/

Time-line

  • Vulnerability identified: 02.01.10
  • Vendor informed: 25.03.10
  • Vendor fix: 02.04.10

References

  • Share/Bookmark
Leave a Comment :, , more...

Crimson Editor Configuration File Buffer Overflow Vulnerability

by sharpe on Mar.18, 2010, under Security, Vulnerabilities

Summary

A vulnerability has been discovered in Crimson Editor, which can be exploited by malicious, anonymous individuals to compromise a vulnerable system.

The vulnerability is caused as a result of improper bounds checking when reading configuration files. This can be exploited to cause a stack-based buffer overflow by tricking a user into using a maliciously constructed configuration file (cedt.cfg).

Successful exploitation of this vulnerability enables execution of arbitrary code.

Affected Versions

This vulnerability is confirmed in the following versions:

  • Crimson Editor 3.70 Release (Freeware)

Other versions may also be affected.

Screen Dumps

The following screen-dump illustrates the result:

A PoC configuration file can be downloaded here.

Resolution

The vendor is currently working on an update for the affected products.

Time-line

  • Vulnerability identified: 01.08.09
  • Vendor informed: 10.08.09
  • Vendor fix: Currently unavailable

References

maliciously

  • Share/Bookmark
Leave a Comment :, , more...

RCE Challenge – nine

by sharpe on Dec.20, 2009, under Challenges, Reverse Code Engineering

My last reverseme was too easy due to the nature of the code de-obfuscation key length and usage. This time I have made some minor changes to precisely this portion of the code. Furthermore, I have added some anti-debugging stuff that I observed in a piece of malware. I hope you enjoy.

Here is a screen dump of this reverseme:

It can be downloaded here: nine (58).

  • Share/Bookmark
Leave a Comment :, more...

Golden FTP Server File Deletion Vulnerability

by sharpe on Nov.18, 2009, under Security, Vulnerabilities

Summary

An input validation error has been discovered in Golden FTP Server, which can be exploited by malicious, anonymous individuals to delete arbitrary files.

The vulnerability is caused by an error in the way FTP “DELE” requests are handled. This can be exploited to escape the FTP root and delete arbitrary files on the affected system by using the “../” character sequence.

Successful exploitation of this vulnerability requires that the “Enable full control” option is enabled.

Affected Versions

This vulnerability is confirmed in the following versions:

  • Golden FTP Server 4.30 Free
  • Golden FTP Server 4.30 Professional

Other versions may also be afected.

Exploit Example

use strict;
use Net::FTP

my $ftp = Net::FTP->new(“192.168.1.35″, Debug => 1) || die $@;

$ftp->login(“anonymous”, ‘anonymous@local.host’) || die $ftp->message;

# The FTP root is, via the configuration, set to C:\ftp\public
$ftp->cwd(“/public/”) || die $ftp->message;

# This deletes the file C:\bollocks.txt
$ftp->delete(“../../bollocks.txt”);

$ftp->quit;

$ftp = undef;

Resolution

Update to version 4.70 Free or Professional.

Time-line

  • Vulnerability identified: 29.10.09
  • Vendor informed: 11.11.09
  • Vendor fix: 17.02.10

References

  • Share/Bookmark
Leave a Comment :, more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Blogroll

A few highly recommended websites...