From Advanced Hunting, covering devices onboarded to Defender for Endpoint. Each can become a detection rule once you tune the false positives.
Encoded PowerShell
T1059.001PowerShell running Base64 or -EncodedCommand. Attackers use it to hide the command.
DeviceProcessEvents
| where Timestamp > ago(1d)
| where FileName in~ ("powershell.exe", "pwsh.exe")
| where ProcessCommandLine has_any ("-enc", "-encodedcommand", "FromBase64String")
| project Timestamp, DeviceName, AccountName, InitiatingProcessFileName, ProcessCommandLine
| order by Timestamp desc
After the result: Decode the Base64 and read the real command. Check the parent process: Office or a browser launching PowerShell is not normal. Management tools can show up here as false positives.
DeviceProcessEvents · Device onboarded to Defender for Endpoint
Office app spawning a shell
T1204.002Word, Excel or Outlook launched cmd, PowerShell or a script host. Usually an attachment with a macro.
DeviceProcessEvents
| where Timestamp > ago(1d)
| where InitiatingProcessFileName in~ ("winword.exe", "excel.exe", "powerpnt.exe", "outlook.exe")
| where FileName in~ ("cmd.exe", "powershell.exe", "wscript.exe", "cscript.exe", "mshta.exe")
| project Timestamp, DeviceName, AccountName, InitiatingProcessFileName, FileName, ProcessCommandLine
After the result: Start from the email or file opened a few minutes earlier. Very few of these are legitimate.
DeviceProcessEvents · Device onboarded to Defender for Endpoint
New scheduled task with schtasks
T1053.005A scheduled task created from the command line. A common persistence method.
DeviceProcessEvents
| where Timestamp > ago(1d)
| where FileName =~ "schtasks.exe"
| where ProcessCommandLine has "/create"
| project Timestamp, DeviceName, AccountName, InitiatingProcessFileName, ProcessCommandLine
After the result: Check the command the task runs and its path. A task that runs a script from a temp folder or as SYSTEM deserves an investigation.
DeviceProcessEvents · Device onboarded to Defender for Endpoint
Deleting shadow copies and backups
T1490Ransomware deletes local backups before it encrypts.
DeviceProcessEvents
| where Timestamp > ago(7d)
| where (FileName =~ "vssadmin.exe" and ProcessCommandLine has "delete" and ProcessCommandLine has "shadows")
or (FileName =~ "wbadmin.exe" and ProcessCommandLine has "delete" and ProcessCommandLine has "catalog")
| project Timestamp, DeviceName, AccountName, InitiatingProcessFileName, ProcessCommandLine
After the result: If it appears on a device, isolate it right away. Contain first, investigate after.
DeviceProcessEvents · Device onboarded to Defender for Endpoint
certutil downloading a file
T1105certutil is a legitimate tool, but attackers use it to download files from the internet.
DeviceProcessEvents
| where Timestamp > ago(7d)
| where FileName =~ "certutil.exe"
| where ProcessCommandLine has_any ("urlcache", "-split", "-decode")
| where ProcessCommandLine has_any ("http://", "https://")
| project Timestamp, DeviceName, AccountName, InitiatingProcessFileName, ProcessCommandLine
After the result: Review the URL and the domain, and check whether the saved file was executed.
DeviceProcessEvents · Device onboarded to Defender for Endpoint