Introduction
On 12th December 2017, Netskope Threat Research Labs identified a very interesting file named “New Order.docx”. Analysis of the file determined that it was not a regular malware which are usually distributed via spam campaigns. Based on the the nature of the attack, the vulnerabilities being exploited by the attackers and the other TTPs used, we suspect this to be a very targeted attack and are calling it BadWolf-1. The Word document, disguised as an important company update, used two recently reported Microsoft Office vulnerabilities (CVE-2017-0199 & CVE-2017-11882) with multi-level payload downloads upon exploitation. At this moment, the intent of the attack seems to be for exfiltrating data from the victim. Interestingly, this data was being emailed out to a specific Google Gmail account by directly connecting from the victim’s machine to Google SMTP server. The credentials of the attackers Google Gmail account were exposed during the analysis, but the attackers had 2-step verification turned on to access their Gmail account which requires both the credentials and also a unique code sent as a text message to a mobile device. Netskope Threat Protection detects the weaponized document as Trojan.Doc.Downloader.AGE.
Attack Kill Chain
The following figure depicts the attack kill chain.
Analysis of documents
Attackers used a crafted document disguised as an important company update that exploits a vulnerability in Microsoft Office and Wordpad. It was assigned the reference as CVE-2017-0199 and was patched by Microsoft in April 2017. The vulnerability exists in the OLE (Windows object linking and embedding) interface of Microsoft Office. Earlier in the year, we blogged about the same vulnerability being distributed by Godzilla botnet. At the time of the Godzilla Botnet analysis, this was a 0-day attack.
On exploiting the vulnerability, it connects to URL “hxxps://deonn[.]com/kcc[.]doc” to download another malicious document file as shown in Figure 1.
Figure 1: Reference to the URL for downloading the second malicious documentThis new malicious downloaded file is an RTF document that then exploits another vulnerability in Microsoft Office and was assigned the reference as CVE-2017-11882. This vulnerability was recently discovered and patched by Microsoft in November 2017. It is a stack buffer overflow vulnerability that exists in the equation editor of Microsoft. Equation editor was compiled and last updated in November 2000. Equation editor works as a COM service and spawns its own process so DEP and ASLR can’t block the exploit as the binary is not compiled to support these features.
Figure 2: Equation OLE object in malicious RTF file
Figure 2 shows a snippet of the RTF file containing the equation OLE object. After extracting the OLE object from the file we can see an equation native stream in the OLE object as shown in Figure 3.
Figure 3: Equation Native stream in ole object
Equation native stream starts with its header followed by MTEF(MathType) data. MTEF format has its own header, followed by MTEF records as shown in Figure 4. The vulnerability exists in the font name of MTEF record. As there is no check on the length of the font name, a long font name overwrites the return address on the stack.
Figure 4: CVE-2017-11882 vulnerability (MTEF header & records)
After taking control over the return address, the attacker used the shellcode to launch mshta.exe to download an .hta file as shown in Figure 5.
Figure 5: Shellcode to execute mshta.exe using WinExec
The .hta file further downloads a binary ‘kc.exe’ as shown in Figures 6 & 7 respectively.
Figure 6: Obfuscated content of HTA file