On macOS, malware is often distributed to users via macOS Installers. Since these are generally going to be extremely noisy in most environments, these are only recommended for threat hunting, baselining or to trigger some automated action to collect more information from the endpoint.
Prelude Operator: Run iShelly with the "Installer Package w/ only preinstall script" Installer Package option. Then execute the pkg file, which will execute an Operator agent after clicking through Installer prompts.
Detect:
EDR:
parent_process_name = "package_script_service" and process_cmdline = "*preinstall*"
Alerting on this will be extremely noisy and is not recommended. If using for baselining, exclude based on the pkg name in process_cmdline, but beware an attacker can also leverage this by naming their package after a popular installer.
Respond:
Review the process_cmdline field of process package_script_service. This will contain the execution of the preinstall script and will have the name of the .pkg being executed.
Review the children of process package_script_service (often this will be the bash process, but could be another script interpreter). These children will be the commands executed as a result of the preinstall script.
Review process creations, network connections and file writes of all children processes of package_script_service.
Prelude Operator: Run iShelly with the "Installer Package w/ only postinstall script" Installer Package option. Then execute the pkg file, which will execute an Operator agent after clicking through Installer prompts.
Detect:
EDR:
parent_process_name = "package_script_service" and process_cmdline = "*postinstall*"
Alerting on this will be extremely noisy and is not recommended. If using for baselining, exclude based on the pkg name in process_cmdline, but beware an attacker can also leverage this by naming their package after a popular installer.
Respond:
Review the process_cmdline field of process package_script_service. This will contain the execution of the postinstall script and will have the name of the .pkg being executed.
Review the children of process package_script_service (often this will be the bash process, but could be another script interpreter). These children will be the commands executed as a result of the postinstall script.
Review process creations, network connections and file writes of all children processes of package_script_service.
This query detects any macOS Installer that leverages an installer plugins.
Adversaries may pair this technique with a social engineering component to execute malware. They may use this technique to generate less known EDR behavioral patterns or when they need malware running as user.
OS Behavior:
When executing the pkg file generated via iShelly, launchd runs Installer as user.
Installer prompts the user with subject "This package will run a program to determine if the software can be installed".
xpcproxy magic happens, and launchd executes InstallerRemotePluginService-x86_64 as user.
InstallerRemotePluginService-x86_64 then launches the script interpreter as a user. In our case this will be bash (since this is how iShelly implements this vector). The cmdline is
as a result of the above bash one liner, bash executes the following children processes- curl, chmod. curl makes a network connection to Operator and writes payload to /Users/$USER/Library/Application\ Support/operator-payload. chmod makes the payload executable.
The same bash process executes operator-payload.
operator-payload makes a network connection to operator.
Execute:
Prelude Operator: Run iShelly with the "Installer Package w/ Installer Plugin" Installer Package option.
Review the children of process InstallerRemotePluginService-x86_64.
Review process creations, network connections and file writes of all children processes of InstallerRemotePluginService-x86_64.
Privileges required: User
MITRE ATT&CK®: T1204.002
macOS Installer Package with JavaScript Functionality
This query detects installer packages leveraging JavaScript functionality via distribution.xml files. The malicious commands can either be in distrubtion.xml file, or the distribution.xml file invoke a script included in the installer. You should test both cases by generating the payloads using iShelly.
Adversaries may pair this technique with a social engineering component to execute malware. They may use this technique to generate less known EDR behavioral patterns or when they need malware running as user.
OS Behavior:
When executing the pkg file generated via iShelly, launchd runs Installer as user.
Installer prompts the user with subject "This package will run a program to determine if the software can be installed".
Prelude Operator: Run iShelly with either the "Installer Package w/ JavaScript Functionality embedded" or "Installer Package w/ JavaScript Functionality in Script" Installer Package option. The embedded option contains the malicious code within the distribution.xml, while the script option contains malicious code in a script file, which is contained
Detect:
EDR:
parent_process_name = "Installer" AND NOT (process_name = "installd" OR process_name = "InstallerRemotePluginService-x86_64" OR process_name= "MTLCompilerService" OR process_name = "package_script_service")
Respond:
Review the children of process Installer.
Review process creations, network connections and file writes of all children processes of Installer.
Privileges required: User
MITRE ATT&CK®: T1204.002