Skip to content

Emerging Threats

WannaMine worm: analysis and intervention

· frtg · 6 min read

Our team recently detected, analysed and managed a compromise attempt by WannaMine malware.

WannaMine is a Worm-type malware (known since 2017) whose purpose is to propagate within corporate networks and perform cryptocurrency mining (Monero) on all compromised systems.

Its propagation capabilities via valid credentials (Mimikatz and Empire modules) and exploitation of SMB protocol vulnerabilities (EternalBlue CVE-2017-0144) render Incident Response activities more complex. Furthermore, the almost entirely fileless structure of the malware enables it to bypass classic Endpoint protections.

Analysis of the sample enabled our analysts to obtain information on the Worm’s compromise and propagation methods as well as the Monero Wallet address associated with this criminal group: 46gVfDm99aq9JqESFxXFp5AyFCZPHsbTn48dWAtVASddf4TmhQMkxvQadhKPvAjszJV8cQKVHHLQ7WpNrh33ogkGUPHhpVP


Some of the Tactics and Techniques associated with WannaMine Worm compromise:

Tattica ID Tecnica Nome Tecnica
Initial Access T1189 Drive-by Compromise
T1566.001 Spearphishing Attachments
Persistence T1546.003 Windows Management Instrumentation Event Subscription
Credential Access T1003.001 OS Credential Dumping
Lateral Movement T1210 Exploitation of Remote Services
T1021.002 Remote Services

The malware, known since 2017, has undergone several modifications and is present in the wild with different variants and functionalities.‎

Article index:

Compromise Chain Analysis

Compromise Initiation

The attack vector used by the Worm is, with high probability, represented by Drive-By Compromise activity. Execution of the dropper (a Powershell script, in6.ps1) on the system triggers a long chain of events responsible for malware installation.

The first part of the code is used to bypass the Windows Anti-Malware Scan Interface (AMSI).

AMSI Bypass

Within the dropper is a list of server URLs used for malware download during Lateral Movement activities:‎

Dropper address list

The remaining code contains instructions for cryptominer installation on the system:

Code to extract artefacts from the $fa variable

Persistence

The malware establishes persistence through the registration of Windows Management Instrumentation (WMI) events. WMI can be used to execute code when a specific event occurs.

For example, it is possible to trigger a command at a certain time of day, at user logon, or after a certain period of system inactivity. In this way, an event can be registered and arbitrary code executed when that event occurs, providing a perfect persistence mechanism.

Persistence
  • SCM Event8 Log Consumer executes approximately every 4 hours to resume the infection process in case the process previously failed;
  • SCM Event8 Log Consumer2 executes 4/5 minutes after system startup.
WMI event subscription setup

Lateral Movement

Lateral movement is executed through the funs, mimi, and sc artefacts extracted from the $fa variable.

Funs is a PowerShell file containing all the functions necessary to infect other systems on the network.
Much of the funs code originates from the Empire framework.
Through Get-creds, it uses the mimi artefact, containing Mimikatz code, to extract usernames and passwords from the system. Subsequently, it uses test-net, to which an array with Class B and C IPs identified on the network is passed.

This function initiates propagation activity across internal corporate networks, a pattern we observed through Managed Detection and Response telemetry showing WMI-based lateral movement across multiple subnets:

Get-creds call passing Mimikatz as argument and use of test-net

The script contains a series of propagation mechanisms (in order of execution):

  1. Remote execution with WMI
  2. Remote execution with Samba
  3. Exploitation of the EternalBlue vulnerability, in which it uses the sc artefact as shellcode.

Cryptocurrency mining

To execute Monero mining activity, the malware uses two artefacts: mon and mue.

First method – MON

‎As a first attempt, the worm executes the mon artefact in fileless mode; the code is embedded in the systemcore_Updater8 class, which is invoked via PowerShell. ‎

The code is a copy of the open-source miner XMRig.

XMRig software configuration:

  • Cryptocurrency: Monero
  • Wallet: 46gVfDm99aq9JqESFxXFp5AyFCZPHsbTn48dWAtVASddf4TmhQMkxvQadhKPvAjszJV8cQKVHHLQ7WpNrh33ogkGUPHhpVP
  • Pool addresses:
    • xmr-eu1.nanopool.org:14444
    • xmr-asia1.nanopool.org:14444
    • xmr-eu2.nanopool.org:14444
    • xmr-us-east1.nanopool.org:14444
    • xmr-us-west1.nanopool.org:14444
    • pool.minexmr.com:80
    • sg.minexmr.com:80
    • ca.minexmr.com:80
mon (XMRig) configuration extract

The artifact ring is then installed on the system under the name WinRing0x64.sys.
This is a Microsoft driver used by mon to optimise the RandomX Monero mining algorithm.
The driver, although legitimate, contains several vulnerabilities that if exploited would allow an attacker to obtain SYSTEM privileges.

Second method – MUE

‎If the first execution does not succeed, WannaMine executes a different artifact, placing the file on disk via WMI, naming it mue.exe (system path C:\Windows\system32). ‎
The executable is an obsolete version of XMRig that does not leverage the WinRing0x64.sys driver.

Disk write and execution of mue.exe

Static Analysis

Script: in6.ps1

Description

PowerShell file acting as a dropper.
It contains a variable $fa holding code encoded in Base64 used to extract all artifacts required for compromise.
A second code section is present with multiple obfuscation layers inserted to evade detection by AntiVirus endpoint protection solutions.

Details

md5B73E5BF7274478FB8FA6CE94AF3F6921
sha198BFD0AC4EE3469A331B4C99436B532E7D18B4D6
sha2563562E13CF2C2B0416B22286217602632A421AC6560FC3E4F9EBF8D13A19CA97E
file-size 13 946 596 (bytes)
entropy4.000

Script: Funs

Description

File containing PowerShell script with auxiliary functions including those for Lateral Movement. Many of these functions are derived from frameworks such as Empire.

Details

md503A5E1B8680B44A07DAAE5D5517FB38F
sha1903AE5A3895D58FFAA384E926B581DCAD1C8CAB3
sha256809FE2FCCDDF5C788812F1CB18B76F0F1BA4BB8AD1CF24F55A5B95E6225E891C
file-size450 722 (bytes)
entropy5.181

Executable: mimi

Description

Contains Mimikatz, is a binary file and is executed via reflected injection so as not to be written to disk. It is used to extract credentials present on the system.

Details

md51A89B3DEBD2B8F45B04A12116893BC9C
sha13147D48F8AEC7615CC803E449F3FF688663395F8
sha256EE8275A57D7A80427131D126A19862D6889AB409F7EC4293721E3BD15AA11C9E
file-size1 293 314 (bytes)
entropy4.536

Executable: mon

Description

Contains a version of the open-source XMRig software, which is a cryptocurrency miner. It is executed in memory via PowerShell without being written to disk.

Details

md5AE8A82C77FD56390B76F6B756DAD101C
sha1DA0CC3211B27616BFE3F9618658C14B65AAB97E2
sha2566DFCE5506FFBECE1CC1DD6AE05D7D4022AC6A73E0EC247A100FA32B04EDFFCF7
file-size2715138 (bytes)
entropy4.800

Executable: WinRing0x64.sys

Description

Legitimate driver used by mon to optimise mining performance. Despite being a legitimate driver, it contains Privilege Escalation vulnerabilities; its installation renders the system less secure.

Details

md50C0195C48B6B8582FA6F6373032118DA
sha1D25340AE8E92A6D29F599FEF426A2BC1B5217299
sha25611BD2C9F9E2397C9A16E0990E4ED2CF0679498FE0FD418A3DFDAC60B5C160EE5
file-size14544 (bytes)
entropy6.266

Executable: mue.exe

Description

Designed to inject the payload into a legitimate process via process hollowing. The injected payload is a version of XMRig.

Details

md5D1AED5A1726D278D521D320D082C3E1E
sha1EFDB3916C2A21F75F1AD53B6C0CCDF90FDE52E44
sha2560A1CDC92BBB77C897723F21A376213480FD3484E45BDA05AA5958E84A7C2EDFF
file-size2863616 (bytes)
entropy7.952

Executable: sc

Description

Shellcode for exploiting the EternalBlue vulnerability. Used for Lateral Movement operations.

Details

md5777D2A050AB7FACE761C1A6449913BAA
sha1061C3DF042325F69BB966ADAEC6D78742DDE2036
sha2569CDB5020DF269828480D77FE03758EF70046A71B11D4C8182BA5465C877715D0
file-size2413 (bytes)
entropy5.260
Speak with our analysts Blog home