67

在 Windows 7 上,我有一个命令行程序由于文件写入权限错误而失败,并且每次运行来自“未知发布者”的命令行程序时都会弹出烦人的UAC对话框。

但是,如果我通过右键单击并选择“以管理员身份运行”来启动我的控制台,那么即使 UAC 对话框仍然存在,安装也可以正常工作。

我的用户已经是“管理员”组的成员,那么“以管理员身份运行”究竟做了什么才能使我的安装工作?

我的具体问题正是:“以管理员身份运行”是做什么的?到目前为止,这两个答案都没有解决这个问题。(例如,它是以“管理员”用户身份运行新进程吗?还是以当前用户身份运行该进程,但具有提升的特权?如果是这样,什么特权?这与我从我的用户在“管理员”组中?

(具体来说,我使用的是SourceForge中的“控制台” ,而不是常规的 CMD 窗口,但我认为这并不重要。这一切都是通过在从 python.org 新安装的 Python3 MSI。它是 64 位 Windows 上的 32 位 Python。请参阅在 Windows 7 上安装 Python 和分发会给出“写入失败...权限被拒绝”

4

8 回答 8

108

当您登录 Windows 时,会创建一个访问令牌。这可以识别您、您所属的组以及您的权限。请注意,用户是否为管理员取决于该用户是否为 Administrators 组的成员。

如果没有 UAC,当您运行程序时,它会获取访问令牌的副本,这将控制程序可以访问的内容。

使用 UAC,当您运行程序时,它会获得受限访问令牌。这是从组列表中删除“管理员”的原始访问令牌(以及一些其他更改)。即使您的用户是管理员组的成员,该程序也不能使用管理员权限。

当您选择“以管理员身份运行”并且您的用户是管理员时,程序将使用原始的无限制访问令牌启动。如果您的用户不是管理员,系统会提示您输入管理员帐户,并且程序在该帐户下运行。

于 2012-01-24T13:58:55.260 回答
10

所以......更多的挖掘,结果。似乎虽然我运行了一个正常进程和一个“以管理员身份”运行,但我关闭了 UAC。将 UAC 转为中等让我看到了不同的结果。基本上,这一切都归结为完整性级别,即 5。

例如,浏览器在低级别 (1) 运行,而服务(系统用户)在系统级别 (4) 运行。一切都在Windows Integrity Mechanism Design中得到了很好的解释。启用 UAC 时,使用中级别(添加 SID S-1-16-8192 AKA 0x2000)创建进程,而当“以管理员身份运行”时,创建高级级别(SID S-1-16-12288 aka 0x3000)。

因此,普通用户(中等完整性级别)的正确 ACCESS_TOKEN 是:

0:000:x86> !token
Thread is not impersonating. Using process token...
TS Session ID: 0x1
User: S-1-5-21-1542574918-171588570-488469355-1000
Groups:
 00 S-1-5-21-1542574918-171588570-488469355-513
    Attributes - Mandatory Default Enabled
 01 S-1-1-0
    Attributes - Mandatory Default Enabled
 02 S-1-5-32-544
    Attributes - DenyOnly
 03 S-1-5-32-545
    Attributes - Mandatory Default Enabled
 04 S-1-5-4
    Attributes - Mandatory Default Enabled
 05 S-1-2-1
    Attributes - Mandatory Default Enabled
 06 S-1-5-11
    Attributes - Mandatory Default Enabled
 07 S-1-5-15
    Attributes - Mandatory Default Enabled
 08 S-1-5-5-0-1908477
    Attributes - Mandatory Default Enabled LogonId
 09 S-1-2-0
    Attributes - Mandatory Default Enabled
 10 S-1-5-64-10
    Attributes - Mandatory Default Enabled
 11 S-1-16-8192
    Attributes - GroupIntegrity GroupIntegrityEnabled
Primary Group:   LocadDumpSid failed to dump Sid at addr 000000000266b458, 0xC0000078; try own SID dump.
s-1-0x515000000
Privs:
 00 0x000000013 SeShutdownPrivilege               Attributes -
 01 0x000000017 SeChangeNotifyPrivilege           Attributes - Enabled Default
 02 0x000000019 SeUndockPrivilege                 Attributes -
 03 0x000000021 SeIncreaseWorkingSetPrivilege     Attributes -
 04 0x000000022 SeTimeZonePrivilege               Attributes -
Auth ID: 0:1d1f65
Impersonation Level: Anonymous
TokenType: Primary
Is restricted token: no.

现在,区别如下:

S-1-5-32-544
Attributes - Mandatory Default Enabled Owner

对于“作为管理员”,而

S-1-5-32-544
Attributes - DenyOnly

对于非管理员。

请注意,S-1-5-32-544 是 BUILTIN\Administrators。此外,特权更少,最重要的是要注意:

行政:

S-1-16-12288
Attributes - GroupIntegrity GroupIntegrityEnabled

而对于非管理员:

S-1-16-8192
Attributes - GroupIntegrity GroupIntegrityEnabled

我希望这有帮助。

进一步阅读: http: //www.blackfishsoftware.com/blog/don/creating_processes_sessions_integrity_levels

于 2013-03-19T10:08:53.067 回答
3

更新

“以管理员身份运行”只是一个命令,使程序能够继续一些需要管理员权限的操作,而不显示 UAC 警报。

即使您的用户是管理员组的成员,像您这样的某些应用程序也需要管理员权限才能继续运行,因为如果应用程序正在执行某些特殊操作(例如编辑系统文件或其他内容),则认为该应用程序不安全。这就是为什么 Windows 需要管理员权限才能执行应用程序并通过 UAC 警报通知您的原因。并非所有应用程序都需要 Amnistrator 帐户才能运行,并且某些应用程序(例如您的应用程序)需要管理员权限。

如果您使用“以管理员身份运行”命令执行应用程序,您将通知系统您的应用程序是安全的,并在您确认后执行需要管理员权限的操作。

如果您想避免这种情况,只需在控制面板上禁用 UAC。

如果您想更进一步,请阅读Microsoft 论坛上的“以管理员身份运行”和 Windows 7 管理员组之间的区别问题或这个超级用户问题。

于 2012-01-24T13:18:39.010 回答
1

诸如“提升特权”、“受限访问令牌”、“管理员特权”之类的东西……管理员特权到底是什么?是胡说八道。

这是通常从属于管理员组的用户运行的进程的 ACCESS_TOKEN。

0: kd> !process 0 1 test.exe
PROCESS 87065030  SessionId: 1  Cid: 0d60    Peb: 7ffdf000  ParentCid: 0618
    DirBase: 2f22e1e0  ObjectTable: a0c8a088  HandleCount:   6.
    Image: test.exe
    VadRoot 8720ef50 Vads 18 Clone 0 Private 83. Modified 0. Locked 0.
    DeviceMap 8936e560
    Token                             935c98e0
0: kd> !token -n 935c98e0
_TOKEN 935c98e0
TS Session ID: 0x1
User: S-1-5-21-2452432034-249115698-1235866470-1000 (no name mapped)
User Groups: 
 00 S-1-5-21-2452432034-249115698-1235866470-513 (no name mapped)
    Attributes - Mandatory Default Enabled 
 01 S-1-1-0 (Well Known Group: localhost\Everyone)
    Attributes - Mandatory Default Enabled 
 02 S-1-5-32-544 (Alias: BUILTIN\Administrators)
    Attributes - Mandatory Default Enabled Owner 
 03 S-1-5-32-545 (Alias: BUILTIN\Users)
    Attributes - Mandatory Default Enabled 
 04 S-1-5-4 (Well Known Group: NT AUTHORITY\INTERACTIVE)
    Attributes - Mandatory Default Enabled 
 05 S-1-2-1 (Well Known Group: localhost\CONSOLE LOGON)
    Attributes - Mandatory Default Enabled 
 06 S-1-5-11 (Well Known Group: NT AUTHORITY\Authenticated Users)
    Attributes - Mandatory Default Enabled 
 07 S-1-5-15 (Well Known Group: NT AUTHORITY\This Organization)
    Attributes - Mandatory Default Enabled 
 08 S-1-5-5-0-85516 (no name mapped)
    Attributes - Mandatory Default Enabled LogonId 
 09 S-1-2-0 (Well Known Group: localhost\LOCAL)
    Attributes - Mandatory Default Enabled 
 10 S-1-5-64-10 (Well Known Group: NT AUTHORITY\NTLM Authentication)
    Attributes - Mandatory Default Enabled 
 11 S-1-16-12288 (Label: Mandatory Label\High Mandatory Level)
    Attributes - GroupIntegrity GroupIntegrityEnabled 
Primary Group: S-1-5-21-2452432034-249115698-1235866470-513 (no name mapped)
Privs: 
 05 0x000000005 SeIncreaseQuotaPrivilege          Attributes - 
 08 0x000000008 SeSecurityPrivilege               Attributes - 
 09 0x000000009 SeTakeOwnershipPrivilege          Attributes - 
 10 0x00000000a SeLoadDriverPrivilege             Attributes - 
 11 0x00000000b SeSystemProfilePrivilege          Attributes - 
 12 0x00000000c SeSystemtimePrivilege             Attributes - 
 13 0x00000000d SeProfileSingleProcessPrivilege   Attributes - 
 14 0x00000000e SeIncreaseBasePriorityPrivilege   Attributes - 
 15 0x00000000f SeCreatePagefilePrivilege         Attributes - 
 17 0x000000011 SeBackupPrivilege                 Attributes - 
 18 0x000000012 SeRestorePrivilege                Attributes - 
 19 0x000000013 SeShutdownPrivilege               Attributes - 
 20 0x000000014 SeDebugPrivilege                  Attributes - 
 22 0x000000016 SeSystemEnvironmentPrivilege      Attributes - 
 23 0x000000017 SeChangeNotifyPrivilege           Attributes - Enabled Default 
 24 0x000000018 SeRemoteShutdownPrivilege         Attributes - 
 25 0x000000019 SeUndockPrivilege                 Attributes - 
 28 0x00000001c SeManageVolumePrivilege           Attributes - 
 29 0x00000001d SeImpersonatePrivilege            Attributes - Enabled Default 
 30 0x00000001e SeCreateGlobalPrivilege           Attributes - Enabled Default 
 33 0x000000021 SeIncreaseWorkingSetPrivilege     Attributes - 
 34 0x000000022 SeTimeZonePrivilege               Attributes - 
 35 0x000000023 SeCreateSymbolicLinkPrivilege     Attributes - 
Authentication ID:         (0,14e4c)
Impersonation Level:       Anonymous
TokenType:                 Primary
Source: User32             TokenFlags: 0x2000 ( Token in use )
Token ID: d166b            ParentToken ID: 0
Modified ID:               (0, d052f)
RestrictedSidCount: 0      RestrictedSids: 00000000
OriginatingLogonSession: 3e7

...这是一个 ACCESS_TOKEN ,用于通常由同一用户使用“以管理员身份运行”运行的进程。

TS Session ID: 0x1
User: S-1-5-21-2452432034-249115698-1235866470-1000 (no name mapped)
User Groups: 
 00 S-1-5-21-2452432034-249115698-1235866470-513 (no name mapped)
    Attributes - Mandatory Default Enabled 
 01 S-1-1-0 (Well Known Group: localhost\Everyone)
    Attributes - Mandatory Default Enabled 
 02 S-1-5-32-544 (Alias: BUILTIN\Administrators)
    Attributes - Mandatory Default Enabled Owner 
 03 S-1-5-32-545 (Alias: BUILTIN\Users)
    Attributes - Mandatory Default Enabled 
 04 S-1-5-4 (Well Known Group: NT AUTHORITY\INTERACTIVE)
    Attributes - Mandatory Default Enabled 
 05 S-1-2-1 (Well Known Group: localhost\CONSOLE LOGON)
    Attributes - Mandatory Default Enabled 
 06 S-1-5-11 (Well Known Group: NT AUTHORITY\Authenticated Users)
    Attributes - Mandatory Default Enabled 
 07 S-1-5-15 (Well Known Group: NT AUTHORITY\This Organization)
    Attributes - Mandatory Default Enabled 
 08 S-1-5-5-0-85516 (no name mapped)
    Attributes - Mandatory Default Enabled LogonId 
 09 S-1-2-0 (Well Known Group: localhost\LOCAL)
    Attributes - Mandatory Default Enabled 
 10 S-1-5-64-10 (Well Known Group: NT AUTHORITY\NTLM Authentication)
    Attributes - Mandatory Default Enabled 
 11 S-1-16-12288 (Label: Mandatory Label\High Mandatory Level)
    Attributes - GroupIntegrity GroupIntegrityEnabled 
Primary Group: S-1-5-21-2452432034-249115698-1235866470-513 (no name mapped)
Privs: 
 05 0x000000005 SeIncreaseQuotaPrivilege          Attributes - 
 08 0x000000008 SeSecurityPrivilege               Attributes - 
 09 0x000000009 SeTakeOwnershipPrivilege          Attributes - 
 10 0x00000000a SeLoadDriverPrivilege             Attributes - 
 11 0x00000000b SeSystemProfilePrivilege          Attributes - 
 12 0x00000000c SeSystemtimePrivilege             Attributes - 
 13 0x00000000d SeProfileSingleProcessPrivilege   Attributes - 
 14 0x00000000e SeIncreaseBasePriorityPrivilege   Attributes - 
 15 0x00000000f SeCreatePagefilePrivilege         Attributes - 
 17 0x000000011 SeBackupPrivilege                 Attributes - 
 18 0x000000012 SeRestorePrivilege                Attributes - 
 19 0x000000013 SeShutdownPrivilege               Attributes - 
 20 0x000000014 SeDebugPrivilege                  Attributes - 
 22 0x000000016 SeSystemEnvironmentPrivilege      Attributes - 
 23 0x000000017 SeChangeNotifyPrivilege           Attributes - Enabled Default 
 24 0x000000018 SeRemoteShutdownPrivilege         Attributes - 
 25 0x000000019 SeUndockPrivilege                 Attributes - 
 28 0x00000001c SeManageVolumePrivilege           Attributes - 
 29 0x00000001d SeImpersonatePrivilege            Attributes - Enabled Default 
 30 0x00000001e SeCreateGlobalPrivilege           Attributes - Enabled Default 
 33 0x000000021 SeIncreaseWorkingSetPrivilege     Attributes - 
 34 0x000000022 SeTimeZonePrivilege               Attributes - 
 35 0x000000023 SeCreateSymbolicLinkPrivilege     Attributes - 
Authentication ID:         (0,14e4c)
Impersonation Level:       Anonymous
TokenType:                 Primary
Source: User32             TokenFlags: 0x2000 ( Token in use )
Token ID: ce282            ParentToken ID: 0
Modified ID:               (0, cddbd)
RestrictedSidCount: 0      RestrictedSids: 00000000
OriginatingLogonSession: 3e7

如您所见,唯一的区别是令牌 ID:

Token ID: d166b            ParentToken ID: 0
Modified ID:               (0, d052f)

对比

Token ID: ce282            ParentToken ID: 0
Modified ID:               (0, cddbd)

抱歉,我还不能为此添加太多光线,但我仍在挖掘。

于 2013-03-14T12:31:01.037 回答
0

Windows 7 要求您有意要求某些特权,以便恶意程序无法对您做坏事。如果您下载的免费计算器需要以管理员身份运行,您就会知道发生了什么事。有一些操作系统命令可以提升应用程序的权限(这将请求用户确认)。

可以在以下位置找到一个很好的描述:

http://msdn.microsoft.com/en-us/magazine/cc163486.aspx#S4

于 2012-01-24T12:50:04.467 回答
0

更清楚一点...具有内核模式访问权限的软件程序可以完全访问计算机的所有数据及其硬件。

自 Windows Vista 以来,Microsoft 已停止任何和所有 I/O 进程再次直接访问内核(环 0)。我们得到的最接近的是一个创建为虚拟内核访问分区的文件夹,但从技术上讲,它不能访问内核本身;内核中途相遇。

这是因为软件本身规定要使用哪个令牌,所以如果它要求管理员访问令牌,而不是像在 Windows XP 上那样只允许与内核通信,每次都会提示您允许访问内核。更改 UAC 可以减少提示,但绝不会减少内核提示。

即使您以管理员身份登录,您也会以标准用户身份运行进程,直到系统提示您提升您拥有的权限。我相信以管理员身份登录可以避免您输入凭据。但它也会写入管理员用户文件夹结构。

内核访问类似于 Linux 中的 root 访问。当您提升权限时,您将自己与 C:\ 的根目录以及其中包含的任何可爱的环境变量隔离开来。

如果您还记得蓝屏死机,这是操作系统在认为错误的 I/O 到达内核时关闭。

于 2015-08-19T17:26:33.503 回答
0

Run as *Anything 命令使您免于以您使用 runas 命令的用户的身份注销和登录。

程序要求这种提升权限的原因始于 Black Comb 和 Panther 文件夹。除非通过 Admin 提示符,否则在 windows 中对内核的访问为 0,然后它只是与 O/S 内核的虚拟关系。

万岁!

于 2015-08-19T16:29:20.940 回答
0

好吧,让我们重新迭代...

实际问题(并且是一个很好的问题)

作为管理员组的成员,‘以管理员身份运行’有什么作用?

(答案)1。它允许您在用户会话下调用管理员权限。

注意:问题放错了;一个是命令,另一个是应用策略的组对象。

打开命令提示符并键入runas /?.

这将列出runas命令行可以使用的所有开关。

至于管理员组,这基于 GPEDIT 或 SECPOL 以及是否存在域管理员或是否存在网络。

通常这些东西会对管理员组不受影响的计算机施加限制。

问题应该是

runas admin 以用户身份运行时没有做什么?

或者

管理员组做了哪些自定义用户组不能做的事情?

你正在混合苹果和橙子。

于 2015-08-20T15:37:16.097 回答