Identifying Persistence Mechanisms

Persistence mechanisms allow malware or attackers to regain access after reboot, login, or system restart. During incident investigation, identifying persistence is critical because it reveals how the attacker maintains long-term control and what components restart automatically in the background. Persistence techniques vary across Windows, Linux, and macOS, but all of them leave traces that can be uncovered through careful forensic analysis.

This chapter explains the most common persistence mechanisms, where they are found, how to identify them, and what indicators suggest malicious persistence on a compromised system.


Understanding Persistence

Persistence is any modification that ensures malicious code runs repeatedly—even after:

  • System reboot

  • User logout

  • System crash

  • Network reconnection

  • Service restart

Attackers rely on persistence to maintain control, launch payloads, exfiltrate data, and re-enter systems even after partial cleanup.


Common Windows Persistence Mechanisms

Windows provides many ways to autostart applications. Malware abuses these mechanisms to maintain presence.


1. Registry Run Keys

Malware frequently writes entries to:

HKCU\Software\Microsoft\Windows\CurrentVersion\Run
HKLM\Software\Microsoft\Windows\CurrentVersion\Run

Indicators:

  • Unknown executables

  • Paths in Temp/AppData

  • Random or misleading names

  • References to scripts (vbs, js, ps1)


2. Scheduled Tasks

Malware creates scheduled tasks to run at boot or intervals.

Commands:

  • schtasks /create ...

  • Tasks under:

    • C:\Windows\System32\Tasks\

    • HKLM\Software\Microsoft\Windows NT\CurrentVersion\Schedule\

Indicators:

  • Unfamiliar task names

  • Tasks running from unusual paths

  • Tasks running hidden windows


3. Services

Malicious services are common for high-privilege persistence.

Locations:

  • HKLM\SYSTEM\CurrentControlSet\Services\

  • Service executables in Temp/AppData

Indicators:

  • Services pointing to unsigned binaries

  • Newly created services after compromise

  • Services set to auto-start


4. WMI Persistence

Attackers create event filters and consumers.

Commands used:

  • wmic

  • PowerShell WMI commands

Indicators:

  • Abnormal WMI subscriptions

  • Permanent event consumers

  • Script contents embedded inside WMI


5. Startup Folders

Executables placed here run at login:

%APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup\
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup\

6. DLL Hijacking & Side-Loading

Malware places DLLs where trusted applications load them automatically.

Indicators:

  • Unusual DLLs next to legitimate EXEs

  • Mismatched signatures


7. Office & PowerShell Persistence

Via macros or profiles:

  • Normal.dotm macro modification

  • PowerShell profile scripts

  • Excel/Word auto-run macros


Common Linux Persistence Mechanisms

Linux persistence often revolves around startup scripts, cron jobs, and service daemons.


1. Cron Jobs

Attackers add tasks into:

/etc/crontab
/var/spool/cron/
crontab -e

Indicators:

  • New jobs running scripts from /tmp or hidden folders

  • Cron jobs running as root


2. Systemd Services

Malicious units created in:

/etc/systemd/system/
~/.config/systemd/user/

Indicators:

  • Services pointing to unknown binaries

  • Services using disguised names (e.g., "systemd-updates")


3. rc.local, profile, bashrc scripts

Payloads embedded inside:

/etc/rc.local
/etc/profile
~/.bashrc
~/.bash_profile

4. SSH Key Abuse

Attackers insert public keys into:

~/.ssh/authorized_keys

Indicators:

  • Unknown SSH keys

  • Keys with suspicious comments/names


5. Kernel Modules (Rootkits)

Attackers load malicious LKM modules:

  • lsmod anomalies

  • Hidden modules

  • Modules without disk backing


Common macOS Persistence Mechanisms

macOS uses LaunchAgents and LaunchDaemons for persistence.


1. LaunchAgents & LaunchDaemons

Locations:

/Library/LaunchAgents/
/Library/LaunchDaemons/
~/Library/LaunchAgents/

Indicators:

  • Unusual plist files

  • Scripts pointing to hidden directories


2. Login Items

Malware registers itself in:

~/Library/Preferences/loginwindow.plist

3. Kernel Extensions (kexts)

Rootkit-level persistence:

  • Suspicious kexts in /Library/Extensions/


4. Browser Extensions

Malicious Chrome or Safari extensions auto-load.

Indicators:

  • Random extension IDs

  • Scripts embedded in extension folders


Indicators of Malicious Persistence (Cross-Platform)

Regardless of OS, persistence almost always shows signs:

  • Unknown or unsigned executables

  • Binaries running from Temp, AppData, /tmp

  • Randomized filenames

  • Recently created autorun locations

  • Scripts or binaries in hidden directories

  • Base64-encoded commands

  • Executables with no metadata or version info

  • Processes relaunching consistently after termination


Tools Used to Identify Persistence

Windows

  • Autoruns

  • Sysmon

  • ProcMon

  • PowerShell logging

  • Volatility’s registry and services plugins

Linux

  • chkconfig / systemctl

  • Cron analysis

  • find / grep for suspicious scripts

  • Volatility’s linux modules

macOS

  • KnockKnock

  • BlockBlock

  • LaunchServices inspection

  • Volatility mac plugins


Memory Indicators of Persistence

Memory analysis often reveals persistence even before disk inspection:

  • Autostart registry keys loaded in RAM

  • WMI objects in memory

  • Services active without matching disk files

  • Suspicious launchd processes

  • Hidden cron job processes

  • Scripts stored in-memory but not on disk

  • Injected processes that respawn after termination

Persistence often manifests as long-running or automatically restarting processes.


Intel Dump

  • Persistence ensures malware survives reboot, logout, and cleanup by modifying autorun locations, creating services, or installing scheduled tasks.

  • Windows persistence includes Run keys, scheduled tasks, WMI events, startup folders, service creation, and DLL hijacking.

  • Linux persistence relies on cron jobs, systemd services, profile/bash scripts, SSH key abuse, and kernel modules.

  • macOS persistence commonly abuses LaunchAgents, LaunchDaemons, login items, browser extensions, and malicious kexts.

  • Key indicators include unsigned binaries, hidden directory execution, obfuscated filenames, suspicious plist files, new cron/systemd entries, and registry modifications.

  • Memory forensics reveals hidden persistence by uncovering autostart artifacts, WMI objects, cron processes, injected code, and long-running malware threads.

HOME COMMUNITY CAREERS DASHBOARD