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

本文详细介绍了如何配置Active Directory审计规则来监控msDS-KeyCredentialLink属性的变更,包括获取属性GUID、使用Set-AuditRule脚本部署审计规则,以及通过KQL查询在Microsoft Sentinel中检测相关安全事件。

启用msDS-KeyCredentialLink变更审计

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

特别鸣谢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
  • schemaIdGuid: 5b47d60f-6090-40b2-9f37-2a4de88f3063

实施审计规则

获取属性架构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 设计