T1037.003 Elastic Security · Elastic

Detect Network Logon Script in Elastic Security

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.

MITRE ATT&CK

Tactic
Persistence Privilege Escalation
Technique
T1037 Boot or Logon Initialization Scripts
Sub-technique
T1037.003 Network Logon Script
Canonical reference
https://attack.mitre.org/techniques/T1037/003/

Elastic Detection Query

Elastic Security (Elastic)
eql
sequence by host.name with maxspan=5m
[
  // Detection 1: Script file created/modified in NETLOGON/SYSVOL paths
  file where event.type in ("creation", "change") and
  (
    file.path : ("*\\NETLOGON\\*", "*\\SYSVOL\\*", "*\\scripts\\*") and
    file.extension : ("bat", "cmd", "ps1", "vbs", "js", "wsf", "hta")
  )
]
or
// Detection 2: Suspicious process spawned from logon script host at logon
sequence by host.name with maxspan=2m
[
  process where event.type == "start" and
  process.parent.name : ("userinit.exe", "explorer.exe") and
  process.name : ("cmd.exe", "powershell.exe", "pwsh.exe", "wscript.exe", "cscript.exe", "mshta.exe", "regsvr32.exe", "rundll32.exe") and
  (
    process.command_line : ("*NETLOGON*", "*SYSVOL*", "*\\scripts\\*") or
    process.parent.command_line : ("*NETLOGON*", "*SYSVOL*", "*\\scripts\\*")
  )
]
or
// Detection 3: Logon script registry key modified
registry where event.type in ("creation", "change") and
(
  registry.path : (
    "*\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon*",
    "*\\SOFTWARE\\Policies\\Microsoft\\Windows\\System*",
    "*\\Environment*"
  ) and
  registry.value : ("UserInitMprLogonScript", "Userinit", "Scripts")
)
high severity high confidence

Detects T1037.003 Network Logon Script persistence via three detection approaches: (1) script files created/modified in NETLOGON, SYSVOL, or scripts share paths with suspicious extensions, (2) suspicious interpreter processes (cmd, PowerShell, wscript, etc.) launched by userinit.exe or explorer.exe referencing logon script paths, and (3) registry key modifications targeting Winlogon or Environment keys used to set logon scripts (UserInitMprLogonScript, Userinit). Covers both file-system and registry-based persistence mechanisms.

Data Sources

Elastic Endpoint Security (endpoint.events.file)Elastic Endpoint Security (endpoint.events.process)Elastic Endpoint Security (endpoint.events.registry)Windows Event Logs via Elastic Agent (winlog.event_id)

Required Tables

logs-endpoint.events.file-*logs-endpoint.events.process-*logs-endpoint.events.registry-*winlogbeat-*

False Positives & Tuning

  • Legitimate IT administrators deploying or updating login scripts in NETLOGON/SYSVOL share as part of scheduled Group Policy maintenance or system provisioning workflows.
  • Software deployment tools (SCCM, Ansible, Puppet) that write scripts to SYSVOL or NETLOGON as part of automated provisioning or configuration management.
  • Security or compliance tooling that modifies Winlogon registry keys (e.g., Userinit) during installation or updates, such as endpoint detection agents or VPN clients.
  • Domain controller replication processes that propagate legitimate SYSVOL script changes across domain controllers, generating file creation events on replica DCs.
Download portable Sigma rule (.yml)

Other platforms for T1037.003


Testing Methodology

Validate this detection against 4 adversary techniques from Atomic Red Team. Each test below lists the behaviour to exercise and the telemetry you should expect to see. Executable commands and cleanup steps are available with Pro.

  1. Test 1Set AD User ScriptPath Attribute via PowerShell

    Expected signal: Security Event ID 5136 on Domain Controller: Directory Service Object Modification with AttributeLDAPDisplayName=scriptPath and the new AttributeValue. AuditLogs (Azure AD) OperationName='Update user' with modifiedProperties containing scriptPath. PowerShell ScriptBlock Log Event ID 4104 with Set-ADUser command.

  2. Test 2Create Malicious Script in NETLOGON Share

    Expected signal: Sysmon Event ID 11 (File Create) on the domain controller: TargetFilename containing \NETLOGON\test_logon_script.bat, Image=powershell.exe. Security Event ID 4663 (if file auditing enabled on NETLOGON share): Object Access with ObjectName=\NETLOGON\test_logon_script.bat.

  3. Test 3Set UserInitMprLogonScript Registry Value for Persistence

    Expected signal: Sysmon Event ID 13 (Registry Value Set): TargetObject=HKCU\Environment\UserInitMprLogonScript, Details=C:\Windows\Temp\test_logon.bat, Image=powershell.exe. Sysmon Event ID 11 (File Create) for the test_logon.bat script file creation. On next logon: Sysmon Event ID 1 process creation for cmd.exe executing the .bat file via userinit.exe.

  4. Test 4Simulate Logon Script Execution via userinit.exe Command Chain

    Expected signal: Sysmon Event ID 1 (Process Create): Image=cmd.exe, CommandLine containing NETLOGON path reference, ParentImage=powershell.exe (or cmd.exe in nested execution). Security Event ID 4688 (if command line auditing enabled): NewProcessName=cmd.exe with CommandLine containing NETLOGON. Sysmon Event ID 11: file creation for test output files.

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

Related Detections