Quantcast
Channel: CodeSection,代码区,网络安全 - CodeSec
Viewing all articles
Browse latest Browse all 12749

New PowerShell-based Backdoor Found in Turkey, Strikingly Similar to MuddyWater ...

0
0

MuddyWater is a well-known threat actor group that has been active since 2017. They targetgroups across Middle East and Central Asia, primarily using spear phishing emails with malicious attachments. Most recently they were connected to a campaign in March that targeted organizations in Turkey, Pakistan, and Tajikistan .

The group has been quite visible since the initial 2017 Malwarebytes report on their elaborate espionage attack against the Saudi Arabian government. After that first report, they were extensively analyzed by other security companies. Through all that, we’ve only seen minor changes to the tools, techniques and procedures (TTPs) they have used.

However, we recently observed a few interesting delivery documents similar to the known MuddyWater TTPs. These documents are named Raport.doc or Gizli Raport.doc (titles mean “Report” or “Secret Report” in Turkish) and maliyeraporti (Gizli Bilgisi).doc (“finance (Confidential Information)” in Turkish) ― all of which were uploaded to Virus Total from Turkey. Our analysis revealed that they drop a new backdoor, which is written in PowerShell as MuddyWater’s known POWERSTATS backdoor. But, unlike previous incidents using POWERSTATS, the command and control (C&C) communication and data exfiltration in this case is done by using the API of a cloud file hosting provider.

The screenshots below show the malicious attachments, which are disguised to look real, similar to any typical phishing document. The images show blurry logos that we’ve identified as belonging to various Turkish government organizations ― the logos add to the disguise and lure users into believing the documents are legitimate. Then the document notifies users that it is an “old version” and prompts them to enable macros to display the document properly. If the targeted victims enable macros, then the malicious process continues.


New PowerShell-based Backdoor Found in Turkey, Strikingly Similar to MuddyWater  ...

Figure 1. Fake Office document tries to get user to enable malicious macros. The blurred document contains logos of different Turkish government entities


New PowerShell-based Backdoor Found in Turkey, Strikingly Similar to MuddyWater  ...

Figure 2. A similar fake Office document has blurred logos for a Turkish government institution related to taxes

The macros contain strings encoded in base52, which is rarely used by threat actors other than MuddyWater. The group is known to use it to encode their PowerShell backdoor.

After enabling macros, a .dll file (with a PowerShell code embedded) and a .reg file are dropped into %temp% directory. The macro then runs the following command:

“C:\windows\System32\cmd.exe” /k %windir%\System32\reg.exe IMPORT %temp%\B.reg

Running this registry file adds the following command to the Run registry key:

rundll32 %Temp%\png.dll,RunPow
New PowerShell-based Backdoor Found in Turkey, Strikingly Similar to MuddyWater  ...

Figure 3. Run registry key

We assume that RunPow stands for “run PowerShell,” and triggers the PowerShell code embedded inside the .dll file. The PowerShell code has several layers of obfuscation. The first layer contains a long base64 encoded and encrypted code with variables named using English curse words.


New PowerShell-based Backdoor Found in Turkey, Strikingly Similar to MuddyWater  ...

Figure 4. Encrypted PowerShell code

The other layers are simple obfuscated PowerShell scripts. But the last layer is the main backdoor body. This backdoor has some features similar to a previously discovered version of the Muddywater backdoor.

Firstly, this backdoor collects the system information and concatenates various pieces of information into one long string. The data retrieved includes: OS name, domain name, user name, IP address, and more. It uses the separator “::” between each piece of information.


New PowerShell-based Backdoor Found in Turkey, Strikingly Similar to MuddyWater  ...

Figure 5. String of system information collected from the victim’s system

The previous MuddyWater version collected similar information but used a different separator:


New PowerShell-based Backdoor Found in Turkey, Strikingly Similar to MuddyWater  ...

Figure 6. String of system information collected from the victim’s system, from older Muddywater backdoor sample

As mentioned above, another difference between this and older Muddywater backdoors is that C&C communication is done by dropping files to the cloud provider. When we analyzed further, we saw that the communication methods use files named <md5 (hard disk serial number)> with various extensions depending on the purpose of the file.

.cmd text file with a command to execute .reg system info as generated by myinfo() function, see screenshot above .prc output of the executed .cmd file, stored on local machine only .res output of the executed .cmd file, stored on cloud storage
New PowerShell-based Backdoor Found in Turkey, Strikingly Similar to MuddyWater  ...

Figure 7. Example of .cmd file content


New PowerShell-based Backdoor Found in Turkey, Strikingly Similar to MuddyWater  ...

Figure 8. Example of .reg file content


New PowerShell-based Backdoor Found in Turkey, Strikingly Similar to MuddyWater  ...

Figure 9.Example of .res file content

In both the older version of the MuddyWater backdoor and this recent backdoor, these files are used as an asynchronous mechanism instead of connecting directly to the machine and issuing a command. The malware operator leaves a command to execute in a .cmd file, and comes back later to retrieve the .res files containing the result of the issued command.

However, in the older MuddyWater backdoor their content was encoded differently. The files are temporarily stored on compromised websites. The more recent backdoor uses a legitimate cloud storage service provider instead.

The .res file can be decoded by replacing “00” with empty string, then converting from hex to ASCII, then reversing the string. The figure below is the decoded .res file from Figure 9.


New PowerShell-based Backdoor Found in Turkey, Strikingly Similar to MuddyWater  ...

Figure 10. Decoded .res file

The backdoor supports the following commands:

$upload upload a file to file hosting service $dispos remove persistence $halt exit $download download file from a hosting service No prefix execute command via Invoke Expression (IEX), a PowerShell command that runs commands or expressions on the local computer

Based on our analysis, we can confirm that the targets were Turkish government organizations related to the finance and energy sectors. This is yet another similarity with previous MuddyWater campaigns, which were known to have targeted multiple Turkish government entities. If the group is responsible for this new backdoor, it shows how they are improving and experimenting with new tools.

Solutions and Recommendations

The main delivery method of this type of backdoor is spear phish

Viewing all articles
Browse latest Browse all 12749