

















Matanbuchus leverages two primary modules: a downloader module and a main module. In the following sections, we analyze the initial infection vector that was observed in an attack and both of the Matanbuchus modules.
The threat actor performed the following hands-on-keyboard actions to deploy Matanbuchus:
gpa-cro[.]com.HRUpdate.exe, which sideloads a malicious DLL. The malicious DLL payload was the Matanbuchus downloader module.hxxps://mechiraz[.]com/cart/checkout/files/update_info.aspxThreatLabz assesses, with medium confidence, that the threat actor’s actions were intended to deploy ransomware to the victim’s organization.
Both the Matanbuchus downloader and main modules use the following obfuscation methods:

Figure 1: Example of junk instructions in the Matanbuchus main module code.
The downloader and main modules share most of the same anti-analysis features; however, the downloader includes an additional feature: long-running loops. These “busy” loops delay the downloader’s functionality for several minutes after initial execution, allowing it to evade behavioral analysis by sandboxes, which often have low analysis timeout values.
The figure below illustrates one of these long-running busy loops.

Figure 2: Example of junk code and long-running busy loops in the Matanbuchus downloader module.
The downloader module contains an embedded, encrypted shellcode that downloads and executes the main module. The downloader leverages a known-plaintext attack technique to decrypt the shellcode via bruteforce. Matanbuchus initiates a loop that starts with the integer value 99999999. The integer is converted to an 8-byte string and prepended to a 24-byte hardcoded value to create a 32-byte ChaCha20 key. Matanbuchus then attempts to decrypt the shellcode with the ChaCha20 key and a hardcoded 12-byte nonce. Matanbuchus compares the result to the following 21 bytes, which correspond to the first 21 bytes of the shellcode, if decrypted properly.
The 21-byte known-plaintext string is shown below.
E9 A0 00 00 00 55 89 E5 6A 33 E8 00 00 00 00 83 04 24 05 CB 48ANALYST NOTE: The ChaCha20 nonce field is set to the hardcoded array 01 02 03 04 05 06 07 08 09 10 11 12, while brute-forcing the shellcode data.
If the first 21 bytes do not match these values, the integer value is decremented by one and the loop is repeated.
The decrypted shellcode downloads the main module by sending an HTTPS GET request to a hardcoded command-and-control (C2) server and decrypts the payload received using the ChaCha20 stream cipher algorithm. The Python script below represents the decryption method for parsing and decrypting the downloaded payload.
def decrypt_downloaded_payload(data: bytes) -> bytes:
”””
Decrypts a downloaded payload from Matanbuchus. If first bytes are equal to 0xDEADBEEF then Matanbuchus writes the payload into disk.
”””
decrypted_file = bytearray()
payload_data = data[4:]
key = payload_data[:32]
nonce = payload_data[32: 44]
encrypted_data = payload_data[44:]
chunk_size = 0x2000
state = 0
for idx in range(0, len(encrypted_data), chunk_size):
cipher = ChaCha20.new(key=key, nonce=nonce)
cipher.seek(64 * state)
cipher = cipher.decrypt(encrypted_data[idx: idx + 0x2000])
decrypted_file.extend(cipher)
state += 1
return bytes(decrypted_file)Matanbuchus adds persistence to the compromised host by executing shellcode that is retrieved from the C2 server after the registration process (described later) is complete. Specifically, Matanbuchus generates a new file path and passes the value to the shellcode. The shellcode creates a new scheduled task with the name Update Tracker Task and a file path with the format below.
%WINDIR%\\SysWOW64\\msiexec.exe -z %Matanbuchus_path%Matanbuchus generates the random file path with the following steps:
APPDATA folder. The name of the directory is derived from the volume serial number of the disk, as shown in Python below.volume_serial_number = -1
directory_name = f"{volume_serial_number:x}{volume_serial_number >> 2:x}"ANALYST NOTE: Matanbuchus creates a unique, per-host mutex to ensure single execution. The mutex name matches the name of the persistence directory, with the string sync prepended to it.
The main module of Matanbuchus includes an embedded configuration blob, which is stored in an encrypted format. Upon execution, Matanbuchus decrypts the configuration blob using ChaCha20. The first 44 bytes of the configuration blob consist of the decryption key, followed by the nonce.
The decrypted configuration blob stores the following information:
It is worth noting that Matanbuchus checks the expiration date only on execution and not at any other stage. Consequently, the compromised host might still communicate with the C2 server if the system was not restarted after the expiration date has passed.
Matanbuchus follows a network communication pattern similar to many other malware families. Matanbuchus starts by registering the compromised host with the C2 server and then requests a set of tasks from the server. If any tasks are available, Matanbuchus executes them and reports back any results.
The network communication pattern is illustrated in the figure below.

Figure 3: Matanbuchus network communication pattern.
Matanbuchus supports three main request types. Each request type is assigned a unique ID, which appears at the beginning of each packet after serialization in a Protobuf data structure. These request ID values are listed in the table below.
Request Type | ID |
|---|---|
Register bot | 1 |
Get task(s) | 2 |
Report task(s) result | 3 |
Table 1: Matanbuchus request IDs.
Matanbuchus uses HTTP(S) for network communications with payloads that contain encrypted Protobufs. Matanbuchus encrypts each Protobuf using ChaCha20 by generating a random key and nonce that is prepended to the packet data. The structure below represents the layout of a network packet created by Matanbuchus.
#pragma pack(1)
struct network_packet
{
uint8_t key[32];
uint8_t nonce[12];
uint32_t data_size;
uint8_t data[data_size];
};The network packet data consists of a Protobuf with various message types.
Before requesting any tasks from the C2 server, Matanbuchus registers the compromised host by collecting and sending the following information.
As soon as the registration process is complete, the following actions are taken.
HKEY_CURRENT_USER\SOFTWARE\%volume_serial_number_based_ID% with the bot ID. Matanbuchus checks this registry path on each execution to verify if the host needs to be registered.After completing registration, Matanbuchus starts requesting tasks from the C2 server. The network commands supported by Matanbuchus are described in the table below.
ANALYST NOTE: Matanbuchus maps the network command IDs found in a packet to internal IDs embedded in the binary’s code. For clarity, both ID types are listed in the table below.
Network Command ID | Internal ID | Description |
|---|---|---|
1 | 0 | Downloads and executes an EXE payload from an external URL. The payload can be executed in one of the following ways:
In addition, Matanbuchus can execute .NET payloads directly in memory. |
2 | 1 | Downloads and executes a DLL payload from an external URL. The payload can be executed in one of the following ways:
|
3 | 2 | Downloads and executes an MSI package from an external URL. The MSI file is written and executed to/from disk. |
4 | 3 | Executes a shellcode. Depending on the parameters passed, the shellcode is executed in one of the following ways:
|
5 | 5 | Collects the running processes on the compromised host. The list includes only the process names. |
6 | 5 | Collects the Windows services installed on the compromised host. The list includes the display names of the services. |
7 | 5 | Collects a list of software applications installed on the compromised host. The list includes the display names of the identified applications. |
8 | 5 | Gathers information on Windows cumulative updates installed on the compromised host.The list includes the name of each identified update, such as |
9 | 6 | Executes a system shell command using CMD. |
10 | 6 | Executes a system shell command using PowerShell. |
11 | 6 | Executes a system shell command using WMI. |
12 | 3 | Similar to network command ID 4, but the shellcode is executed within the context of the currently running thread, if a thread execution type is specified. |
13 | 7 | Terminates the Matanbuchus process. |
14 | 4 | Downloads and decompresses a ZIP archive from a remote URL. Matanbuchus runs any decompressed executable files. |
Table 2: Matanbuchus network commands.
ANALYST NOTE: The reverse engineered Matanbuchus Protobuf structures are available here.
Notably, the payloads downloaded from external URLs may be encrypted. Matanbuchus determines if decryption is required by reading a boolean flag from the incoming Protobuf message. The payload decryption routine also uses ChaCha20, similar to the downloader module.
As a final step, Matanbuchus reports the result of each network command, including any output generated from the command. Each task report packet includes the bot ID, task IDs, and any command output (e.g., the result of executing a system shell command). If a task fails, Matanbuchus does not report the task to the C2 server.
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。