Tracking the Progression of Earth Hundun's Cyberespionage Campaign in 2024 (2024)

Our analysis provided insights into the intricate workings of the downloader, detailing its infection flow, traffic behavior, anti-analysis techniques, and evolutionary trajectory.

In this entry, we examine the behavior of the final Remote Access Trojan (RAT) that we recently managed to download from a C&C server, based on an Earth Hundun campaign from 2024.

In our first entry, we focused on the Waterbear downloader (the first stage) and examined its network behavior. This report uses a case study to describe how the threat actor uses the Waterbear RAT and plugin during the second stage and how Waterbear downloaders are spread to other machines, making it more difficult to detect and track.

Furthermore, we examine the major updates to Deuterbear, including the ability to accept plugins with shellcode formats and the ability to function even without handshakes during RAT operation.

Finally, we will share our findings about the interaction between Earth Hundun and its victims through the Waterbear and Deuterbear malware, showcasing the sophisticated tactics employed by this threat actor.

The following flow chart from a previous campaign illustrates how Waterbear operates in the victim's environment and then spreads more Waterbear downloaders across the internal network.

First stage

Waterbear usually employs a group of three files for downloading purposes during the first stage of an attack (as mentioned in the previous report). These include the patched legitimate executable, the loader, and the encrypted downloader.

Second stage

  1. After connecting to the C&C server, we downloaded the Waterbear RAT (A) in memory, which contains several command codes inside (see Table 1 for the list of RAT commands). In this case, the Waterbear RAT (A) was only used to download the Waterbear plugin via RAT command 1010 and activate the first export function, “Start”, in the plugin to inject the chosen process.
  2. The Waterbear plugin contains Waterbear downloader versions 0.27 and 0.28, both unencrypted, varying based on the process's bit version. If the process is 32-bit, version 0.27 of the Waterbear downloader will run. On the other hand, version 0.28 will execute to facilitate further downloads on the 64-bit process.

    Waterbear downloader versions 0.27 and 0.28 are the latest that we know of. Their behaviors are the same as the versions before 2020.

  3. In this case, the Waterbear plugin injects into a 64-bit process, which results in version 0.28 of the Waterbear downloader trying to connect to the new C&C IP address — which is assigned by Waterbear RAT (A) — and download Waterbear RAT (B), which is almost the same as the previous one, just with a different RSA key inside.
  4. Waterbear RAT (B) will be used to collect the information from the infected machine, including the list of drives and files, and then further spread the Waterbear downloader to other machines. Interestingly, Earth Hundun will replace the C&C string with an internal IP address after downloading the new stage of the RAT or downloader. This is to erase activity traces or connect to other C&C servers in the victim's environment, showing that the threat actor can arbitrarily choose its connection targets.

Waterbear RAT command

Since discussing Waterbear’s functions in our previous blog entry, there have been more that have been implemented, with the latest version shown in the following table:

Command groupCommand code (Hex)Command code (Dec)Capability
File management22Enumerate disk drives
33List files
44Upload file to C&C server
55Download file from C&C server
66Rename file
77Create folder
88Delete file
A10Execute file
B11Move file
C12Disguise file metadata
D13File operation
Other326806Get system language, system time, and Windows installation date
Window management327807Enumerate windows
329809Hide window
32A810Show window
32B811Close window
32C812Minimize window
32D813Maximize window
32F815Take a screenshot
330816Set screenshot event signaled
331817Remote desktop
Process management332818Enumerate process
333819Terminate process
335821Suspend process with pID
336822Resume process with pID
337823Retrieve process module information
338824Retrieve process module information (for files or objects using the authenticode policy provider)
Network management339825Get extended TCP table
33A826SetTcpEntry Set state of the TCP connection with MIB_TCP_STATE_DELETE_TCB
Service management33B827Enumerate services
33C828Manipulate service
33D829
33E830
33F831
340832
Configuration management341833Get C&C in downloader configuration
342834Set C&C in downloader configuration
Remote shell3EE1006Start remote shell
management3EF1007Exit remote shell
3F01008Get remote shell PID
3F21010Download plugin and execute the export function “Start”
Unknown5141300Unknown
Registry management7DB2011Enumerate registry
7DC2012Enumerate registry value
7DD2013Create registry key
7DE2014Set registry value
7DF2015Delete registry key
7E02016Delete registry value
Basic control1F418001Get current window
1F448004Set the infection mark in registry HKCU\Console\Quick\Edit
1F458005Terminate connection and RAT process
Proxy23329010Update C&C IP address
23339011Proxy data to the connected server
23349012Shutdown all connections
23359013Shutdown the given connection
23369014Listen port
23379015Proxy data via the specified socket handle
23389016Close the specified socket handle
23399017Shutdown both sending and receiving of a specific socket handle
233A9018Proxy the data from the socket back to the C&C server
Data offsetData sizeData content
0x000x01IsUserAnAdmin
0x010x9CGetVersionExA
0x9D0x10gethostbyname
0xAD0x44gethostname
0xF10x18GetUserNameA
0x1090x04GetLastInputInfo
0x10D0x50GetWindowTextA
0x15D0x12GetAdaptersInfo
0x16F0x10Downloader version
0x17F0x30Drive of information in current process
0x1AF0x04Infection mark in HKCU\Control Panel\Colors
0x1B30x04GetCurrentProcessId
0x1B70x01RAT version

Table 2.The structure of victim information that Waterbear sends to the C&C server

This section will explain Earth Hundun's use of Deuterbear and provide a comprehensive analysis of the Deuterbear RAT.

Deuterbear installation

download

The installation pathway of Deuterbear is depicted in Figure 3. Note that it is similar to Waterbear, which implements two stages to install the backdoor.

In the first stage, the loader employs a basic XOR calculation to decrypt the downloader, facilitating the retrieval of the first stage RAT from the C&C server. Subsequently, the threat actor applies the first stage RAT to survey the victim’s system and identify an appropriate folder for persistence. This is where the second-stage Deuterbear components will be installed, including the loader with CryptUnprotectData decryption, the encrypted downloader, and associated registries (the decryption flow was discussed in the previous blog entry).

In most of the infected systems, only the second stage Deuterbear is available. Our monitoring indicates that all components of the first stage Deuterbear are totally removed after the “persistence installation” is completed. It seems that Earth Hundun prefers to keep the loaders using CryptUnprotectData decryption, even in cases where the successful installation of Deuterbear is achieved during the first stage. This strategy effectively protects their tracks and prevents the malware from easily being analyzed by threat researchers, particularly in simulated environments rather than real victim systems.

Deuterbear RAT

The Deuterbear RAT directly inherits several components from the downloader, including:

  • All anti-analysis techniques (please refer to our previous report for more details).
  • HTTPS tunnel.
  • Routine to receive and send traffic.
  • RC4 key to decrypt and encrypt traffic.
  • Routine to decrypt and encrypt the desired function.
  • Key to decrypt and encrypt the desired function.

Due to having the same HTTPS channel and RC4 traffic key, Deuterbear RAT doesn't require a handshake with the C&C server to update communication protocols. This enables the threat actor to seamlessly control the client, regardless of whether the process is in the downloader or RAT status. Prior to executing backdoor commands, the Deuterbear RAT transmits victim information to the C&C server via RAT command 975 with the structure (Table 3) highly reminiscent of the Waterbear RAT (Table 2).

Data offsetData sizeData content
0x000x04Signature in configuration of downloader (00 00 01 00)
0x040x01IsUserAnAdmin
0x050x20GetUserNameA
0x250x80OS version
0xA50x04gethostbyname
0xA90x46gethostname
0xEF0x50GetWindowTextA
0x13F0x04GetLastInputInfo
0x1430x26GetAdaptersInfo
0x1690x04GetCurrentProcessId
0x16D0x01RAT Version
0x16E0x04Infection mark in HKCU\Control Panel\Colors
0x1720x08Last write time of temp folder in system folder

Table 3. The structure of victim information that Deuterbear sends to the C&C server

Deuterbear RAT command

Comparing Deuterbear with Waterbear reveals several functionalities directly replicated from the Waterbear RAT, such as process management, file management, and remote shell capabilities.

Although Deuterbear streamlines its capabilities, retaining only 20 RAT commands (Table 4) compared to over 60 for Waterbear (Table 1), the Deuterbear RAT accepts more plugins to enhance flexibility and accommodate additional functionalities, including two shellcodes and a portable executable (PE) DLL via RAT command 979. After installing the plugins, the threat actor sends the next traffic to determine which plugin is launched. There are three kinds of protocols:

  • Execute the first shellcode and the first export function of PE(DLL)
  • Execute the second shellcode and the first export function of PE(DLL)
  • Only execute the first export function of PE(DLL)
Command groupCommand code (Hex)Command code (Dec)Capability
File management0x2739List files (date, size, name)
0x2840Upload file to C&C server
0x2941Download file from C&C server
0x2A42Rename file
0x2C44SHFileOperationA
0x2E46Execute File
Process management0xE7231Enumerate process
0xE8232Terminate targeted process
Configuration management0x1FF511Collect data in the downloader configuration
>C&C string
>Execution time
0x200512Update data in the downloader configuration
>C&C string
>Execution time
Remote shell management0x2FC764Start remote shell
0x2FD765Exit remote shell
0x2FE766Get PID of remote shell
Basic control0x3CE974Get current window
0x3D1977Set infection mark in HKCU\Control Panel\Colors
0x3D2978Terminate connection and RAT process
Plugins management0x3D3979Download plugins from C&C server:
>PE (DLL)
>First Shellcode (Encrypted by key fromconfig of downloader)
>Second shellcode(Encrypted by key from config of downloader)
0x3D4980Uninstall plugins
0x3E8~0x5781000~1400Execute plugins
>First shellcode
>First export function of PE (DLL)
> 0x578> 1400Execute plugins
>Second shellcode
>First export function of PE (DLL)
OtherOther

Execute plugins

>First export function of PE (DLL)

Table 4. List of Deuterbear RAT commands

Examples of similarities in backdoor commands between Waterbear and Deuterbear are shown in the images from Figure 4 to Figure 6.

download

download

download

Comparing the Waterbear and Deuterbear downloaders, Table 5 shows the differences in the RAT part:

PropertiesWaterbear RATDeuterbear RAT
FormatPE fileShellcode
Anti-Memory scanningNoYes
C&C communicationHTTPHTTPS
Size of packet header105
Share the same traffic key with downloaderNoYes
Format of PluginPE filePE file and shellcode
Registry of infection markHKCU\Console\Quick\EditHKCU\Control Panel\Colors
Counts of backdoor command60+20
Functionality of backdoor commandFile management
Process management
Configuration management
Remote Shell management
Windows management
Registry management
Service management
Network management
Proxy
File management
Process management
Configuration management
Remote Shell management
Plugins management

Table 5. Differences between the Waterbear RAT and Deuterbear RAT

Waterbear has gone through continuous evolution, eventually giving rise to the emergence of a new malware, Deuterbear. Interestingly, both Waterbear and Deuterbear continue to evolve independently, rather than one simply replacing the other.

Based on the downloader analysis presented in April 2024. We made a comprehensive examination of the RAT, which is a component seldom downloaded from the C&C server due to temporary port openings. Through a systematic comparison of Deuterbear and Waterbear in the loader, downloader, RAT and behavioral aspects, we gained insights into the evolution of the techniques employed by Earth Hundun. While the Waterbear and Deuterbear family represent just one facet of the group’s arsenal, we believe that continuous refinement of tools will be implemented in other malware for anti-analysis, and detection evasion, particularly in traffic and file handling.

Organizations can defend themselves from Earth Hundun attacks by performing a memory scan for downloads and the Waterbear and Deuterbear RATs. Furthermore, detecting the registry used to decrypt the Deuterbear downloader can help scan for its presence within the system.

MITRE ATT&CK

TacticTechniqueIDDescription
ExecutionShared ModulesT1129Dynamically loads the DLLs through the shellcode
Native APIT1106Dynamically loads the APIs through the shellcode
PersistenceHijack Execution Flow: DLL Side-LoadingT1574.002Uses modified legitimate executable to load the malicious DLL
Boot or Logon Autostart Execution: Print ProcessorsT1547.012Deuterbear abuses print processors to run malicious DLLs during system
Privilege EscalationProcess InjectionT1055Waterbear and Deuterbear inject the targeted process
Defense EvasionDeobfuscate/Decode Files or InformationT1140Uses RC4 or CryptUnprotectData to decrypt encrypted downloader
Execution GuardrailsT1480Targets specific path/registry in the victim’s environment
Virtualization/Sandbox Evasion: Time Based EvasionT1497.003Deuterbear checks sandbox by API, Sleep, whether normal operation.
Debugger EvasionT1622Deuterbear checks debugger mode by process time.
DiscoveryFile and Directory DiscoveryT1083Waterbear and Deuterbear RAT searches files and directories or in specific locations.
System Network Configuration Discovery: Internet Connection DiscoveryT1016.001Downloaders check for internet connectivity on compromised systems.
System Network Connections DiscoveryT1049Waterbear and Deuterbear RAT lists network connections to or from the compromised system they are currently accessing or from remote systems by querying for information over the network.
Process DiscoveryT1057Waterbear and Deuterbear RAT searches specific process.
System Information DiscoveryT1082Waterbear and Deuterbear RAT get detailed information about the operating system and hardware, including version, username, and architecture.
Query RegistryT1012Queries data from registry to decrypt downloader
Lateral MovementRemote Services: Windows Remote ManagementT1021.006Waterbear and Deuterbear RAT control remote shell
CollectionData from Local SystemT1005Collects basic information of victim
ExfiltrationExfiltration Over Command-and-Control ChannelT1041Sends collected data to C&C
Command and ControlApplication Layer Protocol: Web ProtocolsT1071.001Downloaders communicate with C&C by HTTP/HTTPS
Encrypted ChannelT1573Employs a RC4/RSA to conceal command and control traffic
Data Encoding: Non-Standard EncodingT1132.002Encodes traffic with a non-standard RC4 to make the content of traffic more difficult to detect

The indicators of compromise for this entry can be found on this link.

Tracking the Progression of Earth Hundun's Cyberespionage Campaign in 2024 (2024)

References

Top Articles
Latest Posts
Article information

Author: Clemencia Bogisich Ret

Last Updated:

Views: 5984

Rating: 5 / 5 (60 voted)

Reviews: 83% of readers found this page helpful

Author information

Name: Clemencia Bogisich Ret

Birthday: 2001-07-17

Address: Suite 794 53887 Geri Spring, West Cristentown, KY 54855

Phone: +5934435460663

Job: Central Hospitality Director

Hobby: Yoga, Electronics, Rafting, Lockpicking, Inline skating, Puzzles, scrapbook

Introduction: My name is Clemencia Bogisich Ret, I am a super, outstanding, graceful, friendly, vast, comfortable, agreeable person who loves writing and wants to share my knowledge and understanding with you.