以 NT AUTHORITY\SYSTEM 身份运行 PowerShell 命令

以 NT AUTHORITY\SYSTEM 身份运行 PowerShell 命令

有没有办法NT AUTHORITY\SYSTEM从脚本中运行 PowerShell 命令?
我知道我可以使用psexec并以 的身份运行 PowerShell 提示符NT AUTHORITY\SYSTEM,但我想知道是否有办法从“普通”脚本中执行此操作。

答案1

您可以使用调用-TokenManipulation.ps1脚本:

此脚本需要管理员权限。它可以枚举可用的登录令牌并使用它们创建新进程。这允许您通过使用其登录令牌创建进程,通过网络使用其他用户的凭据。即使在 Windows 8.1 LSASS 保护下,这也将有效。

复制粘贴或与脚本一起保存Invoke-TokenManipulation.ps1并使用点源加载:

$ScriptDir = Split-Path $script:MyInvocation.MyCommand.Path
. (Join-Path -Path $ScriptDir -ChildPath 'Invoke-TokenManipulation.ps1')

然后您就可以使用Invoke-TokenManipulation函数了。

例子:

# This command fails on my machine, even with admin rights
Get-ChildItem C:\Windows\CSC

# Makes the current PowerShell thread impersonate SYSTEM.
Invoke-TokenManipulation -ImpersonateUser -Username "nt authority\system"

# Now we can get contents of this folder
Get-ChildItem C:\Windows\CSC

# Stop impersonating an alternate users Token
Invoke-TokenManipulation -RevToSelf

# Check again
Get-ChildItem C:\Windows\CSC

答案2

https://github.com/mkellerman/Invoke-CommandAs

针对本地/远程计算机,创建了以 SYSTEM 或提供凭据身份调用命令的函数。返回 PSObjects、处理网络中断并解决任何双跳问题。

尝试一下,如果这能解决您的问题请告诉我。

相关内容