Practical KQL, Splunk SPL and YARA examples for defenders. Each entry explains its data assumptions and what to investigate. No searches, rule scans or code execute on this website.
8 original research examples
KQL-001KQL · Execution
Office process starts a script interpreter
Microsoft Defender XDR · MITRE T1059
Required: DeviceProcessEvents
Show query / rule and guidance
KQL example
DeviceProcessEvents
| where Timestamp > ago(7d)
| where InitiatingProcessFileName in~ ("winword.exe", "excel.exe", "powerpnt.exe")
| where FileName in~ ("powershell.exe", "pwsh.exe", "cmd.exe", "wscript.exe")
| project Timestamp, DeviceName, AccountName, InitiatingProcessFileName, FileName, ProcessCommandLine
| order by Timestamp desc
Analyst notes: Confirm parent-child relationship and inspect signed binaries, scripts and user context. Office add-ins and approved automation can trigger.
DeviceProcessEvents
| where Timestamp > ago(7d)
| where FileName in~ ("powershell.exe", "pwsh.exe")
| where ProcessCommandLine has_any ("EncodedCommand", "enc", "DownloadString")
| project Timestamp, DeviceName, AccountName, ProcessCommandLine, InitiatingProcessFileName
Analyst notes: Encoded commands may be legitimate administration. Decode offline in an isolated analysis environment and correlate with initiating process and device.
index=wineventlog sourcetype="WinEventLog:Security" EventCode=4625 earliest=-24h
| stats count as failures dc(ComputerName) as hosts by Account_Name, src_ip
| where failures >= 10
| sort - failures
Analyst notes: Replace index=wineventlog with your actual index; event fields and aliases differ by TA. Tune thresholds for service accounts and known scanners.
Analyst notes: Requires process creation auditing and command line inclusion. Adjust field extractions and avoid treating administrative scripting as automatically malicious.
index=dns earliest=-24h
| stats count as requests dc(src_ip) as clients by query
| where clients <= 2 AND requests >= 3
| sort - requests
| head 100
Analyst notes: Adapt index and query field to your DNS source. Rare domains alone are not malicious; enrich with reputation, domain age and requesting process.
PE file containing example PowerShell launch strings
YARA 4.x · MITRE T1059.001
Required: Local file bytes
Show query / rule and guidance
YARA example
rule CI_Demo_PowerShell_Strings
{
meta:
description = "Demo only: executable with PowerShell-related strings"
author = "CyberIntel"
strings:
$mz = { 4D 5A }
$ps1 = "powershell.exe" ascii nocase
$ps2 = "-EncodedCommand" ascii nocase
condition:
filesize < 20MB and $mz at 0 and ($ps1 or $ps2)
}
Analyst notes: Educational heuristic, likely false positives in installers and admin software; no malware-family attribution. Run against trusted samples in a controlled lab.
Analyst notes: A noisy educational indicator; legitimate applications commonly use eval and atob. Correlate with origin and obfuscation rather than auto-blocking.
We link to curated third-party research rather than bulk-copying content. Check each project's licence, original author, update frequency and technical assumptions.