Detection rules › Kusto

Windows Binaries Executed from Non-Default Directory

Status
available
Severity
medium
Time window
1h
Group by
CommandLine, Computer, EventID, NewProcessName, Process, SubjectUserName
Source
github.com/Azure/Azure-Sentinel

The query detects Windows binaries, that can be executed from a non-default directory (e.g. C:\Windows, C:\Windows\System32 etc.). Ref: https://lolbas-project.github.io/

MITRE ATT&CK coverage

Telemetry coverage

Rule body

id: 15049017-527f-4d3b-b011-b0e99e68ef45
name: Windows Binaries Executed from Non-Default Directory
description: |
   'The query detects Windows binaries, that can be executed from a non-default directory (e.g. C:\Windows\, C:\Windows\System32 etc.). 
   Ref: https://lolbas-project.github.io/'
severity: Medium
status: Available
requiredDataConnectors:
  - connectorId: SecurityEvents
    dataTypes:
      - SecurityEvent
  - connectorId: WindowsSecurityEvents
    dataTypes:
      - SecurityEvent
queryFrequency: 1h
queryPeriod: 1h
triggerOperator: gt
triggerThreshold: 0
tactics:
  - Execution
relevantTechniques:
  - T1059
query: |
   let procList = externaldata(Process:string) [@"https://raw.githubusercontent.com/Azure/Azure-Sentinel/master/Sample%20Data/Microsoft_Lolbas_Execution_Binaries.csv"] with (format="csv", ignoreFirstRecord=True);
   SecurityEvent
   | where EventID == 4688 and Process has_any (procList) and not (NewProcessName has ("C:\\Windows\\"))
   | summarize StartTime = min(TimeGenerated), EndTime = max(TimeGenerated) by EventID, Computer, SubjectUserName, NewProcessName, Process, CommandLine
   | extend Name=tostring(split(SubjectUserName, "@")[0]), UPNSuffix=tostring(split(SubjectUserName, "@")[1])
   | extend HostName = iif(Computer has '.',substring(Computer,0,indexof(Computer,'.')),Computer) , DnsDomain = iif(Computer has '.',substring(Computer,indexof(Computer,'.')+1),'')
entityMappings:
  - entityType: Account
    fieldMappings:
      - identifier: Name
        columnName: Name
      - identifier: UPNSuffix
        columnName: UPNSuffix
  - entityType: Host
    fieldMappings:
      - identifier: FullName
        columnName: Computer
      - identifier: HostName
        columnName: HostName
      - identifier: DnsDomain
        columnName: DnsDomain
  - entityType: Process
    fieldMappings:
      - identifier: CommandLine
        columnName: CommandLine
version: 1.0.4
kind: Scheduled

Stages and Predicates

Let binding: procList used in Stage 2

let procList = externaldata(Process:string) [@"https://raw.githubusercontent.com/Azure/Azure-Sentinel/master/Sample%20Data/Microsoft_Lolbas_Execution_Binaries.csv"] with (format="csv", ignoreFirstRecord=True);

Stage 1: source

SecurityEvent

Stage 2: where

| where EventID == 4688 and Process has_any (procList) and not (NewProcessName has ("C:\\Windows\\"))

Stage 3: summarize

| summarize StartTime = min(TimeGenerated), EndTime = max(TimeGenerated) by EventID, Computer, SubjectUserName, NewProcessName, Process, CommandLine

Stage 4: extend

| extend Name=tostring(split(SubjectUserName, "@")[0]), UPNSuffix=tostring(split(SubjectUserName, "@")[1])

Stage 5: extend

| extend HostName = iif(Computer has '.',substring(Computer,0,indexof(Computer,'.')),Computer) , DnsDomain = iif(Computer has '.',substring(Computer,indexof(Computer,'.')+1),'')

Exclusions

The rule actively suppresses these predicates.

FieldKindExcluded valuesSearch
NewProcessNamematchC:\Windows\excludes:NewProcessName field:"NewProcessName" value:"C:\Windows\"

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
EventIDeq
  • 4688 corpus 317 (splunk 283, kusto 33, elastic 1)
field:"EventID" kind:eq value:"4688"
Processmatch
  • procList transforms: term
field:"Process" kind:match value:"procList"

Output fields

These fields are emitted when the rule matches.

FieldSource
CommandLinesummarize
Computersummarize
EndTimesummarize
EventIDsummarize
NewProcessNamesummarize
Processsummarize
StartTimesummarize
SubjectUserNamesummarize
Nameextend
UPNSuffixextend
DnsDomainextend
HostNameextend