Attackers may use the creation of malicious .scr files to execute arbitrary code and maintain persistence on a system. SOC teams should proactively hunt for this behavior in Azure Sentinel to identify potential malware deployment or persistence tactics early.
Detection Rule
title: SCR File Write Event
id: c048f047-7e2a-4888-b302-55f509d4a91d
status: test
description: Detects the creation of screensaver files (.scr) outside of system folders. Attackers may execute an application as an ".SCR" file using "rundll32.exe desk.cpl,InstallScreenSaver" for example.
references:
- https://lolbas-project.github.io/lolbas/Libraries/Desk/
author: 'Christopher Peacock @securepeacock, SCYTHE @scythe_io'
date: 2022-04-27
modified: 2023-08-23
tags:
- attack.defense-evasion
- attack.t1218.011
logsource:
category: file_event
product: windows
detection:
selection:
TargetFilename|endswith: '.scr'
filter:
TargetFilename|contains:
- ':\$WINDOWS.~BT\NewOS\'
- ':\Windows\System32\'
- ':\Windows\SysWOW64\'
- ':\Windows\WinSxS\'
- ':\WUDownloadCache\' # Windows Update Download Cache
condition: selection and not filter
falsepositives:
- The installation of new screen savers by third party software
level: medium
imFileEvent
| where TargetFileName endswith ".scr" and (not((TargetFileName contains ":\\$WINDOWS.~BT\\NewOS\\" or TargetFileName contains ":\\Windows\\System32\\" or TargetFileName contains ":\\Windows\\SysWOW64\\" or TargetFileName contains ":\\Windows\\WinSxS\\" or TargetFileName contains ":\\WUDownloadCache\\")))
Scenario: User creates a screensaver for personal use
Description: A user may manually create a .scr file in their personal directory (e.g., C:\Users\John\Documents\my_screensaver.scr) for personal use.
Filter/Exclusion: Check the file path against user-specific directories (e.g., C:\Users\*\Documents\), or exclude files created by users in their home directories.
Scenario: Scheduled Task runs a legitimate screensaver generator tool
Description: A scheduled job may run a legitimate tool like scrutil or a custom script to generate a screensaver file for automated testing or deployment.
Filter/Exclusion: Exclude events where the file is created by a known legitimate tool or process (e.g., scrutil.exe, powershell.exe with a known script).
Scenario: System update or patching process creates a temporary .scr file
Description: During a system update or patching process, a temporary .scr file may be created in a system directory (e.g., C:\Windows\Temp\) as part of a legitimate installation.
Filter/Exclusion: Exclude files created in temporary directories (C:\Windows\Temp\, C:\Users\*\AppData\Local\Temp\) or by system processes like msiexec.exe.
Scenario: Admin task to deploy a custom screensaver for internal branding
Description: An administrator may deploy a custom .scr file to multiple workstations as part of an internal branding initiative.
Filter/Exclusion: Exclude files created by administrative tools or scripts (e.g., group policy, psexec, PowerShell scripts) or in shared directories like C:\Program Files\Common Files\.
**Scenario: Antivirus or endpoint protection tool creates