🐲
OSCP Notes
  • 🐲OSCP Notes
  • 🐲OSCP Methodology
  • 💡Misc
    • Metasploit
    • Antivirus Evasion
    • Password attacks
    • Reverse Shells
    • Port Forwarding, Tunneling and Pivoting
      • Local Port Forwarding
      • Remote Port Forwarding
      • Dynamic Port Forwarding
      • Lingolo-ng
    • Information Gathering
      • Passive Reconnaissance
        • Whois
        • Google Dorks
        • NetCraft
        • Git Repository
      • Active Reconnaissance
        • DNS Enumeration
        • Host Discovery
        • Port scanning
        • SMTP - 25
        • SNMP
  • Linux
    • Local Enumeration
    • Local Privileges Escalation
      • Scheduled tasks
      • Password Authentication
      • Monitor Processes
      • SetUID Binaries and Capabilities
      • Sudoers
      • Kernel Exploits
  • Windows
    • 🧠Mindmap
    • 🥝Mimikatz Basics
    • Enumeration
      • External Enumeration
      • Local Enumeration
      • Active Directory
        • PowerView
    • NTLM Hashes
    • Local Privilege Escalation
      • Service Binary Hijacking
      • Service DLL Hijacking
      • Unquoted Service Paths
      • Scheduled Tasks
      • Token impersonation
      • Backup Operators Group
    • Lateral Movement
      • WMI and WinRM
      • PsExec
      • Pass The Hash
      • Overpass The Hash
      • Pass The Ticket
      • DCOM
    • Persistence
      • Golden Ticket
      • Shadow Copy
    • Authentication Attacks
      • AS-REP Roasting
      • Kerberoasting
      • Password Spray
      • Silver Ticket
      • DC Sync
    • Client Side
    • NTLM Authentication
    • Kerberos Authentication
    • Cached Credentials
  • Web attacks
    • WordPress
    • SQL Injection (SQLi)
    • Command Injection
    • Directory Traversal
    • Local File Inclusion (LFI)
    • File Upload
Powered by GitBook
On this page
  • Users & Groups
  • Net.exe
  • PowerShell and .NET Classes
  • SPN
  • Active Sessions
  • Domain Controller
  • PowerView
  1. Windows
  2. Enumeration

Active Directory

Users & Groups

Net.exe

Net.exe installed by default on all Windows operating system, Therefore it would be the first go to in domain enumeration.

Note: The Net.exe misses subgroups memberships

Enumerate domain users.

net user /domain

Enumerate information of specific user such as group membership, password last set or whether if the account is active.

net user <user> /domain

Enumerate domain groups.

net group /domain

Enumerate group members.

net group <group> /domain

PowerShell and .NET Classes

Basic function which retrieve LDAP Queries using .NET Classes.

The Function uses two important .NET Classes:

  • System.DirectoryServices.DirectoryEntry: This class represents a node or object in an Active Directory hierarchy

  • System.DirectoryServices.DirectorySearcher: This class is used to perform queries against Active Directory.

ldap.ps1
function LDAPSearch {
    param (
        [string]$LDAPQuery
    )
    $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, $LDAPQuery)

    return $DirectorySearcher.FindAll()
}

Enumerate domain users.

LDAPSearch -LDAPQuery "(objectClass=user)"

Enumerate specific user properties.

(LDAPSearch -LDAPQuery "(sAMAccountName=<username>)") | ForEach-Object { $_.Properties }

Enumerate domain groups.

LDAPSearch -LDAPQuery "(objectClass=group)"

Enumerate specific group properties.

(LDAPSearch -LDAPQuery "(cn=<group_name>)") | ForEach-Object { $_.Properties }

Enumerate specific group members.

(LDAPSearch -LDAPQuery "(cn=<group_name>)").Properties["member"]

Enumerate specific domain user memberships.

(LDAPSearch -LDAPQuery "(sAMAccountName=<username>)").Properties["memberOf"]

Enumerate specific domain group membership

LDAPSearch -LDAPQuery "(memberOf=CN=<group_name>,OU=Groups,DC=domain,DC=com)"

SPN

lists all the Service Principal Names (SPNs) that are registered for the specified user account in Active Directory.

setspn -L <user>

Active Sessions

.\PsLoggedon.exe \<computer>

Domain Controller

Retrieve the Domain Controller with the PdcRoleOwner which indicates its the main DC.

[System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()

PowerView

PowerView is a PowerShell toolset for AD enumeration, useful for penetration testing. It helps gather domain info, user/group details, inspect permissions, and identify network shares. Commonly used in Active Directory enumeration.

PreviousLocal EnumerationNextPowerView

Last updated 7 months ago

Shows users logged onto the specific computer using the tool from sysinternals.

PsLoggedon
PowerView