Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save zyrone27/b186c37f08b4db28dc5f53beff108df8 to your computer and use it in GitHub Desktop.
Save zyrone27/b186c37f08b4db28dc5f53beff108df8 to your computer and use it in GitHub Desktop.
2021-1675 - PrintNightmare KQL - MDE
let serverlist=DeviceInfo
| where DeviceType != "Workstation"
| distinct DeviceId;
let suspiciousdrivers=DeviceImageLoadEvents
| where DeviceId in (serverlist)
| where FolderPath startswith @"c:\windows\system32\spool\drivers"
| distinct SHA1
| invoke FileProfile(SHA1, 1000)
| where GlobalPrevalence < 50 and IsRootSignerMicrosoft != 1 and SignatureState != "SignedValid";
suspiciousdrivers
| join kind=inner (DeviceImageLoadEvents
| where DeviceId in (serverlist)
| where FolderPath startswith @"c:\windows\system32\spool\drivers") on SHA1
| where InitiatingProcessFileName != "ccmexec.exe"
// Optionally filter for only the print spooler to load the driver to make it specific to this attack
//| where InitiatingProcessFileName == "spoolsv.exe"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment