security - SaferCreateLevel SAFER_LEVELID_UNTRUSTED : The application was unable to start correctly (0xc0000142)

标签 security winapi uac

我正在尝试使用 SaferCreateLevel 将一个进程(任何 进程)启动为“不受信任”使用 SAFER_LEVELID_UNTRUSTED 更安全的级别:

Allows programs to execute with access only to resources granted to open well-known groups, blocking access to Administrator and Power User privileges and personally granted rights.

使用 Michael Howards DropMyRights MDSN 文章 (Browsing the Web and Reading E-mail Safely as an Administrator) 中的代码,伪代码是:

//get a handler on a Safer level
hSaferLevel = SaferCreateLevel(SAFER_SCOPEID_USER, SAFER_LEVELID_UNTRUSTED);

//Create a security token out of the safer level handle
hSecurityToken = SaferComputeTokenFromLevel(hSaferLevel);

//Create process as user
CreateProcessAsUser(hSecurityToken, "myapp.exe");

除了进程启动失败:

The application was unable to start correctly (0xc0000142).

enter image description here

这是怎么回事?

注意:在 SAFER_LEVELID_NORMALUSER 启动进程工作正常:

Allows programs to execute as a user that does not have Administrator or Power User user rights. Software can access resources accessible by normal users.

虽然现在每个人都已经作为“普通用户”运行,但它没有什么值(value)。


我的应用程序能够以“低级”用户的身份运行。

最终目标是以与 MandatoryIntegrity\Low 进程相同的特权运行进程(尽管未标记为“低”)。所以我测试了。

我使用 icacls 来标记 my application to run Mandatory Integrity Level\Low :

C:\Develop>icacls RTMS.exe /setintegritylevel Low
processed file: RTMS.exe
Successfully processed 1 files; Failed processing 0 files

我的应用程序正确启动,并以低完整性级别运行:

enter image description here

虽然我可以使用 AddMandatoryAce API,或者我自己摆弄安全 token 中的 ACL,我很好奇 UNTRUSTED 更安全的级别是怎么回事 - 以及为什么我无法启动任何东西。

注意:在 Windows 7 上,如果您将 calcnotepad 标记为 /setintegritylevel low,它们将无法执行启动(没有错误,只是永远不会出现),甚至 though this MSDN article talks about using calc as a test of low integrity level :

enter image description here

最佳答案

0xc0000142 = STATUS_DLL_INIT_FAILED

也许 Process Monitor会给你一些线索吗?

UNTRUSTED 对于大多数事情来说可能太受限制了。您无法访问自己的个人资料,例如:

  • HKEY_CURRENT_USER
  • %温度%

您是否尝试过CONSTRAINED

另一种选择是使用 CreateRestrictedToken并计算一个刚好足够严格的 token 。

我猜 MS 有点忘记了 NT6 中的 Safer*Level 功能,我们取而代之的是 UAC。 (XP 上的 RunAs GUI 对话框有保护我的计算机选项,但该对话框现在消失了(即使在 XP 中,大多数情况下也是 too restrictive))

关于security - SaferCreateLevel SAFER_LEVELID_UNTRUSTED : The application was unable to start correctly (0xc0000142),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6441788/

相关文章:

c++ - 以标准用户身份打开默认浏览器 (C++)

selenium - docker selenium远程服务器如何阻止或将ips列入白名单

database - 在哪里存储密码盐以及如何获取它

javascript - C++,win32 API : How to create an html rendering window so that your application would get callbacks from JS calls?

c - 预响应参数 WTSSendMessage

windows-vista - 禁用每个应用程序的 Vista UAC,或在没有提示的情况下提升权限?

emacs - 如何在 Windows 上的 emacs 中切换到管理员用户?

php - 防止 SQL 注入(inject)

java - AccessController.doPrivileged 是否为 JavaScript 线程提供已签名 Applet 的权限?

c - "HANDLE"与类型为 "HINSTANCE"的参数不兼容