
Analyzing Windows Event Logs In Splunk
- 216 installs
- 27.3k repo stars
- Updated August 2, 2026
- mukul975/anthropic-cybersecurity-skills
Analyzing Windows event logs in Splunk to investigate system behavior, security incidents, and operational issues across Windows infrastructure.
About
This skill teaches how to ingest, search, and analyze Windows event logs using Splunk to uncover security incidents and operational issues. Solo builders and ops teams use it to investigate suspicious activity, audit system changes, and respond to security events. It matters because Windows logs contain critical evidence of breaches, privilege escalation, and system misconfigurations that are essential for security posture and compliance.
- Investigate Windows security events and system logs
- Build Splunk searches to identify anomalies and threats
- Parse event IDs for authentication, process execution, and network activity
Analyzing Windows Event Logs In Splunk by the numbers
- 216 all-time installs (skills.sh)
- +8 installs in the week ending Aug 4, 2026 (Skillselion tracking)
- Ranked #390 of 1,435 DevOps & CI/CD skills by installs in the Skillselion catalog
- Security screen: LOW risk (skills.sh audit)
- Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/mukul975/anthropic-cybersecurity-skills --skill analyzing-windows-event-logs-in-splunkAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 216 |
|---|---|
| repo stars | ★ 27.3k |
| Security audit | 3 / 3 scanners passed |
| Last updated | August 2, 2026 |
| Repository | mukul975/anthropic-cybersecurity-skills ↗ |
What it does
Analyzing Windows event logs in Splunk to investigate system behavior, security incidents, and operational issues across Windows infrastructure.
Files
Analyzing Windows Event Logs in Splunk
When to Use
Use this skill when:
- SOC analysts investigate alerts related to Windows authentication, process execution, or AD changes
- Detection engineers build SPL queries for Windows-based threat detection
- Incident responders need forensic timelines of Windows endpoint or domain controller activity
- Periodic threat hunting targets Windows-specific ATT&CK techniques
Do not use for Linux/macOS endpoint analysis or network-only investigations.
Prerequisites
- Splunk with Windows Event Log data ingested (sourcetype
WinEventLog:Security,WinEventLog:System,XmlWinEventLog:Microsoft-Windows-Sysmon/Operational) - Sysmon deployed on endpoints with SwiftOnSecurity or Olaf Hartong configuration
- CIM data model acceleration for Endpoint and Authentication data models
- Knowledge of Windows Security Event IDs and Sysmon event types
Workflow
Step 1: Authentication Attack Detection
Brute Force Detection (EventCode 4625 — Failed Logon):
index=wineventlog sourcetype="WinEventLog:Security" EventCode=4625
| stats count, dc(TargetUserName) AS unique_users, values(TargetUserName) AS targeted_users
by src_ip, Logon_Type, Status
| where count > 20
| eval attack_type = case(
Logon_Type=3, "Network Brute Force",
Logon_Type=10, "RDP Brute Force",
Logon_Type=2, "Interactive Brute Force",
1=1, "Other"
)
| eval status_meaning = case(
Status="0xc000006d", "Bad Username or Password",
Status="0xc000006a", "Incorrect Password (valid user)",
Status="0xc0000234", "Account Locked Out",
Status="0xc0000072", "Account Disabled",
1=1, Status
)
| sort - count
| table src_ip, attack_type, status_meaning, count, unique_users, targeted_usersPassword Spray Detection:
index=wineventlog sourcetype="WinEventLog:Security" EventCode=4625 Logon_Type=3
| bin _time span=10m
| stats dc(TargetUserName) AS unique_users, count AS total_attempts,
values(TargetUserName) AS users_targeted by src_ip, _time
| where unique_users > 10 AND total_attempts < unique_users * 3
| eval spray_confidence = if(unique_users > 25, "HIGH", "MEDIUM")Successful Logon After Failures (Compromise Indicator):
index=wineventlog sourcetype="WinEventLog:Security"
(EventCode=4625 OR EventCode=4624) src_ip!="127.0.0.1"
| sort _time
| stats earliest(_time) AS first_seen, latest(_time) AS last_seen,
sum(eval(if(EventCode=4625,1,0))) AS failures,
sum(eval(if(EventCode=4624,1,0))) AS successes
by src_ip, TargetUserName, ComputerName
| where failures > 10 AND successes > 0
| eval time_to_success = round((last_seen - first_seen)/60, 1)
| sort - failuresStep 2: Privilege Escalation Detection
New Admin Account Created (T1136.001):
index=wineventlog sourcetype="WinEventLog:Security" EventCode=4720
| join TargetUserName type=left [
search index=wineventlog EventCode=4732 TargetUserName="Administrators"
| rename MemberName AS TargetUserName
]
| table _time, SubjectUserName, TargetUserName, ComputerName
| eval alert = "New account created and added to Administrators group"Special Privileges Assigned (EventCode 4672):
index=wineventlog sourcetype="WinEventLog:Security" EventCode=4672
SubjectUserName!="SYSTEM" SubjectUserName!="LOCAL SERVICE" SubjectUserName!="NETWORK SERVICE"
| stats count, values(PrivilegeList) AS privileges by SubjectUserName, ComputerName
| where count > 0
| search privileges IN ("SeDebugPrivilege", "SeTcbPrivilege", "SeBackupPrivilege",
"SeRestorePrivilege", "SeAssignPrimaryTokenPrivilege")Token Manipulation Detection (T1134):
index=sysmon EventCode=10 TargetImage="*\\lsass.exe"
GrantedAccess IN ("0x1010", "0x1038", "0x1fffff", "0x40")
| stats count by SourceImage, SourceUser, Computer, GrantedAccess
| where NOT match(SourceImage, "(svchost|csrss|wininit|MsMpEng|CrowdStrike)")
| sort - countStep 3: Persistence Mechanism Detection
Scheduled Task Creation (T1053.005):
index=wineventlog (sourcetype="WinEventLog:Security" EventCode=4698)
OR (sourcetype="XmlWinEventLog:Microsoft-Windows-Sysmon/Operational" EventCode=1
Image="*\\schtasks.exe")
| eval task_info = coalesce(TaskContent, CommandLine)
| search task_info="*powershell*" OR task_info="*cmd*" OR task_info="*http*" OR task_info="*\\Temp\\*"
| table _time, Computer, SubjectUserName, TaskName, task_infoRegistry Run Key Modification (T1547.001):
index=sysmon EventCode=13
TargetObject IN (
"*\\CurrentVersion\\Run\\*",
"*\\CurrentVersion\\RunOnce\\*",
"*\\CurrentVersion\\RunServices\\*",
"*\\Explorer\\Shell Folders\\*"
)
| stats count by Computer, Image, TargetObject, Details
| where NOT match(Image, "(explorer\.exe|msiexec\.exe|setup\.exe)")
| sort - countWMI Event Subscription (T1546.003):
index=sysmon EventCode=20 OR EventCode=21
| stats count by Computer, Operation, Consumer, EventNamespace
| where count > 0Step 4: Lateral Movement Detection
Remote Service Exploitation (T1021.002 — SMB/Windows Admin Shares):
index=wineventlog sourcetype="WinEventLog:Security" EventCode=4624 Logon_Type=3
| stats dc(ComputerName) AS unique_destinations, values(ComputerName) AS targets
by src_ip, TargetUserName
| where unique_destinations > 3
| sort - unique_destinations
| table src_ip, TargetUserName, unique_destinations, targetsPsExec Detection (T1021.002):
index=sysmon EventCode=1
(Image="*\\psexec.exe" OR Image="*\\psexesvc.exe"
OR ParentImage="*\\psexesvc.exe"
OR OriginalFileName="psexec.c")
| table _time, Computer, User, ParentImage, Image, CommandLineRDP Lateral Movement (T1021.001):
index=wineventlog sourcetype="WinEventLog:Security" EventCode=4624 Logon_Type=10
| stats count, dc(ComputerName) AS rdp_targets, values(ComputerName) AS destinations
by src_ip, TargetUserName
| where rdp_targets > 2
| sort - rdp_targetsStep 5: Build Forensic Timeline
Create comprehensive timeline for a compromised host:
(index=wineventlog OR index=sysmon) Computer="WORKSTATION-042"
earliest="2024-03-14T00:00:00" latest="2024-03-16T00:00:00"
| eval event_description = case(
EventCode=4624, "Logon: ".TargetUserName." (Type ".Logon_Type.")",
EventCode=4625, "Failed Logon: ".TargetUserName,
EventCode=4688 OR (sourcetype="XmlWinEventLog:*Sysmon*" AND EventCode=1),
"Process: ".Image." CMD: ".CommandLine,
EventCode=4698, "Scheduled Task: ".TaskName,
EventCode=3, "Network: ".DestinationIp.":".DestinationPort,
EventCode=11, "File Created: ".TargetFilename,
EventCode=13, "Registry: ".TargetObject,
1=1, "Event ".EventCode
)
| sort _time
| table _time, EventCode, event_description, User, src_ipStep 6: Create Lookup Tables for Enrichment
Build reference lookups for Windows Event ID context:
| inputlookup windows_eventcode_lookup.csv
| table EventCode, Description, ATT_CK_Technique, SeverityIf lookup doesn't exist, create it:
EventCode,Description,ATT_CK_Technique,Severity
4624,Successful Logon,T1078,Informational
4625,Failed Logon,T1110,Low
4648,Explicit Credential Logon,T1078,Medium
4672,Special Privileges Assigned,T1134,Medium
4688,New Process Created,T1059,Informational
4698,Scheduled Task Created,T1053.005,Medium
4720,User Account Created,T1136.001,High
4732,Member Added to Security Group,T1098,High
4768,Kerberos TGT Requested,T1558,Informational
4769,Kerberos Service Ticket,T1558.003,Low
4771,Kerberos Pre-Auth Failed,T1110,LowKey Concepts
| Term | Definition |
|---|---|
| EventCode 4624 | Successful logon event — Logon_Type 2 (interactive), 3 (network), 10 (RDP), 7 (unlock) |
| EventCode 4625 | Failed logon event — Status code indicates failure reason (bad password, account locked, disabled) |
| Sysmon EventCode 1 | Process creation with full command line, parent process, and hash information |
| Sysmon EventCode 3 | Network connection initiated by a process — source/dest IP, port, and process context |
| Logon Type 3 | Network logon (SMB, WMI, PowerShell Remoting) — key indicator of lateral movement |
| Logon Type 10 | Remote interactive logon via RDP/Terminal Services |
Tools & Systems
- Splunk Enterprise: SIEM platform with SPL query engine for Windows event log analysis and correlation
- Sysmon (System Monitor): Microsoft Sysinternals tool providing detailed process, network, and file activity logging
- Splunk CIM: Common Information Model mapping Windows events to normalized fields for cross-source queries
- Windows Event Forwarding (WEF): Built-in Windows mechanism for centralizing event logs to a collector server
Common Scenarios
- Kerberoasting (T1558.003): Detect EventCode 4769 with encryption type 0x17 (RC4) for non-standard service accounts
- DCSync (T1003.006): Detect EventCode 4662 with DS-Replication-Get-Changes from non-DC sources
- Golden Ticket (T1558.001): Detect EventCode 4769 with abnormal ticket properties (long lifetime, non-standard encryption)
- Pass-the-Hash (T1550.002): Detect EventCode 4624 Logon_Type 3 with NTLM authentication from unexpected sources
- DLL Side-Loading (T1574.002): Sysmon EventCode 7 showing unsigned DLLs loaded by legitimate processes
Output Format
WINDOWS EVENT LOG ANALYSIS — HOST: WORKSTATION-042
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Period: 2024-03-14 to 2024-03-15
Events: 12,847 total (Security: 9,231 | Sysmon: 3,616)
Authentication Summary:
Successful Logons (4624): 487 (Type 3: 312, Type 10: 45, Type 2: 130)
Failed Logons (4625): 847 (from 192.168.1.105 — BRUTE FORCE)
Explicit Creds (4648): 12
Suspicious Findings:
[HIGH] 847 failed logons followed by success at 14:35 from 192.168.1.105
[HIGH] New user "backdoor_admin" created (4720) at 14:38
[HIGH] User added to Administrators group (4732) at 14:38
[MEDIUM] schtasks.exe creating persistence task at 14:42
[MEDIUM] PowerShell encoded command execution at 14:45
ATT&CK Mapping:
T1110.001 — Password Guessing (847 failed logons)
T1136.001 — Local Account Creation (backdoor_admin)
T1053.005 — Scheduled Task (persistence)
T1059.001 — PowerShell (encoded execution)
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to the Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by the Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding any notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. Please do not remove or change
the license header comment from a contributed file except when
necessary.
Copyright 2026 mukul975
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
API Reference: Analyzing Windows Event Logs in Splunk
splunk-sdk Connection
import splunklib.client as client
service = client.connect(host="splunk", port=8089, username="admin", password="pass")Key Windows Security Event IDs
| EventCode | Description | ATT&CK Technique |
|---|---|---|
| 4624 | Successful logon | T1078 |
| 4625 | Failed logon | T1110 |
| 4648 | Explicit credential logon | T1078 |
| 4672 | Special privileges assigned | T1134 |
| 4688 | New process created | T1059 |
| 4698 | Scheduled task created | T1053.005 |
| 4720 | User account created | T1136.001 |
| 4732 | Member added to security group | T1098 |
| 4768 | Kerberos TGT requested | T1558 |
| 4769 | Kerberos service ticket | T1558.003 |
Key Sysmon Event IDs
| EventCode | Description |
|---|---|
| 1 | Process creation (full command line, hashes) |
| 3 | Network connection |
| 7 | Image loaded (DLL) |
| 10 | Process access (LSASS credential dumping) |
| 11 | File creation |
| 13 | Registry value set |
| 22 | DNS query |
Logon Types
| Type | Description | Context |
|---|---|---|
| 2 | Interactive | Local console logon |
| 3 | Network | SMB, WMI, PowerShell Remoting |
| 7 | Unlock | Workstation unlock |
| 9 | NewCredentials | runas /netonly |
| 10 | RemoteInteractive | RDP logon |
SPL Detection Patterns
# Brute force detection
index=wineventlog EventCode=4625 | stats count by src_ip | where count > 20
# Kerberoasting (T1558.003)
index=wineventlog EventCode=4769 Ticket_Encryption_Type=0x17
| where ServiceName != "krbtgt"
# DCSync detection (T1003.006)
index=wineventlog EventCode=4662
| where ObjectType="*domainDNS*"
| search Properties="*Replicating Directory Changes*"References
- splunk-sdk: https://pypi.org/project/splunk-sdk/
- Splunk CIM: https://docs.splunk.com/Documentation/CIM/latest/User/Overview
- Windows Security Log Encyclopedia: https://www.ultimatewindowssecurity.com/securitylog/encyclopedia/
#!/usr/bin/env python3
"""Agent for analyzing Windows event logs in Splunk for SOC operations."""
import os
import json
import argparse
from datetime import datetime
import splunklib.client as client
import splunklib.results as results
def connect(host, port, username, password):
"""Connect to Splunk Enterprise."""
return client.connect(
host=host, port=port, username=username, password=password, autologin=True
)
def search(service, query, earliest="-24h", latest="now"):
"""Run a blocking Splunk search and return results."""
job = service.jobs.create(
f"search {query}",
**{"earliest_time": earliest, "latest_time": latest, "exec_mode": "blocking"}
)
reader = results.JSONResultsReader(job.results(output_mode="json"))
rows = [r for r in reader if isinstance(r, dict)]
job.cancel()
return rows
def detect_brute_force(service, earliest="-24h", threshold=20):
"""Detect brute force via EventCode 4625 with logon type classification."""
query = (
'index=wineventlog sourcetype="WinEventLog:Security" EventCode=4625 '
"| stats count, dc(TargetUserName) as unique_users, "
"values(TargetUserName) as targeted_users by src_ip, Logon_Type, Status "
f"| where count > {threshold} "
'| eval attack_type=case(Logon_Type=3,"Network",Logon_Type=10,"RDP",'
'Logon_Type=2,"Interactive",1=1,"Other") '
"| sort -count"
)
return search(service, query, earliest)
def detect_password_spray(service, earliest="-24h"):
"""Detect password spray attacks targeting many accounts from one source."""
query = (
'index=wineventlog sourcetype="WinEventLog:Security" EventCode=4625 Logon_Type=3 '
"| bin _time span=10m "
"| stats dc(TargetUserName) as unique_users, count as total by src_ip, _time "
"| where unique_users > 10 AND total < unique_users * 3 "
'| eval confidence=if(unique_users > 25, "HIGH", "MEDIUM")'
)
return search(service, query, earliest)
def detect_new_admin_accounts(service, earliest="-7d"):
"""Detect new accounts added to the Administrators group (T1136.001)."""
query = (
'index=wineventlog sourcetype="WinEventLog:Security" EventCode=4720 '
'| join TargetUserName type=left [search index=wineventlog EventCode=4732 '
'TargetUserName="Administrators" | rename MemberName as TargetUserName] '
"| table _time, SubjectUserName, TargetUserName, ComputerName"
)
return search(service, query, earliest)
def detect_lsass_access(service, earliest="-24h"):
"""Detect LSASS credential dumping via Sysmon Event 10 (T1003.001)."""
query = (
'index=sysmon EventCode=10 TargetImage="*\\\\lsass.exe" '
'GrantedAccess IN ("0x1010","0x1038","0x1fffff","0x40") '
"| stats count by SourceImage, SourceUser, Computer, GrantedAccess "
'| where NOT match(SourceImage, "(svchost|csrss|wininit|MsMpEng)") '
"| sort -count"
)
return search(service, query, earliest)
def detect_lateral_movement_smb(service, earliest="-24h"):
"""Detect SMB lateral movement via Type 3 logons to many hosts (T1021.002)."""
query = (
'index=wineventlog sourcetype="WinEventLog:Security" EventCode=4624 Logon_Type=3 '
"| stats dc(ComputerName) as targets, values(ComputerName) as dest_hosts "
"by src_ip, TargetUserName "
"| where targets > 3 | sort -targets"
)
return search(service, query, earliest)
def detect_psexec(service, earliest="-24h"):
"""Detect PsExec execution via Sysmon process creation (T1021.002)."""
query = (
"index=sysmon EventCode=1 "
'(Image="*\\\\psexec.exe" OR Image="*\\\\psexesvc.exe" '
'OR ParentImage="*\\\\psexesvc.exe") '
"| table _time, Computer, User, ParentImage, Image, CommandLine"
)
return search(service, query, earliest)
def build_forensic_timeline(service, hostname, earliest, latest="now"):
"""Build a comprehensive forensic timeline for a host."""
query = (
f'(index=wineventlog OR index=sysmon) Computer="{hostname}" '
"| eval desc=case("
' EventCode=4624, "Logon: ".TargetUserName." (Type ".Logon_Type.")",'
' EventCode=4625, "Failed Logon: ".TargetUserName,'
' EventCode=1, "Process: ".Image," CMD: ".CommandLine,'
' EventCode=3, "Network: ".DestinationIp.":".DestinationPort,'
' EventCode=11, "File Created: ".TargetFilename,'
' EventCode=13, "Registry: ".TargetObject,'
' 1=1, "Event ".EventCode) '
"| sort _time | table _time, EventCode, desc, User, src_ip"
)
return search(service, query, earliest, latest)
def main():
parser = argparse.ArgumentParser(description="Windows Event Log Splunk Analysis Agent")
parser.add_argument("--host", default=os.getenv("SPLUNK_HOST", "localhost"))
parser.add_argument("--port", type=int, default=int(os.getenv("SPLUNK_PORT", "8089")))
parser.add_argument("--username", default=os.getenv("SPLUNK_USERNAME", "admin"))
parser.add_argument("--password", default=os.getenv("SPLUNK_PASSWORD", ""))
parser.add_argument("--earliest", default="-24h")
parser.add_argument("--hostname", help="Target hostname for timeline")
parser.add_argument("--action", choices=[
"brute_force", "password_spray", "new_admin", "lsass_access",
"lateral_smb", "psexec", "timeline", "full_hunt"
], default="full_hunt")
args = parser.parse_args()
svc = connect(args.host, args.port, args.username, args.password)
findings = {}
if args.action in ("brute_force", "full_hunt"):
findings["brute_force"] = detect_brute_force(svc, args.earliest)
print(f"[+] Brute force sources: {len(findings['brute_force'])}")
if args.action in ("password_spray", "full_hunt"):
findings["password_spray"] = detect_password_spray(svc, args.earliest)
print(f"[+] Password spray events: {len(findings['password_spray'])}")
if args.action in ("new_admin", "full_hunt"):
findings["new_admin"] = detect_new_admin_accounts(svc)
print(f"[+] New admin accounts: {len(findings['new_admin'])}")
if args.action in ("lsass_access", "full_hunt"):
findings["lsass_access"] = detect_lsass_access(svc, args.earliest)
print(f"[+] LSASS access events: {len(findings['lsass_access'])}")
if args.action in ("lateral_smb", "full_hunt"):
findings["lateral_smb"] = detect_lateral_movement_smb(svc, args.earliest)
print(f"[+] Lateral movement paths: {len(findings['lateral_smb'])}")
if args.action == "timeline" and args.hostname:
findings["timeline"] = build_forensic_timeline(svc, args.hostname, args.earliest)
print(f"[+] Timeline events: {len(findings['timeline'])}")
print(json.dumps({"generated_at": datetime.utcnow().isoformat(), "findings": findings}, indent=2, default=str))
if __name__ == "__main__":
main()
Related skills
FAQ
Is Analyzing Windows Event Logs In Splunk safe to install?
skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.