SpiderLabs Blog

Double Loaded Zip File Delivers Nanocore

Written by Diana Lopera | Nov 5, 2019 10:38:00 PM

Most malware sent via emails is packaged in archives such as ZIP, RAR, and 7z (7-Zip). Occasionally, we encounter some clever and creative ways these malicious archives are crafted. Here we will examine an example of an oddly formatted ZIP archive hiding the NanoCore malware.

The Spam

We spotted a courier themed spam campaign on our Secure Email Gateway (SEG) cloud recently. The message claimed to be from an Export Operation Specialist of USCO Logistics and that it was sent as per their customer request. Aside from this, there were several other suspicious items we noted:

  • Headers mismatched: The Reply-To and From email address were different. Furthermore, the email address used in Reply-To is from a free email client Gmail.
  • Suspicious message body: The attachment was mentioned in the message body twice, making sure to direct the reader’s attention towards the attachment.
  • Suspicious attachment name: The name of attachment “SHIPPING_MX00034900_PL_INV_pdf.zip” ends with “pdf.zip”. That usually means that the name of the file inside the archive ends with 2 known file extensions “pdf.<extension>” (archiving tools usually defaults the <extension> to the archive’s format e.g. zip)
Figure 1: Trustwave Security Email Gateway (SEG) console displaying the spam containing NanoCore RAT

The Attachment

The attachment “SHIPPING_MX00034900_PL_INV_pdf.zip“ makes this message stand out. The ZIP file had a file size significantly greater than that of its uncompressed content. Typically, the size of the ZIP file should be less than the uncompressed content or, in some cases, ZIP files will grow larger than the original files by a reasonable number of bytes.

Figure 2: The attachment “SHIPPING_MX00034900_PL_INV_pdf.zip“

 

ZIP archives are supposed to have one “End of Central Directory” (EOCD) signifying the end of the archive. Looking deeper into the structure of “SHIPPING_MX00034900_PL_INV_pdf.zip“, the attachment has two EOCDs. After the first EOCD comes some extra data – another ZIP file structure. It turns out that the first ZIP structure is for the image file “order.jpg” while the second one is for an executable file “SHIPPING_MX00034900_PL_INV_pdf.exe“.  Both are compressed when archived, and both indicate that they are the only file in their ZIP structures as indicated in their local file headers and EOCDs respectively.

The Decoy

The image file “order.jpg” contained in the first ZIP structure is actually a non-malicious PNG formatted image file. This serves as a decoy, an attempt to hide the content of the other ZIP structure. The image file has been correctly identified by SEG as a PNG when its file extension is “.jpg” denoting a JPEG formatted image.

The NanoCore RAT

The second ZIP structure contains “SHIPPING_MX00034900_PL_INV_pdf.exe“, which is a NanoCore RAT. This remote access trojan has the capability that allows an attacker to completely take control of the compromised machine. It connects to its command and control server at 194.5.98.85 on port 11903. This NanoCore RAT is version 1.2.2.0 which has been found to be offered for free on the Dark Web just a few months ago.

Figure 3: Process flow of the NanoCore RAT
 
Figure 4: Memory dump of NanoCore RAT captured from the last process in figure 3

 

The ZIP Content as viewed by different Archiving Tools

Obviously the attacker is trying to evade scanning gateways with this dual archive trick. But how do various archive utilities handle the unpacking of this sample?

We used different archiving tools such as PowerArchiver 2019, WinZip, WinRar, 7Zip, and Unzip that is built into the Windows OS in attempting to extract the content of the attachment “SHIPPING_MX00034900_PL_INV_pdf.zip”. Among these 5 tools, only WinZip and Windows’ Unzip were not able to extract anything from the ZIP file as they encountered an error at the start of the extraction process. The other archiving tools were able to extract one file from the ZIP attachment – either “order.jpg” or “SHIPPING_MX00034900_PL_INV_pdf.exe”.  

WinZip version 11.2 and 24.0, and the built-in Unzip tool in Windows, recognized that the attachment “SHIPPING_MX00034900_PL_INV_pdf.zip“  is an invalid archive. Only WinZip gave an explicit reason – the start of central directory of the ZIP was not found. The central directory it pertained to is the one in the second ZIP structure. At figure 2, the second EOCD indicates that its only central directory is located at file offset 0xd148f whereas it is at 0xd40d41. (The size of the first  ZIP structure was not considered.)

Figure 5: WinZip 11.2 error prompt and the snippet of the 2nd ZIP structure’s central directory and EOCD
 
 
Figure 6: Windows’ Unzip prompted an error that the attachment in this spam is invalid

 

Meanwhile, the archiving tools PowerArchiver 2019, WinRar, and 7Zip were able to extract a file from the attachment “SHIPPING_MX00034900_PL_INV_pdf.zip“. Below is the matrix:

The latest versions of PowerArchiver 2019 and WinRar displayed in their respective UI the executable “SHIPPING_MX00034900_PL_INV_pdf.exe” as the only content of the ZIP attachment. No error or warning was prompted during the extraction.

Figure 7: Process monitor tool displaying the PowerArchiver 2019 executable extracting “SHIPPING_MX00034900_PL_INV_pdf.exe”

 

Older versions of 7Zip also behave like PowerArchiver and WinRAR. 7Zip version 9.22 and older saw the executable as well. However, starting from 7Zip version 9.34 (next available installer after version 9.22) up to its latest version 19.0, 7zip saw and was able to extract the image file “order.jpg” instead. The second ZIP structure was treated as extra data; hence, a warning was added to the extracted image file’s properties.

Figure 8: 7Zip version 19.0 extracted “order.jpg” from the ZIP attachment and a warning has been made. The Tail Size from the image’s properties is the size of the second ZIP structure.

 

Among the archiving tools we tried, WinRar 3.30 behaved differently and unexpectedly. The content of the ZIP attachment it displayed in its UI was not the one it extracted!

Figure 9: WinRar version 3.30 displays in its UI “order.jpg” as the sole content of the ZIP attachment. However, it extracts “SHIPPING_MX00034900_PL_INV_pdf.exe”

 

Summary

This sample challenges gateways scanners. Depending on the type of decompression engine used, there is a good probability that only the decoy file may be scrutinized and vetted, and the malicious content unnoticed – just like how some of the most popular archiving tools failed to notice the second ZIP structure. 

Despite what the gateway does, this attack would only succeed if the message got through the gateway and a particular archive utility is used by the end-user, such as certain versions of PowerArchiver, WinRar, and older 7Zip as described above.

In this case, the Trustwave Secure Email Gateway flagged the message as suspicious and it did not get through. Nevertheless, this case does highlight the types of tricks the bad guys are using in an attempt to deliver malware through email.

IOC

SHIPPING_MX00034900_PL_INV_pdf.zip (868,519 bytes)
SHA1: 9474e1517c98d4165300a49612888d16643efbf6

SHIPPING_MX00034900_PL_INV_pdf.exe (1,276,928 bytes)
SHA1: 06b80f9a0fba1d830dcf2ecf225ed1d19060589a 

order.jpg (11,247 bytes)
SHA1: 0429b924e7cdbaf9f9b6aec6744eda19e8131d08