Practical Malware Analysis Notes (2)
LAB03-01.exe
1. Find the malware’s imports and strings
I started with a strings search. The results include:

A URL appears, along with VideoDriver, ws2_32.dll, and vmx32to64.exe, whose name suggests converting video from 32-bit to 64-bit. There are also two registry keys, SOFTWARE\Microsoft\Windows\CurrentVersion\Run and SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders, associated with startup. Running it in Process Explorer and checking its DLLs shows that dnsapi.dll handles DNS queries.
2. What are its host-based indicators of infection?
It modifies the registry, writing C:\WINDOWS\system32\vmx32to64.exe to HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\VideoDriver for automatic startup, and writes the file to C:\Windows\system32\vmx32to64.exe.

Comparing the hashes shows that vmx32to64 is the LAB03-01.exe sample.

It makes DNS requests. I tried apateDNS, but the framework failed; reinstalling did not help. Looking it up suggested the software cannot run on XP. Fortunately, Wireshark is available.
Wireshark shows a DNS request for the IP address of www.practicalsmalwareanalysis.com:

The observed sequence is SSL setup, a DNS lookup, and then SSL traffic to the returned address.
3. Are there useful network signatures? If so, what are they?
The strings search provides these clues:

HTTP/1.0, 503, and 200 are HTTP network signatures.
To learn more, I checked the file in PEID, which identified a junkcode packer.

I first tried a general-purpose unpacker:

That failed, so I tried unpacking it manually in OD.

The entry point behaves strangely: after a few F8 steps, the program exits. I used F7 to step into the call instead.

This is a normal function entry, with even a push of ASCII “ws2_32”. But using F4 at ws2_32 exits immediately, so manual unpacking fails. That concludes this analysis.
Lab03-02.dll
1. How can you get the malware to install itself?
Use the built-in rundll32.exe and run rundll32.exe Lab03-02.dll,installA. First, inspect the export list with PEView to understand why the export is InstallA.

Exports include Install, ServiceMain, UninstallService, installA, and UninstallA. The first install appears related to a service; installA is another important target for analysis. Inspect strings with strings.

The strings suggest several registry operations involving SOFTWARE\Microsoft\Windows NT\CurrentVersion\Svchost.
I used IDA to inspect the imports, since Dependency Walker was rather slow.

GetCurrentDirectoryA gets the current directory.
CreateServiceA and DeleteServiceA create and delete services.
RegCloseKey, RegCreateKeyA, RegOpenKeyExA, RegQueryValueExA, RegSetValueExa, and others manipulate registry values.
The strings view in IDA revealed another set of clues:

There appear to be base64-encoded strings and a base64 alphabet. Decoding them yields connect|unsupport|sleep|cmd|quit, suggesting the program can call cmd. There is also a website.
2. How can you run the malware after installing it?
Run rundll32.exe Lab03-02.dll,installA. First take a registry snapshot because the program modifies the registry; then use net start IPRIP to start it.

In this test, calling Install and InstallA produced the same result.
After running it, compare the registry snapshot to see what changed:

3. How can you find which process is running the malware?
There is now an additional service named IPRIP:


The service runs inside svchost.exe under the respectable-sounding name Intranet Network Awareness (INA+).
Start the service with net start IPRIP and look for the service and filename in Procmon.
4. What Procmon filter can collect information about the malware?

The filter locates the malicious code attached to the system service.
5. What are its host-based indicators?
An IPRIP service remains in the background. Analyze its traffic with Wireshark (ApateDNS will not run on XP, even with .NET Framework installed).

6. Are there useful network signatures?
The connect string seen earlier, HTTP GET/1.1, and so on.
LAB03-03.exe
1. What do you notice while monitoring with Process Explorer?
I began with static analysis in IDA before monitoring the sample:

The strings are mostly simple error messages and garbled text. Next I looked at the import table:

The imports show that it can manipulate memory and files. I then monitored it with Process Explorer.
On execution, Lab03-03.exe appears, creates svchost.exe, and disappears almost immediately. After a few attempts, find the new svchost.exe.

The disguise is not very convincing: the new process is left on its own as an orphan.
2. Can you identify memory modifications?

The original image differs from the image in memory, which includes additional keystrokes. It may be a keylogger.
3. What are its host-based indicators?
A new file named practicalmalwareanalysys.log appears. It looks like a log, so I opened it:

Sure enough, it contains recorded keystrokes.
4. What is the malware’s purpose?
It records keystrokes, generates a log, and sends it to a directory. I found no networking module, so it does not upload it; it resembles the Gray Pigeon Trojan.
Lab03-04.exe
1. What happens when you run the file?
As before, I first checked for a packer and then performed static analysis in IDA.

Fortunately, this file is not packed.
I opened it in IDA:

The imports show obvious socket send and receive operations, as well as execution of Shell commands
and operations on files and the registry.
Then I looked at its strings:


They include common error messages, command.com, days and months, a cmd invocation, and a \c del deletion command. Go to the call to cmd.exe.
2. Why is dynamic analysis ineffective?
The program deletes its own file, which makes it difficult to run repeatedly under observation.
3. Is there another way to run it?
Since the file deletes itself, go to the function containing the cmd.exe call.

It executes the shell command filename+\c del + >> NUL.
Following the function’s cross-references shows that main() calls it:

The program logic shows that several arguments must be supplied at runtime and checked. Step into the final argument validator sub_402510() (I rename functions to simplify reverse engineering).
The first check shows that if three arguments are supplied, the last must be abcd.

The program chooses an operation based on the first argument, so I continued reversing the other functions.

It opens and looks up the Configuration value under HKEY_LOCAL_MACHIME\SOFTWARE\Microsoft\XPS.

At this point, one way to run it becomes clear: execute it on the command line with an argument such as -cc, and have the relevant value in the registry. The approximate command is:
Lab03-04.exe -cc abcd
I tested that invocation:

The sample now runs repeatedly without the file disappearing. That makes it possible to continue the investigation using OD and IDA, although I will not go into that analysis here.


