service

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 28, 2026 License: MIT Imports: 11 Imported by: 0

README

service

LaunchAgent/Daemon persistence, cron job installation, and shell profile modification.

Modules

svc_launch_agent

Creates a LaunchAgent plist and registers it with launchctl bootstrap gui/<uid>. Maps to T1543.001. Cleanup boots it out and removes the plist.

svc_launch_daemon

Creates a LaunchDaemon plist and registers it with launchctl bootstrap system (root required). Maps to T1543.004. Cleanup boots it out and removes the plist.

Both use bootstrap/bootout rather than the legacy load/unload, since detection content increasingly keys on the modern subcommands. Bootstrapping a LaunchAgent needs a GUI session, so it fails on a headless host; that failure is reported as telemetry rather than a module error, and cleanup only attempts a bootout when the bootstrap actually succeeded.

svc_login_item

Adds a Login Item via osascript driving System Events (make login item), the shared-file-list route T1547.015 names for scripting languages. On macOS 13+ this registers through Background Task Management and triggers ES_EVENT_TYPE_NOTIFY_BTM_LAUNCH_ITEM_ADD - the dominant modern persistence surface, which no other module covers. Maps to T1547.015. Cleanup deletes the item by name, and only when Generate actually added one.

Adding a login item needs a GUI (Aqua) session plus Automation consent to control System Events. The module distinguishes the outcomes it cannot control from a real fault: no GUI session reports indeterminate, a refused Automation grant reports denied, and only a genuine failure reports error. Over ssh or on a headless runner it will report indeterminate rather than failing.

macnoise run svc_login_item
macnoise run svc_login_item --param name=com.corp.helper --param path=/Applications/Helper.app

SMAppService (the other route T1547.015 names) is deliberately not used: it requires a signed app bundle registering itself, which a standalone binary cannot do. The System Events route produces the same BTM event without one.

svc_cron

Lists the current crontab, then appends a clearly-marked entry (# macnoise). Emits cron_job_list and cron_job_create events. Maps to T1053.003. Cleanup filters the added entry back out of the crontab.

macnoise run svc_cron
macnoise run svc_cron --param schedule="@hourly" --param command="/usr/bin/true"
svc_shell_profile

Appends a marker block (# macnoise-marker-start / # macnoise-marker-end) containing a configurable payload to a shell profile file. Defaults to ~/.zshrc with export MACNOISE_PERSIST=1. Emits a shell_profile_modify event. Maps to T1546.004. Cleanup strips the marker block from the file.

macnoise run svc_shell_profile
macnoise run svc_shell_profile --param target=~/.bash_profile --param payload="alias sudo='sudo -E'"

Documentation

Overview

Package service provides telemetry modules for LaunchAgent and LaunchDaemon persistence simulation. Modules create plist files and load them via launchctl to generate service installation events visible to EDR and audit frameworks.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL