OSX_OCEANLOTUS.D is a macOS backdoor associated with OceanLotus, also known as APT32. It provides remote command execution, file transfer, and host reconnaissance capabilities. Its infection chain uses a malicious Microsoft Word document masquerading as a Vietnamese event registration form and prompts the recipient to enable macros. Obfuscated macro code invokes Perl to extract and execute a 32-bit Mach-O dropper, which installs an embedded 64-bit Mach-O backdoor.
The dropper checks whether it has root privileges and selects an appropriate installation location and persistence mechanism. It establishes persistence through a LaunchDaemon when running as root or a user LaunchAgent otherwise, configuring the backdoor to launch automatically and remain running. It conceals installed artifacts with hidden attributes, randomizes file timestamps, and deletes itself after installation. Other observed concealment techniques include disguising an application bundle as a Word document.
The backdoor collects the operating-system version, account name, computer name, architecture, hardware identifiers, and network-interface MAC address. It derives a client identifier from host-specific values and transmits system information to command-and-control infrastructure. Communications use custom scrambling and AES-256 encryption; a custom TCP protocol also uses zlib compression. Remote commands support downloading and executing additional files, running command-line programs, uploading files from the compromised host, and deleting files.
1 distinct threat actor Mallory has associated with this family across public reporting. Open in Mallory to see the full evidence chain and overlapping campaigns.
We identified a MacOS backdoor (detected by Trend Micro as OSX_OCEANLOTUS.D) that we believe is the latest version of a threat used by OceanLotus.
43 distinct techniques documented for this family, organized by ATT&CK tactic.
The MacOS backdoor was found in a malicious Word document presumably distributed via email. Upon receiving the malicious document, the user is advised to enable macros.
Both create one thread, and each thread is responsible for either downloading and executing the file or running a command line program in the terminal.
[OSX_OCEANLOTUS.D](https://attack.mitre.org/software/S0352) uses PowerShell scripts.(Citation: TrendMicro MacOS April 2018)
[OSX_OCEANLOTUS.D](https://attack.mitre.org/software/S0352) uses a shell script as the main executable inside an app bundle and drops an embedded base64-encoded payload to the <code>/tmp</code> folder.(Citation: Trend Micro MacOS Backdoor November 2020)(Citation: sentinelone apt32 macOS backdoor 2020)
[OSX_OCEANLOTUS.D](https://attack.mitre.org/software/S0352) uses Word macros for execution.(Citation: TrendMicro MacOS April 2018)
After deobfuscation, we can see that the payload is written in the Perl programming language. It extracts theme0.xml file from the Word document.
For network communications, [OSX_OCEANLOTUS.D](https://attack.mitre.org/software/S0352) loads a dynamic library (`.dylib` file) using `dlopen()` and obtains a function pointer to execute within that shared library using `dlsym()`.(Citation: Unit42 OceanLotus 2017)
...uses the LoadLibraryExW() function to load additional modules... execute additional plugins by loading the respective DLLs... loaded and executed DLLs in memory during runtime... loads a dynamic library (.dylib file) using dlopen() and obtains a function pointer... using dlopen() and dlsym()... calls LoadLibrary then executes exports from a DLL.
Afterwards, the persistence file will be created in /Library/LaunchDaemons/ or ~/Library/LaunchAgents/ folder. The RunAtLoad key will command launchd to run the daemon when the operating system starts up... launchctl load ~/Library/LaunchAgents/ filename.plist
[OSX_OCEANLOTUS.D](https://attack.mitre.org/software/S0352) can create a persistence file in the folder <code>/Library/LaunchAgents</code>.(Citation: TrendMicro MacOS April 2018)(Citation: Trend Micro MacOS Backdoor November 2020)
If running with <code>root</code> permissions, [OSX_OCEANLOTUS.D](https://attack.mitre.org/software/S0352) can create a persistence file in the folder <code>/Library/LaunchDaemons</code>.(Citation: TrendMicro MacOS April 2018)(Citation: sentinelone apt32 macOS backdoor 2020)
Today, I’ll talk about shell environment hijacking trick... The two most interesting files for us are: ~/.zshrc - executed for interactive shells... ~/.zshenv - executed for every instance of zsh... So, the main trick: we append a command to run our malware at the end of these files.
LoginHooks and LogoutHooks have been around for a long time and can still be used to run a persistence script on macOS. When a person logs in or out, these mechanisms run code, as the names suggest.
Afterwards, the persistence file will be created in /Library/LaunchDaemons/ or ~/Library/LaunchAgents/ folder. The RunAtLoad key will command launchd to run the daemon when the operating system starts up... launchctl load ~/Library/LaunchAgents/ filename.plist
[OSX_OCEANLOTUS.D](https://attack.mitre.org/software/S0352) can create a persistence file in the folder <code>/Library/LaunchAgents</code>.(Citation: TrendMicro MacOS April 2018)(Citation: Trend Micro MacOS Backdoor November 2020)
If running with <code>root</code> permissions, [OSX_OCEANLOTUS.D](https://attack.mitre.org/software/S0352) can create a persistence file in the folder <code>/Library/LaunchDaemons</code>.(Citation: TrendMicro MacOS April 2018)(Citation: sentinelone apt32 macOS backdoor 2020)
Today, I’ll talk about shell environment hijacking trick... The two most interesting files for us are: ~/.zshrc - executed for interactive shells... ~/.zshenv - executed for every instance of zsh... So, the main trick: we append a command to run our malware at the end of these files.
LoginHooks and LogoutHooks have been around for a long time and can still be used to run a persistence script on macOS. When a person logs in or out, these mechanisms run code, as the names suggest.
The content repeatedly describes payloads, strings, configuration files, scripts, URLs, and binaries being obfuscated or encoded using Base64, XOR, RC4, AES, RSA, hex encoding, custom algorithms, and other methods across many malware families and threat actors.
[OSX_OCEANLOTUS.D](https://attack.mitre.org/software/S0352) has a variant that is packed with UPX.(Citation: ESET OceanLotus macOS April 2019)
[OSX_OCEANLOTUS.D](https://attack.mitre.org/software/S0352) encrypts its strings in RSA256 and encodes them in a custom base64 scheme and XOR.(Citation: TrendMicro MacOS April 2018)
It extracts theme0.xml file from the Word document. theme0.xml is a Mach-O 32-bit executable... For root user path: /Library/CoreMediaIO/Plug-Ins/FCP-DAL/iOSScreenCapture.plugin/Contents/Resources/ processname: screenassistantd For regular user path: ~/Library/Spelling/ processname: spellagentd
[OSX_OCEANLOTUS.D](https://attack.mitre.org/software/S0352) uses file naming conventions with associated executable locations to blend in with the macOS TimeMachine and OpenSSL services. Such as, naming a LaunchAgent plist file `com.apple.openssl.plist` which executes [OSX_OCEANLOTUS.D](https://attack.mitre.org/software/S0352) from the user's `~/Library/OpenSSL/` folder upon user login.(Citation: Unit42 OceanLotus 2017)
The app bundle is disguised as a doc file to trick users into executing it
[OSX_OCEANLOTUS.D](https://attack.mitre.org/software/S0352) has disguised it's true file structure as an application bundle by adding special characters to the filename and using the icon for legitimate Word documents.(Citation: Trend Micro MacOS Backdoor November 2020)
[OSX_OCEANLOTUS.D](https://attack.mitre.org/software/S0352) has a command to delete a file from the system. [OSX_OCEANLOTUS.D](https://attack.mitre.org/software/S0352) deletes the app bundle and dropper after execution.(Citation: TrendMicro MacOS April 2018)(Citation: Trend Micro MacOS Backdoor November 2020)(Citation: Unit42 OceanLotus 2017)
[OSX_OCEANLOTUS.D](https://attack.mitre.org/software/S0352) can use the <code>touch -t</code> command to change timestamps.(Citation: Trend Micro MacOS Backdoor November 2020)(Citation: 20 macOS Common Tools and Techniques)
[OSX_OCEANLOTUS.D](https://attack.mitre.org/software/S0352) uses a decode routine combining bit shifting and XOR operations with a variable key that depends on the length of the string that was encoded. If the computation for the variable XOR key turns out to be 0, the default XOR key of 0x1B is used. This routine is also referenced as the `rotate` function in reporting.(Citation: Unit42 OceanLotus 2017)
[OSX_OCEANLOTUS.D](https://attack.mitre.org/software/S0352) checks a number of system parameters to see if it is being run on real hardware or in a virtual machine environment, such as `sysctl hw.model` and the kernel boot time.(Citation: Unit42 OceanLotus 2017)(Citation: ESET OceanLotus macOS April 2019)(Citation: 20 macOS Common Tools and Techniques)
[OSX_OCEANLOTUS.D](https://attack.mitre.org/software/S0352) sets the main loader file’s attributes to hidden.(Citation: TrendMicro MacOS April 2018)
...uses the LoadLibraryExW() function to load additional modules... execute additional plugins by loading the respective DLLs... loaded and executed DLLs in memory during runtime... loads a dynamic library (.dylib file) using dlopen() and obtains a function pointer... using dlopen() and dlsym()... calls LoadLibrary then executes exports from a DLL.
[OSX_OCEANLOTUS.D](https://attack.mitre.org/software/S0352) has changed permissions of a second-stage payload to an executable via <code>chmod</code>.(Citation: sentinelone apt32 macOS backdoor 2020)
[OSX_OCEANLOTUS.D](https://attack.mitre.org/software/S0352) uses the command <code>xattr -d com.apple.quarantine</code> to remove the quarantine file attribute used by Gatekeeper.(Citation: Trend Micro MacOS Backdoor November 2020)(Citation: 20 macOS Common Tools and Techniques)
[OSX_OCEANLOTUS.D](https://attack.mitre.org/software/S0352) can collect the network interface MAC address on the infected host.(Citation: TrendMicro MacOS April 2018)(Citation: Trend Micro MacOS Backdoor November 2020)
Running getpwuid ->pw_name, scutil --get ComputerName, and uname –m will provide the following returns respectively: Mac OSX 10.12. System Administrator <owner’s name>'s iMac x86_64
[OSX_OCEANLOTUS.D](https://attack.mitre.org/software/S0352) collects processor information, memory information, computer name, hardware UUID, serial number, and operating system version. [OSX_OCEANLOTUS.D](https://attack.mitre.org/software/S0352) has used the <code>ioreg</code> command to gather some of this information.(Citation: TrendMicro MacOS April 2018)(Citation: Trend Micro MacOS Backdoor November 2020)(Citation: 20 macOS Common Tools and Techniques)
[OSX_OCEANLOTUS.D](https://attack.mitre.org/software/S0352) checks a number of system parameters to see if it is being run on real hardware or in a virtual machine environment, such as `sysctl hw.model` and the kernel boot time.(Citation: Unit42 OceanLotus 2017)(Citation: ESET OceanLotus macOS April 2019)(Citation: 20 macOS Common Tools and Techniques)
The HandlePP::getClientID method uses the following environment variables: Serial number, Hardware UUID, MAC address, Randomly generated UUID
[OSX_OCEANLOTUS.D](https://attack.mitre.org/software/S0352) has the ability to upload files from a compromised host.(Citation: Trend Micro MacOS Backdoor November 2020)
[OSX_OCEANLOTUS.D](https://attack.mitre.org/software/S0352) scrambles and encrypts data using AES256 before sending it to the C2 server.(Citation: TrendMicro MacOS April 2018)(Citation: Trend Micro MacOS Backdoor November 2020)
[OSX_OCEANLOTUS.D](https://attack.mitre.org/software/S0352) has used AES in CBC mode to encrypt collected data when saving that data to disk.(Citation: Unit42 OceanLotus 2017)
Some Backdoor.Oldrea samples use standard Base64 + bzip2... gh0st RAT has used Zlib to compress C2 communications data before encrypting it... HOPLIGHT has utilized Zlib compression to obfuscate the communications payload.
infoClient is responsible for collecting OS info, submitting this info to its C&C servers... Communication with the C&C server after the exchange of OS packet info... HandlePP::urlRequest (/appleauth/static/cssj/N252394295/widget/auth/app.css)
[OSX_OCEANLOTUS.D](https://attack.mitre.org/software/S0352) can also use use HTTP POST and GET requests to send and receive C2 information.(Citation: Trend Micro MacOS Backdoor November 2020)
[OSX_OCEANLOTUS.D](https://attack.mitre.org/software/S0352) has used a custom binary protocol over port 443 for C2 traffic.(Citation: Unit42 OceanLotus 2017)
[OSX_OCEANLOTUS.D](https://attack.mitre.org/software/S0352) has a command to download and execute a file on the victim’s machine.(Citation: TrendMicro MacOS April 2018)(Citation: Trend Micro MacOS Backdoor November 2020)
[OSX_OCEANLOTUS.D](https://attack.mitre.org/software/S0352) has used `zlib` to compress all data after 0x52 for the custom TCP C2 protocol.(Citation: Unit42 OceanLotus 2017)
[OSX_OCEANLOTUS.D](https://attack.mitre.org/software/S0352) has used a custom binary protocol over TCP port 443 for C2.(Citation: Unit42 OceanLotus 2017)
[OSX_OCEANLOTUS.D](https://attack.mitre.org/software/S0352) encrypts data sent back to the C2 using AES in CBC mode with a null initialization vector (IV) and a key sent from the server that is padded to 32 bytes.(Citation: Unit42 OceanLotus 2017)
Many entries state malware or actors can upload, transfer, send, or exfiltrate files from compromised hosts to command-and-control servers or attacker infrastructure.
7 indicators attributed across vendor reports, sandbox runs, and researcher write-ups. Values are masked here and available in full in Mallory.
38 sources tracked across advisories, community write-ups, and news. New activity surfaces here as Mallory finds it.