我正在尝试使用 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).
这是怎么回事?
注意:在 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
我的应用程序正确启动,并以低完整性级别运行:
虽然我可以使用 AddMandatoryAce
API,或者我自己摆弄安全 token 中的 ACL,我很好奇 UNTRUSTED
更安全的级别是怎么回事 - 以及为什么我无法启动任何东西。
注意:在 Windows 7 上,如果您将 calc
或 notepad
标记为 /setintegritylevel low
,它们将无法执行启动(没有错误,只是永远不会出现),甚至 though this MSDN article talks about using calc as a test of low integrity level :
最佳答案
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/