macOS
Catching macOS Persistence in the Unified Log
Scenario
On macOS, persistence almost always touches a small set of locations: Launch Agents, Launch Daemons, login items, and configuration profiles. The Unified
Log sees the daemons that manage them.
Querying the Unified Log
# Surface launchd loading a new agent/daemon in the last hour
log show --last 1h --predicate \
'process == "launchd" && eventMessage CONTAINS "Service only ran"' \
--info
[!NOTE] Unified Logging is ephemeral and lossy by design. For real detection, stream it to a collector with
log streamrather than relying onlog showafter the fact.
Watch the paths directly
Pair the log with FSEvents (or an eslogger/Endpoint Security client) on the
persistence directories:
ls -la ~/Library/LaunchAgents /Library/LaunchAgents /Library/LaunchDaemons
[!TIP] A new
.plistwhoseProgramArgumentspoints at/tmp, a hidden path, or a user-writable directory is persistence until proven otherwise.
Conclusion
You donβt need a third-party agent to catch most macOS persistence, streamed Unified Logging plus Endpoint Security on a handful of directories covers the techniques real intrusions actually use. e.