At the end of May, we discovered a campaign of malware distribution of the Remote Access Trojan (RAT) class, programs that allow attackers to remotely control an infected system.
The group we are considering was distinguished by the fact that it did not choose any specific RAT family for infection. Several Trojans were spotted in the attacks within the campaign (all in the public domain). With this feature, the grouping reminded us of the rat king - a mythical animal that consists of rodents with intertwined tails.

The original is taken from the monograph by K. N. Rossikov "Mice and mouse-like rodents, the most important in economic terms" (1908)
In honor of this creature, we named the grouping we are considering RATKing. In this post, we will talk in detail about how the attackers carried out the attack, what tools they used, and also share our thoughts on the attribution of this campaign.
Attack progress
All attacks in this campaign were carried out according to the following algorithm:
- The user received a phishing email with a link to Google Drive.
- From the link, the victim downloaded a malicious VBS script that wrote a DLL to load the final payload into the Windows registry and launched PowerShell to execute it.
- The DLL-library injected the final payload — in fact, one of the RATs used by the attackers — into the system process and added a VBS script to autorun in order to gain a foothold in the infected machine.
- The final payload was executed in a system process and gave the attacker the ability to control the infected computer.
Schematically, this can be represented as follows:

Next, we will focus on the first three stages, since we are interested in the malware delivery mechanism. We will not describe in detail the mechanism of the malware itself. They are widely available - either sold on specialized forums, or even distributed as open source projects - which means they are not unique to the RATKing group.
Analysis of attack stages
Stage 1. Phishing mailing
The attack began with the victim receiving a malicious email (the attackers used different templates with text, one example is shown in the screenshot below). The message contained a link to a legitimate repository drive.google.com, which allegedly led to a PDF download page.

Example of a phishing email
However, in fact, it was not a PDF document that was loaded at all, but a VBS script.
When clicking on the link from the email in the screenshot above, a file with the name Cargo Flight Details.vbs. In this case, the attackers did not even try to disguise the file as a legitimate document.
At the same time, as part of this campaign, we discovered a script named Cargo Trip Detail.pdf.vbs. It could already pass for a legitimate PDF, because by default Windows hides the file extension. True, in this case, its icon, which corresponded to the VBS script, could still cause suspicion.
At this stage, the victim could recognize the deception: just look at the downloaded files for a second. However, in such phishing campaigns, attackers often rely on an inattentive or hurried user.
Stage 2. Work of the VBS script
The VBS script, which the user could open by negligence, registered the DLL library in the Windows registry. The script has been obfuscated: the lines in it are written as bytes separated by an arbitrary character.

Obfuscated script example
The deobfuscation algorithm is quite simple: every third character was excluded from the obfuscated string, after which the result was decoded from base16 to the original string. For example, from the value 57Q53s63t72s69J70r74e2El53v68m65j6CH6Ct (highlighted in the screenshot above) the result was a line WScript.Shell.
To deobfuscate strings, we used a Python function:
def decode_str(data_enc):
return binascii.unhexlify(''.join([data_enc[i:i+2] for i in range(0, len(data_enc), 3)]))Below, on lines 9-10, the value is highlighted, upon deobfuscation of which a DLL file was obtained. It was he who was launched in the next step using PowerShell.
![]()
Line with obfuscated DLL
Each function in the VBS script was executed as the lines were deobfuscated.
After running the script, the function was called wscript.sleep - with its help, deferred execution was performed.
Further, the script worked with the Windows registry. He used WMI technology for this. With its help, a unique key was created, and the body of the executable file was written to its parameter. Accessing the registry via WMI was performed using the following command:
GetObject(winmgmts {impersonationLevel=impersonate}!\.rootdefault:StdRegProv) 
Registry entry made by VBS script
Stage 3. Work of the DLL-library
At the third stage, the malicious DLL loaded the final payload, injected it into the system process, and ensured that the VBS script was auto-run when the user logged into the system.
Launch via PowerShell
The DLL was executed using the following command in PowerShell:
[System.Threading.Thread]::GetDomain().Load((ItemProperty HKCU:///Software///<rnd_sub_key_name> ).<rnd_value_name>);
[GUyyvmzVhebFCw]::EhwwK('WScript.ScriptFullName', 'rWZlgEtiZr', 'WScript.ScriptName'),0This command did the following:
- received registry value data named
rnd_value_name- this data was a DLL file written on the .Net platform; - loaded the resulting .Net module into the process memory
powershell.exeusing the function[System.Threading.Thread]::GetDomain().Load()(detailed description of the Load() function ); - performed the function
GUyyvmzVhebFCw]::EhwwK()- the execution of the DLL library began with it - with parametersvbsScriptPath,xorKey,vbsScriptName... ParameterxorKeystored the key for decrypting the final payload, and the parametersvbsScriptPathиvbsScriptNamewere transferred in order to register a VBS script in autorun.
Description of the DLL
In the decompiled form, the loader looked like this:

Loader in decompiled form (underlined in red is the function that started the execution of the DLL)
The loader is protected by the .Net Reactor protector. The de4dot utility does an excellent job of removing this protector.
This bootloader:
- carried out the injection of the payload into the system process (in this example, this
svchost.exe); - prescribe VBS-script in autorun.
payload injection
Consider the function that the PowerShell script called.

Function called by PowerShell script
This function did the following:
- decrypted two arrays of data (
arrayиarray2on the screenshot). They were originally gzip-compressed and encrypted using the XOR algorithm with the keyxorKey; - copied data to allocated memory areas. Data from
array- to the memory area pointed tointPtr(payload pointeron the screenshot); data fromarray2- to the memory area pointed tointPtr2(shellcode pointeron the screenshot); - called a function
CallWindowProcA( this feature is available on the Microsoft website) with the following parameters (the names of the parameters are listed below, in the screenshot they go in the same order, but with working values):lpPrevWndFunc- pointer to data fromarray2;hWnd- pointer to a string containing the path to the executable filesvchost.exe;Msg- pointer to data fromarray;wParam,lParam— message parameters (in this case, these parameters were not used and had values of 0);
- created a file
%AppData%MicrosoftWindowsStart MenuProgramsStartup<name>.urlWhere<name>are the first 4 characters of the parametervbsScriptName(in the screenshot, the code fragment with this action begins with the commandFile.Copy). In this way, the malware added a URL file to the list of files to autorun when a user logged into the system, and thereby fixed itself on the infected computer. The URL file contained a link to the script:
[InternetShortcut]
URL = file : ///<vbsScriptPath>
To understand how the injection was carried out, we deciphered the data arrays array и array2. To do this, we used the following Python function:
def decrypt(data, key):
return gzip.decompress(
bytearray([data[i] ^ key[i % len(key)] for i in range(len(data))])[4:])
As a result, we found out that:
arraywas a PE file - this is the final payload;array2was the shellcode required for the injection.
Shellcode from array array2 passed as function value lpPrevWndFunc into a function CallWindowProcA. lpPrevWndFunc is a callback function, its prototype looks like this:
LRESULT WndFunc(
HWND hWnd,
UINT Msg,
WPARAM wParam,
LPARAM lParam
);
So when you run the function CallWindowProcA with parameters hWnd, Msg, wParam, lParam executing shellcode from an array array2 with arguments hWnd и Msg. hWnd is a pointer to a string containing the path to the executable file svchost.exe, Msg — a pointer to the final payload.
The shellcode received function addresses from kernel32.dll и ntdll32.dll by hash values from their names and performed the injection of the final payload into the process memory svchost.exeusing the Process Hollowing technique (you can read more about it in this ). When injecting shellcode:
- created a process
svchost.exein a suspended state using the functionCreateProcessW; - then hide the section mapping in the process address space
svchost.exeusing functionsNtUnmapViewOfSection. Thus the program freed the memory of the original processsvchost.exe, in order to allocate memory for the payload at this address; - allocated memory for the payload in the address space of the process
svchost.exeusing functionsVirtualAllocEx;

Starting the injection process
- write the contents of the payload to the address space of the process
svchost.exeusing functionsWriteProcessMemory(as in the screenshot below); - restarted the process
svchost.exeusing functionsResumeThread.

Completion of the injection process
Downloadable malware
As a result of the described actions, one of several malicious programs of the RAT class was installed on the infected system. The table below lists the malware used in the attack, which we can confidently attribute to one group of attackers, since the samples accessed the same control server.
Name of HPE
First seen
SHA-256
DC
The process into which the injection is carried out
dark track
16-04-2020
ea64fe672c953adc19553ea3b9118ce4ee88a14d92fc7e75aa04972848472702
kimjoy007.dyndns[.]org:2017
svchost
Parallax
24-04-2020
b4ecd8dbbceaadd482f1b23b712bcddc5464bccaac11fe78ea5fd0ba932a4043
kimjoy007.dyndns[.]org:2019
svchost
WARZONE
18-05-2020
3786324ce3f8c1ea3784e5389f84234f81828658b22b8a502b7d48866f5aa3d3
kimjoy007.dyndns[.]org:9933
svchost
netwire
20-05-2020
6dac218f741b022f5cad3b5ee01dbda80693f7045b42a0c70335d8a729002f2d
kimjoy007.dyndns[.]org:2000
svchost
Examples of distributed malware with the same control server
Two things are noteworthy here.
First, the very fact that the attackers used several different RAT families at once. This behavior is not typical for well-known cybergroups, which often use approximately the same set of tools they are used to.
Secondly, RATKing used malware that is either sold on specialized forums for a small price, or is completely open source projects.
A more complete list of the malware used in the campaign - with one important caveat - is given at the end of the article.
About grouping
We cannot attribute the described malicious campaign to any known attackers. So far, we believe that these attacks were carried out by a fundamentally new group. As we wrote at the beginning, we named it RATKing.
To create a VBS script, the grouping probably used a tool similar to the utility from the developer . This is indicated by the similarity of the script that this program creates with the attacker's script. Specifically, they are both:
- carry out deferred execution using the function
Sleep; - use WMI;
- prescribe the body of the executable file as a registry key parameter;
- execute this file using PowerShell in its own address space.
For clarity, compare the PowerShell command to run a file from the registry, which is used by a script created using VBS-Crypter:
((Get-ItemPropertyHKCU:SoftwareNYANxCAT).NYANxCAT);$text=-join$text[-1..-$text.Length];[AppDomain]::CurrentDomain.Load([Convert]::FromBase64String($text)).EntryPoint.Invoke($Null,$Null);with a similar command that the attackers' script used:
[System.Threading.Thread]::GetDomain().Load((ItemProperty HKCU:///Software///<rnd_sub_key_name> ).<rnd_value_name>);
[GUyyvmzVhebFCw]::EhwwK('WScript.ScriptFullName', 'rWZlgEtiZr', 'WScript.ScriptName'),0
Note that the attackers used another utility from NYAN-x-CAT as one of the payloads - .
The C&C server addresses point to another hallmark of RATKing: the grouping favors dynamic DNS services (see list of C&Cs in the IoC table).
IoC
The table below shows a complete list of VBS scripts that can most likely be attributed to the described campaign. All these scripts are similar and carry out approximately the same sequence of actions. All of them inject malware of the RAT class into a trusted Windows process. All of them have C&C addresses registered using Dynamic DNS services.
However, we cannot say that all these scripts were distributed by the same attackers, except for samples with the same C&C addresses (for example, kimjoy007.dyndns.org).
Name of HPE
SHA-256
DC
The process into which the injection is carried out
Parallax
b4ecd8dbbceaadd482f1b23b712bcddc5464bccaac11fe78ea5fd0ba932a4043
kimjoy007.dyndns.org
svchost
00edb8200dfeee3bdd0086c5e8e07c6056d322df913679a9f22a2b00b836fd72
hope.doomdns.org
svchost
504cbae901c4b3987aa9ba458a230944cb8bd96bbf778ceb54c773b781346146
kimjoy007.dyndns.org
svchost
1487017e087b75ad930baa8b017e8388d1e99c75d26b5d1deec8b80e9333f189
kimjoy007.dyndns.org
svchost
c4160ec3c8ad01539f1c16fb35ed9c8c5a53a8fda8877f0d5e044241ea805891
franco20.dvrdns.org
svchost
515249d6813bb2dde1723d35ee8eb6eeb8775014ca629ede017c3d83a77634ce
kimjoy007.dyndns.org
svchost
1b70f6fee760bcfe0c457f0a85ca451ed66e61f0e340d830f382c5d2f7ab803f
franco20.dvrdns.org
svchost
b2bdffa5853f29c881d7d9bff91b640bc1c90e996f85406be3b36b2500f61aa1
hope.doomdns.org
svchost
c9745a8f33b3841fe7bfafd21ad4678d46fe6ea6125a8fedfcd2d5aee13f1601
kimjoy007.dyndns.org
svchost
1dfc66968527fbd4c0df2ea34c577a7ce7a2ba9b54ba00be62120cc88035fa65
franco20.dvrdns.org
svchost
c6c05f21e16e488eed3001d0d9dd9c49366779559ad77fcd233de15b1773c981
kimjoy007.dyndns.org
cmd
3b785cdcd69a96902ee62499c25138a70e81f14b6b989a2f81d82239a19a3aed
hope.doomdns.org
svchost
4d71ceb9d6c53ac356c0f5bdfd1a5b28981061be87e38e077ee3a419e4c476f9
2004para.ddns.net
svchost
00185cc085f284ece264e3263c7771073a65783c250c5fd9afc7a85ed94acc77
hope.doomdns.org
svchost
0342107c0d2a069100e87ef5415e90fd86b1b1b1c975d0eb04ab1489e198fc78
franco20.dvrdns.org
svchost
de33b7a7b059599dc62337f92ceba644ac7b09f60d06324ecf6177fff06b8d10
kimjoy007.dyndns.org
svchost
80a8114d63606e225e620c64ad8e28c9996caaa9a9e87dd602c8f920c2197007
kimjoy007.dyndns.org
svchost
acb157ba5a48631e1f9f269e6282f042666098614b66129224d213e27c1149bb
hope.doomdns.org
cmd
bf608318018dc10016b438f851aab719ea0abe6afc166c8aea6b04f2320896d3
franco20.dvrdns.org
svchost
4d0c9b8ad097d35b447d715a815c67ff3d78638b305776cde4d90bfdcb368e38
hope.doomdns.org
svchost
e7c676f5be41d49296454cd6e4280d89e37f506d84d57b22f0be0d87625568ba
kimjoy007.dyndns.org
svchost
9375d54fcda9c7d65f861dfda698e25710fda75b5ebfc7a238599f4b0d34205f
franco20.dvrdns.org
svchost
128367797fdf3c952831c2472f7a308f345ca04aa67b3f82b945cfea2ae11ce5
kimjoy007.dyndns.org
svchost
09bd720880461cb6e996046c7d6a1c937aa1c99bd19582a562053782600da79d
hope.doomdns.org
svchost
0a176164d2e1d5e2288881cc2e2d88800801001d03caedd524db365513e11276
paradickhead.homeip.net
svchost
0af5194950187fd7cbd75b1b39aab6e1e78dae7c216d08512755849c6a0d1cbe
hope.doomdns.org
svchost
Warzone
3786324ce3f8c1ea3784e5389f84234f81828658b22b8a502b7d48866f5aa3d3
kimjoy007.dyndns.org
svchost
db0d5a67a0ced6b2de3ee7d7fc845a34b9d6ca608e5fead7f16c9a640fa659eb
kimjoy007.dyndns.org
svchost
netwire
6dac218f741b022f5cad3b5ee01dbda80693f7045b42a0c70335d8a729002f2d
kimjoy007.dyndns.org
svchost
dark track
ea64fe672c953adc19553ea3b9118ce4ee88a14d92fc7e75aa04972848472702
kimjoy007.dyndns.org
svchost
WSH RAT
d410ced15c848825dcf75d30808cde7784e5b208f9a57b0896e828f890faea0e
anekesolution.linkpc.net
RegAsm
Lime
896604d27d88c75a475b28e88e54104e66f480bcab89cc75b6cdc6b29f8e438b
softmy.duckdns.org
RegAsm
QuasarRAT
bd1e29e9d17edbab41c3634649da5c5d20375f055ccf968c022811cd9624be57
darkhate-23030.portmap.io
RegAsm
12044aa527742282ad5154a4de24e55c9e1fae42ef844ed6f2f890296122153b
darkhate-23030.portmap.io
RegAsm
be93cc77d864dafd7d8c21317722879b65cfbb3297416bde6ca6edbfd8166572
darkhate-23030.portmap.io
RegAsm
933a136f8969707a84a61f711018cd21ee891d5793216e063ac961b5d165f6c0
darkhate-23030.portmap.io
RegAsm
71dea554d93728cce8074dbdb4f63ceb072d4bb644f0718420f780398dafd943
chrom1.myq-see.com
RegAsm
0d344e8d72d752c06dc6a7f3abf2ff7678925fde872756bf78713027e1e332d5
darkhate-23030.portmap.io
RegAsm
0ed7f282fd242c3f2de949650c9253373265e9152c034c7df3f5f91769c6a4eb
darkhate-23030.portmap.io
RegAsm
aabb6759ce408ebfa2cc57702b14adaec933d8e4821abceaef0c1af3263b1bfa
darkhate-23030.portmap.io
RegAsm
1699a37ddcf4769111daf33b7d313cf376f47e92f6b92b2119bd0c860539f745
darkhate-23030.portmap.io
RegAsm
3472597945f3bbf84e735a778fd75c57855bb86aca9b0a4d0e4049817b508c8c
darkhate-23030.portmap.io
RegAsm
809010d8823da84cdbb2c8e6b70be725a6023c381041ebda8b125d1a6a71e9b1
darkhate-23030.portmap.io
RegAsm
4217a2da69f663f1ab42ebac61978014ec4f562501efb2e040db7ebb223a7dff
darkhate-23030.portmap.io
RegAsm
08f34b3088af792a95c49bcb9aa016d4660609409663bf1b51f4c331b87bae00
darkhate-23030.portmap.io
RegAsm
79b4efcce84e9e7a2e85df7b0327406bee0b359ad1445b4f08e390309ea0c90d
darkhate-23030.portmap.io
RegAsm
12ea7ce04e0177a71a551e6d61e4a7916b1709729b2d3e9daf7b1bdd0785f63a
darkhate-23030.portmap.io
RegAsm
d7b8eb42ae35e9cc46744f1285557423f24666db1bde92bf7679f0ce7b389af9
darkhate-23030.portmap.io
RegAsm
def09b0fed3360c457257266cb851fffd8c844bc04a623c210a2efafdf000d5c
darkhate-23030.portmap.io
RegAsm
50119497c5f919a7e816a37178d28906fb3171b07fc869961ef92601ceca4c1c
darkhate-23030.portmap.io
RegAsm
ade5a2f25f603bf4502efa800d3cf5d19d1f0d69499b0f2e9ec7c85c6dd49621
darkhate-23030.portmap.io
RegAsm
189d5813c931889190881ee34749d390e3baa80b2c67b426b10b3666c3cc64b7
darkhate-23030.portmap.io
RegAsm
c3193dd67650723753289a4aebf97d4c72a1afe73c7135bee91c77bdf1517f21
darkhate-23030.portmap.io
RegAsm
a6f814f14698141753fc6fb7850ead9af2ebcb0e32ab99236a733ddb03b9eec2
darkhate-23030.portmap.io
RegAsm
a55116253624641544175a30c956dbd0638b714ff97b9de0e24145720dcfdf74
darkhate-23030.portmap.io
RegAsm
d6e0f0fb460d9108397850169112bd90a372f66d87b028e522184682a825d213
darkhate-23030.portmap.io
RegAsm
522ba6a242c35e2bf8303e99f03a85d867496bbb0572226e226af48cc1461a86
darkhate-23030.portmap.io
RegAsm
fabfdc209b02fe522f81356680db89f8861583da89984c20273904e0cf9f4a02
darkhate-23030.portmap.io
RegAsm
08ec13b7da6e0d645e4508b19ba616e4cf4e0421aa8e26ac7f69e13dc8796691
darkhate-23030.portmap.io
RegAsm
8433c75730578f963556ec99fbc8d97fa63a522cef71933f260f385c76a8ee8d
darkhate-23030.portmap.io
RegAsm
99f6bfd9edb9bf108b11c149dd59346484c7418fc4c455401c15c8ac74b70c74
darkhate-23030.portmap.io
RegAsm
d13520e48f0ff745e31a1dfd6f15ab56c9faecb51f3d5d3d87f6f2e1abe6b5cf
darkhate-23030.portmap.io
RegAsm
9e6978b16bd52fcd9c331839545c943adc87e0fbd7b3f947bab22ffdd309f747
darkhate-23030.portmap.io
RegAsm
Source: habr.com
