Back to All Modules

10 - Persistence

#Ethical Note

Persistence techniques should only be deployed when explicitly authorized in the engagement scope and rules of engagement. In most penetration tests, persistence is demonstrated as proof-of-concept and immediately cleaned up. Unauthorized persistence may constitute illegal access. Always document persistence mechanisms and remove them during the cleanup phase.

#Overview

Persistence ensures continued access to compromised systems across reboots, user logoffs, password changes, and other disruptions. In Windows environments, persistence mechanisms range from registry modifications to service creation, WMI event subscriptions, and Kerberos ticket forgery. In Linux environments, SSH keys, cron jobs, systemd services, and shared library injection are common methods. The choice of persistence mechanism balances reliability against stealth.

#Method Selection Criteria

FactorImpact on Choice
Privilege levelKernel-level persistence requires root; user-level persistence is simpler
Reboot frequencyMethods that survive reboots (services, scheduled tasks) vs those that do not (memory-only)
Detection riskServices and registry keys are monitored; WMI subscriptions and COM hijacking are stealthier
Recovery difficultySome methods are destructive (Skeleton Key) and hard to clean up
Engagement durationShort-term persistence (days) vs long-term (weeks/months)

#Windows Persistence Methods Summary

MethodRequires AdminSurvives RebootStealthCleanup Difficulty
Scheduled TaskNo*YesMediumEasy
Registry Run KeysNo*YesLowEasy
WMI Event SubscriptionYesYesHighMedium
Service CreationYesYesLowMedium
Startup FolderNoYesLowEasy
DLL HijackingYesYesMediumHard
Winlogon ReplacementYesYesLowHard
COM HijackingNoYesHighMedium
IFEO DebuggerYesYesLowEasy
Golden TicketDomain AdminYes (10 years)MediumHard
Silver TicketService account hashYes (lifetime)HighMedium
Skeleton KeyDomain AdminNoMediumDestructive
DSRM PasswordDomain AdminYesLowMedium
AdminSDHolderDomain AdminYesMediumHard

*For user-level scheduled tasks without SYSTEM trigger.

#Linux Persistence Methods Summary

MethodRequires RootSurvives RebootStealthCleanup Difficulty
SSH Authorized KeysNoYesLowEasy
Cron JobsNo*YesMediumEasy
Systemd ServiceYesYesLowMedium
.bashrc/.profileNoYes (per-login)LowEasy
MOTD TamperingYesYes (per-login)MediumMedium
LD_PRELOADYesYesHighMedium
Web ShellNoYesLowEasy
PAM BackdoorYesYesHighHard

*User-level crontab.

#Cleanup Principles

  1. Document every persistence mechanism during deployment
  2. Remove in reverse order (last created, first removed)
  3. Verify removal by rebooting and attempting reconnection
  4. Restore original file timestamps and permissions where possible
  5. Clear all related log entries

#Cross-References

#Tool References

ToolLink
mimikatzhttps://github.com/gentilkiwi/mimikatz
Rubeushttps://github.com/GhostPack/Rubeus
schtasks (built-in)Windows native
systemctl (built-in)Linux native

#Source Machines

  • Return (Easy, AD) - Service binary modification for persistence via Server Operators
  • Jeeves (Medium, Windows) - Service manipulation for privilege escalation