Detection rules › Kusto

ASR Rare and Untrusted Executables

Group by
FileName, SHA1
Author
Cyb3rMonk
Source
github.com/Cyb3r-Monk/Threat-Hunting-and-Detection

Below query shows Untrusted executables that are seen on few devices (LocalPrevalence). It requires the below ASR rule to be configured and Cloud-delivered protection to be enabled.
Block executable files from running unless they meet a prevalence, age, or trusted list criterion
You may need to exclude software development users/machines/folders.

MITRE ATT&CK coverage

TacticTechniques
StealthNo specific technique

References

Telemetry coverage

Rule body

// Author: Cyb3rMonk(https://twitter.com/Cyb3rMonk, https://mergene.medium.com)
//
// Query parameters:
DeviceEvents
| where Timestamp > ago(30d)
| where ActionType in ("AsrUntrustedExecutableAudited","AsrUntrustedExecutableBlocked")
| summarize arg_min(Timestamp,*), LocalPrevalence = dcount(DeviceId) by SHA1, FileName
| where Timestamp > ago(1d)
| where LocalPrevalence <= 5
// there might be files without signature info, perform leftouter join
| join kind=leftouter (
    DeviceFileCertificateInfo
    | where Timestamp > ago(30d)
    | summarize arg_max(Timestamp,*) by SHA1
    )
    on SHA1
// Get GlobalPrevalence info, etc.
| invoke FileProfile(SHA1, 1000)
// GlobalFirstSeen can be used for filtering the results further
// If you want to list only the files that have invalid signatures uncomment the below line
// there might be files without signature info, don't exclude them
// | where IsTrusted <> 1

Stages and Predicates

Stage 1: source

DeviceEvents

Stage 2: where

| where Timestamp > ago(30d)

Stage 3: where

| where ActionType in ("AsrUntrustedExecutableAudited","AsrUntrustedExecutableBlocked")

Stage 4: summarize

| summarize arg_min(Timestamp,*), LocalPrevalence = dcount(DeviceId) by SHA1, FileName

Stage 5: where

| where Timestamp > ago(1d)

Stage 6: where

| where LocalPrevalence <= 5

Stage 7: join

| join kind=leftouter (
    DeviceFileCertificateInfo
    | where Timestamp > ago(30d)
    | summarize arg_max(Timestamp,*) by SHA1
    )
    on SHA1

Stage 8: invoke

| invoke FileProfile(SHA1, 1000)

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
ActionTypein
  • AsrUntrustedExecutableAudited
  • AsrUntrustedExecutableBlocked
field:"ActionType" kind:in
LocalPrevalencele
  • 5
field:"LocalPrevalence" kind:le value:"5"

Output fields

These fields are emitted when the rule matches.

FieldSource
FileNamesummarize
LocalPrevalencesummarize
SHA1summarize