In this post, we will be covering CinaRAT loader`s evasive TTPs (tactics, techniques, and procedures) as have been identified and prevented by Morphisec’s zero-trust endpoint security solution, powered by moving target defense technology.
We will be reviewing different versions of multi-staged loaders that attempt to inject and execute CinaRAT within the victim’s host memory. CinaRAT code is available on GitHub for download; generally it’s just a rebranded QuasarRAT.
We will focus on the evasive components that allowed the attackers to sustain zero detection for such a long period of time (VirusTotal)
1ST STAGE – ISO/VBS SCRIPT
Our investigation begins with a Visual Basic script that has been identified in a customer environment. We observed its delivery through an ISO archive file.
The script implements reflective loading, persistence, and evasion functionality.
The first step is a reflective loading of a remote .NET DLL executable, usually from a GitHub user account represented by an image download.
Figure 1:The image download
As soon as the image is downloaded and loaded into memory, it is written into a startup folder using an advanced method:
In order to copy itself into the autoruns, the script calls “NameSpace(7).Self.Path” that retrieves the autoruns path. This is a unique technique which isn’t often used for malware delivery.
Figure 2: NameSpace(7) usage
The obfuscation method for each version is different, and within each version the attacker changes the comment line in each code line so they can avoid hash detection.
Figure 3: Comment as a dynamic artifact
An interesting note is that the string technique utilized in the “GMR” variable evades VirusTotal when it is parsed.
Figure 4: VirusTotal content parsing
These are the main changes between Visual Basic script versions
Obfuscation, mainly splitting strings
Figure 5: Part of a split string
“If” condition within the Powershell in order to validate that the payload was successfully downloaded
Different payloads with different URLs
The following table lists a few examples that correlate between the URL download domain to the file path saved within the victim host along with our internal version numbering.
As was described in a previous stage, the Visual Basic script delivers a second .NET file.
The purpose of this .NET file is to decode the final stage .NET CinaRAT payload and inject it into a legitimate Windows process utilizing process hollowing. This is done with several evasion techniques in order to avoid detection and AI.
The RAT payload resides in a base64 encoded string that, during the execution, is decoded and XORed with string as the key. Once the .NET DLL decodes the RAT, it will hollow legitimate images in memory and inject it.
We have observed four different versions along with four subversions between December 8, 2020, and February 2, 2021 It’s noticeable that the attacker updated the evasion techniques from version to version in order to avoid detection.
The following table lists the different internal versions along the with first seen date either from the attacker’s GitHub or VirusTotal submission
Loader Internal version
Github date
VirusTotal date
V1
December 8, 2020
V1.1
December 18, 2020
December 20, 2020
V2
December 24, 2020
V2.1
December 24, 2020
December 31, 2020
V2.2
January 16, 2021
Was not submitted
V3
January 23, 2021
January 27, 2021
V4
January 22, 2021
January 25, 2021
V4.1
February 1, 2021
February 3, 2021
CODE PATTERN:
In each version the code pattern is different but eventually, the execution flow stays the same except for minor changes. Here are a few examples:
The called method convention is the same in all of the versions (axx.bxx.cxx()) except V4 ([WorkArea.Work]::Exe()).
In V1 and V2, the encoded base64 string is loaded from a variable while in V3 and V4 it’s loaded from a bunch of functions that are joined together to form the string.
The XOR key is the same in all of the versions except in V4.
The attacker obfuscated the code using an unregistered version of Eziriz .NET Reactor, although in V2 and V3 it seems that either they switched to a registered version or discarded the remnant code as the following script was not there anymore. In V4 the attacker did not implement any obfuscator, but in V4.1 the obfuscation was implemented again with the “unregistered” remnant code.
Figure 8: Fingerprint string
CODE MASQUERADING:
From V1.1, the attacker added legitimate namespaces from popular .NET libraries to the loader. This evasion technique tries to disguise the loader as a legitimate .DLL in order to avoid analysis. It’s also possible that this technique can bypass AV solutions that implement whitelist rules on chunks from those .NET libraries. The following table lists a few examples of libraries that were used.
Version
Libraries
V1
None
V1.1
Newtonsoft json.NET
V2.1
RestSharp + DiscUtils
Figure 9: Some of the namespaces in V2
Analyzing the submission dates and the first detection dates on all of the loaders in VirusTotal suggests that the code masquerading technique succeeds with bypassing AV solutions.
3RD STAGE – RAT PAYLOAD
We have observed four different versions of RAT payloads. The first one that was used was QuasarRAT 1.4, while later on CinaRAT 1.0.1.1 was used instead with some modifications. For the C2 domain, the attacker mostly used a dynamic DNS service from myq-see[.]com
The following table correlates the observed RAT version with the C2 domain and Loader version.
RAT Version
Loader internal version
C2 Domain
QuasarRAT 1.4
V1
server.homesbill[.]com
CinaRAT 1.0.1.1 variant A
V1.1
V1.1 + V2
aptzebi.myq-see[.]com
V2.1
aptzebi0.myq-see[.]com
V2.1 + V2.2
mahost.myq-see[.]com
CinaRAT 1.0.1.1 variant B
V3
V4
aptzebi3.myq-see[.]com
CinaRAT 1.0.1.1 variant C
V4.1
zebi4.myq-see[.]com
Figure 10: RAT configuration example from V4.1
CONCLUSION
The Morphisec platform prevents attacks from CinaRAT with a zero-trust default-deny approach to endpoint security, powered by moving target defense. Customers of Morphisec are thus protected from CinaRAT, regardless of what evasive techniques the attacker deploys to bypass AV and NGAV solutions.