Phantom, a stealer malware, sends back sensitive data like passwords, browser cookies, credit card information, crypto wallet credentials, victim’s IP addresses, etc to the attacker. This can be used in identity theft, account takeovers or even worse the infected machine can be used as a tool to orchestrate bigger malware attacks.

With the increased use and vast amount of files that are available on the internet, most oblivious users fail to differentiate between safe and malicious content they are downloading. In this blog, we will delve into a stealer named Phantom version 3.5 and its initial vector.

This blog is targeted towards cybersecurity enthusiasts and aspiring malware researchers. It all starts with a file ‘Adobe 11.7.7 installer’ which in our case is obviously a fake name. It was first submitted to VirusTotal on 29th Oct this year.

Fig 1: Fake installer first seen

Fig 2 shows the execution flow of the malware. The file is an obfuscated .xml file with a JavaScript embedded within. The best way to know what a file does is to execute it in a sandbox environment. This is part of our routine analysis.

Fig 2: Malware execution flow
Fig 3: Adobe 11.7.7 installer file dynamic analysis

From dynamic analysis of our installer named file we can see that it contacts the URL hxxp[:]//positivepay-messages.com/file/floor[.]ps1 and downloads the file floor.ps1. Looking closely at the contents we observed that most of the code is obfuscated but some strings are visible in plain text and it is enough to understand what it does. As you can see in the following image, the script downloads a PowerShell script from the URL ‘hxxps[:]//positivepay-messages.com/file/floor[.]ps1’.
It executes the script using PowerShell with hidden attribute and bypassing PowerShell feature that consents to the user before executing any script.

Fig 4: downloader

Also, we can see references to legitimate Windows executable ‘Aspnet_compiler.exe’, run entries to create persistence, taskkill commands to kill the PowerShell process, etc.

Fig 5: Identifiable Strings

Looking at the PowerShell script that was being downloaded ‘floor.ps1’ as shown in Fig 6, we see a base64 string stored in a variable.

 Fig 6: base64 string

This base64 string seems to be RC4 encrypted data. So probably we will find a key somewhere. After scrolling and crashing Notepad++ a few times we reach the variable where the key is stored.

Fig 7: RC4 key and decryption

As we can see the key is in base64. We can use the same script to decode and decrypt the contents or use CyberChef as it is easier. The script executes the decrypted script as shown in Fig 8.

 Fig 8: Executing decrypted script

Let’s move on with the decryption. We can search RC4 in CyberChef’s operation tab. Drag it to the Recipe tab, put the key as it is in the passphrase box and select it as base64. The InputFormat box needs to be selected as base64. Copy the base64 string from the script file and paste it in the input box and voilà! We have the decrypted script. We will save the script and analyse it now.
The decrypted script looks like this:

Fig 9: Decrypted script

After decryption we see a lot of interesting stuff going on.
We see ‘{System.Reflection.Assembly}::Load($RawAssemblyBytes)’. So basically, .NET Common Language Runtime reserves an isolated memory space called managed AppDomain. In this script, RawAssemblyBytes is directly loaded in this memory region. This technique is very common for malwares to evade detection.
It then checks ‘Aspnet_compiler’ if the process is running. It checks it at 5s intervals.
There are base64 encoded strings we can see in Fig 10. Now we copy the base64 string and decode it. On decoding it turns out to be a PE file. Loading this file into CFF explorer, we see it is a .NET file and it is a dll as shown in Fig 11 and Fig 12. On loading it in DIE we can see it is obfuscated.

Fig 10: Encoded base64
Fig 11: .NET file
Fig 12: BLACKHAWK.dll
Fig 13: Obfuscated dll

Since the .NET file is obfuscated we won’t waste time de-obfuscating the whole file. Rather if we go to the User-Strings #US for the file, we can see some interesting strings in Unicode format. WriteProcessMemory, VirtualAllocEx, ResumeThread,etc are names of some of the Windows API functions that programs use to write data into a running process’ memory region. Malwares typically uses these functions to perform Process Injection.

Fig 14: Notable strings in DLL

Moving on to the next set of instructions in the decrypted script. We can see it saves the full file path for Aspnet_compiler.exe into a variable, passes it and a variable called ‘ExecutionPayload’ as parameters to the main method which is ‘Invoke-ManagedAssembly’. This ‘ExecutionPayload’ variable contains binary for a PE file.

 Fig 15: ExecutionPayload

So what is going on in this decrypted script file?
The script first checks if Aspnet_compiler.exe is running, if it does it silently lets it continue running, otherwise it creates the process Aspnet_compiler.exe.
It decodes the base64 encoded dll named BLACKHAWK.dll and loads it into .NET CLR memory region to evade detection.
This BLACKHAWK.dll is an Injector. This dll’s SHOOT method injects the binary stored in the variable ‘ExecutionPayload’ into Aspnet_compiler’s memory region.
If we look at the first 2 comma separated values in the variable ‘ExecutionPayload’ we can see their corresponding ASCII values are M and Z which is the magic number for a PE file.
So we can conclude that a PE file has been injected into Aspnet_compiler.exe’s memory region.
Now we will check if this is actually the case.
First things first, we set up a controlled environment and get tools like ‘hollows_hunter’ and ‘ProcDump’ website. Parallely run ProcessExplorer and ProcessMonitor.
Keeping all the above mentioned tools running in the background except ProcDump as we do not need it for monitoring, we can execute the script happily.
First thing that we see is a process Aspnet_compiler.exe is created. We note down the PID of Aspnet_compiler.exe. ‘hollows_hunter’ lists out all the PIDs for which injection has been made and we can see our Aspnet_compiler.exe PID is one of them. It saves its findings in a log file. The combined screenshot of the log and the process is shown in Fig 16.

Fig 16: log file by ‘hollows_hunter’

ProcessMonitor shows the following behavior as shown in Fig 17.

Fig 17: Script behavior

Some interesting behavior included its repeated TCP connections and the temp files created for exfiltration are deleted.
This type of file names are common in stealers.
‘hollows_hunter’ usually dumps memory regions for injected processes but unfortunately it could not dump it in our case. So we had to rather use ‘ProcDump’ and dump the whole process memory of Aspnet_compiler.exe. After analyzing the dump we could find a PE file within. We did some careful extraction of this file from the dump so that we could analyze it further. Fig 18 left side shows the payload as is in memory and right side shows it after the reconstruction of the PE.

Fig 18: Stealer payload

A VirusTotal lookup for this MD5 showed the first submission date for this file to somewhat match the same date as that fake ‘Adobe 11.7.7 installer’.

Fig 19: Stealer first seen

CFF Explorer shows the .NET directory and its structures which indicates it is a .NET file. Also the PE Characteristics shows it is an executable.

Fig 20: .NET stealer

Since it is a .NET we will load it into dnSpy and see if we can read its code.
On loading it in dnSpy, all its classes and method names are clearly visible as well as its code; what catches our eye is its anti-analysis class.

Fig 21: anti-analysis class method names

To determine if it is run under a controlled environment it matches the user name against a list of usernames. It also checks the same usernames in its lowercase variants. Fig 22 shows few out of 112 hardcoded usernames, Fig 23 shows the code to check lowercase invariants.

Fig 22: Usernames
Fig 23: Lowercase variants

The stealer checks all the components shown in the functions listed in Fig 21. Some more examples are shown in Fig 24.

Fig 24: Some more examples of AntiAnalysis

If we look closely we can see all these functions if matched returns a Boolean value. This value is fetched by the main Function of the AntiAnalysis class. This function seeks the Boolean value and if it is found to be true, invokes a function ‘Melt’. This function is part of the class SelfDestruct as shown in Fig 25.

Fig 25: Main function for AntiAnalysis

We will take a closer look at the ‘SelfDestruct’ class ‘Melt’ function.
As you can see in Fig 26, the function drops a GUID named batch file in the temp directory. It then gets the current process ID and stores it into a variable. Now it starts writing a batch script. It writes task kill PID whose objective is to perform self delete to erase its traces.

Fig 26: ‘melt’ function

Fig 27 shows that the stealer creates a Run entry for persistence.

Fig 27: Persistence

It steals every bit of data available on the system. User credentials, credit card credentials, crypto wallet credentials, wifi passwords, etc. We will discuss only a few of its functionalities.
We will start with some of its browser specific capabilities.

Fig 28: Browser master key

In Fig 28, the stealer extracts AES masterkey and app-bound private keys used for encryption of data in browsers like Chromium, Edge, etc.
Previously we have discussed some anti-analysis techniques, now we will discuss its usermode-hook evasion technique.
It uses a technique called Heaven’s Gate, a technique where an x86 process running under Windows WOW64 switches to 64-bit mode by jumping into the 64-bit code segment. This allows the process to execute 64-bit code or perform native x64 syscalls directly, bypassing the WOW64 layer. Malware commonly uses this to access 64-bit execution paths from within a 32-bit process and evade x86-based monitoring. This allows a malware to evade 32-bit user-mode hooks. In Fig 29 we can see whether it is running 64bit. It attempts to create a duplicate usable handle and this can be used in lower-level operations.

Fig 29: Heaven’s Gate initialization

In Fig 30 we see that it allocates bytes from the process heap in unmanaged memory and copies the stub and payload in the buffer. It makes the page executable by changing memory protections. It then allocates and writes in unmanaged memory for native stub to read it and passes the pointer to the beginning of the payload. The stub switches to x64 and jumps into the payload.

Fig 30: Heaven’s Gate implementation

Now, let’s quickly go through some of the stealer functionalities and wind up our blog.
In Fig 31 it accesses network cookies of Chromium browser, decrypts them and stores them into an array.

Fig 31: Chromium cookies

In Fig 32 and 33 it fetches browser wallet details for Chrome and Edge and copies it to a different location.

Fig 32: Browser wallets
Fig 33: Saves wallets

In Fig 34 we can see information like logins, credit cards are collected from Chromium browser.

Fig 34: Chromium browser stolen info

Fig 35 shows the stealers keylogging capability. It captures the keypresses, differentiates each word by tracking ‘tab’, ‘space’, ‘return’ keys and saves it to a file.

Fig 35: Keylogger

Fig 36 shows data stolen from outlook which is stored with corresponding computer name and time date stamp.

Fig 36: Outlook

Here is a list of all the information stolen that were not covered earlier:

  • Clipboard
  • Desktop wallets
  • Discord credentials
  • Files on the system
  • Filezilla credentials
  • Fox mail accounts and credentials
  • Firefox cookies, credit cards, etc.
  • System Information (Fig 37)
  • Wifi passwords.
Fig 37: System information stolen

Apart from these it also takes a screenshot every 1000ms interval.

Fig 38: Screenshot

For the exfiltration of the collected data it uses various channels like SMTP, FTP protocols. It also uses Telegram to upload the collected information as well as send logs through Discord and Telegram. We will cover only SMTP here. Fig 39 shows how the file is sent over SMTP.

Fig 39: Uploads file over SMTP
Fig 40: SMTP credentials

The SMTP credentials are stored into a base64 encoded value and hardcoded into a variable. The DecryptConfig function shown in Fig 41 decodes the credentials.

Fig 41: DecryptConfig

Protecting one’s PII is crucial in this age of modern internet and AI. We at K7 Labs make it our constant endeavor to find and protect our users from such threats. Although we do our best to safeguard your system and privacy, it is very important as a user to be aware and interact with the intended resources available on the internet.

Users are advised to use a reputable security product like K7 Antivirus software and maintain cyber hygiene to stay safe from such threats.

IOCs

File NameHash
Adobe 11.7.7 Installer01B397CBD39F7DD310CC1252B19DE411
floor.ps1CCCDCBF3C3B6C16AB4743A1289327439
RC4 decrypted scriptF39EFF2188EE90A9CB48CE90A09FEFB3
BLACKHAWK.dll2BE5F6AFA114EE5607D88BC5AEEC4D32
Phantom 3.5 stealer052777DBDE7D784903467ED572F7AAD7

Urls

hxxp[:]//positivepay-messages.com/file/floor[.]ps1

Like what you're reading? Subscribe to our top stories.

If you want to subscribe to our monthly newsletter, please submit the form below.

    0 replies on “Phantom 3.5: Initial Vector Analysis & Forensics”