SpiderLabs Blog

RATs Wrapped and Hidden in PNG | Trustwave

Written by Diana Lopera | Feb 27, 2020 6:00:00 AM

The Remote Access Tool (RAT) is one of the malware types we often encounter with our Security Email Gateway (SEG). Late last year, we noticed spam campaigns leading to RATs via disk image files through attachment and link. More recently, we came across 2 RATs encrypted, packed, and hidden in PNG files - using disk image files again and redirectors as arrival vectors.

Figure 1: Spam campaigns’ attack flow

 

Fake Harassment Video Spam

The first spam campaign is about fake harassment. The sender, claiming to be a school president, is informing his colleague that an anonymous email with video, supposedly in the attachment, shows sexual harassment occurred on their premises.

Figure 2: Trustwave SEG console displaying the mail body of the harassment spam

 

The attachment CONFIDENTIAL0056.zip is a ZIP archive. Inside it is a disk image file CONFIDENTIAL0056.iso which is the Universal Disk Format (UDF) file system format. UDF is managed by Optical Storage Technology Association (OSTA) and is a newer disk image format compared to ISO. UDF is recognized in Windows hence can be mounted when double-clicked.

The image file CONFIDENTIAL0056.iso contains a RAR self-extracting archive (RARSfx) file PRIORITY.scr. Once launched, the RARSfx will silently drop and install 3 files in the %temp% folder. First, a shortcut file Xnekm.lnk will be created. It points to and therefore runs an executable Zhknjdc.exe which is in a folder with the same name as the LNK file. Stored with the EXE file is an image file Zhkn.png.

Figure 3: The attachment in Figure 2 has a UDF disk image file CONFIDENTIAL0056.iso which contains a RARSfx file PROIORITY.scr.

 

Looking into the dropped image Zhkn.png, its filesize is almost on par with the dropped executable file. This is because the PNG has extra data appended at its end of image marker. The extra data starts with a marker “766..;” immediately followed by the encrypted data. The EXE file Zhknjdc.exe, a Delphi compiled executable, will look for the image Zhkn.png in the same directory. Once the PNG is located, the EXE file will look for the marker and decrypt the data after it in the memory. The decrypted data is a DLL – also compiled in Delphi.

Figure 4: RARSfx’s dropped PNG file
 
Figure 5: The decryption routine for the encrypted data in Figure 4

 

The decrypted DLL has 3 major functions:

  1. Create a copy of the RARSFX’s dropped files;
  2. Prepare the system for the arrival of the main malware by disabling some system utilities;
  3. Run the main malware.

The related files for the first function will be dropped at the %userprofile% folder. A folder with the same name as the PNG Zhkn.png will be created and it will host the copies of the said PNG and the EXE file contained inside the RARSfx. In addition, two extra files, an HTA and a VBScript, which are used in the persistence of the EXE file, are also created. The filename of the EXE, HTA, and VBScript will be appended with hardcoded strings, as below.

Figure 6: The hardcoded strings to be appended with the PNG’s name “Zhkn” are “asx.exe”, “_eno.hta”, and “wen.vbs” for the dropped files EXE, HTA, and VBScript respectively.

 

At the %public% folder, 2 binaries and 2 batch files will be dropped to perform the 2nd function – to prepare the infected system for the arrival of the main malware. The binaries, perfmon.exe and SSPICLI.dll, will be extracted from the decrypted DLL’s RCData resource while the batch files Runex.bat and Clean.bat are from the DLL’s data section. They will disable some system utilities like Windows firewall, system restore, notification center, auto-update, and Windows Defender and will be deleted afterward.

The third and the last function is to execute the main malware. The name of the resource where the encrypted main malware is stored is obtained from the “DVCLAL” resource, which contains a string, which when reversed, points to the resource where the main malware is stored.

Figure 8: One of the RCData resources of the decrypted DLL, “B__1165184990”, contains the encrypted data

 

The main malware will be decrypted and injected to one of the following processes. In this sample, the main malware is the latest version of Remcos RAT (v2.5.0 Pro) packed with Morphine.

TapiUnattend.exe
rasphone.exe
runonce.exe
svchost.exe

Figure 8: The main malware is the Remcos RAT packed with Morphine
 
Figure 9: The vertical var delimited list of C&Cs, port, and key obtained from one the processes Remcos was injected into

 

Fake Purchase Spam

A day after the first spam campaign, a related spam campaign was spotted - fake purchase emails. The attachment PO-1109017834665.xlsx.html, disguised as an order slip, is an HTML redirector. It contains a META refresh tag that leads to the download of a RAR file. The HTML also has a hidden paragraph tag with random word padding causing the huge file size of the attachment.

Figure 10: The fake purchase spam leads to an executable with a crafted PNG in the overlay

 

The downloaded file PO-1109017834665.xlsx.rar is a RAR archive which contains 1 file PO-1109017834665.xlsx.exe - a Delphi compiled executable. The EXE’s behavior is almost the same with the EXE file dropped by RARSfx from the first campaign, except the associated PNG is located at its overlay, in other words appended to the end of the executable.

A Delphi compiled DLL will also be obtained from the PNG and executed in the memory. The files extracted from this DLL are the same as the ones from the first campaign except for the main malware.

Figure 11: The RCData resources of the decrypted DLL and its dropped files at %public% folder

 

Netwire is the main malware for this second spam campaign. It Is also packed with Morphine and hidden in an RCData resource “B__1191860879”. This RAT will be injected into one of the following processes.

ieinstal.exe
svchost.exe
notepad.exe

Figure 12: The main malware Packed with Morphine is Netwire.

 

Conclusion

This analysis highlights an increased focus by the bad guys on both novel file formats and abuse of standard file formats. The use of the UDF strengthens our observation from our previous blog – malware authors are trying different disk image formats as containers for their craft. The appending of malicious data to the end of PNG now appears to be a more common trick for these purveyors of RATs. The second example takes it one step further in a Russian doll approach -  malicious data appended to a PNG which itself is appended to an executable.

 

IOC

CONFIDENTIAL0056.iso (2,228,224 bytes) SHA1: D29E67986225DC0BA2216ECB1F0640CB0212BAE1
PRIORITY.scr.rar (1,076,461 bytes) SHA1: B6AE5C8B6D72C45220A1FC45DB7D48E252F20C2D
%temp%\Xnekm.lnk (1,116 bytes) SHA1: 1F94CB181ACEA6C76C4FA018440C02BB16AB5F8E
%temp%\Xnekm\Zhknjdc.exe (805,376 bytes) SHA1: C3B54681E8AC61E605BD399AC680AC15B5608033
%temp%\Xnekm\Zhkn.png (608742 bytes) SHA1: 5FEC6AD1DD292AC48DB2C56D2BC5F12775312E57
%userprofile%\Zhkn\Zhknasx.exe (805376 bytes) SHA1: C3B54681E8AC61E605BD399AC680AC15B5608033
%userprofile%\Zhkn\Zhkn.png (608742 bytes) SHA1: 5FEC6AD1DD292AC48DB2C56D2BC5F12775312E57
%userprofile%\Zhkn\Zhkn_eno.hta (175 bytes) SHA1: 2EFA1CAF73021DA6E94C05F881C81104B9B5D9C8
%userprofile%\Zhkn\Zhknwen.vbs (167 bytes) SHA1: 818A158803EB1AACA1DB603E100BDE4E46380D55

%public%\perfmon.exe (176,640 bytes) SHA1: C3B882CEA05A0371AF48F60D01E0C5DE019E2A2C
%public%\SSPICLI.dll (110,792 bytes) SHA1: AADA5C5AF3232A16F7906307326673C5749E3BBB
%public%\Clean.bat (3,810 bytes) SHA1: 82E5CA631F6756CDF514D40AF776CE07F9DB5E86
%public%\Runex.bat ( 222 bytes) SHA1: 92C8D3DC444E9E6C3B1A7CF94DBEE02E4C7BDA00
Size: 247763 bytes (241 KiB)

PO-1109017834665.xlsx.html (247,763 bytes) SHA1 :A224DB9E9F2F347587DC398CB898057CE50326F5
PO-1109017834665.xlsx.rar (877,737 bytes) SHA1: 9742AEBCE253BFCF3819E28FD5E6CA1E58C10BBF
PO-1109017834665.xlsx.exe (2,169,356 bytes) SHA1: CD24179ABA477EAF9FE41C3CC3AD13326DF0C2D8

%userprofile%\ PO-1109017834665.x\PO-1109017834665.xsex.exe (2,169,356 bytes) SHA1: D24179ABA477EAF9FE41C3CC3AD13326DF0C2D8
%userprofile%\PO-1109017834665.x.hta (180 bytes) SHA1: 17102B28365E47B6C12244037289842C88638992
%userprofile%\PO-1109017834665.x.vbs (146 bytes) SHA1: 7487DBA3045AA8D45B16DBCC95CA18BF84E9948C

checker[.]rneiko-elec[.]com:11012 (C&C Netwire)