| 1 |
// MakeNotWork - encoded / obfuscated PowerShell stagers. |
| 2 |
// Distinct from the plaintext `suspicious_script_in_binary` rule: this targets |
| 3 |
// the base64 / -EncodedCommand form used to hide a downloader from casual |
| 4 |
// inspection. Multi-token conditions keep these off legitimate scripting docs |
| 5 |
// and code samples — an encoded blob alone is benign; an encoded blob next to |
| 6 |
// a download+execute primitive is the stager shape. |
| 7 |
|
| 8 |
rule encoded_powershell_stager { |
| 9 |
meta: |
| 10 |
description = "Base64/encoded PowerShell paired with download or in-memory exec" |
| 11 |
strings: |
| 12 |
$enc1 = "-EncodedCommand" ascii nocase |
| 13 |
$enc2 = "-enc " ascii nocase |
| 14 |
$enc3 = "FromBase64String" ascii nocase |
| 15 |
$exec1 = "IEX" ascii |
| 16 |
$exec2 = "Invoke-Expression" ascii nocase |
| 17 |
$exec3 = "DownloadString" ascii nocase |
| 18 |
$exec4 = "DownloadData" ascii nocase |
| 19 |
$ps = "powershell" ascii nocase |
| 20 |
condition: |
| 21 |
$ps and (1 of ($enc*)) and (1 of ($exec*)) |
| 22 |
} |
| 23 |
|