back to write-ups
PMA April 15, 2025

PMA Lab 20-1: C++ Analysis

The purpose of this first lab is to demonstrate the usage of the this pointer. Analyze the malware in Lab20-01.exe.

pmachapter-20

Lab 20-1

The purpose of this first lab is to demonstrate the usage of the this pointer. Analyze the malware in Lab20-01.exe.

Questions

1) Does the function at 0x401040 take any parameters?

The function doesn’t take any parameters. However, there’s a value moved to ecx prior to the call, which is a pointer to the this object:

image-20250410234405590

Entering the Function and using IDA’s pseudocode, we can see the thiscall calling convention being used:

image-20250410234606968

2) Which URL is used in the call to URLDownloadToFile?

The URL used is passed to the function as a “this pointer”.

image-20250410234911872

The pointer (aHttpWww_practi) points to the following buffer:

http://www.practicalmalwareanalysis.com/cpp.html

image-20250410235029955

3) What does this program do?

This program is rather simple. It passes an URL to sub_401040, and inside this function there’s a call to URLDownloadToFileA. The second parameter (URL) is passed by the “this pointer”, and the rest of the parameters are possible to see in the following image:

image-20250410235135188

Thus, basically this program will download the cpp.html file from the previously mentioned C2 server, and store it as C:\tempdownload.exe.