Threat intelligence

DBatLoader Reloaded: Dual Injection and Resilience

by Madhukar Waghmare

Overview

The SonicWall Capture Labs threat research team has observed the latest variant of DBatLoader performing a dual injection of Remcos RAT, utilizing two distinct injection techniques. The malware is mainly known for delivering Remcos RAT, but also delivers other malware. The malware is delivered as an archive attached to an email, containing highly obfuscated JavaScript that embeds the encrypted DBatLoader wrapper executable.

Below is the DBatLoader infection chain, which we will explore in detail later in this blog post.

Fig_1_DBatLoader_Infection_chain.JPG
Figure 1: DBatLoader infection chain

First Layer: DBatLoader Executable

Upon execution of the obfuscated JavaScript, it drops the DBatLoader executable file in the %temp% folder and starts its execution. This executable is a Delphi-compiled binary that contains extensive obfuscation, junk code, and Delphi library functions, making it highly frustrating for malware researchers to analyze and debug. This Delphi binary contains approximately 1 MB of data in its resource section, which includes the encrypted loader binary, encrypted Remcos RAT, and LOLBins files required for its execution.

The main executable accesses the resource section and reads its data, parsing the large encoded content to pinpoint the exact location of the second-stage payload. Once the position is identified, it reads 0x34604 bytes from the resource section and copies them to a newly allocated memory region to start the decryption routine.

DBatLoader employs a simple addition-based decryption method to retrieve the second-stage payload, which it plans to inject into its own memory for execution. During this process, each encoded byte has 0x014F added to it, and only the least significant byte of the resulting WORD is kept, with the most significant byte discarded. These bytes are then assembled sequentially to reconstruct the byte array representing the second-stage payload.

Fig_2_DecryptionLoop_.PNG
Figure 2: Decryption routine to decrypt the second-stage payload

After completely decrypting the second-stage payload, which is a Delphi DLL, DBatLoader carries out self-injection by manually loading the DLL into its own memory and initiating its execution. Essentially, DBatLoader acts as an in-memory loader, performing manual mapping to inject the DLL and then transferring execution control to it.

Fig_3_self-injected_DLL_execution_started.PNG
Figure 3: Self-injected DLL execution started

Second Layer: Self-Injected DLL by DBatLoader

The second-stage payload is a Delphi-compiled DLL, featuring the same level of obfuscation and junk code as its wrapper executable.

The malware calls the timeSetEvent API to delay a callback function execution by 2710h milliseconds and uses the argument constant TIME_PERIODIC for periodic execution of the callback function. The malware checks the client’s internet status using the API InetIsOffline.

Anti-Debug Functionality

The second-stage payload includes anti-debugging functionality, utilizing the CheckRemoteDebuggerPresent and IsDebuggerPresent APIs to detect the presence of a debugger. If a debugger is detected, it enters an infinite loop, effectively stalling execution until these anti-debugging checks are bypassed.

The malware utilizes the NtReadFile API to read its parent DBatLoader wrapper executable and extract the encoded Remcos Loader, which contains the embedded Remcos RAT. It then decrypts this Remcos Loader in preparation for the dual injection of the Remcos RAT.

Next, the malware launches the colorcpl.exe process using the WinExec API and enumerates running processes to obtain a handle to the colorcpl.exe process.

The second-stage DLL injected by DBatLoader carries out two separate process injections. It first injects the Remcos Loader executable into colorcpl.exe, and then carries out the second injection into the Mercury Loader process.

The malware allocates an RWX memory region in colorcpl.exe using the NtAllocateVirtualMemory API. It then injects the Remcos Loader executable into this allocated memory region with the NtWriteVirtualMemory API. Afterward, it parses the in-memory Remcos Loader binary to identify the Relative Virtual Address (RVA) of the entry point and computes the actual entry point by adding the RVA to the image base address.

Finally, it starts the execution of the Remcos Loader in colorcpl.exe by creating a new thread with the NtCreateThreadEx API, specifying the entry point of the injected Remcos Loader as the thread’s starting address.

Fig_4_Injects_the_stager_payload_into_the_colorcpl.exe_.PNG
Figure 4: Injects the Remcos Loader into colorcpl.exe

Fig_5_Remcos_Loader_started_its_execution_in_colorcpl_.PNG
Figure 5: Remcos Loader starts execution in colorcpl.exe

After injecting the Remcos Loader executable into colorcpl.exe, the malware prepares for a second injection of the same payload, this time targeting the Mercury Loader LOLBins. It drops the Mercury Loader executable onto the disk, specifically in the Links folder— in our case, at the path C:\Users<username>\Links\gmxualuL.pif—and initiates the setup for the second process injection.

The malware starts the Mercury Loader LOLBins process in a suspended state and allocates an RWX memory region within it. It then injects the Remcos Loader into the Mercury Loader process using the NtWriteVirtualMemory API. Next, it modifies the execution context of the suspended process by using the GetThreadContext and SetThreadContext APIs to redirect the instruction pointer to the entry point of the injected payload. Finally, it begins execution of the injected code by resuming the suspended Mercury Loader process with the NtResumeThread API.

Fig_6_Code_injection_in_Mercury_Loader_process_.PNG
Figure 6: Code injection in Mercury Loader process

Third Layer: Remcos Loader

The Remcos Loader now begins its execution concurrently in two separate processes—first through code injection into colorcpl.exe, followed by injection into the Mercury Loader process.

The initial part of the Remcos Loader contains a decryption routine that decrypts a segment of shellcode embedded within the text section and then transfers control to the decrypted code.

The malware employs a combination of XOR and addition operations to decrypt 0x458 bytes of assembly instructions. It then transfers execution to this decrypted code, which contains the final decryption routine responsible for decrypting the Remcos RAT payload.

The malware initiates the final stage of decryption to extract the Remcos RAT payload, using a custom routine that combines arithmetic and bitwise operations.

The snapshot below illustrates the decryption logic used to retrieve the final Remcos payload.

Fig_7_Decryption_routine_to_get_final_payload_of_Remcos_RAT_.PNG
Figure 7: Decryption routine to get the final payload of Remcos RAT

The following snapshot shows the embedded encrypted Remcos RAT within the Remcos Loader binary, highlighting a comparison of the payload before and after decryption.

Fig_8_Remcos_RAT_embedded_withing_the_Remcos_Loader_.PNG
Figure 8: Remcos RAT embedded within the Remcos Loader

Once the Remcos Loader decrypts the Remcos RAT, it acts as a loader for the Remcos RAT.

The malware allocates memory and maps each section of the Remcos binary into the newly allocated space. It then applies relocation fixes by parsing the relocation section of the Remcos binary. Additionally, it modifies the Process Environment Block (PEB), updating the image base and entry point to reflect those of the Remcos RAT. Finally, it resolves the necessary APIs for Remcos execution using the GetProcAddress API and populates the Import Address Table (IAT) accordingly.

Fig_9_Modifies_the_Process_Environment_Block_.PNG
Figure 9: Modifies the Process Environment Block

Finally, the Remcos Loader transfers control to the injected Remcos RAT payload using the jmp eax assembly instruction.

We observed that if code injection into colorcpl.exe fails for any reason, the Mercury Loader process continues running with the injected Remcos RAT payload. However, if colorcpl.exe runs successfully, the Mercury Loader process eventually terminates itself, leaving only colorcpl.exe running with the Remcos payload.

This behavior is likely deliberate, designed to guarantee that at least one instance of the Remcos RAT stays active on the compromised system.

IOCs

SR NoSample DescriptionSHA256
1Archive file6311bff1208eeeb4fbfb9de4535a6766852a48f8da9f74ce1a935ef2076d5275
2JavaScript42cfc09b48fff3915c57328ac5471b91187d3d92d87cc8fbbf561b750aa45485
3DBatLoader wrapper executablee9fb43b5133d5c400045d6f45f4185b8c1b1cddc21d35c854603b88e6884218b
4Injected Delphi DLLca45feb0fe4bbed2c8f2c095f83196ede9bbf8b64824d74852f446d780d685be
5Remcos Loader injected in colorcpl.exe process87f1fd1a9419fd36c8232fd8f02f99e72d05648dc433834c42a0b41ac0c568bc
6Remcos RAT payload069935cdae95fad6e8e5fb3257e86baf65cac2b38de1e9ba4a95d6afc784a83a
7Mercury/32 Loader (LOLBins)7bcdc2e607abc65ef93afd009c3048970d9e8d1c2a18fc571562396b13ebb301

This threat can also be detected by SonicWall Capture ATP with Real-Time Deep Memory Inspection (RTDMI™). Below is the snapshot showing the detection details.

CaptureATPReport.JPG

Share This Article

An Article By

Madhukar Waghmare

Software Dev Senior Engineer

Madhukar is a forward-thinking malware researcher and machine learning specialist with nearly a decade of experience in security research and research-driven programming. He is an expert in reverse engineering a wide range of malwares, analyzing infection chains and developing robust solutions to protect users.

Related Articles

  • Pay2Key: First Ransomware Utilizing I2P Network Instead of Tor
    Read More
  • ZendTo Vulnerability (CVE-2025-34508) Could Lead to Data Exposure and Service Disruption
    Read More