When idle
Screensaver Persistence: SCRNSAVE.EXE on Windows
How the SCRNSAVE.EXE value makes Windows run a program whenever a session goes idle, how attackers point it at their payload, and how to check and restore it.
- MITRE ATT&CK
- T1546.002
- Tactics
- Persistence, Privilege escalation
- Runs
- When idle
- Set up by
- Any user
- Locations
- HKCU\Control Panel\Desktop
- HKCU\Software\Policies\Microsoft\Windows\Control Panel\Desktop
- C:\Windows\System32\*.scr
How it works
A Windows screensaver is an ordinary program: a PE executable with a .scr extension. Windows starts it with /s to run full screen, /c to show its settings and /p followed by a window handle for the preview in the settings dialog. When a session has had no keyboard or mouse input for the configured time, Windows starts the chosen screensaver with /s, in that session and as the logged-on user.
The choice is four string values in the user's HKCU\Control Panel\Desktop:
| Value | Meaning |
|---|---|
SCRNSAVE.EXE | Full path of the screensaver program |
ScreenSaveActive | 1 to use a screensaver, 0 not to |
ScreenSaveTimeOut | Idle time before it starts, in seconds |
ScreenSaverIsSecure | 1 to ask for the password when the session resumes |
Group Policy can force them for a user. The settings "Force specific screen saver", "Enable screen saver", "Screen saver timeout" and "Password protect the screen saver" write the same four values under HKCU\Software\Policies\Microsoft\Windows\Control Panel\Desktop, which take precedence over the user's own.
Because .scr files are executables, double-clicking one runs it too, which is why mail filters commonly block them as attachments. As persistence, the screensaver gives no privilege beyond the user's: it needs no administrator rights to set, and it runs as that user. What it offers is an unusual trigger. The program starts only when the machine sits idle, often when nobody is watching, and on servers where nobody keeps an interactive session open it may never start at all.
Where it lives
| Location | Who can write it | On a stock Windows 10 or 11 |
|---|---|---|
HKCU\Control Panel\Desktop, SCRNSAVE.EXE | The user | Usually absent: no screensaver is chosen |
HKCU\Control Panel\Desktop, ScreenSaveActive, ScreenSaveTimeOut, ScreenSaverIsSecure | The user | May be present; they do nothing without SCRNSAVE.EXE |
HKCU\Software\Policies\Microsoft\Windows\Control Panel\Desktop | Group Policy; standard users cannot write it | Absent unless a policy sets it |
C:\Windows\System32\*.scr | TrustedInstaller | scrnsave.scr (Blank), Bubbles.scr, Mystify.scr, Ribbons.scr, ssText3d.scr (3D Text), PhotoScreensaver.scr (Photos) |
The values live in each user's NTUSER.DAT. The Control Panel\Desktop key also holds the wallpaper, font smoothing and many other display settings, so it changes often for reasons that have nothing to do with screensavers.
How attackers use it
Setting it takes four values and no privileges:
reg add "HKCU\Control Panel\Desktop" /v SCRNSAVE.EXE /t REG_SZ /d "C:\Users\alice\AppData\Local\Microsoft\Windows\Themes\ribbons.scr" /f
reg add "HKCU\Control Panel\Desktop" /v ScreenSaveActive /t REG_SZ /d 1 /f
reg add "HKCU\Control Panel\Desktop" /v ScreenSaveTimeOut /t REG_SZ /d 60 /f
reg add "HKCU\Control Panel\Desktop" /v ScreenSaverIsSecure /t REG_SZ /d 0 /f
A short timeout makes it fire soon, and ScreenSaverIsSecure set to 0 keeps the sign-in screen out of the way when the user comes back. The payload is usually a renamed executable (any PE runs, whatever its extension says), given the name of a Windows screensaver and placed outside System32.
MITRE ATT&CK records Gazer, a backdoor attributed to Turla, setting itself as the screensaver to persist. The value can also point at a program that is not a screensaver at all. With administrator rights, an attacker could instead replace a .scr file in System32, leaving the registry at its stock value.
How to check a host
On a live machine, for the current user:
reg query "HKCU\Control Panel\Desktop" /v SCRNSAVE.EXE
reg query "HKCU\Software\Policies\Microsoft\Windows\Control Panel\Desktop"
Get-ItemProperty 'HKCU:\Control Panel\Desktop' | Select-Object 'SCRNSAVE.EXE', ScreenSaveActive, ScreenSaveTimeOut, ScreenSaverIsSecure
Get-ItemProperty 'Registry::HKEY_USERS\*\Control Panel\Desktop' -Name 'SCRNSAVE.EXE' -ErrorAction SilentlyContinue
Get-AuthenticodeSignature 'C:\Windows\System32\Bubbles.scr'
The second command covers every user whose hive is loaded; load the others with reg load from their NTUSER.DAT. Check that the program named is one of Windows' screensavers in System32, or one that a known product installed, and that the file there is signed by Microsoft.
Offline, read Control Panel\Desktop and Software\Policies\Microsoft\Windows\Control Panel\Desktop in each NTUSER.DAT. The key's last-write time is weak evidence, since display settings change it too. Process creation events (4688 with command lines, or Sysmon event 1) are more telling: a process started with /s whose image is not one of Windows' .scr files, or which spawns a shell, a script host or network connections. Amcache and Prefetch show when the .scr file ran.
What stands out: a SCRNSAVE.EXE outside System32, a file name that copies a Windows screensaver in a user folder, a path that does not end in .scr, a very short timeout, and ScreenSaverIsSecure set to 0 where policy requires a locked screen.
What Windows Persistence flags
The tool reads SCRNSAVE.EXE in Control Panel\Desktop and in the policy key Software\Policies\Microsoft\Windows\Control Panel\Desktop of each user hive in the collection, including the Default profile's and SYSTEM's .DEFAULT. Each non-empty value is an entry triggered by idle time. ScreenSaveActive in the same key decides whether it shows as enabled (unknown when absent), the timeout is shown in seconds, and entries from the policy key are marked as set by Group Policy.
- One of Windows' screensavers (
scrnsave,Bubbles,Mystify,Ribbons,ssText3d,PhotoScreensaver,logonand the Windows XP names such assspipesandssstars) in Windows' folders is marked as the Windows default. - A path that does not end in
.scrraises Screensaver is not a .scr file (high). - Any other
.scrraises Non-Windows screensaver: low when it sits in Windows' folders or Program Files, medium anywhere else.
The command-line rules run on the value as a per-user autostart: Runs from a temporary or public folder, Runs from a network share, Windows program name in the wrong place, Name one letter away from a Windows program, Machine-made name and the others. Across mechanisms: Written date when the key changed in the 7 days before the newest time collected from that host (a wallpaper change moves it too), Inside a Defender exclusion (exclusion) and program also runs from mechanisms.
With Hide Windows entries on, a Windows screensaver at its stock location is hidden.
Limits: the tool reads the path, not the file, so a Bubbles.scr replaced inside System32 looks stock. It does not read ScreenSaverIsSecure, and when the policy key sets the program but not ScreenSaveActive, the entry's enabled state is unknown.
Cleaning up
- Preserve:
reg export "HKCU\Control Panel\Desktop" desktop.reg(or theHKU\<SID>path of another user), then copy and hash the program the value names. - Remove the value, or choose "(None)" in the screensaver settings:
reg delete "HKCU\Control Panel\Desktop" /v SCRNSAVE.EXE /f. RestoreScreenSaverIsSecureandScreenSaveTimeOutto what your policy requires. - If the policy key holds the value, fix the Group Policy Object, local or domain, that sets it; deleting the value by hand only lasts until the next refresh.
- Delete the payload. If a file in
System32was replaced, runsfc /scannow, orsfc /scanfile=C:\Windows\System32\Bubbles.scrfor that file alone. - Look for the same program in the user's other autostarts, and rotate the user's passwords and sessions.
See also
Related techniques
On Windows Forensics
The artifacts behind this technique, in the Windows Forensics reference: