T1543.002

Systemd Service

Adversaries may create or modify systemd services to repeatedly execute malicious payloads as part of persistence. Systemd is the default initialization system on many Linux distributions. Adversaries create new .service unit files or modify existing ones, placing them in /etc/systemd/system/, /lib/systemd/system/, or user-level ~/.config/systemd/user/ directories. The ExecStart, ExecStartPre, ExecReload, and ExecStop directives within service files execute commands when services start, reload, or stop. Threat actors including TeamTNT, Rocke, and Scattered Spider have leveraged systemd services for persistence and privilege escalation.

Microsoft Sentinel / Defender
kusto
let SystemdServicePaths = dynamic([
  "/etc/systemd/system/",
  "/lib/systemd/system/",
  "/usr/lib/systemd/system/",
  "/run/systemd/system/",
  ".config/systemd/user/",
  "/etc/systemd/user/"
]);
let SuspiciousServiceNames = dynamic([
  "syslogd", "systemd-network", "systemd-resolve", "kthreadd",
  "netns", "cron2", "update-rc", "sshd2", "rsyslogd"
]);
// Detection 1: New service file created in systemd directories
DeviceFileEvents
| where Timestamp > ago(24h)
| where ActionType in ("FileCreated", "FileModified")
| where FolderPath has_any (SystemdServicePaths)
| where FileName endswith ".service"
| extend IsUserLevelService = FolderPath contains ".config/systemd/user"
| extend IsSuspiciousName = FileName has_any (SuspiciousServiceNames)
| project Timestamp, DeviceName, AccountName, ActionType, FolderPath, FileName,
         InitiatingProcessFileName, InitiatingProcessCommandLine, InitiatingProcessAccountName,
         IsUserLevelService, IsSuspiciousName
| sort by Timestamp desc
// Detection 2: systemctl enable/start on newly created services
// Uncomment and union with above for broader coverage:
// union (
//   DeviceProcessEvents
//   | where Timestamp > ago(24h)
//   | where FileName =~ "systemctl"
//   | where ProcessCommandLine has_any ("enable", "start", "daemon-reload")
//   | where ProcessCommandLine matches regex @"systemctl.*(enable|start).*\.service"
// )
high severity high confidence

Data Sources

File: File Creation File: File Modification Linux file system events via MDE

Required Tables

DeviceFileEvents DeviceProcessEvents

False Positives

  • Package managers (apt, yum, dnf, rpm) installing legitimate software that includes systemd service units
  • System administrators manually creating or modifying service files for legitimate infrastructure automation
  • Configuration management tools (Ansible, Chef, Puppet, SaltStack) deploying service configurations
  • Docker or container runtime installations that register systemd services
  • Development environments where developers create test services locally

Unlock Pro Content

Get the full detection package for T1543.002 including response playbook, investigation guide, and atomic red team tests.

Response PlaybookInvestigation GuideHunting QueriesAtomic Red Team TestsTuning Guidance

Related Detections