Operator On The Wire
Join
← Back to Knowledge Base
BLUE TEAM / THREAT HUNT / LINUX / PERSISTENCE

Systemd Service Persistence

This note documents detection patterns related to Systemd Service Persistence on Linux systems.


Direct Indicators

SourceGrep Pattern / ArtifactMeaningForensic ValueNotes
/etc/systemd/system/New .service fileCustom persistent service installedCriticalPrimary systemd persistence artifact.
/lib/systemd/system/Modified unit fileService tamperingCriticalMay overwrite legitimate service definitions.
User systemd path~/.config/systemd/user/Per-user persistenceCriticalOften missed during triage.
Service fileExecStart=Executed command pathCriticalHighest-value persistence field.
Service file/tmp, /dev/shm, hidden pathSuspicious execution targetCriticalVery high confidence malicious signal.
Service fileRestart=alwaysPersistence resilienceHighCommon attacker durability pattern.
Shell historysystemctl enablePersistence activationCriticalStrong operator evidence.
Shell historysystemctl daemon-reloadService registrationCriticalTypical service insertion step.
Shell historysystemctl startImmediate persistence testHighConfirms activation attempt.
journalctlservice start recordsExecution evidenceCriticalPrimary runtime confirmation.
auditdwrite to service pathsProcess attributionCriticalBest attribution if enabled.
File timestampsrecent service creationTimeline anchorCriticalCorrelates with intrusion window.
Service ownership anomalyunexpected ownerHighReveals attacker mistake.
Symbolic link in wants targetenabled persistence linkCriticalService auto-start confirmed.

Indirect Indicators

IndicatorWhat To Look ForForensic ValueNotes
Service added after SSH or sudoStabilization after footholdCriticalCommon attacker progression.
Service name mimics legitimate daemonCamouflageCriticalVery common stealth pattern.
Service runs hidden scriptSecondary payloadCriticalOften temp or hidden home path.
Service restarts repeatedlyBeacon durabilityHighCommon malicious persistence behavior.
User service under dormant accountSilent persistenceCriticalOften overlooked.
Service points to deleted fileCleanup after insertionHighIndicates incomplete cleanup.
Legitimate unit modified recentlyService hijackCriticalHarder to spot than new file.
Service starts outbound connectionCallback persistenceCriticalStrong compromise signal.
Service plus cron or key persistenceRedundant persistenceCriticalAdvanced operator behavior.
Daemon reload near intrusion timelineService registration eventHighUseful temporal clue.

Common Tools

ToolUsage
systemctl enablePersist service across reboot.
systemctl startImmediate execution.
systemctl daemon-reloadRegister new service definition.
Direct file editDrop service file manually.
ln -sManual enable through wants symlink.

Relevant Artifacts

ArtifactPath / CommandForensic ValueNotes
System services/etc/systemd/system/CriticalPrimary persistence path.
Vendor services/lib/systemd/system/CriticalService hijack possibility.
User services~/.config/systemd/user/CriticalUser persistence path.
Wants symlinksmulti-user.target.wants/CriticalEnablement truth.
JournaldjournalctlCriticalRuntime execution evidence.
Shell history.bash_history, .zsh_historyCriticalService creation commands.
Audit logs/var/log/audit/audit.logCriticalFile write attribution.
Payload targetExecStart referenced fileCriticalActual executable under service.

MITRE ATT&CK References

  • T1543 Create or Modify System Process
  • T1543.002 Systemd Service
  • T1053 Scheduled Task or Job

Decision Tree

  1. Is new or modified service present?

    • Enumerate system and user service paths.
  2. Is service expected?

    • Validate naming, purpose, package ownership.
  3. What does ExecStart launch?

    • Inspect target file and arguments.
  4. Is service enabled?

    • Check wants symlink or enable state.
  5. Has it executed?

    • Review journal runtime records.
  6. Pivot

    • Service file → payload path.
    • Payload path → timestamps and hashes.
    • User → intrusion timeline.
  7. Confirm persistence

    • Unknown service + suspicious ExecStart + intrusion timing = malicious persistence.

Example Detection Templates

Grep

grep -R "ExecStart=" /etc/systemd/system /lib/systemd/system ~/.config/systemd/user 2>/dev/null
grep -R "/tmp\|/dev/shm\|bash\|python\|curl\|wget" /etc/systemd/system /lib/systemd/system ~/.config/systemd/user 2>/dev/null
grep -R "systemctl enable\|daemon-reload\|systemctl start" /home/*/.bash_history /root/.bash_history 2>/dev/null

Journalctl

journalctl | grep systemd
journalctl -u suspicious.service

File Inspection

find /etc/systemd/system /lib/systemd/system -type f -printf '%TY-%Tm-%Td %TT %p\n' 2>/dev/null | sort
find /etc/systemd/system -type l 2>/dev/null

Sigma

title: Linux Systemd Service Persistence
id: linux-systemd-service-persistence
status: experimental
description: Detects suspicious systemd service creation or execution indicators
logsource:
  product: linux
detection:
  selection_keywords:
    message|contains:
      - 'systemd'
      - 'ExecStart'
      - 'daemon-reload'
  condition: selection_keywords
fields:
  - message
  - hostname
falsepositives:
  - Legitimate service deployment
level: high
tags:
  - attack.persistence
  - attack.t1543.002

Mitigation & Hardening

Control AreaMitigationEffectivenessNotes
Service baselineInventory expected unit filesCriticalUnknown services should stand out.
File monitoringWatch systemd pathsCriticalStrong invariant detection.
Least privilegeRestrict service creation rightsHighLimits persistence insertion.
AuditdMonitor writes to service pathsHighStrong attribution.
Temp execution controlBlock service execution from temp pathsCriticalStops common abuse.
Journald retentionPreserve service logsHighNeeded for runtime proof.

Fast Triage Checks

QuestionCommand / ArtifactWhy It Matters
Any new service files?inspect systemd dirsImmediate persistence check.
Is ExecStart suspicious?inspect service contentExecution truth.
Is service enabled?inspect wants symlinksPersistence confirmation.
Has service run?journalctlRuntime proof.
Is payload still present?inspect target pathPayload analysis.
Was service added post-login?correlate timestampsIntrusion chain.

High Value Grep Strings

PatternWhy It Matters
ExecStart=Core execution field.
Restart=alwaysDurability signal.
/tmpSuspicious path.
/dev/shmStealth path.
systemctl enableActivation command.
daemon-reloadRegistration step.
WantedBy=Enablement context.

Analyst Notes

ScenarioInterpretation
Service name mimics legit daemonStrong camouflage attempt.
ExecStart in temp pathHigh-confidence malicious persistence.
User-level service onlyStealth persistence under account context.
Service plus outbound callbackActive beacon persistence likely.
Modified legit serviceService hijack harder to spot.
Service + cron redundancyStrong operator persistence discipline.