Logon script written to the NETLOGON or SYSVOL share
AN1034 correlates a Group Policy change that configures a network logon script with the script later executing at logon. Of the two halves, only the change is worth alerting on: the execution half fires for every user at every logon in any domain that uses logon scripts at all, while the domain-wide script files themselves are written only when someone edits them. So this rule takes the brief's Security EventID 5145 leg and matches a detailed file-share access in which the requested access includes write or append, the share is NETLOGON or SYSVOL, and the target file carries a script or executable extension — the act of planting or tampering with the script, on the domain controller that serves it. This is the surface two neighbouring published rules deliberately leave open: T1037.001 suppresses command lines naming these two shares because the ordinary domain logon script would otherwise match at every logon, and the T1080 share-write rule excludes them because tampering there is this technique. The access check is written twice over because collectors disagree on the value: raw event data carries the unresolved message-table codes `%%4417`/`%%4418`, while a collector that resolves message strings writes the same access as `WriteData (or AddFile)` / `AppendData (or AddSubdirectory)`. Confirm which form your pipeline stores before trusting the result. MITRE's `TargetObject` knob — "path to network-based script execution" — is what the share gate implements, populated here with the two default domain script shares; its `ParentProcessName` and `UserContext` knobs belong to the process leg and have no counterpart on 5145. Three limits. 5145 records the access a client requested at the share check, not a completed write. Anything done on the domain controller's own filesystem rather than over the share — an interactive session on the DC, or a service running locally — produces no 5145 at all. And the extension list only sees the file; a payload appended to an existing logon script produces the same record as any other write to it. This rule is written in the native Security 5145 vocabulary (`ShareName`, `RelativeTargetName`, `AccessList`). 5145 requires the *Audit Detailed File Share* subcategory, which is off by default and absent from the Microsoft and CIS baselines — with it off this rule returns zero rows, and zero rows here means blind, not quiet. The brief's third log source, System EventIDs 4016 and 5312, is not used: those are Group Policy processing records emitted on every host at every policy refresh, and they name no script. UNVERIFIED AS AUTHORED — derived from MITRE ATT&CK DET0367, not hand-written and not tested by its author. Any lab result is on this rule's own page.Full descriptionShow less
The detection
The 4 SIEM queries below are previews produced by Siemphony’s own translator, not pySigma, and none has been executed against a real backend — review before you deploy.
detection.yml
Sentinel · KQL
Run this as a search.
SecurityEvent| where (EventID == 5145 and (ShareName endswith "\\NETLOGON" or ShareName endswith "\\SYSVOL") and (AccessList contains "%%4417" or AccessList contains "%%4418" or AccessList contains "WriteData" or AccessList contains "AppendData") and (RelativeTargetName endswith ".bat" or RelativeTargetName endswith ".cmd" or RelativeTargetName endswith ".ps1" or RelativeTargetName endswith ".vbs" or RelativeTargetName endswith ".vbe" or RelativeTargetName endswith ".js" or RelativeTargetName endswith ".jse" or RelativeTargetName endswith ".wsf" or RelativeTargetName endswith ".hta" or RelativeTargetName endswith ".exe" or RelativeTargetName endswith ".dll"))
Splunk · SPL
Run this as a search.
index=* (EventID="5145" AND (ShareName="*\\NETLOGON" OR ShareName="*\\SYSVOL") AND (AccessList="*%%4417*" OR AccessList="*%%4418*" OR AccessList="*WriteData*" OR AccessList="*AppendData*") AND (RelativeTargetName="*.bat" OR RelativeTargetName="*.cmd" OR RelativeTargetName="*.ps1" OR RelativeTargetName="*.vbs" OR RelativeTargetName="*.vbe" OR RelativeTargetName="*.js" OR RelativeTargetName="*.jse" OR RelativeTargetName="*.wsf" OR RelativeTargetName="*.hta" OR RelativeTargetName="*.exe" OR RelativeTargetName="*.dll"))Elastic · ES|QL
Run this as a search.
FROM logs-*| WHERE (event.code == 5145 AND (TO_LOWER(ShareName) LIKE "*\\\\netlogon" OR TO_LOWER(ShareName) LIKE "*\\\\sysvol") AND (TO_LOWER(AccessList) LIKE "*%%4417*" OR TO_LOWER(AccessList) LIKE "*%%4418*" OR TO_LOWER(AccessList) LIKE "*writedata*" OR TO_LOWER(AccessList) LIKE "*appenddata*") AND (TO_LOWER(RelativeTargetName) LIKE "*.bat" OR TO_LOWER(RelativeTargetName) LIKE "*.cmd" OR TO_LOWER(RelativeTargetName) LIKE "*.ps1" OR TO_LOWER(RelativeTargetName) LIKE "*.vbs" OR TO_LOWER(RelativeTargetName) LIKE "*.vbe" OR TO_LOWER(RelativeTargetName) LIKE "*.js" OR TO_LOWER(RelativeTargetName) LIKE "*.jse" OR TO_LOWER(RelativeTargetName) LIKE "*.wsf" OR TO_LOWER(RelativeTargetName) LIKE "*.hta" OR TO_LOWER(RelativeTargetName) LIKE "*.exe" OR TO_LOWER(RelativeTargetName) LIKE "*.dll"))
Wazuh · XML rule
Deploy to your manager — this is a rule, not a search.
<group name="sigma,windows,"> <!-- Rule ids must be unique on your manager; 100000+ is the user range. --> <rule id="100000" level="7"> <!-- Set <if_sid> to the decoder/base rule for windows so this only evaluates relevant events. --> <field name="EventID" type="pcre2">(?i)^5145$</field> <field name="ShareName" type="pcre2">(?i)(\\NETLOGON$|\\SYSVOL$)</field> <field name="AccessList" type="pcre2">(?i)(%%4417|%%4418|WriteData|AppendData)</field> <field name="RelativeTargetName" type="pcre2">(?i)(\.bat$|\.cmd$|\.ps1$|\.vbs$|\.vbe$|\.js$|\.jse$|\.wsf$|\.hta$|\.exe$|\.dll$)</field> <description>Logon script written to the NETLOGON or SYSVOL share</description> <mitre> <id>T1037.003</id> </mitre> </rule></group>
Verdicts · reactions · comments
Community
Verdicts from engineers who actually deployed it, and the conversation around it.
Nobody has run this in a real environment and said what happened.
Verdicts from engineers who deployed it
0 castNo verdicts reported yet. The first one is worth more than the tenth — say what you ran it against.
Log in to report a verdict.
Log in to join the discussion.
No comments yet. Someone who deploys this will have something to say about it.