gpt4 book ai didi

PowerShell 执行策略被 powershell.exe 参数破坏

转载 作者:行者123 更新时间:2023-12-03 17:03:56 25 4
gpt4 key购买 nike

在 PowerShell 中,除了试图控制哪些脚本文件可以运行之外,限制性执行策略是否还有优势?

默认情况下,不允许运行 PowerShell 脚本,但似乎如果恶意方想要运行 PowerShell 脚本,他们可以使用调用 PowerShell 并将 -ExecutionPolicy 参数设置为“绕过”的 BAT 文件引导进入该脚本.

我是不是遗漏了什么,或者这是否破坏了执行策略机制?当您可以减少执行策略的限制时,为什么要签署脚本(looks like quite a hassle)?

下面是我编写的 BAT 脚本,它创建一个未签名的 .ps1 文件并运行它。它在执行策略为 Restricted 的机器上运行,该策略应该禁止脚本。 UAC处于开启状态且不显示提升提示。它甚至拨出到 Internet 并获得 "Hey, Scripting Guy!" 的最新标题。博客。

echo write-host "`r`nPowershell code running on $(hostname).`r`n`r`nHere's the latest headline from the 'Hey, Scripting Guy!' blog: '$(([xml](New-Object Net.WebClient).DownloadString("http://blogs.technet.com/b/heyscriptingguy/atom.aspx")).feed.entry[0].title)'.`r`n`r`nPress Enter to close.`r`n"; read-host > script.ps1
powershell -ExecutionPolicy bypass -Command .\script.ps1

最佳答案

执行策略将防止某人修改由其他人运行的现有脚本,或作为自动化过程(例如计划任务)。从安全的角度来看,使用 .bat 文件与将代码编译成 .exe 没有什么不同。

此外,-ExecutionPolicy 参数在 the execution policy is set via local/group policy 时不起作用。在机器上(根据 Ansgar 对问题的评论)。

关于PowerShell 执行策略被 powershell.exe 参数破坏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21615696/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com