HijackLoader Expands Techniques to Improve Defense Evasion
Posted: Thursday, Feb 08

i 3 Table of Contents

HijackLoader Expands Techniques to Improve Defense Evasion
  • HijackLoader continues to become increasingly popular among adversaries for deploying additional payloads and tooling
  • A recent HijackLoader variant employs sophisticated techniques to enhance its complexity and defense evasion
  • CrowdStrike detects this new HijackLoader variant using machine learning and behavior-based detection capabilities

 

CrowdStrike researchers have identified a HijackLoader (aka IDAT Loader) sample that employs sophisticated evasion techniques to enhance the complexity of the threat. HijackLoader, an increasingly popular tool among adversaries for deploying additional payloads and tooling, continues to evolve as its developers experiment and enhance its capabilities.

In their analysis of a recent HijackLoader sample, CrowdStrike researchers discovered new techniques designed to increase the defense evasion capabilities of the loader. The malware developer used a standard process hollowing technique coupled with an additional trigger that was activated by the parent process writing to a pipe. This new approach has the potential to make defense evasion stealthier.

The second technique variation involved an uncommon combination of process doppelgรคnging and process hollowing techniques. This variation increases the complexity of analysis and the defense evasion capabilities of HijackLoader. Researchers also observed additional unhooking techniques used to hide malicious activity.

This blog focuses on the various evasion techniques employed by HijackLoader at multiple stages of the malware.

HijackLoader Analysis

Infection Chain Overview

The HijackLoader sample CrowdStrike analyzed implements complex multi-stage behavior in which the first-stage executable (streaming_client.exe) deobfuscates an embedded configuration partially used for dynamic API resolution (usingย PEB_LDR_DATAย structure without other API usage) to harden against static analysis.

Afterward, the malware uses WinHTTP APIs to check if the system has an active internet connection by connecting toย https[:]//nginx[.]org.

If the initial connectivity check succeeds, then execution continues, and it connects to a remote address to download the second-stage configuration blob. If the first URL indicated below fails, the malware iterates through the following list:

  • https[:]//gcdnb[.]pbrd[.]co/images/62DGoPumeB5P.png?o=1
  • https[:]//i[.]imgur[.]com/gyMFSuy.png;
  • https[:]//bitbucket[.]org/bugga-oma1/sispa/downloads/574327927.png

 

Upon successfully retrieving the second-stage configuration, the malware iterates over the downloaded buffer, checking for the initial bytes of a PNG header. It then proceeds to search for the magic valueย ย C6 A5 79 EA, which precedes theย XORย key (32 B3 21 A5ย in this sample) used to decrypt the rest of the configuration blob.

HijackLoader Key Retrieving and Decrypting

Figure 1. HijackLoader Key Retrieving and Decrypting

ย 

 

Following XOR decryption, the configuration undergoes decompression using theย RtlDecompressBufferย API withย COMPRESSION_FORMAT_LZNT1. After decompressing the configuration, the malware loads a legitimate Windows DLL specified in the configuration blob (in this sample,ย C:WindowsSysWOW64mshtml.dll).

The second-stage, position-independent shellcode retrieved from the configuration blob is written to theย .textย section of the newly loaded DLL before being executed. The HijackLoader second-stage, position-independent shellcode then performs some evasion activities (further detailed below) to bypass user mode hooks using Heavenโ€™s Gate and injects subsequent shellcode intoย cmd.exe.The injection of the third-stage shellcode is accomplished via a variation ofย process hollowing that results in an injected hollowedย mshtml.dllย into the newly spawnedย cmd.exeย child process.

The third-stage shellcode implements a user mode hook bypass before injecting the final payload (a Cobalt Strike beacon for this sample) into the child processย logagent.exe. The injection mechanism used by the third-stage shellcode leverages the following techniques:

  • Process Doppelgรคngingย Primitives: This technique is used to hollow aย Transacted Sectionย (mshtml.dll) in the remote process to contain the final payload.
  • Process/DLL Hollowing: This technique is used to inject the fourth-stage shellcode that is responsible for performing evasion prior to passing execution to the final payload within the transacted section from the previous step.

 

Figure 2 details the attack path exhibited by this HijackLoader variant.

 

HijackLoader โ€” Infection Chain

Figure 2. HijackLoader โ€” Infection Chain

Main Evasion Techniques Used by HijackLoader and Shellcode

The primary evasion techniques employed by the HijackLoader include hook bypass methods such as Heaven’s Gate and unhooking by remapping system DLLs monitored by security products. Additionally, the malware implements variations of process hollowing and an injection technique that leverages transacted hollowing, which combines the transacted section and processย doppelgรคngingย techniques with DLL hollowing.

Hook Bypass: Heavenโ€™s Gate and Unhooking

Like other variants of HijackLoader, this sample implements a user mode hook bypass using Heaven’s Gate (when run inย SysWOW64) โ€” this is similar toย existingย (x64_Syscallย function) implementations.

This implementation of Heaven’s Gate is a powerful technique that leads to evading user mode hooks placed inย SysWOW64 ntdll.dllย by directly calling the syscall instruction in the x64 version ofย ntdll.

 

Each call toย Heaven’s Gateย uses the following as arguments:

  • The syscall number
  • The number of parameters of the syscall
  • The parameters (according to the syscall)

 

 

This variation of the shellcode incorporates an additional hook bypass mechanism to elude any user mode hooks that security products may have placed in the x64ย ntdll. These hooks are typically used for monitoring both the x32 and x64ย ntdll.

During this stage, the malware remaps theย .textย section of x64ย ntdllย by using Heavenโ€™s Gate to callย NtWriteVirtualMemoryย andย NtProtectVirtualMemoryย to replace the in-memory mappedย ntdllย with theย .textย from a freshย ntdllย read from the fileย C:windowssystem32ntdll.dll. This unhooking technique is also used on the process hosting the final Cobalt Strike payload (logagent.exe) in a final attempt to evade detection.

Process Hollowing Variation

To inject the subsequent shellcode into the child processย cmd.exe, the malware utilizes common process hollowing techniques. This involves mapping the legitimate Windows DLLย mshtml.dllย into the target process and then replacing itsย .textย section with shellcode. An additional step necessary to trigger the execution of the remote shellcode is detailed in a later section.

To set up the hollowing, the sample creates two pipes that are used to redirect theย Standard Inputย and theย Standard Outputย of the child process (specified in the aforementioned configuration blob,ย C:windowssyswow64cmd.exe) by placing the pipesโ€™ handles in aย STARTUPINFOWย structure spawned withย CreateProcessWย API.

ย One key distinction between this implementation and the typical “standard” process hollowing can be observed here: In standard process hollowing, the child process is usually created in a suspended state. In this case, the child isย notย explicitly created in a suspended state, making it appear less suspicious. Since the child process is waiting for an input from the pipe created previously, its execution is hanging on receiving data from it. Essentially, we can call this an interactive process hollowing variation.

ย As a result, the newly spawnedย cmd.exeย will read input from theย STDINย pipe, effectively waiting for new commands. At this point, itsย EIPย (Extended Instruction Pointer) is directed toward the return from theย NtReadFileย syscall.

The following section details the steps taken by the second-stage shellcode to set up the child processย cmd.exeย ultimately used to perform the subsequent injections used to execute the final payload.

The parent processย streaming_client.exeย initiates anย NtDelayExecutionย to sleep, waiting forย cmd.exeย to finish loading. Afterward, it reads the legitimate Windows DLLย mshtml.dllย from the file system and proceeds to load this library intoย cmd.exeย as a shared section. This is accomplished using the Heaven’s Gate technique for:

  • Creating a shared section object usingย ย NtCreateSection
  • Mapping that section in the remoteย cmd.exeย usingย NtMapViewOfSection

 

It then replaces theย .textย section of theย mshtmlย DLL with malicious shellcode by using:

  • Heavenโ€™s Gate to callย ย NtProtectVirtualMemoryย onย cmd.exeย to setย RWXย permissions on theย .textย section of the previously mapped sectionย mshtml.dll
  • Heavenโ€™s Gate to callย NtWriteVirtualMemoryย on the DLLโ€™sย .textย section to stomp the module and write the third-stage shellcode

 

Finally, to trigger the execution of the remote injected shellcode, the malware uses:

  • Heavenโ€™s Gate to suspend (NtSuspendThread) the remote main thread
  • A newย CONTEXTย (by usingย NtGetContextThreadย andย NtSetContextThread) to modify theย EIPย to point to the previously written shellcode
  • Heavenโ€™s Gate to resume (NtResumeThread) the remote main thread ofย cmd.exe

 

However, becauseย cmd.exeย is waiting for user input from theย STDINPUTย pipe, the injected shellcode in the new process isn’t actually executed upon the resumption of the thread. The loader must take an additional step:

  • The parent processย streaming_client.exeย needs to write (WriteFile)ย rnย string to theย STDINPUTย pipe created previously to send an input toย cmd.exeย after callingย NtResumeThread. This effectively resumes execution of the primary thread at the shellcodeโ€™s entry point in the child processย cmd.exe.

 

Interactive Process Hollowing Variation: Tradecraft Analysis

We have successfully replicated the threadless process hollowing technique to understand how the pipes trigger it. Once the shellcode has been written as described, it needs to be activated. This activation is based on the concept that when a program makes a syscall, the thread waits for the kernel to return a value.

 

In essence, the interactive process hollowing technique involves the following steps:

  • CreateProcess:ย This step involves spawning theย cmd.exeย process to inject the malicious code by redirectingย STDINย andย STDOUTย to pipes. Notably, this process isn’t suspended, making it appear less suspicious. Waiting to read input from the pipe, theย NtReadFileย syscall sets its main thread’s state toย Waitingย andย _KWAIT_REASONย toย Executive, signifying that it’s awaiting the execution of kernel code operations and their return.
  • WriteProcessMemory:ย This is where the shellcode is written into theย cmd.exeย child process.
  • SetThreadContext:ย In this phase, the parent sets the conditions to redirect the execution flow of theย cmd.exeย child process to the previously written shellcodeโ€™s address by modifying theย EIP/RIPย in the remote threadย CONTEXT.
  • WriteFile:ย Here, data is written to theย STDINย pipe, sending an input to theย cmd.exeย process. This action resumes the execution of the child process from theย NtReadFileย operation, thus triggering the execution of the shellcode. Before returning to user space, the kernel is reading and restoring the values saved in theย _KTRAP_FRAMEย structure (containing theย EIP/RIPย register value) to resume from where the syscall was called. By modifying theย CONTEXTย in the previous step, the loader hijacks the resuming of the execution toward the shellcode address without the need to suspend and resume the thread, which this technique usually requires.
Transacted Hollowingยฒ (Transacted Section/Doppelgรคnger + Hollowing)

The malware writes the final payload in the child processย logagent.exeย spawned by the third-stage shellcode inย cmd.exeย by creating a transacted section to be mapped in the remote process. Subsequently, the malware injects fourth-stage shellcode intoย logagent.exeย by loading and hollowing another instance ofย mshtml.dllย into the target process. The injected fourth-stage shellcode performs the aforementioned hook bypass technique before executing the final payload previously allocated by the transacted section.

Transacted Section Hollowing

Similarly to process doppelgรคnging, the goal of a transacted section is to create a stealthy malicious section inside a remote process by overwriting the memory of the legitimate process with a transaction.

 

In this sample, the third-stage shellcode executed insideย cmd.exeย places a malicious transacted section used to host the final payload in the target child processย logagent.exe. The shellcode uses the following:

  • NtCreateTransactionย to create a transaction
  • RtlSetCurrentTransactionย andย CreateFileWย with a dummy file name to replace the documentedย ย CreateFileTransactedW
  • Heavenโ€™s Gate to callย NtWriteFileย in a loop, writing the final shellcode to the file in 1,024-byte chunks
  • Creation of a section backed by that file (Heavenโ€™s Gate callย NtCreateSection)
  • A rollback of the previously created section by using Heavenโ€™s Gate to callย ย NtRollbackTransaction

 

Existing similar implementations have publicly been observed inย this projectย that implements transaction hollowing.

Once the transacted section has been created, the shellcode generates a function stub at runtime to hide from static analysis. This stub contains a call to theCreateProcessWย API to spawn a suspended child processย logagent.exeย (c50bffbef786eb689358c63fc0585792d174c5e281499f12035afa1ce2ce19c8) that was previously dropped byย cmd.exeย  under theย %TEMP%ย folder.

After the target process has been created, the sample uses Heavenโ€™s Gate to:

  • Read itsย PEBย by callingย NtReadVirtualMemoryย to retrieve its base address (0x400000)
  • Unmap theย logagent.exeย image in theย logagent.exeย process by usingย ย NtUnMapViewofSection
  • Hollow the previously created transacted section inside the remote process by remapping the section at the same base address (0x400000) withย NtMapViewofSection
Process Hollowing

After the third-stage shellcode withinย cmd.exeย injects the final Cobalt Strike payload inside the transacted section of theย logagent.exeย process, it continues by process hollowing the target process to write the fourth shellcode stage ultimately used to execute the final payload (loaded in the transacted section) in the remote process. The third-stage shellcode maps the legitimate Windows DLLย C:WindowsSysWOW64mshtml.dllย in the target process prior to replacing itsย .textย with the fourth-stage shellcode and executing it viaย NtResumeThread.

This additional fourth-stage shellcode written toย logagent.exeย performs similar evasion activities to the third-stage shellcode executed inย cmd.exeย (as indicated in the hook bypass section) before passing execution to the final payload.

Falcon Coverage

CrowdStrike employs a layered approach for malware detection using machine learning and indicators of attack (IOAs). As shown in Figure 3, the CrowdStrike Falconยฎย sensorโ€™s machine learning capabilities can automatically detect and prevent the HijackLoader in the initial stages of the attack chain; i.e., as soon as the malware is downloaded onto the victimโ€™s machine. Behavior-based detection capabilities (IOAs) can recognize malicious behavior at various stages of the attack chain, including when employing tactics like process injection attempts.

CrowdStrike Falcon Platform Machine Learning and IOA Coverage for the HijackLoader Sample

Figure 3. CrowdStrike Falcon Platform Machine Learning and IOA Coverage for the HijackLoader Sample


 

Indicators of Compromise (IOCs)

File

SHA256

streaming_client.exe 6f345b9fda1ceb9fe4cf58b33337bb9f820550ba08ae07c782c2e142f7323748

 

MITRE ATT&CK Framework

The following table maps reported HijackLoader tactics, techniques and procedures (TTPs) to the MITRE ATT&CKยฎย framework.

ID

Technique

Description

T1204.002

User Execution: Malicious File The sample is a backdoored version of streaming_client.exe, with the Entry Point redirected to a malicious stub.

T1027.007

Obfuscated Files or Information: Dynamic API Resolution HijackLoader and its stages hide some of the important imports from the IAT by dynamically
retrievingย kernel32ย andย ntdllย API addresses. It does this by parsingย PEB->PEB_LDR_DATAย  and
retrieving the function addresses.

T1016.001

System Network Configuration Discovery: Internet Connection Discovery This variant of HijackLoader connects to a remote server to check if the machine is connected to the internet by using theย ย WinHttpย API (WinHttpOpenRequestย andย WinHttpSendRequest).

T1140

Deobfuscate/Decode Files or Information HijackLoader utilizes XOR mechanisms to decrypt the downloaded stage.

T1140

Deobfuscate/Decode Files or Information HijackLoader utilizesย RtlDecompressBufferย to LZ decompress the downloaded stage.

T1027

Obfuscated Files or Information HijackLoader drops XOR encrypted files to the %APPDATA% subfolders to store the downloaded stages.

T1620

Reflective Code Loading

 

HijackLoader reflectively loads the downloaded shellcode in the running process by loading and stomping theย mshtml.dllย module using theย LoadLibraryWย andย VirtualProtectย APIs.

T1106

Native API

 

HijackLoader uses direct syscalls and the following APIs to perform bypasses and injections:ย WriteFileW,ย ReadFile,ย CreateFileW,ย LoadLibraryW,ย GetProcAddress,ย NtDelayExecution,
RtlDecompressBuffer,ย CreateProcessW,ย GetModuleHandleW,ย CopyFileW,ย VirtualProtect,
NtProtectVirtualMemory,ย NtWriteVirtualMemory,ย NtResumeThread,ย NtSuspendThread,
NtGetContextThread,ย NtSetContextThread,ย NtCreateTransaction,ย RtlSetCurrentTransaction,
NtRollbackTransaction,ย NtCreateSection,ย NtMapViewOfSection,ย NtUnMapViewOfSection,
NtWriteFile, NtReadFile, NtCreateFile and CreatePipe.

T1562.001

Impair Defenses: Disable or Modify Tools HijackLoader and its stages useย Heavenโ€™s Gateย and remap x64ย ntdllย to bypass user space hooks.

T1055.012

Process Injection: Process Hollowing HijackLoader and its stages implement a process hollowing technique variation to inject inย cmd.exeย andย logagent.exe.

T1055.013

Process Injection: Process Doppelgรคnging The HijackLoader shellcode implements a process doppelgรคnging technique variation (transacted section hollowing) to load the final stage inย logagent.exe.

 

 

Additional Resources

  • The CrowdStrike Falconยฎ platform achieved 100% protection, 100% visibility and 100% analytic detection across all steps in the MITRE Engenuity ATT&CKยฎ Evaluations: Enterprise, Round 5.ย Learn more in this blog post.
  • CrowdStrike was named a Leader in the 2023 Gartnerยฎ Magic Quadrantโ„ข for Endpoint Protection Platforms โ€” furthest right in Vision and highest in Ability to Execute.ย Read about it here.ย 
  • Find out how the Falcon platform stops breaches, saves time and saves money in this IDC analysis:ย The Business Value of the CrowdStrike Falcon XDR Platform.
  • See the Falcon platform in action โ€”ย sign up for a free demoย today.ย 
Liviu Arsene
Liviu Arsene is a Director, Threat Research and Reporting, at CrowdStrike, with a strong background in security and technology. He has been in the cybersecurity industry for over a decade, and his experience spans malware research, outbreaks and the threat landscape. He has authored/co-authored investigations and reports on threats across a wide variety of industry verticals. He researches global trends and developments in cybersecurity, focusing on malware and threats while assessing their impact on infrastructures. His passions revolve around innovative technologies and gadgets, particularly on their security applications and long-term strategic impact. When he's not online, he's either taking something apart or putting it back together again.
Share This