【问题标题】:Powershell Encoded Command not executingPowershell编码命令未执行
【发布时间】:2018-12-24 08:05:55
【问题描述】:

我有一个 powershell 脚本,它作为 installshield 安装程序的一部分在装有 Windows 10 的机器上运行。Powershell 版本(主要:5,次要:1,内部版本 17134,修订版 112)。开发机器(一切正常)(主要:5,次要:1,Build 15063,Revision 1155)

基本上,一个 .bat 脚本运行一个编码的 powershell 命令,但它没有执行,我将它简化为一个简单的脚本来显示我在说什么:

Powershell 脚本:

$text="Write-Output Hello"
$encoded=[Convert]::ToBase64String([System.Text.Encoding]::Unicode.GetBytes($text))

Write-Output "Trying encoded command:"
powershell -EncodedCommand $encoded

Write-Output "Trying not encoded command:"
powershell $text

这是输出:

Trying encoded command:
Trying not encoded command:
Hello

我还添加了一个解码语句来做一个额外的检查:

$decoded = [System.Text.Encoding]::Unicode.GetString([Convert]::FromBase64String($encoded))
Write-Output "Decoded:"
Write-Output $decoded

输出:

Trying encoded command:
Trying not encoded command:
Hello
Decoded:
Write-Output Hello

执行策略设置为“绕过”,我只是想知道 Windows 注册表/设置/安全/组策略/等中是否有某些内容。会阻止这样的编码命令吗?为什么它可以在纯文本中工作而不是编码? Powershell版本与它有什么关系吗?

【问题讨论】:

  • 您是否收到任何错误消息?尝试将$ErrorActionPreference = 'Stop'; 放入$text 并重试。您还可以检查事件查看器以查看是否有任何启发式方法正在运行?
  • @TheIncorrigible1 我把它放在脚本的第一行?执行此操作时,我没有看到任何错误。
  • 您的原始命令对我有用。您是否有阻止编码命令的防病毒引擎?
  • @TessellatingHeckler 我该如何检查?
  • 您是否安装了任何 AV 软件,它是否显示其控制台中有任何被阻止的内容?

标签: powershell windows-10 installshield group-policy


【解决方案1】:

原来在编码命令上存在来自 AV 的块。谢谢@TessellatingHeckler

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-03
    • 1970-01-01
    • 2021-07-28
    • 1970-01-01
    • 2021-01-12
    相关资源
    最近更新 更多