T1569.001: Launchctl

Adversaries may abuse launchctl to execute commands or programs. Launchctl interfaces with launchd, the service management framework for macOS. Launchctl supports taking subcommands on the command-line, interactively, or even redirected from standard input.

Adversaries use launchctl to execute commands and programs as Launch Agents or Launch Daemons. Common subcommands include: launchctl load,launchctl unload, and launchctl start. Adversaries can use scripts or manually run the commands launchctl load -w "%s/Library/LaunchAgents/%s" or /bin/launchctl load to execute Launch Agents or Launch Daemons.

Detection

IDDS0017Data source and componentCommand: Command ExecutionDescription

Monitor command-line execution of the launchctl command immediately followed by abnormal network connections.

IDDS0022Data source and componentFile: File ModificationDescription

Every Launch Agent and Launch Daemon must have a corresponding plist file on disk which can be monitored. Plist files are located in the root, system, and users /Library/LaunchAgents or /Library/LaunchDaemons folders. Launch Agent or Launch Daemon with executable paths pointing to /tmp and /Shared folders locations are potentially suspicious.

IDDS0019Data source and componentService: Service CreationDescription

Monitor for newly constructed services/daemons to execute commands or programs.

Notes: This detection is to identify a creation of “user mode service” where the service file path is located in non-common service folder in windows.

Analytic 1 - Create Service In Suspicious File Path

(source="WinEventLog:Security" EventCode="4697") OR (source="WinEventLog:System" EventCode="7045") Service_File_Name = ".exe" NOT (Service_File_Name IN ("C:\Windows\", "%windir%\", "C:\Program File", "C:\Programdata\", "%systemroot%\")) Service_Type = "user mode service"

IDDS0009Data source and componentProcess: Process CreationDescription

Monitor for newly executed daemons that may abuse launchctl to execute commands or programs.

Mitigation

IDM1018NameUser Account ManagementDescription

Prevent users from installing their own launch agents or launch daemons.