Powershell 没有正确解码 base64 命令

Powershell not decoding base64 command correctly

我完全不明白为什么会这样。

当我按原样 运行 时,下面的 powershell 脚本工作正常:

$test=New-Object IO.MemoryStream(,[Convert]::FromBase64String("base64 string"));IEX (New-Object IO.StreamReader(New-Object IO.Compression.GzipStream($test,[IO.Compression.CompressionMode]::Decompress))).ReadToEnd();

然而,当我将脚本 base64 并 运行 它与 powershell 作为编码命令时,我得到以下信息:

powershell.exe -encodedcommand <Base64string>

(GZIP encoded Content) is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again

At line:1 char:1
+ (GZIP Encoded Content)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : ObjectNotFound: (GZIP Encoded Content:STring [], CommandNotFoundException)
+ FullyQualifiedErrorId : CommandNotFoundException

据我所知,它没有执行脚本的 IEX 部分,也没有解码 gzip 内容:

IEX (New-Object IO.StreamReader(New-Object IO.Compression.GzipStream($new,[IO.Compression.CompressionMode]::Decompress))).ReadToEnd()

是分号 (;) 解析不正确,还是我在做假动作?

对不起大家,我是假人。

传递给 -EncodedCommand 的 Base64 编码字符串必须对 UTF-16LE(“Unicode”)字符串的字节表示形式进行编码。不支持 UTF-8。

经过更多的谷歌搜索,我发现了这个: