Inside BlackMatter: Technical Analysis of BlackMatter Ransomware

SRMA

Inside BlackMatter: Technical Analysis of BlackMatter Ransomware

BlackMatter Ransomware Technical Analysis

Overview

Greetings friends! A client approached us with an incident related to BlackMatter. The problem kept recurring, which led the client to request a security audit. In this article we provide a technical analysis of BlackMatter ransomware, focusing on its methods, libraries, and techniques used to infect and encrypt target systems. BlackMatter is a ransomware family first observed in July 2021. It is widely described as a possible rebrand of DarkSide, a Russian-speaking Ransomware-as-a-Service (RaaS) group based in Eastern Europe. The BlackMatter ransomware was written in C++ and compiled for the Win32 platform. Like other ransomware variants, it encrypts victims’ files and demands a ransom payment in exchange for a decryption key. BlackMatter uses a combination of symmetric and asymmetric encryption:

  • It generates a random 256-bit key to encrypt victim data.
  • That key is then encrypted using an RSA public key unique per victim.
  • Only attackers holding the corresponding private key can decrypt the data. One notable aspect of BlackMatter is its use of the Salsa20 algorithm for symmetric encryption.

Analysis

To analyze BlackMatter ransomware, we used:

Let’s explore how BlackMatter works

Before starting the main routine, BlackMatter performs preparatory work. If all checks succeed, it begins the encryption stage. image

Library loading and API resolution

BlackMatter loads libraries and resolves API addresses dynamically: image From the loaded modules list, you can see the ransomware relies on bcrypt and ncrypt modules for cryptography. image

API hashing

BlackMatter uses API hashing to hide suspicious Windows APIs from the Import Address Table (IAT), increasing the difficulty of static analysis. Reference: https://www.ired.team/offensive-security/defense-evasion/windows-api-hashing-in-malware Before decrypting API hashes: image After decrypting API hashes: image

Packed and encrypted section

BlackMatter keeps part of its data in a packed and encrypted section, then unpacks and decrypts it at startup to complicate static analysis. Unpack and decode function: image Unpacking process: image

Language checks

The ransomware avoids execution in certain locales, including former USSR countries and Syria, which aligns with its attribution to a Russian-speaking group. Language checks: image Table of unsupported languages: image

Administrator check

BlackMatter uses SHTestTokenMembership to check whether the launching user is a member of the Administrators group. Checks token: image

OS version check

Next, the malware checks the OS version. Checks OS version: image

Privilege escalation attempt and masquerading

If conditions are not met, the malware attempts to acquire administrative privileges. The sample uses a COM-based elevation technique and also masks itself as DllHost.exe via LdrEnumerateModulesCallback. This renaming can confuse debuggers into believing a different binary is loaded, potentially invalidating breakpoints. Trying to acquire admin privileges: image COM interface and COM Elevation Moniker usage: image Masquerading as DllHost.exe via LdrEnumerateModulesCallback: image Proof of concept for the renaming behavior: image

Extension generation (Machine GUID based)

The malware generates a file extension based on the machine GUID stored at:

  • HKLM\Software\Microsoft\Cryptography In our case, the generated extension was:
  • KmyLfX2Lb image It also generates a README extension. On our test machine it looked like:
  • KmyLfX2Lb.README.txt image

Privilege enabling

The malware enables a set of privileges before continuing. Privileges list:

  • SeBackupPrivilege
  • SeCreatePagefilePrivilege
  • SeCreateSymbolicLinkPrivilege
  • SeDebugPrivilege
  • SeDelegateSessionUserImpersonatePrivilege
  • SeIncreaseBasePriorityPrivilege
  • SeIncreaseQuotaPrivilege
  • SeIncreaseWorkingSetPrivilege
  • SeLoadDriverPrivilege
  • SeManageVolumePrivilege
  • SeProfileSingleProcessPrivilege
  • SeRemoteShutdownPrivilege
  • SeRestorePrivilege
  • SeSecurityPrivilege
  • SeShutdownPrivilege
  • SeSystemEnvironmentPrivilege
  • SeSystemProfilePrivilege
  • SeSystemtimePrivilege
  • SeTakeOwnershipPrivilege
  • SeTimeZonePrivilege
  • SeUndockPrivilege Enables privileges: image

Process priority changes

Next, the cryptor raises priority for the current process via NtSetInformationProcess, setting a high CPU priority and medium I/O priority to improve performance. Raise process priority: image

Code injection behavior

If the malware lacks enough privileges, it attempts code injection into svchost.exe as part of its privilege workflow. Preparing before injection: image Injecting into svchost.exe: image

Disable sleep and hibernation

BlackMatter sets ES_CONTINUOUS | ES_SYSTEM_REQUIRED to prevent sleep and hibernation during execution. Changes thread execution state: image

Drive enumeration

The malware collects drive information and stores it in JSON format. image

Service and process termination

The malware stops and deletes services on a blacklist. The list matches that used by REvil ransomware and includes: Vss SqlSvc$ Memtas Mepocs Sophos Veeam Backup GxVss GxBlr GxFWD GxCVD GxCIMgr Stop and delete services from the blacklist: image It also stops processes on a blacklist. The list is similar to REvil and includes examples such as: Sql Oracle Ocssd Dbsnmp Synctime Agntsvc Isqlplussvc Xfssvccon Mydesktopservice Ocautoupds Encsvc Firefox Tbirdconfig Excel Outlook Powerpoint Steam Winword Notepad and others. Stop processes from the blacklist: image

Encryption

BlackMatter uses Salsa20 to encrypt files:image

Detection

For endpoint protection against this threat, we used:

  • A YARA rule to detect BlackMatter ransomware
  • A behavioral solution to detect BlackMatter activity Behavior-based detection can help identify encrypted and packed malware. Useful behavioral signals include:
  • Hooks on process termination and service stop APIs
  • Registry activity monitoring
  • Exploit execution patterns

Recommended organizational defenses

The SToFU team recommends:

  • Security audits: Regularly audit the corporate network.
  • Backups: Maintain frequent backups and store them offline or offsite.
  • Patch management: Keep operating systems and software up to date.
  • Anti-malware: Deploy endpoint protection to detect and prevent infections.
  • Access controls: Restrict access to sensitive systems and data.
  • Security awareness: Train employees to spot phishing and suspicious activity.
  • Incident response plan: Prepare and rehearse a ransomware response plan.
  • Cybersecurity partner: Work with a skilled partner for assessment, investigation, and timely prevention.

Cooperation

Friends, for cooperation in reverse engineering, malware analysis, security audits, and corporate cybersecurity, contact us:

  • midgard@stofu.io We are sincerely glad to cooperate and welcome new partners!
Serhii L.

Serhii L. – Windows System Developer & Security Researcher

Experienced Windows System Developer and Security Researcher with a passion for developing high quality scalable systems.

Back to Blogs

Start the Conversation

Share the system, the pressure, and what must improve. Or write directly to midgard@stofu.io.