Registry-Based Persistence on Windows
What you'll learn: How attackers exploit specific Windows registry keys to ensure their malware survives reboots and remains active on compromised systems.
Why the Registry?
After achieving initial access (Lesson 1536's persistence fundamentals), attackers need their code to execute automatically. The Windows registry is a hierarchical database that controls system and application startup behavior—making it a prime target for persistence mechanisms.
Common Persistence Locations
Run and RunOnce Keys
These keys execute programs at user login. Think of them as a "startup checklist" Windows reads every time you log in:
HKCU\Software\Microsoft\Windows\CurrentVersion\Run(current user)HKLM\Software\Microsoft\Windows\CurrentVersion\Run(all users)RunOncevariants execute once, then delete themselves
Analogy: Like putting a sticky note on your front door that says "call Mom" every time you leave—except malware adds "launch backdoor.exe."
Winlogon Key
Controls the Windows logon process itself:
HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon- Attackers modify
UserinitorShellvalues to inject malicious executables alongside legitimate ones - Example: Changing
Shellfromexplorer.exetoexplorer.exe,malware.exe
Other Abused Locations
- Services:
HKLM\System\CurrentControlSet\Services(runs with SYSTEM privileges) - Scheduled Tasks: Via
\Software\Microsoft\Windows\CurrentVersion\Schedulereferences - Browser Helper Objects (BHOs): Load with Internet Explorer
- AppInit_DLLs: Inject DLLs into every process (deprecated but still seen)
Detection Strategy
Monitor registry modifications to these keys using tools like Sysmon (Lessons 1512-1516) with specific event filtering for registry changes.
Key Takeaway: Attackers abuse legitimate Windows startup registry keys—particularly Run, RunOnce, and Winlogon—to ensure malware execution after reboot, requiring continuous monitoring of these critical persistence chokepoints.