Hello, in this post, we will do malware analysis and reverse engineering of VIP Keylogger.

The file was downloaded from MalwareBazaar

The SHA256 hash of the file is as shown below,

d6255b39e2be431e6226c8414b75721a16c114960f8a87acc06ea9fa7563006f

The file is being flagged by 4 security vendors as malicious.

vip keylogger virustotal result

The file opened in Notepad appears to be obfuscated.

obfuscated script in notepad

The data present within %% can be replaced to create a meaningful batch command, i.e., the first line can be evaluated as @echo off.

deobfuscated first line

We replaced the first few lines to deobfuscate,

deobfuscated few lines

The deobfuscated lines above yield the current file’s full path when executed,

variable returns file fullpath

The preceding few lines execute the current batch file with a minimized window and also copy itself to the user profile directory with the name aoc.bat.

execute and copy to user profile directory

All the next lines contain similar obfuscation,

redudnant data between percentage

We can use the regex %([a-z]{15}+)% to replace the data to create meaningful statements within a batch script.

regex replace unusable code

Once replaced, we can observe data being set to variables.

data after regex replace

After the deobfuscation, we can see those variables being concatenated at a later point within the script.

variables concatenated afterwards

NOTE: Don’t replace the regex entirely within the file. Since the replacement will also remove the code where data is being concatenated, it will make the script unexecutable.

issue due to regex replace

The concatenated string contains 229 variables for replacement. We use the previously deobfuscated data after regex replace to print the concatenated output to the console.

echo data to be concatenated batch script

The data is,

decoded concatenated data

Finally, we replace the remaining lines with the previously mentioned regular expression to produce the deobfuscated batch script.

entire deobfuscated script

The console output of concatenated data from various variables, after being deobfuscated, results in another PowerShell command, as shown.

concatenated deobfuscated powershell command

The PowerShell command contains a string that contains a replacement of “ghobbwnmfz”. We replace the following to get another string within the PowerShell command as

replaced powershell command

The formed string after replacement contains a base64 encoded string, which we decode using CyberChef.

base64 decoded powershell command

The decoded string, in turn, contains another PowerShell script.

embedded powershell script beautified

The script extracts data in parts that start with :::[1-4] from the initial batch script that copied itself to user profiles with the name aoc.bat

parts extraction from initial script

The following are the parts extracted.

extracted parts

The extracted parts are being concatenated, replaced, and base64 decoded.

parts concatenated replaced decoded

Equivalent output of the above operation using CyberChef,

parts concatenated replaced decoded cyberchef

The output contains PowerShell script that contains functions, as shown below,

powershell functions

In short, the functions perform the following operations,

Function Description
Initialize-FlowerGarden Initializes the environment variables
Setup-FlowerPolicy Sets the execution policy to bypass/unrestricted
Disable-FlowerLogging Disables event logging
Setup-FlowerEnvironment Disables/tweaks AMSI
Perform-FlowerMaintenance Disables/tweaks AMSI

Further, the variable $orange also contains base64 encoded data that is being decoded and uncompressed using gzip.

orange encoded data

Cyberchef would help to decode this as follows,

orange decoded data

Yet another PowerShell script is being shown as output.

final powershell script

Unlike the last PowerShell script that extracted parts from the initial script containing :::[1-4], this script extracts :: from the initial script located in the user profile directory for performing further operations,

final powershell script data extracted

The extracted data is being split with \ to create an array containing two elements. Afterward, respective elements are base64 decoded. Then, it was decrypted using AES and uncompressed using gzip.

final powershell script data split decoded

The decoded output is,

cyberchef decoded base64 final

The first part, after performing the previously mentioned operations, results in an executable file,

first exe

The second part, after performing the previously mentioned operations, also results in an executable file,

second exe

Thank you for being up to here. We will continue the analysis in the next part for the executables uncovered.

to be continued