本文详细介绍了如何利用单个Active Directory账户构建三种高效检测机制,包括AD枚举检测、Kerberoasting攻击检测和密码喷洒攻击检测,通过具体PowerShell命令和KQL查询实现实时威胁预警。
一个Active Directory账户即可成为最佳早期预警
作者:Jordan Drysdale
Jordan在科技行业已有25年经验,因Napster而深陷技术世界。作为Black Hills Information Security团队十年成员,他以多种身份参与工作,并作为讲师见证了Antisyphon Training的惊人成长。
技术核心:三种检测机制
通过单个AD账户可实现以下三种关键检测:
- AD枚举检测:通过ADExplorer、BloodHound和LDP.exe工具
- Kerberoasting和服务主体攻击检测
- 密码喷洒、凭据填充和暴力破解检测
实验环境搭建
使用Azure ARM模板构建AD实验环境:
1
2
3
4
|
# 环境验证命令
whoami
hostname
setspn -T doazlab.com -Q */*
|
创建诱饵账户
创建名为Ricardo Beneficio的AD账户用于检测:
1
2
3
4
5
|
# 创建蜜罐账户
New-ADUser -UserPrincipalName ricardo.beneficio@doazlab.com -Path "OU=DomainUsers,dc=doazlab,DC=com" -GivenName "Ricardo" -Surname "Beneficio" -Enabled 1 -Name "Ricardo.Beneficio" -desc "Accounting Controller" -office "Accounting" -title "Controller" -company "DevLabs" -AccountPassword (ConvertTo-SecureString "Contrasena#2" -AsPlainText -Force)
# 获取对象GUID
Get-ADUser -Identity ricardo.beneficio -Properties "ObjectGuid"
|
审计配置与事件监控
UAC属性审计配置
1
2
3
4
5
6
7
|
$DecoySamAccountName = ricardo.beneficio
Set-ADAccountControl -Identity $DecoySamAccountName -PasswordNeverExpires $true
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:\CN=ricardo.beneficio,DC=DomainUsers,DC=doazlab,DC=com' -WellKnownSidType WorldSid -Rights ReadProperty -InheritanceFlags All -AttributeGUID bf967a68-0de6-11d0-a285-00aa003049e2 -AuditFlags Success
|
事件ID 4662检测查询
1
2
3
4
|
SecurityEvent
| where EventID == 4662
| where ObjectName contains "e84b8538-2b00-4b82-909b-45051e55e6b1"
| project TimeGenerated , Account , ObjectName , ObjectType
|
Kerberoasting攻击检测
注册SPN服务主体名称
1
|
setspn -a ws05/ricardo.beneficio.doazlab.com:1433 doazlab.com\ricardo.beneficio
|
Kerberoasting攻击检测查询
1
2
3
4
5
6
7
8
9
|
SecurityEvent
| where TimeGenerated >= ago(2h)
| where EventID == 4769
| parse EventData with * 'Status">' Status "<" *
| where Status == '0x0'
| parse EventData with * 'ServiceName">' ServiceName "<" *
| where ServiceName !contains "$" and ServiceName contains "ricardo"
| parse EventData with * 'IpAddress">' SourceIP "<" *
| project TimeGenerated , ServiceName , SourceIP , EventID , Activity
|
密码喷洒攻击检测
失败登录检测查询
1
2
3
4
|
SecurityEvent
| where EventID == 4625
| where Account contains "Ricardo.Beneficio"
| project TimeGenerated , Activity , Account , IpAddress
|
检测工程方法论总结
- 创建诱饵AD对象
- 设置审计规则检测UAC属性读取操作
- 在诱饵账户上设置服务主体名称
- 构建查询逻辑检测属性读取、Kerberos票证操作和失败登录
- 监控警报仪表板
攻击者活动模式
- 获取初始AD凭据
- 使用BloodHound或AdExplorer进行架构分析和AD枚举
- 执行Kerberoasting攻击
- 对环境中AD用户进行密码喷洒
通过这种检测工程方法,可以高效捕获常见的对抗性战术、技术和程序(TTPs)。