Analysing STOP Ransomware
Overview
STOP/DJVU ransomware can be executed with one of the parameters listed: --Admin
, --ForNetRes
, --Task
, --AutoStart
or --Service
. It gathers location information of the victim with the help of a geolocation API service and compares its hard coded country codes to the victim’s code, if one of them matches the malware stops running. It uses the Salsa20
algorithm to encrypt files and adds the .cdpo
file extension at the end of each one of them. The malware maintains persistence with two methods: a run key named SysHelper
and a scheduled task called Time Trigger Task
. It drops additional payloads (in our case Vidar and a Clipboard Hijacker) from malicious URLs and a Public Key is also loaded from the C2 server.
Unpacking
The unpacking procedure is fairly simple. We only have to put a breakpoint on the WriteProcessMemory
function that writes data to an area of memory in a specified process, then run the program until it hits that breakpoint. We need to dump the 3rd argument of WriteProcessMemory
which is the lpBuffer
that is a pointer to the buffer that contains data to be written in the address space of the specified process. After following it in dump, the MZ
signature is found which is a clear indicator of a Windows executable. The last thing that should be done is to clear the junk code in a hex editor and we finally obtain the unpacked file.
Execution Parameters
Before we get into analysing what this malware is capable of, it’s important to note that it can execute itself with different parameters from command line.
First, the ransomware tries to launch itself with --Admin IsNotAutoStart IsNotTask
parameters. It gives admin access rights while the IsNotAutoStart
indicates it won’t run automatically when the system starts up and the IsNotTask
parameter means the execution of the program is not scheduled automatically.
However, STOP ransomware has five more ways to start its execution:
--Admin IsAutoStart IsTask
--ForNetRes IsAutoStart IsTask
--Task
--AutoStart
--Service
Location Information
The malware first makes a request to the Geo-IP API service https[:]//api.2ip.ua/geo.json
which obtains quite a few location related information of the victim and collects it in a JSON
file. Here is an example of it according to the geolocation site:
|
|
The country_code
field is compared and checked to numerous other countries:
Where RU
is Russia, BY
is Belarus, UA
is Ukraine, AZ
is Azerbaijan, AM
is Armenia, TJ
is Tajikistan, KZ
is Kazakhstan, KG
is Kyrgyzstan, UZ
is Uzbekistan, SY
is Syria. In case one of the hard coded country_code
is detected, the ransomware stops execution. However, if it doesn’t match, the execution of the malware continues.
Persistence
This malware uses two types of persistence methods. Under the Software\Microsoft\Windows\CurrentVersion\Run
registry key, it creates a value called SysHelper
. This makes the malware run every time the victim logs on. Then it executes the following command inside the created directory:
icacls "C:\Users\admin\AppData\Local\8a4577dc-de55-4eb5-b48a-8a3eee60cd95" /deny *S-1-1-0:(OI)(CI)(DE,DC)
The command denies the “Delete” and “Delete Child” permissions for the group ‘Everyone’ on this specific directory. The randomly named directory 8a4577dc-de55-4eb5-b48a-8a3eee60cd95
is generated by the malware itself with the UuidCreate
and UuidToStringW
functions.
The other persistence mechanism is a scheduled task with the Task Scheduler COM API. After viewing and searching the scheduled tasks on the infected machine, we notice a suspicious task called Time Trigger Task
. The action details confirm that it is indeed related to the malware and it is repeated after every 5 minutes indefinitely.
HTTP Communication
Public Key
In this specific PCAP, we have three crucial HTTP messages to analyse. First, it sends a GET
request to the habrafa[.]com
C2 host which contains a pid
in the URL that is an MD5
hash of the victim’s MAC address. The host then responds back with a PUBLIC KEY
(in PEM
format) and an id
which are stored in a text file called bowsakkdestx.txt
on the victim’s machine.
Malicious Payloads
The second HTTP message requests a file from brusuax[.]com
with the name build2.exe
which is a Windows executable. After unpacking, it is revealed that it’s a Vidar stealer malware which is quite common in case of STOP ransomware. It steals information and cryptocurrencies, if you want to get familiar with the infostealer and its functionalities, look for related articles in Malpedia’s collection.
There is also a build3.exe
loaded by the ransomware from the habrafa[.]com
C2 host. This is also a Windows executable as the MZ
signature indicates.
This PE file seems packed, but fortunately the unpacking is pretty easy and similar to the one described above. We just have to set a breakpoint on the NtWriteVirtualMemory
function, then follow the third argument in dump. After that, follow in memory map and dump it to a file. The very last thing we have to do is cleaning the file in a hex editor.
This additional payload is a Clipboard Hijacker
that keeps track of the clipboard activity and aims to replace the cryptocurrency address with the attacker’s own address. It executes the following command on the victim:
/C /create /F /sc minute /mo 1 /tn "Azure-Update-Task" /tr "C:\Users\admin\AppData\Roaming\Microsoft\Network\mstsca.exe"
This creates a scheduled task named Azure-Update-Task
with a schedule frequency of one minute, and runs the mstsca.exe
file which is the malicious executable.
Further looking into the unpacked sample, a mutex named M5/610HP/STAGE2
and several cryptocurrency addresses were found:
Cryptocurrency Addresses |
---|
1My2QNmVqkvN5M13xk8DWftjwC9G1F2w8Z |
3NLzE3tXwoagBrgFsjNNkPZfrESydTD8JP |
bc1qx8vykfse9s9llguez9cuyjmy092yeqkesl2r5v |
bnb136ns6lfw4zs5hg4n85vdthaad7hq5m4gtkgf23 |
LLiNjWA9h4LxVtDigLQ79xQdGiJYC4oHis |
MBD2C8QV7RDrNtSDRe9B2iH5r7yH4iMcxk |
ltc1qa5lae8k7tzcw5lcjfvfs3n0nhf0z3cgrsz2dym |
addr1qx4jwm700r2w6fneakg0r5pkg76vu7qkt6qv7zxza3qu3w9tyahu77x5a5n8nmvs78grv3a5eeupvh5qeuyv9mzpezuq60zykl |
Ae2tdPwUPEZDqNhACJ3ZT5NdVjkNffGAwa4Mc9N95udKWYzt1VnFngLMnPE |
t1VQgJMcNsBHsDyu1tXmJZjDpgbm3ftmTGN |
DBbgRYaKG993LFJKCWz73PZqveWsnwRmGc |
89SPVUAPHDLSq5pRdf8Eo6SLnKRJ8BNSYYnvPL6iJxGP4FBCBmkeV3CTSLCbk6uydxRnub4gLH6TBRycxSAQN2m1KcnhrSZ |
42UxohbdHGMYGPvW5Uep45Jt9Rj2WvTV958B5G5vHnawZhA4UwoD53Tafn6GRmcGdoSFUfCQN6Xm37LBZZ6qNBorFw3b6s2 |
0xa6360e294DfCe4fE4Edf61b170c76770691aA111 |
Configuration
The malware has several data tables in the .data
section. These tables have either 10 or 16 values that point to the .rdata
section. That is the location of the actual data we have to decrypt to extract the configuration. The XOR operator is used for the encryption procedure with the value 0x80
.
File Encryption
The ransomware uses the Salsa20 algorithm to encrypt files on the victim’s computer. After analyses, the file indicates that OpenSSL was also used in the encryption process since it contains several related strings. There are a few file extensions that the malware doesn’t encrypt, such as .sys
, .ini
, .DLL
, .dll
, .blf
, .bat
, .lnk
, and .regtrans-ms
.
This sample uses the .cdpo
file extension for the encrypted files, however the extension varies from executable to executable. The first 5 bytes are not encrypted by the ransomware while at the end of each file, the ransomware appends a UUID
(created with CreateUuid
and UuidToStringA
functions) that is encrypted with the RSA 2048 Public Key, the PersonalID
and the {36A698B9-D67C-4E07-BE82-0EC5B14B4DF5}
value:
The ransom note is placed in the _readme.txt
file that specifies the ransom demand and presents additional information like emails to contact, a WeTransfer link that supposedly demonstrates how to decrypt an encrypted file and the personal ID of the user:
A PersonalID.txt
file is also created and placed in the SystemID
folder on the victim’s machine:
Yara Rule
|
|
IOCs
Indicators of Compromise | Description |
---|---|
5e19952acedb1da68215069d44ce1f3d48da10491151003148f1cceab03f1073 | STOP Packed Sample |
236259fb27568c5b6ba0ed090909d2f1aeb70258673f3b561514350a65eba77a | STOP Unpacked Sample |
e3d16f3f69fa0857f966022387ee6f9408385ddf389d09ffe7dc44acc8ac1ad5 | Packed Vidar Infostealer (build2.exe) |
0e5849b3c364687599909abee08ab6638521ea62b887dc365e40d2589959ac8b | Unpacked Vidar Infostealer |
fef2c8ca07c500e416fd7700a381c39899ee26ce1119f62e7c65cf922ce8b408 | Packed Clipboard Hijacker (build3.exe) |
8d7f0e6b6877bdfb9f4531afafd0451f7d17f0ac24e2f2427e9b4ecc5452b9f0 | Unpacked Clipboard Hijacker |
habrafa[.]com/test1/get.php | Command and Control (C2) |
http[:]//brusuax[.]com/dl/build2.exe | Payload URL , drops Vidar |
http[:]//habrafa[.]com/files/1/build3.exe | Payload URL, drops Clipboard Hijacker |
References
- DJVU: The Ransomware That Seems Strangely Familiar…
- The STOP Ransomware Variant
- STOP Ransomware Technical Analysis Report
- A Detailed Analysis of the STOP Ransomware
- Package deal: Malware bundles causing disruption and damage across EMEA
- STOP (DJVU) RANSOMWARE: RANSOM FOR YOUR SHADY HABITS!
- ANY.RUN Task Of The Sample