启用msDS-KeyCredentialLink变更审计以防御影子凭据攻击

本文详细介绍了如何通过配置Active Directory审计规则监控msDS-KeyCredentialLink属性变更,包含属性GUID获取方法、PowerShell脚本实施步骤及Microsoft Sentinel检测逻辑,有效防御权限提升攻击。

启用msDS-KeyCredentialLink变更审计

标准审计配置不会记录msDS-KeyCredentialLink属性的变更。这给调查工作带来巨大挑战,直到信息安全合作伙伴TrustedSec提供了关键解决方案。

荣誉归于卓越研究:
https://trustedsec.com/blog/a-hitch-hackers-guide-to-dacl-based-detections-part-1b
此方案解决了近期常用于权限提升的属性缺乏审计的问题。

特别感谢Open Threat Research Forge的Roberto Rodriguez和Jose Luis Rodriguez。
他们的开源贡献显著,开发了后续命令中使用的Set-AuditRule.ps1工具:
https://github.com/OTRF/Set-AuditRule

配置目录服务审计

要为域中所有目标对象的msDS-CredentialLink属性配置审计,需创建新审计规则并指定属性GUID。
msDS-CredentialLink架构GUID参考:
https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-ada2/45916e5b-d66f-444e-b1e5-5b0666ed4d66

属性详情:

  • cn: ms-DS-Key-Credential-Link
  • ldapDisplayName: msDS-KeyCredentialLink
  • attributeID: 1.2.840.113556.1.4.2328
  • attributeSyntax: 2.5.5.7
  • omObjectClass: 1.2.840.113556.1.1.1.11
  • oMSyntax: 127
  • isSingleValued: FALSE
  • schemaIdGuid: 5b47d60f-6090-40b2-9f37-2a4de88f3063
  • systemOnly: FALSE
  • searchFlags: 0
  • linkId: 2220
  • systemFlags: FLAG_SCHEMA_BASE_OBJECT
  • attributeSecurityGUID: 9b026da6-0d3c-465c-8bee-5199d7165cba
  • showInAdvancedViewOnly: TRUE

实施审计规则

获取属性架构GUID(5b47d60f-6090-40b2-9f37-2a4de88f3063)后,使用Set-AuditRule.ps1在域顶层为所有后代对象添加审计规则:

1
2
3
4
Import-Module ActiveDirectory
iwr -Uri https://raw.githubusercontent.com/OTRF/Set-AuditRule/master/Set-AuditRule.ps1 -OutFile Set-AuditRule.ps1
Import-Module .\Set-AuditRule.ps1
Set-AuditRule -AdObjectPath 'AD:\DC=doazlab,DC=com' -WellKnownSidType WorldSid -Rights WriteProperty,GenericWrite -InheritanceFlags All -AttributeGUID 5b47d60f-6090-40b2-9f37-2a4de88f3063 -AuditFlags Success

配置审计规则后,若域控制器启用目录服务审计,对象msDS-KeyCredentialLink的后续变更将生成审计事件日志。

Microsoft Sentinel检测逻辑

将日志导入Sentinel后,可使用KQL查询狩猎msDS-KeyCredentialLink属性变更:

1
2
3
4
5
6
union Event, SecurityEvent
| where EventID == 5136
| parse EventData with * 'ObjectDN">' ObjectDN "<" *
| parse EventData with * 'AttributeLDAPDisplayName">' ModifiedAttribute "<" *
| where ModifiedAttribute == "msDS-KeyCredentialLink"
| project Computer , TimeGenerated , Activity, ObjectDN, ModifiedAttribute

相关内容可在GitHub获取:
https://github.com/DefensiveOrigins/Detect-msDS-KeyCredentialLink

comments powered by Disqus
使用 Hugo 构建
主题 StackJimmy 设计