T1037.003
Network Logon Script
Adversaries may use network logon scripts automatically executed at logon initialization to establish persistence. Network logon scripts can be assigned using Active Directory or Group Policy Objects. These logon scripts run with the privileges of the user they are assigned to. Depending on the systems within the network, initializing one of these scripts could apply to more than one or potentially all systems. Adversaries may use these scripts to maintain persistence on a network. Depending on the access configuration of the logon scripts, either local credentials or an administrator account may be necessary.
Microsoft Sentinel / Defender
kusto
let SuspiciousScriptExtensions = dynamic([".bat", ".cmd", ".ps1", ".vbs", ".js", ".wsf", ".hta"]);
let KnownLogonScriptPaths = dynamic(["\\NETLOGON\\", "\\SYSVOL\\", "\\scripts\\"]);
// Detection 1: AD User object ScriptPath attribute modification via LDAP/AD changes
let ADScriptChange = AuditLogs
| where TimeGenerated > ago(24h)
| where OperationName has_any ("Update user", "Modify user")
| where TargetResources has "scriptPath"
| extend ModifiedBy = tostring(InitiatedBy.user.userPrincipalName)
| extend TargetUser = tostring(TargetResources[0].userPrincipalName)
| extend ChangedProperties = tostring(TargetResources[0].modifiedProperties)
| project TimeGenerated, OperationName, ModifiedBy, TargetUser, ChangedProperties, CorrelationId
| extend DetectionType = "AD ScriptPath Attribute Modified";
// Detection 2: Script file created or modified in NETLOGON/SYSVOL share paths
let ScriptFileCreation = DeviceFileEvents
| where Timestamp > ago(24h)
| where FolderPath has_any (KnownLogonScriptPaths)
| where FileName has_any (SuspiciousScriptExtensions)
| where ActionType in ("FileCreated", "FileModified", "FileRenamed")
| project Timestamp, DeviceName, AccountName, FolderPath, FileName, ActionType,
InitiatingProcessFileName, InitiatingProcessCommandLine, SHA256
| extend DetectionType = "Script File Created/Modified in NETLOGON/SYSVOL";
// Detection 3: Suspicious process spawned from logon script host processes at logon
let LogonScriptExecution = DeviceProcessEvents
| where Timestamp > ago(24h)
| where InitiatingProcessFileName in~ ("userinit.exe", "explorer.exe")
| where FileName in~ ("cmd.exe", "powershell.exe", "pwsh.exe", "wscript.exe", "cscript.exe", "mshta.exe", "regsvr32.exe", "rundll32.exe")
| where ProcessCommandLine has_any (KnownLogonScriptPaths) or
(InitiatingProcessCommandLine has_any (KnownLogonScriptPaths))
| project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine,
InitiatingProcessFileName, InitiatingProcessCommandLine
| extend DetectionType = "Suspicious Process Spawned from Logon Script Path";
// Detection 4: Registry key for logon script set or modified
let RegistryLogonScript = DeviceRegistryEvents
| where Timestamp > ago(24h)
| where RegistryKey has_any (
"\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon",
"\\SOFTWARE\\Policies\\Microsoft\\Windows\\System",
"\\Environment"
)
| where RegistryValueName in~ ("UserInitMprLogonScript", "Userinit", "Scripts")
| project Timestamp, DeviceName, AccountName, RegistryKey, RegistryValueName,
RegistryValueData, ActionType, InitiatingProcessFileName, InitiatingProcessCommandLine
| extend DetectionType = "Logon Script Registry Key Modified";
// Union all detections
ADScriptChange
| project-away ModifiedBy, TargetUser, ChangedProperties, CorrelationId
| union
(ScriptFileCreation | project-away ActionType, SHA256),
(LogonScriptExecution | project-away FileName),
(RegistryLogonScript | project-away RegistryKey, RegistryValueName, RegistryValueData, ActionType)
| sort by TimeGenerated desc high severity
medium confidence
Data Sources
Active Directory: Active Directory Object Modification File: File Creation File: File Modification Process: Process Creation Windows Registry: Windows Registry Key Modification
Required Tables
AuditLogs DeviceFileEvents DeviceProcessEvents DeviceRegistryEvents
False Positives
- IT administrators legitimately deploying or updating logon scripts via Group Policy or AD Users and Computers for software deployment or environment configuration
- SCCM/Intune or other endpoint management platforms that modify SYSVOL/NETLOGON share contents as part of normal GPO operations
- Automated provisioning systems that set the scriptPath attribute on new user accounts during onboarding workflows
- Domain controllers replicating SYSVOL content via DFS-R or FRS, which generates file creation/modification events in the SYSVOL path
Last updated: 2026-04-16 Research depth: deep
References (8)
- https://attack.mitre.org/techniques/T1037/003/
- https://www.petri.com/setting-up-logon-script-through-active-directory-users-computers-windows-server-2008
- https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/dn789190(v=ws.11)
- https://docs.microsoft.com/en-us/windows/security/threat-protection/auditing/event-5136
- https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/T1037.003/T1037.003.md
- https://adsecurity.org/?p=2716
- https://www.ultimatewindowssecurity.com/securitylog/encyclopedia/event.aspx?eventID=5136
- https://docs.microsoft.com/en-us/windows-server/identity/ad-ds/manage/component-updates/active-directory-replication-status-tool
Unlock Pro Content
Get the full detection package for T1037.003 including response playbook, investigation guide, and atomic red team tests.
Response PlaybookInvestigation GuideHunting QueriesAtomic Red Team TestsTuning Guidance