For the complete documentation index, see llms.txt. This page is also available as Markdown.

AppDomain Hijacking: Analyzing a LNK malware

Overview

Windows shortcut files use the .lnk file extension and function as a virtual link that allows people to easily access other files without having to navigate through multiple folders on a Windows host. The flexibility of LNK files makes them a powerful tool for attackers, as they can both execute malicious content and masquerade as legitimate files to deceive victims into unintentionally launching malware.

Figure: Execution Flow of malware

Technical Analysis

On getting lnk file i quickly looked into its metadata to find out the arguments it is utilizing and its clear that it has configured to look as a pdf file and since lnk extensions gets hidden in windows, it makes it more suitable as a attack vector. On dumping the configuration of the sample i found out that it is launching powershell in background with setting the exeution policy to bypass and also stops and user profile scripts from loading by -nop, sets the working directory to temp directory. Then, it reads itself after 2087 offset, mainly it extracts the next part of payload and writes it and executes it.

Figure 1: Setup of malware

So i used a python script to extract the second part of the malware -

And it turned out that it is first searching for current user's startup folder to run if any binary is there and then to achieve it, it copies a legitimate windows binary dfsvc.exe of .NET framework to the startup folder with a name of NetworkConfig.exe because signed binaries bypasses basic AV checks. Then, it copies something from lnk file and stores it as a config named NetworkConfig.exe.config, this to forcefully load the dll, which it is extracting just after this as NetworkConfig.dll. After all this, it extracts another conf from lnk and stores it in NetworkConfig.conf and then starts the copied binary.

Figure 2: Second payload extracted from lnk

So, I extracted all the required files from the lnk using python script -

The config file NetworkConfig.exe.config is a way of using AppDomainManager Injection for DLL-Side loading by defining some attributes in XML file that tells the .NET Runtime to load custom app domain manager named NetworkConfig before executing main application.

Figure 3: AppDomainManager Injection

Now opening the dll in a decompiler, first thing I uncovered that the malware is using unicode characters like U+00A0, mostly invisible characters which is common obfuscation technique in .NET sample. Now the function u00a0 is used to crafting a standard HTTP request for fetching data and just after this another function named u00a0 which is checking some common sandbox evasion techniques, first it checks is default domain if its being tampered, checks existence of NetworkConfig.conf file, sleep loop for automated sandboxes.

Figure 4: Sandbox evasion techniques

But before moving any further we have to find out the string decryption engine to understand what strings are being passed rather than guessing. On expanding PrivateImplementatioDetails, there is a constructor u003670D375Bu002dB8F4u002d45A4u002d94F9u002d00A08E8BCEA0() that is just xoring a blob of data using current index and constant 204. And based on this other getter functions have been created to return these decrypted values, So i decrypted these strings and correctly mapping each of them with required getter functions. I found interesting things from this like C2 url, endpoints, User-Agent, Names, RegKey used.

Now coming to InitializeNewDomain function, first thing it does is calls \u1680.\u1680(); which opens makes a new seperate thread and creates a named pipe PipesOfPiece and starts a infinite while loop that waits for client program to connect and reads whatever client sends, reverse it and sends back to client and then close the connection and this loop continues. Now \u1680.\u00a0();, it queries registery for value of chrome and brave and it also creates a named pipe and sends AABBCC123 to server and closes the pipe.

Figure 5: Creating Named pipes

Figure 6: Sandbox evasion techniques

Then, it calls global::\u00a0.\u00a0.\u00a0(); which reads or creates the registry key if didn't exist Software\Microsoft\Windows\CurrentVersion\Explorer\StartupApproved\StartupFolder and disable the autostart program 3, 0, 0, 0 from hardcoded command, which disables its non-executables NetworkConfig.dll, NetworkConfig.exe.config, NetworkConfig.conf.

Then it crafts, the url https[:]//mskmailforwarder[.]com/849d16c2-829f-4e19-93ba-cb0e2c309afc/api/auth[.]php makes request to it and maps a memory region of 150000 bytes with RWX permissions, this will be the region where it will drop its main shellcode, then if the file C:\Users\<Username>\AppData\Local\NetworkConfig.conf exists but on the first run it won't be there, then it takes this file as 1st parameter and value of registry MachineGuid from HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography as 2nd into \u2001.\u00a0() which is basically a RC4 cipher which uses the MachineGuid as the key after xoring it wtih 0x41 to decrpyt the main shellcode. Else it will take response from https[:]//mskmailforwarder[.]com/849d16c2-829f-4e19-93ba-cb0e2c309afc/api/batchLogHandle[.]php and XOR it with 0x41 and use it to decrypt the shellcode and stores it an array and then again re-encrypts the shellcode but using the victim's MachineGuid and save into C:\Users\<Username>\AppData\Local\NetworkConfig.conf then delete the original file NetworkConfig.conf, and writes this shellcode into the mapped memory region. In the initial run the else would be executed and that uses C2 key for initial decryption of payload, then on reboot the if block executes which uses Victim keys for decryption of shellcode.

Since the C2 infra is offline I won't able to proceed further with analysis.

Conclusion

The malware uses a sophisticated approach to payload delivery, evasion, and environmental keying. By leveraging an AppDomain hijack to side-load its core DLL through a legitimate Microsoft binary (dfsvc.exe). Instead of relying on a static decryption key, the loader implements a dynamic, phase-based execution flow. The initial infection mandates a live connection to the attacker's C2 infrastructure to fetch the master key via a custom XOR routine, effectively neutralizing offline static analysis and sandboxing. Once decrypted in memory, the malware pivots: it re-encrypts the raw shellcode using the victim's unique registry MachineGuid and caches it in %LocalAppData%. Ultimately, while burned C2 infrastructure can prevent the static extraction of the initial dropper's shellcode.

IOCs

  • C2 Domain - mskmailforwarder[.]com

  • Endpoints - api/auth.php, api/batchLogHandle.php

  • Dropped Files - NetworkConfig.conf, NetworkConfig.exe.config, NetworkConfig.dll

  • Registries - HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography\MachineGuid, HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\StartupApproved\StartupFolder

  • Hashes

Last updated