The turnout failed: we bring AgentTesla to clean water. Part 1
Recently, Group-IB was approached by a European electrical equipment manufacturer after an employee received a suspicious email with a malicious attachment in the mail. Ilya Pomerantsev, a malware analysis specialist at CERT Group-IB, conducted a detailed analysis of this file, found the AgentTesla spyware there and told what to expect from such malware and why it is dangerous.
With this post, we open a series of articles on how to analyze such potentially dangerous files, and we are waiting for the most curious on December 5 for a free interactive webinar on the topic "Malware analysis: analysis of real cases". All the details are under the cut.
Propagation mechanism
We know that malware entered the victim's machine via phishing emails. The recipient of the letter was probably placed in a blind copy.
Header analysis shows that the sender of the email was spoofed. In fact, the letter went from vps56[.]oneworldhosting[.]com.
In the attachment of the letter there is a WinRar archive qoute_jpeg56a.r15 with a malicious executable QOUTE_JPEG56A.exe inside.
HPE ecosystem
Now let's see what the ecosystem of the malware under investigation looks like. The diagram below shows its structure and directions of interaction of components.
Now let's take a closer look at each of the malware components.
Loader
Original file QOUTE_JPEG56A.exe is a compiled AutoIt v3 script.
To obfuscate the original script, an obfuscator with similar PELock AutoIT-Obfuscator characteristics.
Deobfuscation is performed in three stages:
Removing obfuscation For If
The first step is to restore the control flow of the script. Control Flow Flattening is one of the most common ways to protect application binary code from analysis. Obfuscating transformations dramatically increase the complexity of extracting and recognizing algorithms and data structures.
String recovery
Two functions are used to encrypt strings:
gdorizabegkvfca - performs Base64-like decoding
xgacyukcyzxz - simple byte XOR of the first string with the length of the second
Removing obfuscation BinaryToString ΠΈ Run
The main load is stored in a separated form in the directory Fonts file resource section.
The order of gluing is as follows: TIEQHCXWFG, MY, SPDGUHIMPV, KQJMWQQAQTKTFXTUOSW, AOCHKRWWSKWO, JSHMSJPS, NHHWXJBMTTSPXVN, BFUTIFWWXVE, HWJHO, AVZOUMVFRDWFLWU.
To decrypt the extracted data, use the WinAPI function CryptDecrypt, and the session key generated based on the value is used as the key fZgFiZlJDxvuWatFRgRXZqmNCIyQgMYc.
The decrypted executable file is input to the function RunPEwhich carries out ProcessInject Π² RegAsm.exe using the built-in ShellCode (also known as RunPE ShellCode). Copyright belongs to a Spanish forum user indetectables[.]net under the nickname Wardow.
It is also worth noting that in one of the threads of this forum, an obfuscator for AutoIt with similar properties revealed during the analysis of the sample.
To say more about ShellCode quite simple and attracts attention only borrowed from the AnunakCarbanak hacker group. API call hashing function.
We also know the use cases French Shellcode various versions.
In addition to the described functionality, we also identified inactive functions:
Blocking manual termination of a process in the task manager
Restarting a child process if it terminates
Bypass UAC
Saving the payload to a file
Demonstration of modal windows
Waiting for the mouse position to change
AntiVM and AntiSandbox
Self-destruction
Downloading the payload from the network
We know that such functionality is typical for the protector CypherIT, which, apparently, is the bootloader under study.
The main module of malware
Next, we will briefly describe the main malware module, and consider it in more detail in the second article. In this case, it is an application on . NET.
During the analysis, we found that an obfuscator was used ConfuserEX.
IELibrary.dll
The library is stored as a core module resource and is a well-known plugin for agent Tesla, which provides functionality for extracting various information from Internet Explorer and Edge browsers.
Agent Tesla is a modular malware-as-a-service spyware package disguised as a legitimate keylogger product. Agent Tesla is capable of extracting and transmitting user credentials from browsers, email clients and FTP clients to the server to attackers, registering clipboard data, and capturing the device screen. At the time of the analysis, the official website of the developers was unavailable.
The entry point is the function GetSavedPasswords Internet Explorer class.
In general, the execution of the code is linear and does not contain means of protection from analysis. Only unrealized function deserves attention GetSavedCookies. Apparently, the functionality of the plugin was supposed to be expanded, but this was never done.
Fixing the bootloader in the system
Let's study how the bootloader is fixed in the system. The examined instance does not perform pinning, however, in similar events, it occurs as follows:
In the folder C:UsersPublic a script is created Visual Basic
Sample script:
The content of the loader file is padded with a null character and saved to the folder %Temp%<Custom folder name><File name>
An autorun key is created in the registry for the script file HKCUSoftwareMicrosoftWindowsCurrentVersionRun<Script name>
So, according to the results of the first part of the analysis, we were able to establish the names of the families of all components of the malware under study, analyze the infection scheme, and also obtain objects for writing signatures. We will continue the analysis of this object in the next article, where we will take a closer look at the main module agent Tesla. Do not miss!
By the way, on December 5, we invite all readers to a free interactive webinar on the topic "Malware analysis: analysis of real cases", where the author of this article, a CERT-GIB specialist, will show online the first stage of malware analysis - semi-automatic unpacking of samples using the example of three real mini-cases from practice, and you can take part in the analysis. The webinar is suitable for specialists who already have experience in analyzing malicious files. Registration strictly from corporate mail: Register. Waiting for you!