
Analyzing Security Logs With Splunk
- 232 installs
- 27.3k repo stars
- Updated August 2, 2026
- mukul975/anthropic-cybersecurity-skills
Analyzing Security Logs With Splunk is an agent skill that teaches Splunk SPL patterns and investigation workflows for threat detection and security log analysis.
About
Analyzing Security Logs With Splunk is an agent skill that teaches solo builders and small teams how to turn raw security telemetry into actionable hunts using Splunk Search Processing Language. It is aimed at operators who already ingest auth, firewall, endpoint, and proxy logs and need repeatable queries instead of ad-hoc grep in production. The skill walks through index and sourcetype hygiene, basic and advanced SPL, statistical correlation, and threat-hunting patterns aligned to common MITRE-style scenarios such as credential abuse, exfiltration, and lateral movement. It also covers dashboard and alert design, CIM-oriented field normalization, and performance tactics so searches stay within SLA during incidents. Use it when you are responding to alerts, doing proactive hunts, or improving detection coverage after a near-miss. It does not replace a full SOC playbook or vendor-specific Enterprise Security configuration, but it gives your coding agent structured SPL templates and investigation steps you can adapt to your indexes.
- Covers five core SPL workflows: event search, stats and correlation, threat hunting, dashboards, and performance pattern
- Provides copy-ready SPL for brute force, impossible travel, data exfiltration, lateral movement, and malware indicators
- Documents an eight-step investigation procedure from alert validation through containment, eradication, and post-inciden
- Includes optimization guidance: indexes, sourcetypes, CIM field normalization, and tstats versus raw search tradeoffs
- Optional Python helpers for scripted searches and results export against the Splunk REST API
Analyzing Security Logs With Splunk by the numbers
- 232 all-time installs (skills.sh)
- +13 installs in the week ending Aug 4, 2026 (Skillselion tracking)
- Ranked #717 of 2,203 Security 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-security-logs-with-splunkAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 232 |
|---|---|
| repo stars | ★ 27.3k |
| Security audit | 3 / 3 scanners passed |
| Last updated | August 2, 2026 |
| Repository | mukul975/anthropic-cybersecurity-skills ↗ |
What it does
Write and tune Splunk SPL to hunt threats, triage alerts, and build security dashboards from production logs.
Who is it for?
Best when you're running Splunk (or Splunk-compatible pipelines) and need structured hunts, brute-force and exfiltration queries, and faster incident triage without hiring a full-time analyst.
Skip if: Projects with no centralized logging or SIEM, teams that only need static pre-launch checklist reviews without runtime telemetry, or orgs on non-Splunk stacks where SPL guidance does not transfer.
When should I use this skill?
You need to analyze security logs in Splunk for threat detection, anomaly hunting, incident investigation, or security dashboards using SPL.
What you get
After using the skill, you have tuned SPL queries, correlation and hunting playbooks, and dashboard or alert definitions you can run and iterate during live monitoring.
- Ready-to-adapt SPL queries and correlation searches for common attack patterns
- Threat-hunting and eight-step investigation playbooks aligned to alert types
- Dashboard, alert, and performance-tuning recommendations (tstats, summaries, index design)
By the numbers
- Five core SPL workflow areas: search, stats, threat hunting, dashboards, and performance optimization
- Eight-step security investigation procedure from alert validation through post-incident tuning
- SPL examples tagged with HIGH, MEDIUM, and LOW severity tiers for prioritization
Files
Analyzing Security Logs with Splunk
When to Use
- Investigating a security incident that requires correlation across multiple log sources
- Hunting for adversary activity using known TTPs and IOCs
- Building detection rules for specific attack patterns
- Reconstructing an incident timeline from disparate log sources
- Analyzing authentication anomalies, lateral movement, or data exfiltration patterns
Do not use for real-time packet-level analysis; use Wireshark or Zeek for full packet capture analysis.
Prerequisites
- Splunk Enterprise or Splunk Cloud with Enterprise Security (ES) app installed
- Log sources ingested: Windows Event Logs (via Splunk Universal Forwarder or WEF), firewall, proxy, DNS, EDR, email gateway
- Splunk CIM (Common Information Model) data models configured for normalized field names
- SPL proficiency at intermediate level or higher
- Role-based access with
searchandaccelerate_searchcapabilities in Splunk
Workflow
Step 1: Scope the Investigation in Splunk
Define search parameters based on incident triage data:
| Set initial investigation scope
index=windows OR index=firewall OR index=proxy
earliest="2025-11-14T00:00:00" latest="2025-11-16T00:00:00"
(host="WKSTN-042" OR src_ip="10.1.5.42" OR user="jsmith")
| stats count by index, sourcetype, host
| sort -countThis query establishes which log sources contain relevant data for the investigation timeframe and affected assets.
Step 2: Analyze Authentication Events
Investigate suspicious authentication patterns using Windows Security Event Logs:
| Detect brute force and credential stuffing
index=windows sourcetype="WinEventLog:Security" EventCode=4625
earliest=-24h
| stats count as failed_attempts, values(src_ip) as source_ips,
dc(src_ip) as unique_sources by TargetUserName
| where failed_attempts > 10
| sort -failed_attempts
| Detect pass-the-hash (Logon Type 9 - NewCredentials)
index=windows sourcetype="WinEventLog:Security" EventCode=4624
Logon_Type=9
| table _time, host, TargetUserName, src_ip, LogonProcessName
| Detect lateral movement via RDP
index=windows sourcetype="WinEventLog:Security" EventCode=4624
Logon_Type=10
| stats count, values(host) as targets by TargetUserName, src_ip
| where count > 3
| sort -countStep 3: Trace Process Execution
Use Sysmon logs to reconstruct process execution chains:
| Process creation with parent chain (Sysmon Event ID 1)
index=sysmon EventCode=1 host="WKSTN-042"
earliest="2025-11-15T14:00:00" latest="2025-11-15T15:00:00"
| table _time, ParentImage, ParentCommandLine, Image, CommandLine, User, Hashes
| sort _time
| Detect suspicious PowerShell execution
index=sysmon EventCode=1 Image="*\\powershell.exe"
(CommandLine="*-enc*" OR CommandLine="*-encodedcommand*"
OR CommandLine="*downloadstring*" OR CommandLine="*iex*")
| table _time, host, User, ParentImage, CommandLine
| sort _time
| Detect LSASS credential dumping
index=sysmon EventCode=10 TargetImage="*\\lsass.exe"
GrantedAccess=0x1010
| table _time, host, SourceImage, SourceUser, GrantedAccessStep 4: Analyze Network Activity
Correlate network logs with endpoint events:
| Detect C2 beaconing pattern
index=proxy OR index=firewall dest_ip="185.220.101.42"
| timechart span=1m count by src_ip
| where count > 0
| Detect DNS tunneling (high query volume to single domain)
index=dns
| rex field=query "(?<subdomain>[^\.]+)\.(?<domain>[^\.]+\.[^\.]+)$"
| stats count, avg(len(query)) as avg_query_len by domain, src_ip
| where count > 500 AND avg_query_len > 40
| sort -count
| Detect large data transfers (potential exfiltration)
index=proxy action=allowed
| stats sum(bytes_out) as total_bytes by src_ip, dest_ip, dest_host
| eval total_MB=round(total_bytes/1024/1024,2)
| where total_MB > 100
| sort -total_MBStep 5: Build the Incident Timeline
Reconstruct a unified timeline across all log sources:
| Unified incident timeline
index=windows OR index=sysmon OR index=proxy OR index=firewall
(host="WKSTN-042" OR src_ip="10.1.5.42" OR user="jsmith")
earliest="2025-11-15T14:00:00" latest="2025-11-15T16:00:00"
| eval event_summary=case(
sourcetype=="WinEventLog:Security" AND EventCode==4624, "Logon: ".TargetUserName." from ".src_ip,
sourcetype=="WinEventLog:Security" AND EventCode==4625, "Failed logon: ".TargetUserName,
sourcetype=="XmlWinEventLog:Microsoft-Windows-Sysmon/Operational" AND EventCode==1,
"Process: ".Image." by ".User,
sourcetype=="proxy", "Web: ".http_method." ".url,
1==1, sourcetype.": ".EventCode)
| table _time, sourcetype, host, event_summary
| sort _timeStep 6: Create Detection Rules
Convert investigation findings into persistent Splunk correlation searches:
| Correlation search: PowerShell spawned by Office applications
index=sysmon EventCode=1
Image="*\\powershell.exe"
(ParentImage="*\\winword.exe" OR ParentImage="*\\excel.exe"
OR ParentImage="*\\outlook.exe")
| eval severity="high"
| eval mitre_technique="T1059.001"
| collect index=notable_eventsKey Concepts
| Term | Definition |
|---|---|
| SPL (Search Processing Language) | Splunk's query language for searching, filtering, transforming, and visualizing machine data |
| CIM (Common Information Model) | Splunk's field normalization standard that maps vendor-specific field names to common names for cross-source queries |
| Notable Event | An event in Splunk Enterprise Security flagged for analyst review based on a correlation search match |
| Data Model | Structured representation of indexed data in Splunk enabling accelerated searches and pivot-based analysis |
| Sourcetype | Classification label in Splunk that defines the format and parsing rules for a specific log type |
| Correlation Search | Scheduled Splunk search that runs continuously and generates notable events when conditions are met |
| Timechart | SPL command that creates time-series visualizations for identifying patterns, anomalies, and trends |
Tools & Systems
- Splunk Enterprise Security (ES): Premium SIEM application providing correlation searches, risk-based alerting, and investigation workbench
- Splunk SOAR: Orchestration platform integrated with Splunk ES for automated response playbooks
- Sysmon: Microsoft system monitoring tool providing detailed process, network, and file change telemetry ingested into Splunk
- Splunk Attack Analyzer: Automated threat analysis that detonates suspicious files and URLs, feeding results into Splunk
- BOSS of the SOC (BOTS): SANS/Splunk training dataset for practicing incident investigation SPL queries
Common Scenarios
Scenario: Investigating Credential Stuffing Leading to Account Takeover
Context: Security operations receives an alert for multiple successful logins to a single account from geographically dispersed IP addresses within a 30-minute window.
Approach: 1. Query Event ID 4624 for the affected account to map all login sources and times 2. Correlate login IPs against threat intelligence feeds using a Splunk lookup table 3. Check proxy logs for suspicious activity from the authenticated sessions 4. Search for lateral movement from the compromised account (Event ID 4624 Type 3 to other hosts) 5. Build a timeline showing credential stuffing attempts, successful login, and post-compromise activity 6. Create a correlation search to detect similar patterns on other accounts
Pitfalls:
- Searching only the last 24 hours when the credential stuffing may have occurred over weeks
- Not checking for VPN logs that may show the same account authenticating from impossible travel distances
- Failing to normalize timestamps across log sources in different time zones
Output Format
SPLUNK INVESTIGATION REPORT
============================
Incident: INC-2025-1547
Analyst: [Name]
Investigation Period: 2025-11-14 00:00 UTC - 2025-11-16 00:00 UTC
SEARCH SCOPE
Indexes: windows, sysmon, proxy, firewall, dns
Hosts: WKSTN-042, SRV-FILE01
Users: jsmith, svc-backup
Source IPs: 10.1.5.42, 10.1.10.15
KEY FINDINGS
1. [timestamp] - Initial compromise via phishing (Sysmon Event 1)
2. [timestamp] - C2 established (proxy logs, beacon pattern detected)
3. [timestamp] - Credential theft (Sysmon Event 10, LSASS access)
4. [timestamp] - Lateral movement to SRV-FILE01 (Event 4624 Type 3)
5. [timestamp] - Data staging and exfiltration (proxy bytes_out anomaly)
SPL QUERIES USED
[numbered list of key queries with descriptions]
DETECTION GAPS IDENTIFIED
- No Sysmon deployed on SRV-FILE01 (blind spot)
- Proxy logs missing SSL inspection for C2 domain
- PowerShell ScriptBlock logging not enabled
RECOMMENDED DETECTIONS
1. Correlation search for Office-spawned PowerShell
2. Threshold alert for LSASS access patterns
3. Behavioral rule for beacon-interval network traffic
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 Security Logs with Splunk
splunk-sdk (splunklib)
Connection
import splunklib.client as client
service = client.connect(
host="splunk.example.com",
port=8089,
username="admin",
password="secret",
autologin=True,
)Running Searches
import splunklib.results as results
# Blocking (synchronous) search
job = service.jobs.create(
"search index=windows EventCode=4625 | stats count by src_ip",
**{"earliest_time": "-24h", "latest_time": "now", "exec_mode": "blocking"}
)
# Read results as JSON
reader = results.JSONResultsReader(job.results(output_mode="json"))
for row in reader:
if isinstance(row, dict):
print(row)
job.cancel()Oneshot Search (Simple Queries)
result_stream = service.jobs.oneshot(
"search index=windows EventCode=4624 | head 10",
earliest_time="-1h",
output_mode="json",
)
reader = results.JSONResultsReader(result_stream)Saved Searches
# List saved searches
for saved in service.saved_searches:
print(saved.name)
# Run a saved search
saved_search = service.saved_searches["My Alert"]
job = saved_search.dispatch()KV Store Lookups
collection = service.kvstore["threat_intel_iocs"]
# Insert record
collection.data.insert(json.dumps({"ip": "1.2.3.4", "threat": "C2"}))
# Query records
records = collection.data.query(query=json.dumps({"threat": "C2"}))Key SPL Patterns for Security Analysis
| Pattern | SPL |
|---|---|
| Failed logons | `index=windows EventCode=4625 \ |
| Lateral movement | `index=windows EventCode=4624 Logon_Type=3 \ |
| Process creation | `index=sysmon EventCode=1 \ |
| C2 beaconing | `index=proxy \ |
| DNS tunneling | `index=dns \ |
Splunk REST API Endpoints
| Endpoint | Method | Description |
|---|---|---|
/services/search/jobs | POST | Create a new search job |
/services/search/jobs/{sid}/results | GET | Retrieve search results |
/services/saved/searches | GET | List saved searches |
/services/data/indexes | GET | List available indexes |
/services/authentication/users | GET | List Splunk users |
References
- splunk-sdk PyPI: https://pypi.org/project/splunk-sdk/
- Splunk REST API docs: https://docs.splunk.com/Documentation/Splunk/latest/RESTREF
- Splunk SDK for Python: https://dev.splunk.com/enterprise/docs/devtools/python/sdk-python/
#!/usr/bin/env python3
"""Agent for analyzing security logs with Splunk using splunk-sdk."""
import os
import json
import time
import argparse
from datetime import datetime
import splunklib.client as client
import splunklib.results as results
def connect_splunk(host, port, username, password):
"""Establish connection to Splunk instance."""
service = client.connect(
host=host,
port=port,
username=username,
password=password,
autologin=True,
)
return service
def run_search(service, query, earliest="-24h", latest="now"):
"""Execute a Splunk search and return parsed results."""
kwargs_search = {
"earliest_time": earliest,
"latest_time": latest,
"search_mode": "normal",
"exec_mode": "blocking",
}
job = service.jobs.create(f"search {query}", **kwargs_search)
reader = results.JSONResultsReader(job.results(output_mode="json"))
rows = [row for row in reader if isinstance(row, dict)]
job.cancel()
return rows
def detect_brute_force(service, threshold=10, earliest="-24h"):
"""Detect brute force attacks via failed logon events (EventCode 4625)."""
query = (
'index=windows sourcetype="WinEventLog:Security" EventCode=4625 '
f"| stats count as failed_attempts, dc(src_ip) as unique_sources, "
f"values(src_ip) as source_ips by TargetUserName "
f"| where failed_attempts > {threshold} "
f"| sort -failed_attempts"
)
return run_search(service, query, earliest=earliest)
def detect_lateral_movement(service, earliest="-24h"):
"""Detect lateral movement via Type 3 network logons to multiple hosts."""
query = (
'index=windows sourcetype="WinEventLog:Security" EventCode=4624 '
"Logon_Type=3 "
"| stats dc(ComputerName) as unique_targets, values(ComputerName) as targets "
"by TargetUserName, src_ip "
"| where unique_targets > 3 "
"| sort -unique_targets"
)
return run_search(service, query, earliest=earliest)
def detect_suspicious_powershell(service, earliest="-24h"):
"""Detect encoded or download-cradle PowerShell execution via Sysmon."""
query = (
'index=sysmon EventCode=1 Image="*\\\\powershell.exe" '
'(CommandLine="*-enc*" OR CommandLine="*-encodedcommand*" '
'OR CommandLine="*downloadstring*" OR CommandLine="*iex*") '
"| table _time, host, User, ParentImage, CommandLine "
"| sort _time"
)
return run_search(service, query, earliest=earliest)
def detect_lsass_access(service, earliest="-24h"):
"""Detect credential dumping via LSASS process access (Sysmon Event 10)."""
query = (
'index=sysmon EventCode=10 TargetImage="*\\\\lsass.exe" '
"GrantedAccess=0x1010 "
"| table _time, host, SourceImage, SourceUser, GrantedAccess"
)
return run_search(service, query, earliest=earliest)
def build_incident_timeline(service, hosts, users, earliest="-24h", latest="now"):
"""Build a unified incident timeline across multiple log sources."""
host_filter = " OR ".join(f'host="{h}"' for h in hosts)
user_filter = " OR ".join(f'user="{u}"' for u in users)
query = (
f"index=windows OR index=sysmon OR index=proxy OR index=firewall "
f"({host_filter} OR {user_filter}) "
'| eval event_summary=case('
' sourcetype=="WinEventLog:Security" AND EventCode==4624, '
' "Logon: ".TargetUserName." from ".src_ip, '
' sourcetype=="WinEventLog:Security" AND EventCode==4625, '
' "Failed logon: ".TargetUserName, '
' EventCode==1, "Process: ".Image." by ".User, '
' 1==1, sourcetype.": ".EventCode) '
"| table _time, sourcetype, host, event_summary "
"| sort _time"
)
return run_search(service, query, earliest=earliest, latest=latest)
def generate_report(findings):
"""Format investigation findings into a structured report."""
report = {
"report_type": "SPLUNK INVESTIGATION REPORT",
"generated_at": datetime.utcnow().isoformat() + "Z",
"findings": findings,
}
return json.dumps(report, indent=2, default=str)
def main():
parser = argparse.ArgumentParser(description="Splunk Security Log 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", help="Search earliest time")
parser.add_argument("--action", choices=[
"brute_force", "lateral_movement", "powershell",
"lsass_access", "timeline", "full_investigation"
], default="full_investigation")
parser.add_argument("--hosts", nargs="*", default=[], help="Target hosts for timeline")
parser.add_argument("--users", nargs="*", default=[], help="Target users for timeline")
parser.add_argument("--threshold", type=int, default=10)
args = parser.parse_args()
service = connect_splunk(args.host, args.port, args.username, args.password)
findings = {}
if args.action in ("brute_force", "full_investigation"):
findings["brute_force"] = detect_brute_force(service, args.threshold, args.earliest)
print(f"[+] Brute force: {len(findings['brute_force'])} accounts targeted")
if args.action in ("lateral_movement", "full_investigation"):
findings["lateral_movement"] = detect_lateral_movement(service, args.earliest)
print(f"[+] Lateral movement: {len(findings['lateral_movement'])} suspicious paths")
if args.action in ("powershell", "full_investigation"):
findings["suspicious_powershell"] = detect_suspicious_powershell(service, args.earliest)
print(f"[+] Suspicious PowerShell: {len(findings['suspicious_powershell'])} events")
if args.action in ("lsass_access", "full_investigation"):
findings["lsass_access"] = detect_lsass_access(service, args.earliest)
print(f"[+] LSASS access: {len(findings['lsass_access'])} events")
if args.action == "timeline" and args.hosts:
findings["timeline"] = build_incident_timeline(
service, args.hosts, args.users, args.earliest
)
print(f"[+] Timeline: {len(findings['timeline'])} events")
print(generate_report(findings))
if __name__ == "__main__":
main()
Related skills
How it compares
Use this as a Splunk-focused SPL and hunt playbook instead of generic “paste your logs in chat” triage with no index discipline or correlation patterns.
FAQ
Who is analyzing-security-logs-with-splunk for?
It is for operators who ship SaaS or APIs, ingest auth and infrastructure logs into Splunk, and want an agent to draft SPL, hunts, and investigation steps during monitoring and security incidents.
When should I use analyzing-security-logs-with-splunk?
Use it in Operate when reviewing alerts and dashboards, during Ship when validating detection coverage before go-live, and whenever you need hunts for brute force, impossible travel, exfiltration, or lateral movement after logs are flowing.
Is analyzing-security-logs-with-splunk safe to install?
Treat it like any third-party skill: review the Security Audits panel on this Prism page, confirm the Apache 2.0 license fits your policy, and avoid pasting live secrets or PII into agent sessions when generating SPL.