Hworm/njRAT is a Remote Access Tool (RAT) that first appeared in 2013 in targeted attacks against the international energy industry, primarily in the Middle East. It was soon commoditized and is now part of a constantly evolving family of RATs that pop-up in various new formats. Today we see this attack employed on a regular basis as part of widespread spam phishing campaigns - if successful, Hworm gives the attacker complete control of the victim’s system. Morphisec Labs recently observed a new version with a minor modification to its obfuscation technique.
The attack uses the kind of fileless VBScript injector, leveraging DynamicWrapperX, that has been seen used in the wild by RATs such as HWorm, DarkComet, KilerRAT and others. We observed a new obfuscation level, as the distribution of this RAT is still changing and running. We will describe the injector stage and how it used to load Hworm/Houdini RAT.
The payload is a VBS file, which, in some cases, comes obfuscated or encoded with couple of layers.
The next stage VBS file contains 3 chunks of base64 streams:
DCOM_DATA: Holds a PE file, which is DynamicWrapperX. It allows to call functions exported by DLL libraries, in particular Windows API functions, from JScript and VBScript.
LOADER_DATA: Holds RunPE shellcode.
FILE_DATA: Holds the shellcode that is injected to the host process. This will be discussed later.
As the script executes, it drops a copy of itself into %appdata%\Microsoft and gains persistence by editing the registry key: ‘HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run’.
The second stage is basically FILE_DATA which is injected to ‘msbuild.exe’ using LOADER_DATA (RunPE). FILE_DATA is base64 encoded – trying to decode and look at it does not yield information, as there is another layer of encoding.
LOADER_DATA (RunPE shellcode) is responsible for the second decoding routine.
Eventually, we see FILE_DATA is a portable executable, written in Dot Net. Looking at the decompiled source code we can see Hworm (njRAT) configuration.
Morphisec protects against Hworm and similar attacks. By applying Moving target defense technology, we deterministically prevent this attack without relation to signatures / patterns or obfuscation techniques.