T1037.001
Logon Script (Windows)
Adversaries may use Windows logon scripts automatically executed at logon initialization to establish persistence. Windows allows logon scripts to be run whenever a specific user or group of users log into a system. This is done via adding a path to a script to the HKCU\Environment\UserInitMprLogonScript Registry key. Adversaries such as APT28, Cobalt Group, and malware families including Attor, JHUHUGIT, KGH_SPY, and Zebrocy have all leveraged this technique to maintain persistence on compromised systems.
Microsoft Sentinel / Defender
kusto
// Detect registry modifications to UserInitMprLogonScript for logon script persistence
let LogonScriptKey = "HKEY_CURRENT_USER\\Environment";
let LogonScriptValue = "UserInitMprLogonScript";
// Primary detection: Registry key modification
DeviceRegistryEvents
| where Timestamp > ago(24h)
| where RegistryKey has "Environment"
| where RegistryValueName =~ "UserInitMprLogonScript"
| where ActionType in ("RegistryValueSet", "RegistryKeyCreated")
| extend ScriptPath = RegistryValueData
| extend IsSuspiciousExtension = RegistryValueData has_any (".bat", ".cmd", ".ps1", ".vbs", ".js", ".exe", ".hta", ".wsf", ".scr")
| extend IsInUserWritablePath = RegistryValueData has_any ("%APPDATA%", "%TEMP%", "%TMP%", "AppData", "Temp", "Users\\", "ProgramData")
| extend IsInSystemPath = RegistryValueData has_any ("C:\\Windows\\", "C:\\Program Files\\", "C:\\Program Files (x86)\\")
| project
Timestamp,
DeviceName,
AccountName,
ActionType,
RegistryKey,
RegistryValueName,
ScriptPath,
IsSuspiciousExtension,
IsInUserWritablePath,
IsInSystemPath,
InitiatingProcessFileName,
InitiatingProcessCommandLine,
InitiatingProcessParentFileName
| sort by Timestamp desc high severity
high confidence
Data Sources
Registry: Registry Key Modification Microsoft Defender for Endpoint
Required Tables
DeviceRegistryEvents
False Positives
- Enterprise software that legitimately uses UserInitMprLogonScript for logon-time configuration (e.g., some VPN clients or network drive mapping tools)
- Group Policy or IT administration scripts that configure logon scripts via the registry for specific users
- Security assessment or penetration testing tools running authorized tests on the environment
Last updated: 2026-04-16 Research depth: deep
References (10)
- https://attack.mitre.org/techniques/T1037/001/
- http://www.hexacorn.com/blog/2014/11/14/beyond-good-ol-run-key-part-18/
- https://technet.microsoft.com/en-us/library/cc758918(v=ws.10).aspx
- https://unit42.paloaltonetworks.com/unit42-playbook-viewer/
- https://www.welivesecurity.com/2019/10/10/eset-attor-spy-platform/
- https://www.welivesecurity.com/2018/11/20/sednit-what-happened-zebrocy/
- https://blog.morphisec.com/cobalt-gang-2.0
- https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/T1037.001/T1037.001.md
- https://github.com/SigmaHQ/sigma/blob/master/rules/windows/registry/registry_set/registry_set_logon_script_userinitmpr.yml
- https://learn.microsoft.com/en-us/windows/security/threat-protection/auditing/event-4657
Unlock Pro Content
Get the full detection package for T1037.001 including response playbook, investigation guide, and atomic red team tests.
Response PlaybookInvestigation GuideHunting QueriesAtomic Red Team TestsTuning Guidance