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.
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)
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.
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 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 22.214.171.124 on port 11903. This NanoCore RAT is version 126.96.36.199 which has been found to be offered for free on the Dark Web just a few months ago.
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.)
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.
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.
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!
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.
SHIPPING_MX00034900_PL_INV_pdf.zip (868,519 bytes)
SHIPPING_MX00034900_PL_INV_pdf.exe (1,276,928 bytes)
order.jpg (11,247 bytes)