|
| 1 | +# Detect PsExec being used to spread files |
| 2 | + |
| 3 | +This query was originally published in the threat analytics report, *Ryuk ransomware*. There is also a related [blog](https://www.microsoft.com/security/blog/2020/03/05/human-operated-ransomware-attacks-a-preventable-disaster/). |
| 4 | + |
| 5 | +[Ryuk](https://www.microsoft.com/en-us/wdsi/threats/malware-encyclopedia-description?Name=Ransom:Win32/Ryuk&threatId=-2147232689) is human-operated ransomware. Much like [DoppelPaymer](https://www.microsoft.com/security/blog/2020/03/05/human-operated-ransomware-attacks-a-preventable-disaster/) ransomware, Ryuk is spread manually, often on networks that are already infected with Trickbot. |
| 6 | + |
| 7 | +Ryuk operators use [PsExec](https://docs.microsoft.com/en-us/sysinternals/downloads/psexec) to manually spread the ransomware to other devices. |
| 8 | + |
| 9 | +The following query detects remote file creation events that might indicate an active attack. |
| 10 | + |
| 11 | +The [See also](#See-also) section below lists links to other queries associated with Ryuk ransomware. |
| 12 | + |
| 13 | +## Query |
| 14 | + |
| 15 | +```Kusto |
| 16 | +// Find PsExec creating multiple files on remote machines in a 10-minute window |
| 17 | +DeviceFileEvents |
| 18 | +| where Timestamp > ago(7d) |
| 19 | +// Looking for PsExec by accepteula command flag |
| 20 | +| where InitiatingProcessCommandLine has "accepteula" |
| 21 | +// Remote machines and file is exe |
| 22 | +| where FolderPath has "\\\\" and FileName endswith ".exe" |
| 23 | +| extend Exe = countof(InitiatingProcessCommandLine, ".exe") |
| 24 | +// Checking to see if command line has 2 .exe or .bat |
| 25 | +| where InitiatingProcessCommandLine !has ".ps1" and Exe > 1 or |
| 26 | +InitiatingProcessCommandLine has ".bat" |
| 27 | +// Exclusions: Remove the following line to widen scope of AHQ |
| 28 | +| where not(InitiatingProcessCommandLine has_any("batch", "auditpol", |
| 29 | +"script", "scripts", "illusive", "rebootrequired")) |
| 30 | +| summarize FileCount = dcount(FolderPath), make_set(SHA1), make_set(FolderPath), |
| 31 | +make_set(FileName), make_set(InitiatingProcessCommandLine) by DeviceId, |
| 32 | +TimeWindow=bin(Timestamp, 10m), InitiatingProcessFileName |
| 33 | +| where FileCount > 4 |
| 34 | +``` |
| 35 | + |
| 36 | +## Category |
| 37 | + |
| 38 | +This query can be used to detect the following attack techniques and tactics ([see MITRE ATT&CK framework](https://attack.mitre.org/)) or security configuration states. |
| 39 | + |
| 40 | +| Technique, tactic, or state | Covered? (v=yes) | Notes | |
| 41 | +|-|-|-| |
| 42 | +| Initial access | | | |
| 43 | +| Execution | | | |
| 44 | +| Persistence | | | |
| 45 | +| Privilege escalation | | | |
| 46 | +| Defense evasion | | | |
| 47 | +| Credential Access | | | |
| 48 | +| Discovery | | | |
| 49 | +| Lateral movement | v | | |
| 50 | +| Collection | | | |
| 51 | +| Command and control | | | |
| 52 | +| Exfiltration | | | |
| 53 | +| Impact | | | |
| 54 | +| Vulnerability | | | |
| 55 | +| Misconfiguration | | | |
| 56 | +| Malware, component | | | |
| 57 | + |
| 58 | +## See also |
| 59 | + |
| 60 | +* [Detect credential theft via SAM database export by LaZagne](../Credential%20Access/lazagne.md) |
| 61 | +* [Detect Cobalt Strike invoked via WMI](../Campaigns/cobalt-strike-invoked-w-wmi.md) |
| 62 | + |
| 63 | +## Contributor info |
| 64 | + |
| 65 | +**Contributor:** Microsoft Threat Protection team |
0 commit comments