Threat Intelligence
EnkiWhiteHat
2024. 9. 13.
1. Overview
Following Microsoft's move to block macros by default in Office applications and the deprecation of VBScript, there has been a notable increase in attacks leveraging LNK files as an initial compromise vector.
Among these, information regarding RokRAT, a malware executed via LNK files, was identified on Twitter. This report provides an analysis of this malware.

2. Malware Analysis
2.1. Attack Flow

caption - Attack Flow
2.2. LNK File Analysis
Gate access roster 2024.xlsx.lnk
Attackers typically compress either the LNK file with embedded commands by itself or along with legitimate files, then send it to the target via email. As we were unable to obtain the initial archive, our analysis begins with the malicious LNK file itself.
LNK files allow specifying a target application and arguments for execution. Attackers exploit this by embedding malicious commands, and tricking users into running them. The embedded commands can be inspected via the properties dialog.

caption - LNK File Properties

caption - LNK File Properties
The full command embedded in the LNK file can be identified using the LECmd analysis tool.

caption - LECmd Output
Upon execution, the LNK file performs the following actions:
Executes
*rshell.exe
located inC:\Windows\SysWow64\WindowsPowerShell\v1.0\
. This, in turn, runs PowerShell.
If the current working directory is
System32
orProgram Files
, the$dirPath
variable is set to the temporary directory (%Temp%
). Otherwise,$dirPath
remains the current working directory.
Recursively searches within the directory specified by
$dirPath
for an LNK file with a size of 41,951,597 bytes.
Extracts multiple embedded file data from the LNK file found in the previous step and saves them as files. The files created at this stage are listed in the table below.
Following extraction, the decoy spreadsheet
Gate access roster 2024.xlsx
is opened, andfind.bat
is executed. The LNK file then deletes itself.

caption - Gate access roster 2024.xlsx Run Results
2.3. PowerShell Script Analysis
The find.bat
and search.dat
files are created and executed by the LNK file.
find.bat
The find.bat
script constructs a PowerShell ScriptBlock from search.dat
's contents, and then invokes it.
search.dat
The search.dat
file reads viewer.dat
, loads it into memory, and creates a new thread to execute the loaded code. The viewer.dat
file is shellcode.
2.4. Shellcode Analysis
The shellcode decrypts the encrypted RokRAT payload and then executes it in memory. It resolves API functions by looking up their addresses based on provided API hash values and then calls them.

caption - Dynamic Import Code
The encrypted RokRAT payload is embedded within the shellcode. It is decrypted using an XOR operation and then executed in memory.

caption - RokRAT Decryption Code
A script to decrypt the RokRAT payload is provided below.
2.5. RokRAT Analysis
RokRAT uses the cloud services pCloud, DropBox, and Yandex for C&C. It uploads collected victim system information to these cloud services and receives data containing command codes through them.
Before creating the main thread that performs its primary functions, RokRAT first collects information from the infected system.

caption - RokRAT Victim System Information Collection Code
Key information collected includes:
Windows Build Version
Windows Bitness
Computer Name
Username
Current Process Path
System Product
VMware Tools Version (if present)
System BIOS Version
Intertwined with information collection, RokRAT uses RNGs to generate values used to communicate through the cloud services.

caption - Data Generation Code for Communication
The malware incorporates two string decryption functions. Both functions use the first byte of the encrypted data as the key. The difference is that one function additionally subtracts 2048 from an intermediate value during decryption.


A script to print the decrypted results of all encrypted strings is provided below.

caption - Decryption Script Execution Results
Once victim system information collection is complete, a thread is created to communicate with cloud services and perform malicious activities.

caption - Main Function Pseudocode
The cloud services used for communication are pCloud and Yandex. pCloud is used as the primary C&C, while Yandex serves as a fallback. Although DropBox-related code is present, it is unused.
Cloud service tags and token information are hardcoded, as shown in the table below:

caption - pCloud Token Information

caption - Yandex Token Information
Data prepared for exfiltration to the C&C server, including collected system information, is constructed as follows:
Append 4 bytes of hardcoded data from the malware.
Append collected victim system information.
Append delimiter (
0x28
).Append screenshot.
Append delimiter (
0x2a
).Append the length of process list information.
Append the list of running processes.

caption - Data Generation Routine for Cloud Service Transmission
The final data structure is as follows.

This data is then encrypted before upload.
First, it is XOR encrypted using a randomly generated 4-byte key. Since the first 4 bytes of the data being encrypted are known to the attacker during malware creation, the attacker can deduce this 4-byte key through reverse operations.

caption - Encryption and Upload Code
Second, the data is encrypted with AES-128-CBC. The key and IV used for this encryption are initialized by the following code.

caption - AES Key and IV Initialization Code
The AES key is encrypted using an RSA public key and uploaded to the cloud service along with the victim system information. The RSA public key is BER-encoded and embedded in the malware.

caption - BER-Encoded Data Containing the RSA Public Key
Data received from the cloud service is decrypted using AES-128-CBC. The actions performed depend on the command code received, as detailed below:
3. Conclusion
This report detailed APT37's use of LNK files as an initial compromise vector and the inner workings and key characteristics of the RokRAT malware. RokRAT employs the Living Off Trusted Sites (LOTS) technique, abusing the legitimate services pCloud, Yandex, and DropBox for its attacks, thereby enabling malicious activities without the need to establish separate infrastructure. In response to such abuse, pCloud, for instance, has implemented measures to block abuse through a strict screening process before issuing API tokens.
We hope this report serves as a valuable resource in understanding and countering the ever-evolving landscape of cyber attacks.
4. Appendix
4.1. Analysis Scripts
LNK Embedded File Dumper
API Hashing Script
pCloud File Download Script
aes key, iv initialization
4.2. Analyzed Structures
RokRAT System Information Structure
4.3. IOC
c25e5e87d1e665197209e7aaec64e484ce30e2dabcc9e457c5593ac6c7bb5686 (Gate access roster 2024.xlsx.lnk)
- dd3803ade05abe200bac8cb34247b4318b45fc8e731f4f1b4a2f26f613201d07 ((Gate access roster 2024.xlsx)
- 95aedd9c8ec64d3abd6ecf016b6886eec6af73ee278a2d7da9f20ff97e157e6f (search.dat)
- cdfa3a84b1bf6a58218bb6435a513b8e0bae4dbc849dfa045ed72216d817ae2b (find.bat)
- 2ae727feffb939434fd9c3804517d868fbe42a8e2d66fd0eef9fa14f3e9c7a27 (viewer.dat)
- 94159655fa0bfb1eff092835d8922d3e18ca5c73884fd0d8b78f42c8511047b6 (RokRAT)
0a501fd9d043b043de9083d03870b9c9ddb4f18a89366bc2ca413f835709415c
- 653202d94d655f9fafbb1217fba57d23f30a7e3ed7fe3272f237ec21e0731126
- e97b31d85345d899bdd207e52c7660cf036a65f0c0d224f3e035544f999bf0ad
- 94fb40e50f2614d11e3b122be91e76d2fd233791b8a7b36927f6dcbeb79ea0c3
- 903b02ff3ef690ea53103737a07c36a732bd81ab04f78d6f5eb61ac0fc6f98a6
- b8d034814d9c8aa12b49372c9007f364733a0b8d083307f5ee747c1018341282
23549c774f56aae77115b456bdcad6c81fb82a0936841da0e056c922db83d342
- 653202d94d655f9fafbb1217fba57d23f30a7e3ed7fe3272f237ec21e0731126
- e97b31d85345d899bdd207e52c7660cf036a65f0c0d224f3e035544f999bf0ad
- 94fb40e50f2614d11e3b122be91e76d2fd233791b8a7b36927f6dcbeb79ea0c3
- 903b02ff3ef690ea53103737a07c36a732bd81ab04f78d6f5eb61ac0fc6f98a6
- b8d034814d9c8aa12b49372c9007f364733a0b8d083307f5ee747c1018341282
b02329000ae4f8f4238db366d8fe394867dcad8222d02d9a76e82a376c6b1405
- 9646372af573fb90a7f3665386629cc3b08ee44fb5d294f479c931ad7300bb31
- e6f4bbc21b34b10b10a9bc83ccc329a286b2710f3d34ce427846b5ff53b611c5
- 94fb40e50f2614d11e3b122be91e76d2fd233791b8a7b36927f6dcbeb79ea0c3
- dc6ca2e9ce800245a65715647bb1614c35632f270d1879e796472e786cdfc0fc
- 1fa815ed72933b3d2efdae7b13d6cc87ef261ea0d45903a02226a9278ccd49d0
b1025baa59609708315326fe4279d8113f7af3f292470ef42c33fccbb8aa3e56
- 81269c3c41d957765314a1704e0ea6cdf9666eab729597207fd1cc844c749beb
- e6f4bbc21b34b10b10a9bc83ccc329a286b2710f3d34ce427846b5ff53b611c5
- 4ec203d22097e29d83a6425e523cfb3e26ff5b39454585f78a627f2f0fb658f8
- dc6ca2e9ce800245a65715647bb1614c35632f270d1879e796472e786cdfc0fc
- 1fa815ed72933b3d2efdae7b13d6cc87ef261ea0d45903a02226a9278ccd49d0
c25e5e87d1e665197209e7aaec64e484ce30e2dabcc9e457c5593ac6c7bb5686
- dd3803ade05abe200bac8cb34247b4318b45fc8e731f4f1b4a2f26f613201d07
- 95aedd9c8ec64d3abd6ecf016b6886eec6af73ee278a2d7da9f20ff97e157e6f
- cdfa3a84b1bf6a58218bb6435a513b8e0bae4dbc849dfa045ed72216d817ae2b
- 2ae727feffb939434fd9c3804517d868fbe42a8e2d66fd0eef9fa14f3e9c7a27
- 94159655fa0bfb1eff092835d8922d3e18ca5c73884fd0d8b78f42c8511047b6
cbc777d1e018832790482e6fd82ab186ac02036c231f10064b14ff1d81832f13
- 14e507f2160b415d8aae1bbe4e5fbcf0a10563a72bb53b7d8a9fc339518bc668
- e97b31d85345d899bdd207e52c7660cf036a65f0c0d224f3e035544f999bf0ad
- 94fb40e50f2614d11e3b122be91e76d2fd233791b8a7b36927f6dcbeb79ea0c3
- f3d98b1638dbe6fd0f97ae3b1d2c9d5c0f592baa1317c862042e5201a1e14aed
- 4f5d8bb87b68b943c1e4f05c12a8c0836dc7744bc4e7868c6189cbd5881c2d79
dbd5d662cc53d4b91cf7da9979cdffd1b4f702323bb9ec4114371bc6f4f0d4a6
- 653202d94d655f9fafbb1217fba57d23f30a7e3ed7fe3272f237ec21e0731126
- e97b31d85345d899bdd207e52c7660cf036a65f0c0d224f3e035544f999bf0ad
- 94fb40e50f2614d11e3b122be91e76d2fd233791b8a7b36927f6dcbeb79ea0c3
- 903b02ff3ef690ea53103737a07c36a732bd81ab04f78d6f5eb61ac0fc6f98a6
- b8d034814d9c8aa12b49372c9007f364733a0b8d083307f5ee747c1018341282
e914f39c7800f87e99ca4821c7a6d4ac580d99b5d70bea54d17c2b6e862b2de6
- 00f45a18a4ca30f2de40c213186bd9e9e1202f24c844cbcae29ae01d93cbae93
- faa8312eb5dfaafae9be18b4470990e6e0ff4911c862e33879196ed233d18745
- 92bad80b08407755da14760de5703dcd7a88703ffca7443f18fd94d853b08056
- cbc777d1e018832790482e6fd82ab186ac02036c231f10064b14ff1d81832f13