windows访问控制列表 --ACL(Access Control List)

关于授权(authorization) 与 访问控制(Acess Control)

微软官网详细介绍:

  1. https://docs.microsoft.com/zh-cn/windows/win32/secauthz/authorization-portal
  2. https://docs.microsoft.com/zh-cn/windows/win32/secauthz/access-control

术语

  • ACL: 访问控制列表(ACL,Access Control Lists)。
  • ACE: 访问控制项(ACE,Access Control ITEM)
  • SO : 安全对象 (securable object)
  • SD : 安全描述符 (securable Descriptors)
  • SID : 安全标识符 (securable identifiers)
  • ADSI : Active Directory服务接口(service interface)

定义

ACL是一个windows中的表示用户(组)权限的列表。

分类

ACL分为两类

  1. Discretionary Access Control List (DACL) 自由访问控制列表
  2. System Access Control List (SACL) 系统访问控制列表

DACL

DACL列表包含了用户和组的列表,以及相应的权限,允许或拒绝。每一个用户或组在任意访问控制列表中都有特殊的权限。

DACL是安全对象(securable object) 的一个属性,用来表示 安全对象 的访问权限的列表。

当一个进程试图访问一个安全对象时,系统会检查该指向的DACL中的ACE。

  • 如果该对象没有DACL,允许任何访问。
  • 如果有DACL,但是其中没有ACE,拒绝所有访问。

DACL控制访问控制的详细原理 https://docs.microsoft.com/zh-cn/windows/win32/secauthz/how-dacls-control-access-to-an-object

SACL

而SACL是为审核服务的,包含了对象被访问的时间,他们都是在sd(securable Descriptors——安全描述符)中的!

SACL是系统中的一个列表,用来记录指定用户(组)、指定类型的访问的访问结果,并记录。

安全对象(so) & 安全描述符(sd)

安全对象

安全对象(Securable Object): 微软官网解释

以下引用内容来自微软官网:

A securable object is an object that can have a security descriptor. All named Windows objects are securable. Some unnamed objects, such as process and thread objects, can have security descriptors too. For most securable objects, you can specify an object’s security descriptor in the function call that creates the object. For example, you can specify a security descriptor in the CreateFile and CreateProcess functions.

In addition, the Windows security functions enable you to get and set the security information for securable objects created on operating systems other than Windows. The Windows security functions also provide support for using security descriptors with private, application-defined objects. For more information about private securable objects, see Client/Server Access Control.

Each type of securable object defines its own set of specific access rights and its own mapping of generic access rights. For information about the specific and generic access rights for each type of securable object, see the overview for that type of object.

译文:

安全对象是可以具有安全描述符的对象。所有命名的Windows对象都是安全的。一些未命名的对象(例如进程和线程对象)也可以具有安全描述符。对于大多数安全对象,您可以在创建对象的函数调用中指定对象的安全描述符。例如,您可以在CreateFileCreateProcess函数中指定安全描述符。

此外,Windows安全功能使您可以获取和设置在Windows以外的操作系统上创建的安全对象的安全信息。Windows安全功能还支持将安全描述符与私有的应用程序定义的对象一起使用。有关私有安全对象的详细信息,请参阅客户端/服务器访问控制

每种类型的安全对象都定义了自己的一组特定访问权限以及它自己的通用访问权限映射。有关每种类型的安全对象的特定和通用访问权限的信息,请参阅该类型对象的概述。

下表显示了用于操作某些常见安全对象的安全信息的函数.

Object type Security descriptor functions
Files or directories on an NTFS file system
(NTFS文件系统上的文件或目录)
GetNamedSecurityInfo, SetNamedSecurityInfo, GetSecurityInfo, SetSecurityInfo
Named pipes (命名管道)
Anonymous pipes(匿名管道)
GetSecurityInfo, SetSecurityInfo
Processes(进程)
Threads(线程)
GetSecurityInfo, SetSecurityInfo
File-mapping objects(文件映射对象) GetNamedSecurityInfo, SetNamedSecurityInfo, GetSecurityInfo, SetSecurityInfo
Access tokens (访问令牌) SetKernelObjectSecurity, GetKernelObjectSecurity
Window-management objects window stations and desktops (窗口管理对象(窗口站和桌面)) GetSecurityInfo, SetSecurityInfo
Registry keys(注册表项) GetNamedSecurityInfo, SetNamedSecurityInfo, GetSecurityInfo, SetSecurityInfo
Windows services (Windows服务) GetNamedSecurityInfo, SetNamedSecurityInfo, GetSecurityInfo, SetSecurityInfo
Local or remote printers (本地或远程打印机) GetNamedSecurityInfo, SetNamedSecurityInfo, GetSecurityInfo, SetSecurityInfo
Network shares (网络共享) GetNamedSecurityInfo, SetNamedSecurityInfo, GetSecurityInfo, SetSecurityInfo
Interprocess synchronization objects (events, mutexes, semaphores, and waitable timers) (进程间同步对象(事件,互斥锁,信号量和等待计时器)) GetNamedSecurityInfo, SetNamedSecurityInfo, GetSecurityInfo, SetSecurityInfo
Job objects(工作对象) GetNamedSecurityInfo, SetNamedSecurityInfo, GetSecurityInfo, SetSecurityInfo
Directory service objects (目录服务对象) These objects are handled by Active Directory Objects. For more information, see Active Directory Service Interfaces. (这些对象由Active Directory对象处理。有关更多信息,请参阅Active Directory服务接口。)

安全描述符

安全描述符包含与安全对象关联的安全信息。安全描述符由SECURITY_DESCRIPTOR结构及其关联的安全信息组成。安全描述符可包含以下安全信息:

  • 对象的所有者和主要组的安全标识符(SID)。其标识了该信息是哪个对象的,也就是用于记录安全对象的ID。
  • 一个DACL,指定允许或拒绝特定用户或组的访问权限。当一个进程需要访问安全对象,系统就会检查DACL来决定进程的访问权。如果一个对象没有DACL,那么就是说这个对象是任何人都可以拥有完全的访问权限。
  • 一个SACL,指定为对象生成审核记录的访问尝试类型。其指出了在该对象上的一组存取方式(如,读、写、运行等)的存取控制权限细节的列表。
  • 一组控制位,用于限定安全描述符或其各个成员的含义。

应用程序不得直接操作安全描述符的内容。Windows API提供了在对象的安全描述符中设置和检索安全信息的功能。此外,还有用于为新对象创建和初始化安全描述符的功能。

在Active Directory对象上使用安全描述符的应用程序可以使用Windows安全功能或Active Directory服务接口(ADSI)提供的安全接口。有关ADSI安全性接口的详细信息,请参阅访问控制在Active Directory中的工作原理

SECURITY_DESCRIPTOR结构体

https://docs.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-security_descriptor

该SECURITY_DESCRIPTOR结构包含与对象相关联的安全信息。应用程序使用此结构来设置和查询对象的安全状态。

由于安全描述符的内部格式可能不同,因此我们建议应用程序不要直接修改SECURITY_DESCRIPTOR结构。要创建和操作安全描述符,请使用另请参阅中列出的函数。

typedef struct _SECURITY_DESCRIPTOR {
  BYTE                        Revision;
  BYTE                        Sbz1;
  SECURITY_DESCRIPTOR_CONTROL Control;
  PSID                        Owner;
  PSID                        Group;
  PACL                        Sacl;
  PACL                        Dacl;
} SECURITY_DESCRIPTOR, *PISECURITY_DESCRIPTOR;