|
| 1 | +# Detect malicious use of Msiexec |
| 2 | + |
| 3 | +This query was originally published in the threat analytics report, *Msiexec abuse*. |
| 4 | + |
| 5 | +*[Msiexec.exe](https://docs.microsoft.com/windows-server/administration/windows-commands/msiexec)* is a Windows component that installs files with the *.msi* extension. These kinds of files are Windows installer packages, and are used by a wide array of legitimate software. However, malicious actors can re-purpose msiexec.exe for living-off-the-land attacks, where they use legitimate system binaries on the compromised device to perform attacks. |
| 6 | + |
| 7 | +The following query detects activity associated with misuse of msiexec.exe, particularly alongside [mimikatz](https://www.varonis.com/blog/what-is-mimikatz/), a common credential dumper and privilege escalation tool. |
| 8 | + |
| 9 | +## Query |
| 10 | + |
| 11 | +```Kusto |
| 12 | +//Find possible download and execution using Msiexec |
| 13 | +DeviceProcessEvents |
| 14 | +| where Timestamp > ago(7d) |
| 15 | +//MSIExec |
| 16 | +| where FileName =~ "msiexec.exe" and |
| 17 | +//With domain in command line |
| 18 | +(ProcessCommandLine has "http" and ProcessCommandLine has "return")//Find PowerShell running files from the temp folder |
| 19 | +
|
| 20 | +DeviceProcessEvents |
| 21 | +| where Timestamp > ago(7d) |
| 22 | +//Looking for PowerShell |
| 23 | +| where FileName =~ "powershell.exe" |
| 24 | +//Looking for %temp% in the command line indicating deployment |
| 25 | +and ProcessCommandLine contains "%temp%"//Find credential theft attempts using Msiexec to run Mimikatz commands |
| 26 | +
|
| 27 | +DeviceProcessEvents |
| 28 | +| where Timestamp > ago(7d) |
| 29 | +| where InitiatingProcessFileName =~ "msiexec.exe" |
| 30 | +//Mimikatz commands |
| 31 | +and (ProcessCommandLine contains "privilege::" |
| 32 | +or ProcessCommandLine has "sekurlsa" |
| 33 | +or ProcessCommandLine contains "token::") |
| 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 | v | | |
| 44 | +| Persistence | | | |
| 45 | +| Privilege escalation | v | | |
| 46 | +| Defense evasion | | | |
| 47 | +| Credential Access | v | | |
| 48 | +| Discovery | | | |
| 49 | +| Lateral movement | | | |
| 50 | +| Collection | | | |
| 51 | +| Command and control | | | |
| 52 | +| Exfiltration | | | |
| 53 | +| Impact | | | |
| 54 | +| Vulnerability | | | |
| 55 | +| Misconfiguration | | | |
| 56 | +| Malware, component | | | |
| 57 | + |
| 58 | +## Contributor info |
| 59 | + |
| 60 | +**Contributor:** Microsoft Threat Protection team |
0 commit comments