Query Details
// https://emsroute.com/2025/05/23/why-defendnot-is-a-wakeup-call-a-ground-level-analysis/
// https://github.com/es3n1n/defendnot
// Remember to set the query period
let AvModeDescription = dynamic({"0":"Normal", "1":"Passive", "4":"EDR Block"});
let DeviceEDRPassive =
DeviceTvmInfoGathering
| extend AdditionalFields = parse_json(AdditionalFields)
| extend AvEngineVersion = tostring(AdditionalFields.["AvEngineVersion"])
| extend AvPlatformVersion = tostring(AdditionalFields.["AvPlatformVersion"])
| extend AvMode = tostring(AvModeDescription[tostring(AdditionalFields.["AvMode"])])
| where isnotempty( AvMode ) and AvMode == "Passive"
| distinct DeviceName;
DeviceRegistryEvents
| where ActionType == "RegistryValueSet"
| where RegistryKey has "\\SOFTWARE\\Microsoft\\Security Center\\Provider\\Av"
| where DeviceName has_any(DeviceEDRPassive)
This KQL (Kusto Query Language) query is designed to identify devices that are in "Passive" mode for their antivirus settings and then check for specific registry changes related to antivirus providers on those devices. Here's a simplified breakdown of what the query does:
Define Antivirus Modes: The query starts by defining a mapping of antivirus mode codes to their descriptions. Specifically, it maps "0" to "Normal", "1" to "Passive", and "4" to "EDR Block".
Identify Devices in Passive Mode:
DeviceTvmInfoGathering table to extract additional fields related to antivirus settings.Check Registry Changes:
DeviceRegistryEvents table to find events where a registry value was set.In summary, this query is used to find devices with antivirus software running in "Passive" mode and then checks if there have been any registry changes related to antivirus providers on those devices.

Steven Lim
Released: May 23, 2025
Tables
Keywords
Operators