Practical Malware Analysis Notes (1)

Analysis of LAB01-01.dll and LAB01-01.exe

First, I submitted the file to www.virustotal.com for online analysis:

image-20191201015128319.png

Most antivirus engines identify it as a Trojan.

The result for LAB01-01.exe:

image-20191201015401592.png

The executable receives a result similar to the DLL.

Next, I moved the samples into a virtual machine for closer inspection.

image-20191201015743894.png

LAB01-01.dll is not packed: it is an ordinary dll compiled with VS6. Its code section is easy to identify, and it also has a relocation section.

image-20191201015854401.png

LAB01-01.exe is not packed either. It is a regular VC6 executable, again with a recognizable code section.

I used strings to look for clues inside LAB01-01.exe:

image-20191201020213238.png

Besides the basic KERNEL32.DLL and MSVCRT.DLL, there are suspicious API calls such as CreateFileA and CopyFileA. The strings suggest that the program copies lab01-01.dll to C:\Windows\system32\kernel132.dll, renames it, then finds and calls it.

Next I checked the DLL’s strings:

image-20191201020523141.png

WS2_32.dll is used for network socket programming, and there is a private IP address that may be used for communication. APIs such as CreateMutexA and OpenMutexA perform atomic mutex operations; there are also handle creation functions. This may be a background process.

Dependency Walker gives another view of the functions imported by the DLL:

image-20191201021058507.png

The imports include mutex operations, handle management, process creation, and sleep. Together they suggest a process that remains in the background.

To test that hypothesis, I opened the sample in IDA.

image-20191201021627627.png

A closer look in the disassembler supports the earlier hypothesis.

The first check stops the program unless its argument is WARNING_THIS_WILL_DESTROY_YOUR_MACHINE.

It disguises LAB01-01.dll as kerne132.dll, copies it into the original kernel32.dll, and calls the DLL to run the Trojan.

Analysis of LAB01-02.exe

1. Inspect it on www.virustotal.com

image-20191201023013670.png

The scan identifies this sample as another Trojan.

2. Check for packing

image-20191201022726924.png

image-20191201023140215.png

It is packed with UPX, a simple packer. Experts can unpack it manually using the ESP method; I use a tool. The absence of common code sections such as .text prevents normal disassembly.

I unpacked it with upx -o newFilename -d originalFilename:

image-20191201023324229.png

I then checked the unpacked file again in PEiD:

image-20191201023428540.png

7. The result is immediate; inspect the strings

image-20191201023535092.png

3. Inspect imported functions

We can see functions for network programming with WININET.DLL, obtaining the module name, creating processes and mutexes, opening Internet Explorer, and opening a URL in IE. The URL itself appears below.

4. Signs of infection

A likely sign of infection would be the affected computer opening the website shown in the strings.

6. Analyze with Study_PE

image-20191201024237851.png

Imports include common functions such as CreatMutexA, SystemTimeToFileTime, ExitProcess, and CreateThread.

wininet.dll is the Windows application networking module, responsible for communication such as opening the URL shown.

advapi32.dll provides advanced APIs for the registry, functions and objects, event logs, and more.

7. The purpose of the Malservice string

My guess is that the malware installs itself as a background service and runs at a particular time.

I opened the sample in IDA to check that theory:

image-20191201025127570.png

The code does indeed install the sample as a service and run it.

image-20191201025459146.png

Further call analysis confirms the hypothesis. The mutex is named HGL345, and after the service is created, the website is opened 20 times.

Analysis of lab01-03.exe

1. Upload for analysis

image-20191201030147123.png

The scan produces many detections. The first engine only marks the file as suspicious; the next two identify it as a Trojan.

2. Check for packing and unpack

image-20191201030338150.png

There are no section names, and the packer is FSG 1.0. I searched for more information about the packer.

image-20191201030619188.png

The online instructions all involve manual unpacking, so I use an unpacking tool from my collection.

image-20191201031223878.png

This time the unpacking succeeded.

Looking at the unpacked file’s import table in Dependency Walker reveals two unusual DLLs.

image-20191201031547803.png

Looking them up shows that they support object linking and embedding, functions for advanced object-oriented programming. The call table shows nothing unusual, so inspect the other DLLs.

image-20191201032031719.png

The other DLLs do not reveal anything especially unusual either: their functions cover file operations and a beep. A strings search turns up little apart from a suspicious URL.

image-20191201032228890.png

I turned to IDA for a closer look.

image-20191201032336500.png

It appears to create an object. I did not know what SysAllocString() did, but Microsoft’s documentation describes it as a copying operation in Ole32.dll.

4. Signs of infection

My guess is that it allocates the URL in memory and creates an object for it, probably to visit the site.

Running the sample in a virtual machine confirmed that it visits the site.

Analysis of lab01-04.exe

1. Upload for analysis

image-20191201032950875.png

Many engines flag it as a Trojan, with some identifying it as a downloader for other Trojans.

2. Check for packing and unpack

image-20191201033048021.png

Fortunately, this sample is not packed.

3. Find when the file was compiled

image-20191201033305211.png

The site clearly gives its creation time as 2019-08-30 22.26.59.

4. Use imports to infer the program’s function

image-20191201113735463.png

It can manipulate files and create remote threads, possibly for remote control. It also obtains program addresses and the temp directory. Nothing else looks unusual, although it obtains extensive permissions.

I also searched the file’s strings:

image-20191201114110519.png

The results include a URL and a DLL used to open URLs.

5. Signs of infection

The URL and URL-related process refer to an EXE. The program may download that executable to the computer’s temp directory.

6. Extract the resource

In PEview, I found an unusual section inside .rsrc:

image-20191201114642739.png

The section has the same descriptive text seen earlier, suggesting that it contains executable code.

I extracted the resource with Resource Hacker so I could inspect it separately:

image-20191201115135826.png

This is the section I was looking for.

Next I checked the extracted file in PEID:

image-20191201115334824.png

Fortunately, the extracted file is not packed either.

I searched its strings for further clues:

image-20191201115449765.png

The same URL appears again, suggesting that the interesting behavior is in this extracted file. I opened it in IDA.

image-20191201115701299.png

It appears to download the file to the system tmp directory, disguise it as \System32\wupdmgrd.exe, and execute it on the command line.