UAC 提示提升 - 它是如何工作的?

发布于 2024-12-10 16:49:26 字数 292 浏览 0 评论 0原文

当需要执行某些与安全相关的操作时,Windows会在“安全桌面”上显示UAC提示。显然有一些 API 可以创建安全桌面并在其上创建窗口,但我不知道在哪里可以找到涉及的机制。我想我可以对 UAC 机制进行逆向工程,但我不太擅长这种水平的逆向工程(而且我很确定其中涉及一些法律后果......)

无论如何,我知道有一个 API 可以创建新桌面在当前会话中,但我能找到的任何文档中都没有提到安全桌面。出于好奇,我想知道整个安全桌面/UAC 提示创建是如何工作的。

免责声明:这纯粹是理论上的,我不打算在我的任何代码中部署它。

Windows displays UAC prompts on the "secure desktop" when certain security-related operations need to be performed. There's obviously some API somewhere that creates the secure desktop and creates a window on it, but I have no idea where I would find out about the mechanisms involved. I guess I could reverse engineer the UAC mechanisms, but I'm not that good at that level of reverse engineering (and I'm pretty sure there's some legal ramifications involved...)

Anyway, I know there's an API to create new desktops on the current session, but there's no mention of secure desktops in any documentation I can find. Out of curiosity, I'd like to know how the whole secure desktop / UAC prompt creation works.

Disclaimer: This is purely theoretical, and I'm not looking to deploy this in any of my code.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

甜扑 2024-12-17 16:49:26

从系统的角度来看,安全桌面似乎只是一个具有适当 ACL 的完全正常的桌面。请注意,CreateDesktop 允许您为新桌面指定安全描述符。

据我所知,安全桌面没有特殊行为,因此我认为没有理由假设涉及任何其他 API(记录或未记录)。

It seems likely that, from the point of view of the system, the secure desktop is just a perfectly normal desktop with a suitable ACL. Note that CreateDesktop allows you to specify a security descriptor for the new desktop.

So far as I know, the secure desktop has no special behaviour, so I see no reason to suppose that any additional API (documented or not) is involved.

凉城 2024-12-17 16:49:26

您可能已经看到了这一点,但以防万一,对于阅读本文的其他用户,这里有一个关于 UAC 架构的漂亮流程图......

http://msdn.microsoft.com/en-us/library/bb756945.aspx

至于 UAC 据我所知的所有信息如何UAC 是在链接阶段与嵌入在 exe 或 dll 中的清单中的特定应用程序一起工作的。

由于 .Net 发生变化,即使是非 .Net 应用程序也需要有一个清单来告诉 Windows 它们不是 .Net。在较新版本的 Visual Studio 中构建的所有内容(或者至少是我构建的版本)在链接器选项的清单部分中都有多种 UAC 选项,包括允许禁用它的选项。

You may have seen this but just in case, and for other users reading this, there is a nice flow chart here on the UAC Architecture here....

http://msdn.microsoft.com/en-us/library/bb756945.aspx

As for UAC as far as I know all of the information for how UAC is to work with a specific application is in the manifest which embedded in the exe or dll in the linking phase.

Since the .Net change, even non-.Net applications are required to have a manifest in them to tell Windows that they are not .Net. Everything built in the newer versions of Visual Studio, or at least the ones that I have built in, have a wide range of UAC options in the manifest section of the linker options, including ones which allow you to disable it.

土豪 2024-12-17 16:49:26

有一个 UAC 克隆,其源代码也可以在 XP 上运行。它称为 SuRun,并包含更多功能,例如特定应用程序的自动提升。

博客和文档为德语:http://kay-bruns.de/wp/software/surun< /a>
德语文档包含大量详细信息:
http://kay-bruns.de/download/SuRun1209。 pdf

Sourceforge 页面:http://sourceforge.net/projects/surun/
它是C++

There is a UAC clone with source that also works on XP. It is called SuRun and contains some more features like automatic elevation for specific apps.

Blog and docs are in German : http://kay-bruns.de/wp/software/surun
The German docs contains lots of detailed information: http://kay-bruns.de/download/SuRun1209.pdf

Sourceforge Page: http://sourceforge.net/projects/surun/
It is C++

过期情话 2024-12-17 16:49:26

Windows 中启动进程的方式是使用CreateProcess

CreateProcess 执行 3 个检查来查看应用程序是否需要提升:

  • 应用程序要求运行提升的 (requestedExecutionLevel=requireAdministrator)
  • 启发式认为该应用程序可能是一个安装程序(例如名为 setup.exe, installer.exe, update.exe) (可以通过组策略禁用)
  • AppCompat 表示该狗屎应用程序需要 升高

如果 CreateProcess 决定进程需要以管理员权限启动,而用户当前没有管理员权限,它会失败并返回错误:

ERROR_ELEVATION_REQUIRED (740)

ShellExecute 知道如何处理这个新的错误代码

ShellExecuteCreateProcess 的更高级别包装器。它知道如何处理来自CreateProcess的新错误代码。

ShellExecute 是调用AppInfo(应用程序信息)服务的函数。 AppInfo 服务启动 Consent.exe,这是 UAC 提示符。它执行提升。

  • 如果用户是管理员且管理权限被拒绝,则提示授权;
  • 如果用户是标准用户,则提示输入凭据

AppInfo 启动新进程,并且 ShellExecute 返回。

The way a process is launched in Windows is using CreateProcess.

CreateProcess performs 3 checks to see if the application requires elevation:

  • the application asks to run elevated (requestedExecutionLevel=requireAdministrator)
  • a heuristic thinks the app might be an installer (e.g. named setup.exe, installer.exe, update.exe) (which can be disabled by group policy)
  • AppCompat says that the shit application needs to be elevated

If CreateProcess decides the process needs to be launched with administrator privileges, and the user doesn't currently have administrator privileges, it fails and returns the error:

ERROR_ELEVATION_REQUIRED (740)

ShellExecute knows how to handle this new error code

ShellExecute is a higher level wrapper around CreateProcess. It knows how to handle this new error code from CreateProcess.

ShellExecute is the function that calls into the AppInfo (Application Information) service. AppInfo service launches Consent.exe, which is the UAC prompt. And it performs the elevation.

  • if the user is an administrator with admin privileges denied, it prompts for authorization
  • if the user is a standard user, it prompts for credentials

AppInfo launches the new process, and ShellExecute returns.

Source

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文