BadUSB HID injection PowerShell via Windows Run dialog
Description
Identifies PowerShell spawned by explorer.exe with a hidden window and a remote-execution or evasion flag. Consistent with BadUSB HID injection opening the Windows Run dialog via WIN+R; the explorer.exe parent is the keystroke- injection signal.
Query · kql
let timeframe = 1d;
let EvasionFlags = dynamic([
"-NoProfile",
"-NonInteractive",
"-EncodedCommand",
"DownloadString",
"IEX",
"Invoke-Expression",
"WebClient",
"Start-Process"
]);
DeviceProcessEvents
| where TimeGenerated >= ago(timeframe)
| where FileName in~ ("powershell.exe", "pwsh.exe")
| where InitiatingProcessFileName =~ "explorer.exe"
| where ProcessCommandLine has_all ("-WindowStyle", "Hidden")
| where ProcessCommandLine has_any (EvasionFlags)
or ProcessCommandLine has_all ("-ExecutionPolicy", "Bypass")
| extend AccountCustomEntity = AccountName
| extend HostCustomEntity = DeviceName
| project
TimeGenerated,
DeviceName,
HostCustomEntity,
AccountName,
AccountCustomEntity,
AccountDomain,
ProcessCommandLine,
InitiatingProcessFileName,
InitiatingProcessCommandLine,
ReportId
| sort by TimeGenerated desc