CmdID

CmdID / Rules / macOS

Launch Agent/Daemon Execution Via Launchctl

A Sigma rule for process creation on macOS, by Pratinav Chandra.

medium 3 ATT&CK techniques 1 program it names 5 everyday examples trip it

What it looks for

its detection, as SigmaHQ writes it
detection:
  selection:
    CommandLine|contains:
      - 'submit'
      - 'load'
      - 'start'
    Image|endswith: '/launchctl'
  condition: selection

The rule’s detection, its selections and fields in order of name. The whole rule, with its references and false positives, is on SigmaHQ, by Pratinav Chandra, under the Detection Rule License 1.1. CmdID evaluates it on a command line alone: a test on what a command line cannot show, such as the parent process or the user, is not met.

Command lines that trip it

everyday examples from tldr-pages, CC BY 4.0, each read by CmdID

Activate a user-specific agent to be loaded into launchd whenever the user logs in on the page for launchctl

launchctl load ~/Library/LaunchAgents/my_script.plistIdentify

Activate an agent which requires root privileges to run and/or should be loaded whenever any user logs in (note the absence of ~ in the path) on the page for launchctl

sudo launchctl load /Library/LaunchAgents/root_script.plistIdentify

Activate a system-wide daemon to be loaded whenever the system boots up (even if no user logs in) on the page for launchctl

sudo launchctl load /Library/LaunchDaemons/system_daemon.plistIdentify

Unload a currently loaded agent, e.g. to make changes (Note: The plist file is automatically loaded into launchd after a reboot and/or logging in) on the page for launchctl

launchctl unload ~/Library/LaunchAgents/my_script.plistIdentify

Manually run a known (loaded) agent/daemon, even if it is not the right time (Note: This command uses the agent's label, rather than the filename) on the page for launchctl

launchctl start script_fileIdentify

Programs and files it names

their pages here

ATT&CK

the techniques it is tagged with
T1543.001Create or Modify System Process: Launch Agent
T1543.004Create or Modify System Process: Launch Daemon
T1569.001System Services: Launchctl