Blogs & Stories

SpiderLabs Blog

Attracting more than a half-million annual readers, this is the security community's go-to destination for technical breakdowns of the latest threats, critical vulnerability disclosures and cutting-edge research.

3-in-1 Malware Infection through Spammed JavaScript Attachments

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.

EmailSample copy

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


JavaScript Deobfuscation and Analysis

The attached JavaScript file is obfuscated. One of the easiest ways to deobfuscate 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 deobfuscated 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 Messagebox will popup containing the deobfuscated 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.



The downloaded files have a destructive payload, one of which may result to permanent loss of files. The deobfuscated 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 fileswhich 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.



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 adminstrators 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