T1037.003 Splunk · SPL

Detect Network Logon Script in Splunk

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/

SPL Detection Query

Splunk (SPL)
spl
| union
[
  search index=wineventlog sourcetype="WinEventLog:Security" EventCode=5136
  | eval ObjectClass=spath(_raw, "ObjectClass")
  | eval AttributeLDAPDisplayName=spath(_raw, "AttributeLDAPDisplayName")
  | where AttributeLDAPDisplayName="scriptPath"
  | eval SubjectUserName=spath(_raw, "SubjectUserName")
  | eval ObjectDN=spath(_raw, "ObjectDN")
  | eval AttributeValue=spath(_raw, "AttributeValue")
  | eval DetectionType="AD scriptPath Attribute Modified (Event 5136)"
  | table _time, host, SubjectUserName, ObjectDN, AttributeLDAPDisplayName, AttributeValue, DetectionType
]
[
  search index=wineventlog sourcetype="XmlWinEventLog:Microsoft-Windows-Sysmon/Operational" EventCode=11
  (TargetFilename="*\\NETLOGON\\*" OR TargetFilename="*\\SYSVOL\\*" OR TargetFilename="*\\scripts\\*")
  (TargetFilename="*.bat" OR TargetFilename="*.cmd" OR TargetFilename="*.ps1" OR TargetFilename="*.vbs" OR TargetFilename="*.js" OR TargetFilename="*.wsf" OR TargetFilename="*.hta")
  | eval DetectionType="Script File Created in NETLOGON/SYSVOL (Sysmon 11)"
  | table _time, host, User, Image, CommandLine, TargetFilename, DetectionType
]
[
  search index=wineventlog sourcetype="XmlWinEventLog:Microsoft-Windows-Sysmon/Operational" EventCode=1
  (ParentImage="*\\userinit.exe" OR ParentImage="*\\explorer.exe")
  (Image="*\\cmd.exe" OR Image="*\\powershell.exe" OR Image="*\\wscript.exe" OR Image="*\\cscript.exe" OR Image="*\\mshta.exe" OR Image="*\\rundll32.exe" OR Image="*\\regsvr32.exe")
  (CommandLine="*NETLOGON*" OR CommandLine="*SYSVOL*" OR CommandLine="*\\scripts\\*" OR ParentCommandLine="*NETLOGON*" OR ParentCommandLine="*SYSVOL*")
  | eval DetectionType="Suspicious Process Spawned from Logon Script Path (Sysmon 1)"
  | table _time, host, User, Image, CommandLine, ParentImage, ParentCommandLine, DetectionType
]
[
  search index=wineventlog sourcetype="XmlWinEventLog:Microsoft-Windows-Sysmon/Operational" EventCode=13
  (TargetObject="*\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon*" OR TargetObject="*\\Environment*" OR TargetObject="*\\SOFTWARE\\Policies\\Microsoft\\Windows\\System*")
  (TargetObject="*UserInitMprLogonScript*" OR TargetObject="*Userinit*")
  | eval DetectionType="Logon Script Registry Key Modified (Sysmon 13)"
  | table _time, host, User, Image, CommandLine, TargetObject, Details, DetectionType
]
[
  search index=wineventlog sourcetype="WinEventLog:Security" EventCode=4688
  (ParentProcessName="*userinit.exe" OR ParentProcessName="*explorer.exe")
  (NewProcessName="*cmd.exe" OR NewProcessName="*powershell.exe" OR NewProcessName="*wscript.exe" OR NewProcessName="*cscript.exe" OR NewProcessName="*mshta.exe")
  (CommandLine="*NETLOGON*" OR CommandLine="*SYSVOL*" OR CommandLine="*\\scripts\\*")
  | eval SubjectUserName=spath(_raw, "SubjectUserName")
  | eval DetectionType="Logon Script Process Execution (Security 4688)"
  | table _time, host, SubjectUserName, NewProcessName, CommandLine, ParentProcessName, DetectionType
]
| sort - _time
high severity medium confidence

Detects network logon script persistence using five complementary data sources via Splunk union: (1) Security Event 5136 for AD scriptPath attribute modifications on user objects, (2) Sysmon Event 11 for script file creation in NETLOGON/SYSVOL share paths, (3) Sysmon Event 1 for suspicious child processes spawned by userinit.exe or explorer.exe referencing logon script paths, (4) Sysmon Event 13 for registry value modifications to UserInitMprLogonScript and Userinit keys, and (5) Security Event 4688 for process creation with NETLOGON/SYSVOL paths in command lines. Each result is tagged with a DetectionType field for analyst triage.

Data Sources

Active Directory: Active Directory Object ModificationFile: File CreationProcess: Process CreationWindows Registry: Windows Registry Key ModificationSysmon Event ID 1Sysmon Event ID 11Sysmon Event ID 13Windows Security Event ID 5136Windows Security Event ID 4688

Required Sourcetypes

XmlWinEventLog:Microsoft-Windows-Sysmon/OperationalWinEventLog:Security

False Positives & Tuning

  • 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
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