Skip to main content

Persistence

Persistence is the technique by which an adversary ensures continued access to a compromised systemβ€”even after reboots, logouts, or temporary disconnections. It is one of the defining characteristics of a determined attacker and a critical phase in real-world intrusions, Advanced Persistent Threats (APTs), and red team operations.


πŸ’‘ Why Persistence Matters​

Once access has been gained, it can easily be lost. A user rebooting their machine, an AV cleanup script, or even a missed heartbeat from your C2 implant can sever your connection.

Persistence is about ensuring reliable access over timeβ€”it’s the difference between a one-off shell and full control over the environment.

It enables:

  • Resilience: Maintain presence across disruptions.
  • Strategic Operations: Execute long-term actions at a time of your choosing.
  • Multi-stage Campaigns: Lay groundwork for lateral movement and privilege escalation.
  • Stealth: Blend in with scheduled tasks, services, registry keys, or startup folders.

πŸ” What Is Considered Persistence?​

Persistence can take many forms depending on OS, privileges, and tooling:

πŸͺŸ On Windows:​

CategoryExamples
Startup Items%APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup
Scheduled Tasksschtasks /create, Task Scheduler GUI
Registry KeysHKCU\Software\Microsoft\Windows\CurrentVersion\Run
ServicesNew-Service, sc.exe
WMI SubscriptionsEvent-triggered payloads
Office MacrosDocuments that run scripts
DLL HijackingAbuse of load order or PATH
Signed BinariesLOLBAS (e.g., mshta, regsvr32)
Credential DumpingSteal tokens and automate re-login

🐧 On Linux/macOS:​

CategoryExamples
Crontabs@reboot /path/to/script.sh
Init Scripts/etc/init.d, /etc/rc.local
Systemd Services~/.config/systemd/user/
Bash Profile.bashrc, .bash_profile, .zshrc
LD_PRELOADShared object injection
SSH KeysAppend to ~/.ssh/authorized_keys
Plist HijackingOn macOS: ~/Library/LaunchAgents/

🧠 Strategic Considerations​

When designing persistence methods, red teamers must consider:

  • OPSEC tradeoffs: Is this method noisy? Does it write to disk or trigger EDR rules?
  • Privileges required: Userland vs admin vs SYSTEM.
  • Durability: Will this survive reboots, logouts, AV cleanups?
  • Trigger: What initiates the payload? Login, boot, event?

Example:

  • HKCU\...\Run is stealthier but only works on login.
  • A scheduled task with SYSTEM permissions may run independent of user activity.

πŸ”’ OPSEC Concerns​

Persistence can trigger alerts more than almost any other tactic.

Tips:

  • Use native tooling (schtasks, reg, wscript) where possible.
  • Minimize writes to common AV/EDR-watched locations.
  • Store payloads in alternate data streams, encrypted files, or non-standard extensions.
  • Consider β€œvolatile” persistence (in-memory or re-implant methods) for stealthy ops.

🧭 Where Does Persistence Fit?​

Initial Access β†’ Execution β†’ [ Post-Ex Recon ] β†’ [ Persistence ] β†’ Lateral Movement / Objectives

Persistence is often set before or after lateral movement, depending on the operator’s level of access and environment stability.


πŸ“Œ Summary​

Persistence is about longevity and strategic foothold. It’s not just about staying inβ€”it’s about coming back, whenever you want, and from wherever you need.

Mastering it gives red teams and adversaries a temporal advantageβ€”the ability to pause, regroup, and strike again on their own terms.