【问题标题】:Windows 10: after gaining remote access, remotely start Quick Assist as .\Administrator without UAC, or temporarily disable UACWindows 10:获得远程访问权限后,远程启动 Quick Assist 为 .\Administrator without UAC,或暂时禁用 UAC
【发布时间】:2021-06-29 09:56:04
【问题描述】:

我想在这种情况下使用脚本

  1. 无需管理员权限即可获得远程访问权限
  2. .\Administrator 的身份远程启动 Quick Assist 而不是进行 UAC 对话。

第 1 步通常使用 Quick Assist,有时使用 Teams 屏幕共享。


我知道我可以在文件资源管理器中找到 quickassist.exe,然后使用 Shift 和上下文菜单来以其他用户身份运行,但我想脚本化方法。

实验A

这可行,但有一个是/否 UAC 对话:

$isElevated = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
if ( -not $isElevated ) {
    Start-Process powershell.exe -Credential Administrator -NoNewWindow -ArgumentList {
        Start-Process quickassist.exe -Verb RunAs ;
    } ;
}

实验 B

我犯了很多错误,不知道如何改正。 (我正在尝试逐步学习 PowerShell,但我在学习时很容易感到困惑;有点阅读障碍。)

$isElevated = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)

if ( -not $isElevated ) {
  Start-Process powershell.exe -Credential Administrator {
    Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -Name "PromptOnSecureDesktop" -Value 0 -Force;
    };
  Write-Host "UAC (user account control) is weakened for a Quick Assist session …" -ForegroundColor Red;

  Start-Process powershell.exe -Credential Administrator -NoNewWindow -ArgumentList {Start-Process quickassist.exe -Verb RunAs -Wait};
  Write-Host "… Quick Assist session complete …" -ForegroundColor Red;

  Start-Process powershell.exe -Credential Administrator {
    Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -Name "PromptOnSecureDesktop" -Value 1 -Force;
    };
  Write-Host "… UAC is strengthened." -ForegroundColor Red;
}
  • 未发生对注册表的两项预期更改
  • 第三个凭据对话框出现得太快了 - 我希望它在快速协助会话结束之前出现。

此外,从概念上讲,当 UAC 暂时被削弱时,可能不需要以管理员身份运行 Quick Assist。

参考文献

https://stackoverflow.com/a/2258134/38108 (2010-02-13) 我看到 -CredentialInvoke-Command 一起使用,但是当我尝试做类似的事情时,为了更改注册表,我搞砸了。

https://stackoverflow.com/a/47516161/38108 (2017-11-27) 自升式 PowerShell 脚本。

https://superuser.com/a/1524960/84988 (2020-02-12) 和 https://serverfault.com/a/1003238/91969 (2020-02-15) 很有趣——两个答案中的脚本相同——但是我需要像 -Credential Administrator 这样的东西来代替 -ComputerName

https://stackoverflow.com/a/60292423/38108 (2020-03-07) 通过https://stackoverflow.com/a/60263039/38108

PowerShell commands - PowerShell - SS64.com

https://github.com/okieselbach/Intune/blob/master/DisablePromptOnSecureDesktop.ps1 (2020-11-13) 通过Quick Assist the built-in Remote Control in Windows 10 – Modern IT – Cloud – Workplace

【问题讨论】:

  • 当你使用这样的逻辑时它是否有效...pastebin.com/YTHKn72Y。在示例 b 中的另一个启动进程中存在启动进程,因此 -wait 参数可能需要与外部启动进程而不是内部启动进程一起使用。我通常不会在任何本地计算机上运行它,它总是在远程计算机上运行,​​我将帮助非管理员用户在同一网络上执行任务并连接到同一域。您不能针对您正在连接的远程计算机远程调用命令吗?
  • 还有用于禁用安全桌面的 reg 设置,以允许您查看 UAC 并自己输入凭据,而不是让非管理员用户输入它们,您会看到 UAC 屏幕远程需求并与之交互无论它是提升还是以管理员身份运行,都运行。从isElevated 逻辑中取出该逻辑并始终在没有任何条件的情况下运行它,然后在没有条件的情况下重新启用其他 reg 设置。看看这些东西是否有帮助。
  • UAC 旨在防止您这样做。 (如果 UAC 这么容易绕过,那么这正是所有恶意软件都会做的事情。)
  • Bill_Stewart 你误会了。我没有试图绕过身份验证对话。
  • 好的,如果您更喜欢这个术语,UAC 旨在仅在显示请求此权限的对话框后才允许提升。 (如果这是可能的,那么所有恶意软件都可以以管理员身份感染您的计算机而不受惩罚。)

标签: windows powershell uac remote-desktop user-account-control


【解决方案1】:

简短的回答是不要。获取真正的远程管理工具或让某人点击 UAC 是提示。

这比 powershell 更像是一个 windows 的东西,因为 windows 明确拒绝在不通过 UAC 的情况下本地提升进程(并且有充分的理由!)。你曾经能够做这样的事情:

# Use Enter-PSSession to start a "remote" session 
# This may still support elevation if you specify CredSSP and configure credential delegation):
New-PSSession MyPCName -Auth CredSSP -cred (get-credential)

# Create a scheduled task with RunAs/elevated permissions:
Register-ScheduledTask -Action $action -User .\Administrator -TaskName "Admin-Stuff" -RunLevel Highest

现在在本地运行时会显示胖访问被拒绝消息。您也无法在没有提升的情况下编辑 HKLM: 中的注册表设置,因此暂时禁用 uac 不是一种选择。

您也许可以利用这个exploit 允许管理员用户绕过 uac,但我认为您仍然必须以其他用户身份运行您的 shell 才能使用它。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-06-15
    • 2013-09-20
    • 2012-06-16
    • 2013-12-24
    • 2015-11-01
    • 1970-01-01
    • 2011-05-21
    相关资源
    最近更新 更多