← Back to SOC feed Coverage →

PSExec Attrib commands

kql MEDIUM Azure-Sentinel
DeviceProcessEvents
huntinglateral-movementmicrosoftofficialransomware
This rule was pulled from an open-source repository and enriched with AI. Validate in a test environment before deploying to production.
View original rule at Azure-Sentinel →
Retrieved: 2026-05-05T11:00:00Z · Confidence: medium

Hunt Hypothesis

Adversaries may use Attrib commands to gather file attribute information across multiple drives as part of reconnaissance before deploying Macaw ransomware. SOC teams should proactively hunt for this behavior in Azure Sentinel to identify potential pre-attack reconnaissance activities and mitigate the risk of ransomware deployment.

KQL Query

DeviceProcessEvents 
| where InitiatingProcessParentFileName endswith "PSEXESVC.exe" 
| where InitiatingProcessCommandLine has ".bat" 
| where FileName =~ "cmd.exe" and ProcessCommandLine has_all("-s", "-h", "-r", "-a", "*.*") 
| take 100 

Analytic Rule Definition

id: 28f56c18-a66e-4c51-94f6-3c8902cb58af
name: PSExec Attrib commands
description: |
  Prior to deploying Macaw ransomware in an organization, adversaries wil use Attrib to display file attribute information on multiple drives and all subfolders.
requiredDataConnectors:
- connectorId: MicrosoftThreatProtection
  dataTypes:
  - DeviceProcessEvents
tactics:
- Discovery
- Ransomware
query: |
  DeviceProcessEvents 
  | where InitiatingProcessParentFileName endswith "PSEXESVC.exe" 
  | where InitiatingProcessCommandLine has ".bat" 
  | where FileName =~ "cmd.exe" and ProcessCommandLine has_all("-s", "-h", "-r", "-a", "*.*") 
  | take 100 

Required Data Sources

Sentinel TableNotes
DeviceProcessEventsEnsure this data connector is enabled

MITRE ATT&CK Context

References

False Positive Guidance

Original source: https://github.com/Azure/Azure-Sentinel/blob/main/Hunting Queries/Microsoft 365 Defender/Campaigns/Macaw Ransomware/PSExec Attrib commands.yaml