Assesses Active Directory security posture using PingCastle, BloodHound, and Purple Knight to identify misconfigurations, privilege escalation paths, and attack vectors.
npx claudepluginhub killvxk/cybersecurity-skills-zhThis skill uses the workspace's default tool permissions.
Active Directory(AD)是大多数企业环境中的主要身份和访问管理系统(Identity and Access Management),也是关键的攻击目标。本技能涵盖使用 PingCastle 进行健康检查、BloodHound 进行攻击路径分析、Purple Knight 进行安全态势评分的全面 AD 安全评估。这些工具可识别错误配置、过度权限、Kerberos 弱点和横向移动机会。
Assesses Active Directory security using PingCastle, BloodHound, and Purple Knight to identify misconfigurations, privilege escalations, and attack vectors in enterprise environments.
Assesses Active Directory security posture using PingCastle, BloodHound, and Purple Knight to identify misconfigurations, privilege escalations, and attack vectors. For audits, pentests, and incident response.
Executes authorized Active Directory attack simulations using BloodHound for path analysis, Mimikatz for credential extraction, Impacket for Kerberos attacks like roasting and delegation abuse. For AD pentesting and domain compromise assessment.
Share bugs, ideas, or general feedback.
Active Directory(AD)是大多数企业环境中的主要身份和访问管理系统(Identity and Access Management),也是关键的攻击目标。本技能涵盖使用 PingCastle 进行健康检查、BloodHound 进行攻击路径分析、Purple Knight 进行安全态势评分的全面 AD 安全评估。这些工具可识别错误配置、过度权限、Kerberos 弱点和横向移动机会。
# 下载 PingCastle
Invoke-WebRequest -Uri "https://github.com/netwrix/pingcastle/releases/latest/download/PingCastle.zip" `
-OutFile "PingCastle.zip"
Expand-Archive PingCastle.zip -DestinationPath C:\Tools\PingCastle
# 对当前域执行健康检查
cd C:\Tools\PingCastle
.\PingCastle.exe --healthcheck
# 对指定域执行健康检查
.\PingCastle.exe --healthcheck --server dc01.corp.local --user CORP\scanner_account --password P@ssw0rd
# 以扫描器模式运行,用于多个域
.\PingCastle.exe --scanner --scannerlp
# 生成综合报告
.\PingCastle.exe --healthcheck --level Full
| 分类 | 描述 | 风险领域 |
|---|---|---|
| StaleObjects(陈旧对象) | 不活跃账户、旧密码、已淘汰操作系统 | 幽灵账户、已过期凭据 |
| PrivilegiedGroup(特权账户) | 过多管理员权限、嵌套组 | Domain Admin 泛滥、SID 历史记录 |
| Trust(信任关系) | 林和域信任配置 | 可传递信任滥用、SID 过滤 |
| Anomaly(异常) | 安全设置偏差 | GPO 错误配置、架构问题 |
# PingCastle 报告中需重点审查的关键项目:
- 具有"密码永不过期"标志的账户
- 禁用 Kerberos 预身份验证的账户(AS-REP 可烘焙账户)
- 具有 Kerberos 委派的账户(非约束/约束委派)
- 运行不受支持操作系统版本的域控制器
- AdminSDHolder 权限修改
- 特权组中的账户(Domain Admins、Enterprise Admins、Schema Admins)
- 禁用 SID 过滤的信任关系
- 允许权限提升的 GPO 漏洞
# 下载 SharpHound 采集器
# https://github.com/SpecterOps/BloodHound/tree/main/packages/csharp/SharpHound
# 运行 SharpHound 采集(所有方法)
.\SharpHound.exe --collectionmethods All --domain corp.local --zipfilename bloodhound_data.zip
# 隐蔽采集(最小噪音)
.\SharpHound.exe --collectionmethods Session,LoggedOn --domain corp.local --stealth
# 使用指定域控制器进行采集
.\SharpHound.exe --collectionmethods All --domain corp.local --domaincontroller dc01.corp.local
# 通过 PowerShell 运行
Import-Module .\SharpHound.ps1
Invoke-BloodHound -CollectionMethod All -Domain corp.local -OutputDirectory C:\BH_Data
# 使用 Docker 部署 BloodHound 社区版
curl -L https://ghst.ly/getbhce -o docker-compose.yml
docker compose up -d
# 在 http://localhost:8080 访问 BloodHound CE
# 默认凭据显示在 docker compose 日志中
# 通过 Web UI 或 API 上传 SharpHound 数据
curl -X POST "http://localhost:8080/api/v2/file-upload/start" \
-H "Authorization: Bearer $BH_TOKEN" \
-H "Content-Type: application/json" \
-d '{"fileName": "bloodhound_data.zip"}'
# 查找到 Domain Admin 的最短路径
MATCH p=shortestPath((u:User)-[*1..]->(g:Group {name:"DOMAIN ADMINS@CORP.LOCAL"}))
WHERE u.name <> "ADMINISTRATOR@CORP.LOCAL"
RETURN p
# 查找具有管理员权限的 Kerberoastable 账户
MATCH (u:User {hasspn:true})-[:MemberOf*1..]->(g:Group)
WHERE g.name CONTAINS "ADMIN"
RETURN u.name, u.serviceprincipalnames
# 查找 Domain Admin 已登录的计算机
MATCH (c:Computer)-[:HasSession]->(u:User)-[:MemberOf*1..]->(g:Group {name:"DOMAIN ADMINS@CORP.LOCAL"})
RETURN c.name, u.name
# 查找 AS-REP 可烘焙账户
MATCH (u:User {dontreqpreauth:true})
RETURN u.name, u.description
# 查找非约束委派主机
MATCH (c:Computer {unconstraineddelegation:true})
WHERE NOT c.name CONTAINS "DC"
RETURN c.name
# 查找 GPO 滥用路径
MATCH p=(u:User)-[:GenericAll|GenericWrite|WriteOwner|WriteDacl]->(g:GPO)
RETURN p
# 从 https://www.purple-knight.com/ 下载 Purple Knight
# 以域管理员或具有适当读取权限的账户运行
.\PurpleKnight.exe
# Purple Knight 跨以下类别检查 130+ 个安全指标:
# - 账户安全(密码策略、特权账户)
# - AD 基础设施(复制、DNS、LDAP 签名)
# - 组策略(GPO 权限、安全设置)
# - Kerberos 安全(委派、加密类型、SPN)
# - AD 委派(AdminSDHolder、OU 权限)
| 评分范围 | 等级 | 所需行动 |
|---|---|---|
| 90-100 | 优秀 | 维持当前安全态势 |
| 75-89 | 良好 | 处理高风险发现 |
| 60-74 | 一般 | 制定修复优先级计划 |
| 40-59 | 较差 | 立即修复所需 |
| 0-39 | 严重 | 需要紧急响应 |
# 查找分配给用户账户的 SPN(Kerberoasting 目标)
Get-ADUser -Filter {ServicePrincipalName -ne "$null"} -Properties ServicePrincipalName |
Select-Object Name, ServicePrincipalName, PasswordLastSet, Enabled
# 查找禁用预身份验证的账户
Get-ADUser -Filter {DoesNotRequirePreAuth -eq $true} -Properties DoesNotRequirePreAuth |
Select-Object Name, DoesNotRequirePreAuth, Enabled
# 检查是否通过 GPO 禁用了 LLMNR
Get-ItemProperty "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\DNSClient" -Name EnableMulticast -ErrorAction SilentlyContinue
# 统计关键组中的成员数量
$groups = @("Domain Admins", "Enterprise Admins", "Schema Admins", "Account Operators", "Backup Operators")
foreach ($group in $groups) {
$count = (Get-ADGroupMember -Identity $group -Recursive).Count
Write-Output "$group : $count members"
}
| 发现项 | 风险 | 修复措施 |
|---|---|---|
| Kerberoastable 管理员账户 | 严重 | 移除 SPN 或使用 MSA/gMSA |
| 非域控制器上的非约束委派 | 严重 | 切换为约束委派/RBCD |
| 管理员账户密码永不过期 | 高 | 启用密码轮换策略 |
| AS-REP 可烘焙账户 | 高 | 启用 Kerberos 预身份验证 |
| AdminSDHolder 修改 | 高 | 审计并恢复默认 ACL |
| 陈旧计算机账户(超过 90 天) | 中 | 禁用并移至隔离 OU |
| 未强制执行 LDAP 签名 | 中 | 通过 GPO 在所有 DC 上启用 |