Back to hub

Basic PowerShell Encoded Command Detection

Query for junior SOC analysts that detects PowerShell executions with the -EncodedCommand flag, a common LotL technique for obfuscating malicious commands and evading plaintext signature-based detections

EDRpowershellencoded-commandbeginnerlotlT1059.001T1027
FDR Beginnerby CQL Hub 1 min read

Query

#repo="base_sensor" #event_simpleName=ProcessRollup2
| FileName=/(?i)powershell\.exe/
| CommandLine=/(?i)(-enc|-encodedcommand|-ec\s)/
| groupBy([ComputerName, UserName, ParentBaseFileName], function=[count(as=encoded_runs)])
| sort(encoded_runs, order=desc, limit=20)

Explanation

PipeDescripción
#repo="base_sensor" #event_simpleName=ProcessRollup2Eventos de creacion de procesos del sensor Falcon
FileName=/(?i)powershell\.exe/Filtra solo ejecuciones de PowerShell
`CommandLine=/(?i)(-enc\-encodedcommand\-ec\s)/`Detecta variantes del flag de comando codificado en Base64
groupBy([ComputerName, UserName, ParentBaseFileName], ...)Agrupa por host, usuario y proceso padre para contexto
sort(encoded_runs, order=desc, limit=20)Ordena por frecuencia para priorizar investigacion

Adjustable Variables

Se puede agregar un filtro ParentBaseFileName!=/(?i)svchost\.exe/ para excluir procesos del sistema. El limit puede aumentarse para entornos grandes.