Mac Malware Uses ‘run-only’ AppleScripts To Evade Analysis
A cryptocurrency mining campaign targeting macOS is using malware that has evolved into a complex variant giving researchers a lot of trouble analyzing it.
The malware is tracked as OSAMiner and has been in the wild since at least 2015. Yet, analyzing it is difficult because payloads are exported as run-only AppleScript files, which makes decompiling them into source code a tall order.
A recently observed variant makes analyzing even more difficult as it embeds a run-only AppleScript into another scripts and uses URLs in public web pages to download the actual Monero miner.
Reversing run-only AppleScript
OSAMiner typically spreads via pirated copies of games and software, League of Legends and Microsoft Office for macOS being among the more popular examples.
The malware has been researched in the past [1, 2] but the run-only AppleScript file hindered full analysis, limiting it to observing the behavior of the sample.
Also Read: 10 Practical Benefits of Managed IT Services
AppleScript files include both the source and the compiled code but enabling “run-only” saves only the compiled version so the human-readable code is no longer available, thus removing the possibility of reverse engineering.
Security researchers at Sentinel One discovered at the end of 2020 a new sample of OSAMiner that complicated “the already difficult process of analysis.”
However, they were able to reverse engineer some samples they collected by using a less-known AppleScript disassembler (Jinmo’s applescript-disassembler) and a decompiler tool developed internally called aevt_decompile.
Evasion actions
The recent OSAMiner campaigns use three run-only AppleScript files to deploy the mining process on the infected macOS machine, Sentinel One found:
- a parent script that executes from the trojanized application
- an embedded script
- the miner setup AppleScript
The main role of the parent script is to write the embedded AppleScript to ~/Library/k.plist using a “do shell script” command and execute it. It also checks if the machine has enough free space and exits if there isn’t sufficient storage.
Other tasks it runs include collecting the serial number of the device, restarting the ‘launchctl’ job responsible for loading and unloading daemons or agents, and to kill the Terminal application.
The researchers say that the main script also sets up a persistence agent and downloads the first stage of the miner from a URL set on a public page.
Some samples may not lead to a live URL. However, Sentinel One was able to find an active one (https://www[.]emoneyspace[.]com/wodaywo) and noticed that the malware parsed a link in the source code of the page that pointed to a PNG image.
This was the third run-only AppleScript, downloaded to the ~/Library/11.PNG. Its purpose is to download the open-source XMR-Stak Monero miner that works on Linux, Windows, and macOS.
“The setup script includes pool address, password and other configuration information but no wallet address,” the researchers say in a report today, adding that it also uses the “caffeinate” tool to prevent the machine from entering sleep mode.
Also Read: What Legislation Exists in Singapore Regarding Data Protection and Security?
Evading detection
According to Sentinel One, the second script is intended to prevent analysis and evade detection. Supporting this conclusion is killing the Activity Monitor, which is the equivalent of the Task Manager in Windows, likely to prevent users from checking the system’s resource usage.
Furthermore, the script is designed to kill processes belonging to popular tools for system monitoring and cleaning. It finds them by checking a hardcoded list.
Sentinel One says that while AppleScript incorporates more powerful features [1, 2], the authors of OSAMiner are not currently taking advantage. This is likely because the current setup allowed them to run their cryptocurrency mining campaigns with little resistance from the security community.
However, as Sentinel One proved, the technique is not infallible and researchers have the means to analyze it and prepare defenses against other malware that may choose to use it.
0 Comments