Defense Evasion (TA0005)(external, opens in a new tab or window)
text code block:event.category:process and host.os.type:windows and powershell.file.script_block_text : ( "[string]::join" or "-Join" or "[convert]::toint16" or "[char][int]$_" or ("ConvertTo-SecureString" and "PtrToStringAuto") or "-BXor" or ("replace" and "char") or "[array]::reverse" or "-replace" ) and powershell.file.script_block_text : ( ("$pSHoMe[" and "+$pSHoMe[") or ("$ShellId[" and "+$ShellId[") or ("$env:ComSpec[4" and "25]-Join") or (("Set-Variable" or "SV" or "Set-Item") and "OFS") or ("*MDR*" and "Name[3,11,2]") or ("$VerbosePreference" and "[1,3]+'X'-Join''") or ("rahc" or "ekovin" or "gnirts" or "ecnereferpesobrev" or "ecalper" or "cepsmoc" or "dillehs") or ("System.Management.Automation.$([cHAr]" or "System.$([cHAr]" or ")+[cHAR]([byte]") ) and not powershell.file.script_block_text : ( ("Copyright (c) 2018 Ansible Project" or "Export-ModuleMember -Function Add-CSharpType") and ("[Object]$AnsibleModule" or "$AnsibleModule.Tmpdir") )
Install detection rules in Elastic Security
Detect Potential PowerShell Obfuscated Script in the Elastic Security detection engine by installing this rule into your Elastic Stack.
To setup this rule, check out the installation guide for Prebuilt Security Detection Rules(external, opens in a new tab or window).