🌵
Rotta
  • ☕General
    • About Me
    • Recently Added
  • ☣️Offensive Tool Development
    • Windows Internals
      • Registers
      • x64 Calling Convention
      • PE File Format
        • PE File Structure
        • DOS Header, DOS Stub, & Rich Header
        • NT Headers
        • Data Directories & Section Headers
        • Import Directory Table, ILT & IAT
        • Image Export Table
        • PE Base Relocations
      • Processes & PEB Structure
      • Threads & TEB Structure
      • Event Tracing for Windows (ETW)
        • Interacting with ETW
        • ETW Tools
    • Enumeration
      • Process Enumeration
        • CreateToolhelp32Snapshot
        • EnumProcesses (psapi.h)
        • NtQuerySystemInformation
        • NtQueryInformationProcess
      • Thread Enumeration
        • CreateToolhelp32Snapshot
        • NtQuerySystemInformation
      • DLL Enumeration
    • Memory Allocation
      • Private Memory Allocation
      • Memory Mapping
    • Access Tokens
      • Page 1
    • Techniques and Exploitation Methods
      • Thread Hijacking
      • DLL Injection
      • Shellcode Reflective DLL Injection
      • APC Injection
      • Callback Process Injection
      • Function Stomping
      • DLL Sideloading
      • Local PE Injection
      • Reflective DLL Injection
      • Process Hollowing
    • PE Tips & Tricks
      • Parsing PE Headers
      • Patching IAT
      • Patching Base Relocations
      • Fixing Memory Permissions
      • Embed an EXE inside a LNK
      • PE Infection
    • Staging
      • Fetch Payload from Web Server
      • Fetch DLL from Web Server
    • Bypassing AV
      • String Hashing
      • Hiding & Obfuscating IAT
      • Custom WINAPI Functions
        • GetProcAddressHash
      • File Bloating
    • Evading EDR
      • Payload Execution Control
      • Wrapping NTAPI Functions
        • NtCreateUserProcess
        • NtQuerySystemInformation
      • PPID Spoofing
      • Call Stack Spoofing
      • NTDLL Unhooking
        • NTDLL Unhooking - From Disk
        • NTDLL Unhooking - From KnownDlls
        • NTDLL Unhooking - From Suspended Process
        • NTDLL Unhooking - From Web Server
    • Anti-Analysis Techniques
      • Anti-Debugging Techniques
        • Check If Running In a Debugger
        • Self Deleting Malware
      • Anti-Virtual Environments (AVE) Techniques
        • Detecting Hardware Specs
        • Delaying Execution
        • API Hammering
      • Reducing Binary Entropy
      • Brute Forcing Decryption Key
      • Removing MSCRT
      • Hiding / Camouflaging IAT
    • API Hooking
      • Userland Hooking
      • Custom Hooking Function
      • Open-Source Hooking Libraries
        • Microsoft's Detours Library
        • MinHook Library
    • Syscalls
      • NTAPI Syscall Process Injection
      • Direct Syscalls
        • SysWhispers
      • Indirect Syscalls
    • C2 Development
      • Consensus & Design Patterns
      • Infrastructure
      • Teamserver
      • Listeners
      • Agent Stubs
      • Encrypting Communication
    • User Defined Reflective Loader (UDRL)
    • MalDev Environment Setup
      • Setting up Dev Box
      • Setting up Pwn Box
      • Setting up Dev Server
      • Commando VM
    • Maldev Checklist
  • 👺Red Teaming
    • Setting up Infrastructure
    • External Recon
    • Internal Recon & Enumeration
      • Host Reconnaissance
      • Host Enumeration
    • Password Attacks
      • Password Spraying OWA
    • Phishing / Initial Compromise
      • Setting up Infrastructure
      • Crafting the Email
      • EvilGinx
      • Browser In Browser Attack
      • MS Office Phishing
        • VBA Macro Beacon
        • Remote Template Injection
        • HTML Smuggling
    • Privilege Escalation
      • Windows Services
      • UAC Bypass
      • Elevated SYSTEM Persistence
    • Persistence
      • Scheduled Tasks
      • Registry AutoRun
      • Startup Folder
      • COM Hijacking
      • Elevated SYSTEM Persistence
    • Payload Delivery
      • MS Office Payloads
        • Mark of the Web (MOTW).
        • Visual Basic Macro (VBA)
        • Remote Template Injection
      • SCR File Attack
    • Stealing Credentials
      • MimiKatz
      • Rubeus
      • Page 2
    • Domain Reconnaissance
      • PowerView & SharpView
      • ADSearch
    • Lateral Movement
      • User Impersonation
        • Pass The Hash (PTH)
        • Pass The Ticket (PTT)
        • Overpass The Hash
        • Token Impersonation
        • Token Store
    • Kerberos & Active Directory Attacks
      • Kerberoasting
      • ASREP Roasting
      • Kerberos Relay Attacks
      • Shadow Credentials
      • Unconstrained Delegation
      • Constrained Delegation
    • Cobalt Strike
      • Start Team Server
      • Configure Listeners
      • Beacons
        • UDRLess Beacon
    • Cracking Passwords
    • Tools & Checklists
      • Commands Cheat Sheet
      • Tools
      • Red Team Checklist
  • 🪟Active Directory
    • Active Directory Toolkit
      • Windows Tools
        • ActiveDirectory PowerShell Module
        • PowerView
        • SharpHound/BloodHound
        • Snaffler
      • Kali Linux Tools
        • Windapsearch & Ldapsearch
        • CrackMapExec
        • SMBMap
        • rpcclient
        • Impacket Toolkit
        • Bloodhound
    • Enumerating Active Directory
      • net.exe
      • Powershell Active Directory Commands
      • Powershell & .NET Classes
      • PowerView / SharpView
      • Enumerating Service Accounts
      • Enumerating Object Permissions
      • Enumerating Objects
      • Active Directory Certificate Services (AD CS)
    • Attacking Active Directory Authentication
      • AS-REP Roasting
      • Kerberoasting
      • Silver Tickets
      • Domain Controller Synchronization (Dsync Attack)
      • Kerberos Relay Attack
      • NTLM Relay Attack
      • Attacking Service Accounts
    • Password Spraying
      • Enumeration & Retrieving Password Policy
      • Creating a Target User List
      • Brute Force / Password Spraying - Linux Tools
      • Internal Spraying - From Windows
    • Lateral Movement Techniques
      • WMI and WinRM
      • PsExec
      • Pass The Hash
      • Overpass The Hash
      • Pass The Ticket
      • DCOM
    • Persistence
      • Golden Ticket
      • Shadow Copies
    • God Access
      • GenericAll Abuse
      • NTDS Tom Foolery
    • Lab Environment Setup
      • Installing Forest
      • Adding Data to Active Directory
    • Templates & Cheat Sheets
  • 🦈Penetration Testing
    • Information Gathering / Reconnaisance
      • Client Fingerprinting
      • External Recon and Enumeration
      • Network Reconnaisance
        • Scanning for Hosts
        • Initial Enumeration of AD Network
        • SMB Network Shares
      • Vulnerability Scanning
        • Nessus
        • Nmap
      • Popped a Shell
    • Pivoting, Tunneling, and Port Forwarding
      • SSH
      • Socat
      • Pivoting
        • plink.exe
        • netsh
        • Web Server Pivoting with Rpivot
      • Tunneling
        • Chisel
        • sshuttle
        • Dnscat2
      • Double Pivots
        • RDP and SOCKS Tunneling with SocksOverRDP
    • Cracking Passwords
      • Password Cracking Prerequisites
      • Mutating Wordlists
        • Identifying & Building Rules
      • Password Managers
      • SSH Private Keys
      • NTLM Toolkit
      • NTLMv2
      • MS-Cachev2 (DCC2)
      • Password Protected Files
    • Windows Privilege Escalation
      • Initial Enumeration
      • Searching For Sensitive Files
      • Searching Logs & Event Viewer
      • Escalating Privilege
      • Leveraging Windows Services
        • Service Binary Hijacking
        • Service DLL Hijacking
        • Abusing Unquoted Paths
      • Scheduled Tasks
      • Enumerating Services & Tasks
      • Dumping Secrets
    • Linux Privilege Escalation
      • Initial Enumeration
      • Automated Enumeration
      • Searching For Sensitive Information
      • Insecure File Permissions
      • Insecure System Components
        • Abusing Setuid Binaries and Capabilities
        • Sudo Trickery
        • Kernel Vulnerabilities
      • Abusing Environment Variables
      • Escaping Jail
      • Wildcard Injection
    • Exploiting Microsoft Office
      • Phishing with Teams
      • Malicious Macros
      • Windows Library Files
    • Setting up Infrastructure
      • C2 Infrastructure
      • EvilGinx2 Phishing Infrastructure
    • Ex-filtrating Data
      • WebDAV
      • SMB
      • Converting files to Hex Strings
    • Phishing
      • OSCP Phishing Guide
    • Templates & Cheat Sheets
      • OSCP Cheat Sheet
      • Impacket Cheat Sheet
      • Useful Commands
      • Penetration Test Checklist
  • 🛡️Azure & M365
    • Information Gathering / Reconnaissance
      • Domain Enumeration
      • User Enumeration
      • AADInternals
    • Attacking Authentication
      • OWA Password Spraying
      • OAuth Abuse
    • Azure AD Killchain
    • Azure Lab Setup
    • Azure & M365 Checklist
  • 🥾Security Operation Center
    • Network Traffic Analysis
      • Tcpdump
      • Wireshark
    • Windows Event Logs
      • Sysmon
    • Event Tracing for Windows (ETW)
    • Microsoft 365 Defender
    • Splunk as SIEM
      • Using Splunk Applications
      • Search Processing Language (SPL) Commands
      • Hunting with Splunk
      • Intrusion Detection
    • Incident Response Process
    • MITRE ATT&CK Framework
      • Persistence
        • Registry Run Keys
    • Templates & Cheat Sheets
      • Interview Prep
  • 🔬Digital Forensics
    • Tools
  • 🔍Malware Analysis
    • Network Traffic Analysis
      • INetSim
    • Static Analysis
      • Signatures & Fingerprints
      • Pestudio
      • x64dbg
    • Dynamic Analysis
      • Noriben
    • Reverse Engineering / Code Analysis
      • IDA
      • x64dbg
      • Returning Source Code
        • .NET Binary
    • Creating Detection Rules
    • Tools
  • 🛠️Programming
    • MASM Assembly
    • Qt
      • Setting up Qt in CLion
    • Windows Development on MacOS
      • CLion Setup
    • Windows API
      • Deleting Files
      • Strings
      • wininet.h
      • Wrapping WinAPI Functions
      • code_seg
      • Locating WinAPI Functions - Tips
    • Visual Studio
      • Creating DLL's
      • Debug & Release Mode
    • Mingw
      • Windows Development
    • Position Independent Code (PIC)
      • Creating Shellcode
      • Debugging & Development Tips
      • Strings
      • Macros
      • PIC Checklist
  • 🏠Home Lab
    • Current Setup
Powered by GitBook
On this page
  • References
  • Identify Available Data
  • View all indices
  • View sourcetypes
  • View sources (data files)
  • View Raw Data in sourcetypes
  • View all data in sourcetype
  • View data in sourcetype
  • View Field Summary
  • View uncommon events with rare
  • Basic Commands
  • fields
  • table
  • rename
  • dedup
  • Sort
  • stats
  • chart
  • eval
  • rex
  • lookup
  • inputlookup
  • Time Range
  • transaction
  • subsearches
  • Identify Available Data
  • Additional Commands
  1. Security Operation Center
  2. Splunk as SIEM

Search Processing Language (SPL) Commands

PreviousUsing Splunk ApplicationsNextHunting with Splunk

Last updated 7 months ago

References

Here are some good references

Identify Available Data

We can use metadata to retrieve metadata about the data in our indexes. The type=sourcetypes argument tells Splunk to return metadata about sourcetypes.

View all indices

| eventcount summarize=false index=* | dedup index | fields index

This command returns all available indices.

View sourcetypes

index="*" | stats count by sourcetype
| metadata type=sourcetypes index=* | table sourcetype

These commands return a list of all sourcetypes in the Spunk environment

View sources (data files)

index="*" | stats count by source
| metadata type=sources index=* | table source

These commands return a list of all data sources in the Splunk environment.

View Raw Data in sourcetypes

Once we have the sourcetypes, we can use sourcetype to view the data they contain.

sourcetype="WinEventLog:Security" | table _raw

This command will return the raw data (actual file) for the specified source type.

View all data in sourcetype

sourcetype="WinEventLog:Security" | table *

This command will return the data in a table for the specified source type. NOTE: be cautious, as the use of table * can result in a very wide table if our events have a large number of fields.\

View data in sourcetype

sourcetype="WinEventLog:Security" | fields Account_Name, EventCode 
| table Account_Name, EventCode

This is a better approach, listing specific fields and creating a table is better for visualizing data.

View Field Summary

sourcetype="WinEventLog:Security" | fieldsummary

The above command is a great way to return just the fields using fieldsummary

This search will return a table that includes every field found in the events returned by the search (across the sourcetype we've specified). The table includes several columns of information about each field:

  • field: The name of the field.

  • count: The number of events that contain the field.

  • distinct_count: The number of distinct values in the field.

  • is_exact: Whether the count is exact or estimated.

  • max: The maximum value of the field.

  • mean: The mean value of the field.

  • min: The minimum value of the field.

  • numeric_count: The number of numeric values in the field.

  • stdev: The standard deviation of the field.

  • values: Sample values of the field.

We may also see:

  • modes: The most common values of the field.

  • numBuckets: The number of buckets used to estimate the distinct count.

NOTE: The values shown in this command are based on the provided time in our search. We need to specify it in the search!

index=* sourcetype=* | bucket _time span=1d | stats count by _time, index, sourcetype 
| sort - _time

bucket command is used to group the events based on the _time field into 1-day buckets\

View uncommon events with rare

index=* sourcetype=* | rare limit=10 index, sourcetype

This query retrieves all data and finds the 10 rarest combinations of indexes and sourcetypes.

Basic Commands

By default a search query returns all results, but can be narrowed down with keywords, boolean operators, wildcards, and more.

fields

The fields command specifies which fields should be included or excluded in the search results.

index="main" sourcetype="WinEventLog:Sysmon" EventCode=1 | fields - User

table

The table command presents search results in a tabular format.

index="main" sourcetype="WinEventLog:Sysmon" EventCode=1 | table _time, host, Image

rename

The rename command renames a field in the search results.

index="main" sourcetype="WinEventLog:Sysmon" EventCode=1 | rename Image as Process

dedup

The dedup command removes duplicates.

index="main" sourcetype="WinEventLog:Sysmon" EventCode=1 | dedup Image

Sort

The sort command sorts the search results. (example sorts results in decending order)

index="main" sourcetype="WinEventLog:Sysmon" EventCode=1 | sort - _time

stats

The stats command performs statistical operations. (example returns a table of timestamp (_time) and a process (Image)"

index="main" sourcetype="WinEventLog:Sysmon" EventCode=3 | stats count by _time, Image

chart

The chart command creates a data visualization based on statistical operations.

index="main" sourcetype="WinEventLog:Sysmon" EventCode=3 | chart count by _time, Image

eval

The eval command creates or redefines fields. (example creates a new field Process_Path which contains the lowercase version of the Image field)

index="main" sourcetype="WinEventLog:Sysmon" EventCode=1 | eval Process_Path=lower(Image)

rex

The rex command extracts new fields from existing ones using regular expressions.

index="main" EventCode=4662 | rex max_match=0 "[^%](?<guid>{.*})" | table guid
  • index="main" EventCode=4662 filters the events to those in the main index with the EventCode equal to 4662. This narrows down the search to specific events with the specified EventCode.

  • rex max_match=0 "[^%](?<guid>{.*})" uses the rex command to extract values matching the pattern from the events' fields. The regex pattern {.*} looks for substrings that begin with { and end with }. The [^%] part ensures that the match does not begin with a % character. The captured value within the curly braces is assigned to the named capture group guid.

  • table guid displays the extracted GUIDs in the output. This command is used to format the results and display only the guid field.

  • The max_match=0 option ensures that all occurrences of the pattern are extracted from each event. By default, the rex command only extracts the first occurrence.

lookup

The lookup command enriches the data with external sources

Suppose the following CSV file called malware_lookup.csv.

filename, is_malware
notepad.exe, false
cmd.exe, false
powershell.exe, false
sharphound.exe, true
randomfile.exe, true

inputlookup

The inputlookup command retrieves data from a lookup file without joining it to the search results.

| inputlookup malware_lookup.csv

Time Range

Every event in Splunk has a timestamp. We can limit the searches to specific time periods using the earliest and latest commands.

index="main" earliest=-7d EventCode!=1

transaction

The transaction command is used in Splunk to group events that share common characteristics into transcation.

index="main" sourcetype="WinEventLog:Sysmon" (EventCode=1 OR EventCode=3) | transaction Image startswith=eval(EventCode=1) endswith=eval(EventCode=3) maxspan=1m | table Image |  dedup Image 

subsearches

A subsearch in Splunk is a search that is nested inside another search.

index="main" sourcetype="WinEventLog:Sysmon" EventCode=1 NOT [ search index="main" sourcetype="WinEventLog:Sysmon" EventCode=1 | top limit=100 Image | fields Image ] | table _time, Image, CommandLine, User, ComputerName

Identify Available Data

Splunk can ingest a wide variety of data sources. To identify available source types we can run the followning SPL commands:

Using fields command:

We can get Account_Name, EventCode and create a table of the summarized data.

sourcetype="WinEventLog:Security" | fields Account_Name, EventCode | table Account_Name, EventCode

View list of fields

If we can to get a list of fields we can use the command:

sourcetype="WinEventLog:Security" | fieldsummary

This command displays the 20 least common values of the ParentImage field.

index="main" | rare limit=20 useother=f ParentImage

A more complex query can provide a detailed summary of fields. This search shows a summary of all fields (fieldsummary), filters out fields that appear in less than 100 events (where count < 100)

index=* sourcetype=* | fieldsummary | where count < 100 | table field, count, distinct_count

Good command:

index=* sourcetype=* | bucket _time span=1d | stats count by _time, index, sourcetype | sort - _time

A more complex query can provide a detailed summary of fields.

index=* | sistats count by index, sourcetype, source, host

Additional Commands

| eventcount summarize=false index=* | table index

This query uses eventcount to count events in all indexes, then summarize=false is used to display counts for each index separately, and finally, the table command is used to present the data in tabular form.

| metadata type=sourcetypes

The result is a list of all sourcetypes in our Splunk environment, along with additional metadata such as the first time a source type was seen (firstTime), the last time it was seen (lastTime), and the number of hosts (totalCount).

Simpler view:

| metadata type=sourcetypes index=* | table sourcetype

Here, the metadata command retrieves metadata about the data in our indexes. In table form:

| metadata type=sources index=* | table source

Once we know our source types, we can investigate the kind of data they contain.

Say we're interesting in: WinEventLog:Security

sourcetype="WinEventLog:Security" | table _raw

The table command generates a table with the specified fields as columns. Here, _raw represents the raw event data. This command will return the raw data for the specified source type.

🥾
Welcome to the Search Reference - Splunk Documentation
Logo
Get started with Search - Splunk Documentation
Logo