林内攻击-配置命名上下文

1. 实验环境

  • DC02(子域控制器)- 10.129.229.207(DHCP)/ 172.16.210.3(双网卡) dev.inlanefreight.ad
  • DC01(父域控制器)- 172.16.210.99 inlanefreight.ad
  • DC02 的账号密码:Administrator 和 HTB_@cademy_adm!
    Pasted image 20260307145558.png

2. 配置命名上下文(NC)

配置命名上下文 (Configuration Naming Context, NC) 是 Active Directory 中存储全林范围配置数据的仓库,因此它必须在整个 AD 林中进行复制。该上下文的可分辨名称 (DN) 为 CN=Configuration,DC=inlanefreight,DC=ad,其中 DC=inlanefreight,DC=ad 代表林根域 (Forest Root Domain) 的 DN。

配置 NC 是林配置信息的主要存储库,会复制到林中的每个域控制器。此外,林中的每个可写域控制器都持有一份可写的配置 NC 副本

2.1. 如何配置NC

  1. 打开ADSI (adsiedit.msc
  2. 点击Action
  3. 下拉菜单选中Conect to ...
    Pasted image 20260307160206.png
  4. Connection Settings 窗口中,于 Select a well-known Naming Context下选择 Configuration
    Pasted image 20260307160241.png
  5. 点击 OK 进行连接
  6. 连接成功后,您将能够访问 Configuration Naming Context ,在此处可以查看和管理 Active Directory 的配置设置
    Pasted image 20260307160332.png

因此,在森林根级别对 Configuration 中的对象所做的任何修改都将 向下复制 到森林内的所有域。但需要注意的是, reverse 同样成立。如果 Configuration 中的对象在子域中发生更改,该变更将 upwards 传播至森林根。这种行为是由于森林中每个可写域控制器都维护着森林 Configuration 命名上下文的一个可写副本。

2.2. Abuse Configuration Naming Context

攻击者可以通过利用 Active Directory 中 Configuration Naming Context 的 replication 机制,在整个域基础设施中传播未经授权的更改或配置的攻击策略。通过利用此方法,攻击者可能引入后门、提升权限或操纵关键设置,从而危及整个 Active Directory 环境的安全性和完整性。

我们可以使用 Get-Acl cmdlet 来检索AD中的配置命名上下文DN关联的相关ACL权限

*Evil-WinRM* PS C:\Users\Administrator\Documents> Import-Module ActiveDirectory
*Evil-WinRM* PS C:\Users\Administrator\Documents> $dn = "CN=Configuration,DC=INLANEFREIGHT,DC=AD"
*Evil-WinRM* PS C:\Users\Administrator\Documents> $acl = Get-Acl -Path "AD:\$dn"
*Evil-WinRM* PS C:\Users\Administrator\Documents> $acl.Access | Where-Object {$_.ActiveDirectoryRights -match "GenericAll|Write" }


ActiveDirectoryRights : GenericAll
InheritanceType       : None
ObjectType            : 00000000-0000-0000-0000-000000000000
InheritedObjectType   : 00000000-0000-0000-0000-000000000000
ObjectFlags           : None
AccessControlType     : Allow
IdentityReference     : NT AUTHORITY\SYSTEM
IsInherited           : False
InheritanceFlags      : None
PropagationFlags      : None

ActiveDirectoryRights : CreateChild, Self, WriteProperty, ExtendedRight, Delete, GenericRead, WriteDacl, WriteOwner
InheritanceType       : Descendents
ObjectType            : 00000000-0000-0000-0000-000000000000
InheritedObjectType   : 00000000-0000-0000-0000-000000000000
ObjectFlags           : None
AccessControlType     : Allow
IdentityReference     : INLANEFREIGHT\Domain Admins
IsInherited           : False
InheritanceFlags      : ContainerInherit
PropagationFlags      : InheritOnly

ActiveDirectoryRights : GenericAll
InheritanceType       : All
ObjectType            : 00000000-0000-0000-0000-000000000000
InheritedObjectType   : 00000000-0000-0000-0000-000000000000
ObjectFlags           : None
AccessControlType     : Allow
IdentityReference     : INLANEFREIGHT\Enterprise Admins
IsInherited           : False
InheritanceFlags      : ContainerInherit
PropagationFlags      : None

查看NC的ACL,可以发现以下实体具有修改域控配置NC的权限

User 对于配置NC的ACL
NT AUTHORITY\SYSTEM Full Control
INLANEFREIGHT\Domain Admins Read all, List all, Write all, All Extended rights
INLANEFREIGHT\Enterprise Admins Full Control

可以发现子域的NT AUTHORITY\SYSTEM 在配置NC上有 完全控制权限Or Generic ALL.

说明子域控制器上的 SYSTEM 账户有权通过查询其本地副本,对林(Forest)内的配置命名上下文进行权威性修改。因此,在此上下文中发起的任何更改都会通过replication过程传播回父域。

攻击者可以通过配置ADCSGPOs、修改DNS条目或者执行 GoldenGMSA攻击等方式来从子域进行横向移动