PowerShell 编码命令失败

PSHelper12

我正在尝试使用 Powershell 的 -EncodedCommand 标志弹出一个简单的消息框,但它一直失败。在过去的几个小时里,我试过谷歌搜索,但似乎无法正常工作。它几乎看起来像是编码错误,但我使用的是带有标准 ASCII 向后兼容字符的常规 UTF-8。

不断失败的命令:

Powershell.exe -EncodedCommand QWRkLVR5cGUgLUFzc2VtYmx5TmFtZSBQcmVzZW50YXRpb25Db3JlLFByZXNlbnRhdGlvbkZyYW1ld29yaztbU3lzdGVtLldpbmRvd3MuTWVzc2FnZUJveF06OlNob3coJ3dvcmtpbmcnKTs=

b64解码后的命令是:

Add-Type -AssemblyName PresentationCore,PresentationFramework;[System.Windows.MessageBox]::Show('working');

我错过了什么?感谢您帮助解决我的菜鸟问题

克莱门特0

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

$cmd = 'Add-Type -AssemblyName PresentationCore,PresentationFramework;[System.Windows.MessageBox]::Show(''working'')'
$encodedCmd = [Convert]::ToBase64String([System.Text.Encoding]::Unicode.GetBytes($cmd))

powershell.exe -EncodedCommand $encodedCmd

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章