返回 TI 主页

Overview

Recently, QiAnXin Threat Intelligence Center found a series of targeted attacks against Pakistan targets. Attacker exploited one vulnerability (CVE-2017-12824) of InPage to craft bait documents (.inp). InPage is a word processing software designed specifically for Urdu speakers (official language in Pakistan). In addition, Office documents with CVE-2018-0798 vulnerability were also used in the attack. Kaspersky disclosed one target attack in which InPage vulnerability was exploited in November 2016[6] . However, first attack by using such software vulnerability can be traced back to June 2016[14].

Through the analysis of this group of documents with InPage vulnerabilities and related attack activities, we can conclude that the attacker is BITTER APT organization disclosed by us in 2016 [5] . After further analysis, some samples in the attack have strong connections with some APT groups, specifically Patchwork, Bahamut, and Confucius. That shows more connections among those 4 APT groups from South Asian.

Timeline

QiAnXin Threat Intelligence Center sorts out the timeline of targeted attacks in which InPage vulnerability was exploited in the past two years as following:

InPage Vulnerability Analysis (CVE-2017-12824)

The scan result of documents with InPage vulnerability on VirusTotal:

InPage is a word processing software specially designed for Urdu speakers, and the vulnerability number involved in the wild attack sample is CVE-2017-12824.

After the analysis of the vulnerability by QiAnXin Threat Intelligence Center, it was found that the vulnerability was caused by the fact that InPage word processing software did not check the data type (Type) to be processed when it is processing document flow, which led to the out-of-bounds reading. Through carefully constructed InPage document, arbitrary code could be triggered to execute.

We used InPage 2015 software environment to analyze the vulnerability in detail, and the process is as follows.

InPage 2015

Cause of Vulnerability: Out-of-bound Read

The essence of the CVE-2017-12824 vulnerability is out-of-bound Read. The InPage word processor does not check the data type to be processed while processing the InPage100 stream in the document, and the data type to be processed is specified by a field in the InPage document. This allows an attacker to cause an InPage program to make an out-of-bounds read error by setting a value outside the Type range.

The key data structures that trigger the vulnerability in document (.inp) are as follows. 0x7E and 0x72 represent a class of type in the document stream to be processed. We mark 0x7E as Type1 and 0x72 as Type2:

InPage processes a.inp file as follows:

InPage first calls Ole!The StgCreateDocfile function parses the entire.inp file and then calls Ole! COleStreamFile: : OpenStream open InPage InPage100 data flow in the document:

All the processing logic related to the InPage100 stream will be carried out in PraseInPage100_432750 function, and the data in the stream will be read with the callback function InPage100Read_440ED0:

The trigger vulnerability Type data, 0x7E and 0x72 mentioned earlier, is eventually processed by the function sub_453590.The buf in the figure below reads the data containing Type by calling InPage100Read_440ED0:

The vulnerability function sub_453590 will select the corresponding processing process according to Type1 and Type2 (0x7E and 0x72 bytes). First, it reads the function pointer array according to Type1, then reads the function from the function pointer array according to Type2, and finally calls the function to process data:

Let's look at the assignment and range of dword_656A28 in the figure above:

Type1 = ECX(0x1F8)>>2 = 0x7E(126), Type2 = EDI(0x72) :

Find the assignment of dword_656A28[0x7E] through IDA Pro:

You can see that the actual size of the dword_656E60 array is 30 (0x1E) :

Since the size of Type2 in the vulnerability document is set to 0x72, EDI=0x72, but the InPage does not judge the size of Type2 passed in, this will result in access to dword_656E60[0x72], and because 0x72>30(0x1E), an out-of-bounds read error occurs.

The Exploitation

Since the attacker sets Type2 in the document to 0x72, after addressing calculation, the code at the function address 0x00455AFA will be accessed across the line:

You can see that dword_656E60[0x72] (0x455AFA) is just a pop retn instruction:

The pop retn instruction sequence plays a role as "jump" address, when performing Type related processing function, due to the incoming parameters (pointer: 0 x031e383f) pointing to a data InPage document flow, an attacker can fill the controllable data flow with ShellCode, so after the pop retn instructions will be returned directly to the attacker set ShellCode executed:

However, the InPage program does not turn on DEP and ASLR protection, which results in ShellCode being directly executed:

Analysis of Four Types of Attack Framework Using InPage Vulnerability

QiAnXin Threat Intelligence Center conducted analysis on the samples with InPage vulnerabilities in Pakistan, found that a number of samples generated time, size, initial ShellCode InPage100 document flow and related flow label all consistent. We can confirm that those samples come from same source.

Through the analysis of this batch of InPage vulnerability utilization documents and relevant malicious code, we found that the malicious code carried by the vulnerability documents used four different types of attack frameworks: four types of completely different backdoor programs. The analysis is as follows.

WSCSPL:Full - featured Backdoor

A decoy document captured by QiAnXin Threat Intelligence Center is called "SOP for Retrieval of Mobile Data Records. Inp" (SOP for Mobile Data Records Retrieval). Cve-2017-12824 vulnerability utilization document will eventually download and execute a full-featured back door program named WSCSPL.

Relevant vulnerability utilization document information is as follows:

MD5 863f2bfed6e8e1b8b4516e328c8ba41b
The file name For Retrieval of Mobile Data Records, SOP for Retrieval of Mobile Data Records. Inp

ShellCode

After the bug is successfully triggered, ShellCode will locate the main function ShellCode by searching the special logo "27862786". Then it will download Payload from khurram.com.pk/js/drv and save it to c:\conf\ smss.exe for execution:

Downloader

MD5 c3f5add704f2c540f3dd345f853e2d84
Compile time 2018.9.24
PDB path C: \ Users \ Asterix \ Documents \ 28 novdwn VisualStudio2008 \ Projects \ \ Release \ 28 novdwn PDB

The downloaded EXE file is mainly used to communicate with C2 and obtain the executables of other modules. After execution, the registry key value (key: HKCU\Environment, key value: AppId, data: c:\ Intel \drvhost. EXE) will be set first.

Persistence is achieved by adding itself to the registry bootstrap:

And determine whether the current process path is c:\ Intel \drvhost. Exe, if not, copy itself to the path and execute:

When the process path meets the conditions, the machine GUID, computer user name and other information obtained from the registry are encrypted and concatenated into a string:

Then send the constructed string to communicate with C2:nethosttalk.com and get the command to execute again:

In this case, the C2 server returns an AXE:# instruction. The native program determines whether the instruction is an AXE:# or an AXE.

If "AXE:#" is followed by the string content, the plug-in is downloaded and executed

In the process of debugging and analysis by QiAnXin Threat Intelligence Center analysts, we successfully obtained an executable plug-in named "WSCSPL" :

Backdoor - WSCSPL

MD5 1c2a3aa370660b3ac2bf0f41c342373b
Compile time 2018.9.13
Original file name Exe winsvc.

This Trojan has same functionality as the Trojan used by Patchwork APT group disclosed by us in 2016[5]. The Trojan supports 17 commands, including uploading a list of hard disk, finding, reading, creating a specified file, enumerating a list of processes, and ending a specified process. Trojan function analysis is as follows:

Set two 10-second interval timers after the Trojan program runs:

  • Timer 1: request the IP of C&C:wcnchost.ddns.net. If the request is successful, save the IP to the global variable and set the id variable to 1.

  • Timer 2: check the value of the identifying variable, if 1, try to connect C&C:

Then create two threads:

  • Thread 1: detects the connection status with C&C and receives the C&C command executable if the connection is successful

  • Thread 2: checks whether the global variable dword_C9618 has data, and if so, sends the data to C&C

The command execution code snippet is as follows:

Trojan’s all commands and corresponding functions are shown in the following table:

3000 Get RAT status information
3001 Get computer hard disk information
3002 Gets the list of files in the specified directory
3004 Get RAT log 1
3005 Create the specified file
3006 Writes data to the create file
3007 Open the specified file
3009 Reads the contents of the specified file
3012 Create remote console
3013 Execute remote commands
3015 Get RAT log 2
3016 End remote console
3017 Closes the specified handle
3019 Gets a process that has an UPD active link
3021 Get RAT log 3
3032 End the specified process
3023 Gets process information in the system
3025 Get RAT log 4

Visual Basic Backdoor

Another captured vulnerability exploit document, CVE-2017-12824 named ‘AAT national assembly final.inp’, drop the backdoor written by Visual Basic.

Relevant vulnerability document information is as follows:

MD5 ce2a6437a308dfe777dec42eec39d9ea
The file name The AAT national assembly final. Inp

ShellCode

First, ShellCode triggered by the vulnerability locates the main ShellCode through the memory global search string "LuNdLuNd" :

Locate the main ShellCode and get the API functions you want to use, and ensure that only one instance runs by creating the mutex "QPONMLKJIH" :

Then extract a DLL module contained in the document and execute it by memory loading:

Dropper

MD5 43920ec371fae4726d570fdef1009163
The PDP path C: \ users \ mz \ documents \ visualstudio2013 \ Projects \ Shellcode \ Release \ Shellcode PDB

The DLL file loaded in memory is a Dropper, which contains two resource files, "Bin" and "Bin2" :

Bin file is the back door program written by Visual Basic, while Bin2 is the normal inp decoy file released and opened after the vulnerability is triggered. The contents of relevant decoy documents are as follows:

Backdoor - SMTPLDR. Exe

MD5 694040b229562b8dca9534c5301f8d73
Compile time 2018.7.4
Original file name Exe SMTPLDR.

Bin file is a backdoor program written by Visual Basic, which is mainly used to obtain command execution. After the Trojan horse runs, it first gets the installed application name of the current system from "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" :

Then determine whether the installed application includes kaspersky, NORTON, trend technology and other related software killing applications:

Then WMI executes the select * from win32_computersystem command to get the application information and detect the virtual machine environment by determining whether the word "virtual" is included in the name:

If the detection is in the virtual machine environment, the popover displays not a valid file and exits:

If the detection passes, "SMTP Loader. LNK" will be created in the directory of %Start% to achieve self-startup:

Finally, it communicates with C&C: referfile.com to obtain subsequent instruction execution:

Delphi Backdoor Program

QiAnXin Threat Intelligence Center found a batch of backdoor written by Delphi through big data correlation, which are also documents with InPage vulnerability. Relevant sample information is as follows:

MD5 fec0ca2056d679a63ca18cb132223332
Original file name Exe adobsuit.

The captured Delphi backdoor is the same as the backdoor written by Visual Basic, which is also released from the resource file by similar Dropper and created by creating Adobe creative suit. LNK file in the directory of %Start% and pointing to the implementation of persistence:

The backdoor will Ducument in % % folder to create the users. The TXT file, and random write 30 bytes of the string:

Trojan program will access to a computer user name and the computer user name after encrypting the Ducument to % % / SyLog. The log file:

After that, I communicated with C2:errorfeedback.com and sent the contents of sylog.log file as POST:

When C2 returned to Success, and C2 communication in the form of HTTP GET request again, if return a string, continued to from "errorfeedback.com/ MarkQuality455 TTGKWoFdyQHEwpyYKmfVGtzQLfeqpJ/string" perform download the following content:

A Backdoor Using Cobalt Strike

Another captured InPage vulnerability exploit document ends up executing a backdoor generated by Cobalt Strike, with the following documentation information:

MD5 74aeaeaca968ff69139b2e2c84dc6fa6
The file type InPage vulnerability exploit documentation
Find the time 2018.11.02

ShellCode

After the vulnerability is successfully triggered, ShellCode first locates the main ShellCode with the special identifier "LuNdLuNd", and then loads the attached DLL in memory and executes.

Dropper

MD5 ec834fa821b2ddbe8b564b3870f13b1b
PDB path C: \ users \ mz \ documents \ visualstudio2013 \ Projects \ Shellcode \ Release \ Shellcode PDB

Memory loaded DLL file and the above Visual Basic/Delphi back door, is also from the resources to release Trojan files and execute:

Downloader - winopen. Exe

MD5 09d600e1cc9c6da648d9a367927e6bff
Compile time 2018.10.12

Release the Downloader executive called winopen. Exe, it will get a normal JPEG file header from jospubs.com/foth1018/simple.jpg encrypted files, if successful, is from the JPEG file 49th bytes begin with 0 x86 or decryption:

The decrypted file is a DLL file, which is then loaded and executed.DLL program will first determine the running environment and check whether the DLL loading process is rundll32.exe:

If the loading process is not rundll32.dll, release the backdoor program named aflup64.dll under C: ProgramData\Adobe64:

Exe "C:\ ProgramData\ Adobe64\ aflup64.dll", exe "C:\ ProgramData\ Adobe64\ aflup64.dll"

Finally, start rundll32.exe to load aflup64.dll and call its export function IntRun:

Backdoor - aflup64. DLL

MD5 91e3aa8fa918caa9a8e70466a9515666
Compile time 2018.10.12

Exportation IntRun will do the same thing again, get the JPEG file, xor decrypt it, and then execute.Because it is through rundll32 starts, so will go to another branch, first create the mutex "9 a5f4cc4b39b13a6aecfe4c37179ea63" :

Then, create "nnp74DE. TMP" file in the directory of %TEMP%. Then, execute the command tasklist, ipconfig./all, dir to get system process information, network information, file list and so on.

Then get the machine ID, system version, current system time, connect all the acquired information beginning with "tag FluffyBunny", base64-encoded connect C&C and upload:

After the information transmission is successful, Base64 encoding of the string "OK" will be returned:

If the request line is not successful, the request line is looped.After the successful launch, it will enter the second stage to send base64-encoded data of calculation name-user name to jospubs/foth1018/go.php and obtain the command execution:

The format of relevant commands that can be obtained is in the form of "number: parameter", which supports 5 commands in total. The list of relevant commands is as follows:

The command ID function
103 Download the Plugin and drop it into the %TEMP% directory
105 Gets the file memory load
115 Gets the contents of the parameter file
117 Delete the start. LNK file
120 Download the file to the %temp% directory and delete start.lnk

The Plugins - jv77CF. TMP

MD5 c9c1ec9ae1f142a8751ef470afa20f15
Compile time 2018.4.3

In the debugging process of QiAnXin Threat Intelligence Center analysts, we successfully acquired a Trojan horse plug-in which was executed on the ground.The Trojan plugin continues to get the encrypted file from pp5.zapto.org:

Upon successful retrieval, hetero or decryption is performed, and the decrypted file is a remote back door generated by Cobalt Strike:

Analysis of CVE-2018-0798 Samples

By expanding the big data platform of QiAnXin Threat Intelligence Center, we found a vulnerability utilization document of Office CVE-2018-0798 belonging to the same series of attack activities.The document is called "SOP for Retrieval of Mobile Data Records. Doc", which is the same name as the InPage vulnerability for the release of the WSCSPL Trojan (with the same origin as the Retrieval of the impersonal Records). However, the vulnerability document is targeted at Microsoft Office.

MD5 61a107fee55e13e67a1f6cbc9183d0a4
The file name For SOP for Retrieval of Mobile Data Records. Doc

The Objdata object information containing the vulnerability is as follows:

After the vulnerability successfully triggers the execution, subsequent Payload executables will be obtained by means of the same download address as the SOP for Retrieval of Mobile Data Records. Inp (InPage) vulnerability makes use of the file for the Retrieval of Mobile Data Records:

Attribution and Correlation

QiAnXin Threat Intelligence Center through the analysis of this batch of InPage vulnerability utilization documents and related attack activities, it is the "BITTER" APT organization disclosed by 360 company in 2016 that is the group behind the targeted attack using WSCSPL backdoor program[5]And after further analysis, many samples in the series of attacks are also strongly related to APT organizations such as mahagrass, Bahamut and Confucius.

BITTER APT Group

After in-depth analysis of several InPage vulnerability documents with a relatively short attack time by QiAnXin Threat Intelligence Center, it was found that the Trojan program released by the vulnerability document was the backdoor program used by APT organization "manlinghua" exposed by 360 company in 2016[5], is the analysis of the WSCSPL full - featured backdoor program.

Command ID Function
2000 Retrieve RAT status information
2001 Retrieve hard disk list
2002 Retrieve file list in given directory
2004 Retrieve RAT log 1
2005 Create file by given filename
2006 Write bytes into created file (2005)
2007 Open file
2009 Read file content (2007)
2012 Create remote console
2013 Execute remote command
2015 Retrieve RAT log 2
2016 Terminate remote console
2017 Close handle
2019 Retrieve a list of processes with UPD activity link
2021 Retrieve RAT log 3
2022 Terminate process by process ID
2023 Retrieve a list of active processes
2025 Retrieve RAT log 4

In addition, many of these C&C addresses are also strongly related to APT organization "manlinghua" in the internal analysis platform of QiAnXin Threat Intelligence Center. These C&C addresses have been repeatedly used in attacks against China.Therefore, the relevant attack activities can be identified as "vine spirit flower".

Relation to Confucius

Delphi backdoor attack framework used in the C&C address errorfeedback.com in Trend Micro exploring Confucius and mahagrass similarity[10]Appears that the domain name has been disclosed as a trend of Confucius use.

Relation to Patchwork

Through the in-depth analysis and correlation of Delphi backdoor attack framework mentioned above, we also found that the attack framework and sample also appeared in the InPage attack sample analyzed by Palo Alto in 2017[13]Palo Alto thought the attack framework and backdoor might have something to do with mahagrass.

Relation to "Bahamut"

A vulnerability document "AAT national assembly final.inp" analyzed by QiAnXin Threat Intelligence Center into the attack activity was finally executed by the Trojan horse (Visual Basic backdoor program) using the domain name referfile.com as C2, which was published by Cisco Talos security research team in July 2018 as "a case of targeted attack against Indian iOS users".[9]It was revealed that Talos security research team associated with this domain name was also used by a Visual Basic backdoor program, and the related network assets were suspected to be owned by APT organization "Bahamut".

Summary and Conjecture

QiAnXin Threat Intelligence Center analyzed a group of document samples with same attribution (timestamp, ShellCode, InPage100 flow size, flow characteristics) , and found that those samples use at least 4 different malicious code framework, and have connections with "PatchWork", "BITTER”, "Confucius", "Bahamut" APT organization has produced more or less.Maybe these APT groups are actually one group? Or their digital weapons are provided by one vendor(Their supporter give them same exploitation tools)?

The following is a TTP summary of APT groups mentioned in this article:

BITTER PatchWork Confucius Bahamut
Target China, Pakistan China, Pakistan South Asia South Asia (mainly Pakistan), Middle East
Attack platform PC/Android PC/Android PC/Android PC/Android/iOS
Programming language C Delphi/c # Delphi Delphi/VB
Attack vector Spear-phishing attack Social networks, spear-phishing attack Social network Social networks, spear-phishing attack

IOC

Documents with InPage vulnerability
863f2bfed6e8e1b8b4516e328c8ba41b
ce2a6437a308dfe777dec42eec39d9ea
74aeaeaca968ff69139b2e2c84dc6fa6
Office vulnerability exploit documents
61a107fee55e13e67a1f6cbc9183d0a4
Trojans
c3f5add704f2c540f3dd345f853e2d84
f9aeac76f92f8b2ddc253b3f53248c1d
8dda6f85f06b5952beaabbfea9e28cdd
25689fc7581840e851c3140aa8c3ac8b
1c2a3aa370660b3ac2bf0f41c342373b
43920ec371fae4726d570fdef1009163
694040b229562b8dca9534c5301f8d73
fec0ca2056d679a63ca18cb132223332
ec834fa821b2ddbe8b564b3870f13b1b
09d600e1cc9c6da648d9a367927e6bff
91e3aa8fa918caa9a8e70466a9515666
4f9ef6f18e4c641621f4581a5989284c
afed882f6af66810d7637ebcd8287ddc
C&C
khurram.com.pk
nethosttalk.com
xiovo416.net
nethosttalk.com
newmysticvision.com
wcnchost.ddns.net
referfile.com
errorfeedback.com
Jospubs.com
traxbin.com
referfile.com

Reference

[1]. https://ti.qianxin.com/

[2]. http://www.inpage.com/

[3]. https://en.wikipedia.org/wiki/InPage

[4]. https://ti.qianxin.com/blog/articles/analysis-of-apt-campaign-bitter/

[5]. https://www.anquanke.com/post/id/84910

[6]. https://www.kaspersky.com/blog/inpage-exploit/6292/

[7]. https://cloudblogs.microsoft.com/microsoftsecure/2018/11/08/attack-uses-malicious-inpage-document-and-outdated-vlc-media-player-to-give-attackers-backdoor-access-to-targets/

[8]. https://blog.talosintelligence.com/2018/07/Mobile-Malware-Campaign-uses-Malicious-MDM.html

[9]. https://blog.talosintelligence.com/2018/07/Mobile-Malware-Campaign-uses-Malicious-MDM-Part2.html

[10]. https://blog.trendmicro.com/trendlabs-security-intelligence/confucius-update-new-tools-and-techniques-further-connections-with-patchwork/

[11]. https://documents.trendmicro.com/assets/appendix-confucius-update-new-tools-techniques-connections-patchwork-updated.pdf

[12]. https://researchcenter.paloaltonetworks.com/2016/09/unit42-confucius-says-malware-families-get-further-by-abusing-legitimate-websites/

[13]. https://researchcenter.paloaltonetworks.com/2017/11/unit42-recent-inpage-exploits-lead-multiple-malware-families/

[14]. https://www.virustotal.com/gui/file/9bf55fcf0a25a2f7f6d03e7ba6123d5a31c3e6c1196efae453a74d6fff9d43bb/submissions

蔓灵花 BITTER APT INPAGE 摩诃草 CONFUCIUS BAHAMUT