SpiderLabs Blog

3-in-1 Malware Infection through Spammed JavaScript Attachments

Written by Rodel Mendrez | Dec 22, 2015 9:19:00 AM

Recently we've observed a massive uptick of malicious spam with JavaScript attachments with an intention to spread and infect Windows systems with variety of malicious executables. The spam usually contains a ZIP file attachment containing only one JavaScript file.

 

The spam campaign has been ongoing for the past months but last week we've observed a massive huge uptick in our spam traps

An example of the spam campaign claims to be a resume from a fake named sender.

Extracting the ZIP file contains a file with .JS file extension

JavaScript De-obfuscation and Analysis

The attached JavaScript file is obfuscated. One of the easiest ways to de-obfuscate this script is to look for the eval() method within the script and replace it with alert() method. The alert() method will display a dialogue box of the de-obfuscated JS string instead of the eval() method that compiles and runs the string. For this particular sample, the eval() method is not called directly in the code and is hidden inside a variable that appears to be a random string.

After replacing the variable to alert() method, we will then save the file and run the script by opening it through a browser. If successful, a Message box will popup containing the de-obfuscated JavaScript:

Cleaning up the code shows a function named "dl" that carries out the download routine using ActiveXObject framework, saving downloaded files to the Windows Temporary folder and then executing them.

Payloads

The downloaded files have a destructive payload, one of which may result to permanent loss of files. The de-obfuscated URL shows the link pointing to .JPG files; these are actually malicious Windows executables. Once they are downloaded, the files are renamed to .EXE file extension and saved in the Temporary folder. The file named 2.jpg belongs to a Fareit botnet that is designed to steal credentials from FTP clients, web browsers, mail clients and even bitcoin wallets.

The routine where the malware tries to steal user credentials from FireFTP Firefox add-on

 

 

Fareit Trojan also attempts to steal bitcoin in the infected system

The stolen credentials are then sent to a list of remote control servers.

The other downloaded executable disguised in the URL link as 3.jpg is an Outlook email harvester. The Trojan attempts to harvest Outlook contacts and sends the collected data to the domain name spamhausgandon[.]com.

The last payload is the file 1.jpg that is actually an executable file of a ransomware otherwise known as a Cryptolocker. The Trojan encrypts targeted files which include Office documents such as .doc, .docx, .xls, .xlsx, .pdf, also of images such as .jpg, .png, .raw, .svg and others

After encrypting the target files, an instruction note in different file format (html or txt or image) is dropped in the victim's computer with instructions on how to pay the operators in exchange for restoring the encrypted files.

Conclusion

Malicious JavaScript is just another method used by the crooks to spread malware, but it is increasing in popularity it seems even with such a small amount of obfuscated code, it is capable of downloading multiple payloads.

Email administrators should consider blocking inbound JavaScript files outright at the gateway. For end users, consider disabling the Windows Script Host (WSH). Instructions for disabling WSH can be found in this link from Microsoft.

Trustwave Secure Email Gateway blocks this malicious spam campaign