Module 13: Active Directory Enumeration

Abusing Lightweight Directory Access Protocol

Understanding LDAP

LDAP was designed to interact with a directory service, such as Active Directory. It is built upon the client-server model.

LDAP clients send requests called operations to an LDAP server. These are used to authenticated clients or retrieve/modify entries within a directory.

Simple LDAP client-server model

Interacting with LDAP

LDAP is inter-operable with custom applications, which is largely possible due to the inclusion of Active Directory Service Interfaces (ADSI).

PowerShell script to perform LDAP lookup

By default, DirectorySearcher instantiates an object with the Filter property to the value of (objectClass=*), which is an LDAP query returning every entry within a directory service.

PowerShell script to execute LDAP as a different user

Enumerating Active Directory with PowerView

PowerView contains dozens of functions that can be used to enumerate Active Directory. They incorporate OS APIs.

Detecting Active Directory Enumeration

Auditing Object Access

To identify malicious enumeration events taking place against AD, we need to implement an audit policy. These are extensions of the built-in Windows logging.

We can display and configure audit policies with the auditpol command line utility.

Listing audit policy categories

Listing audit policy subcategories

Listing audit policy subcategory setting

DC-2 Options
DC-2 Properties
Auditing permissions on DC-2

Object audit security elements

Element
Description

Principal

The identity that is being targeted for auditing

Type

Target success, failure, or both types of events

Access

Types of permissions that can be granted (and tracked)

Inherited From

Designates whether an audit entry was configured at a higher level than the target object, which would recurse down to any sub entries.

Applies To

Designates whether the entry is targeting only the current object, descendant objects, or specific object types

Object Access event

Key information

  • Subject: Details about the Account that accessed the object.

  • Object: Details about the object accessed.

  • Operation: Details about the action taken place.

Baseline Monitoring

Utilize XPath filters to select specific nodes from an XML document. When using the "Filter Current Log" option in Event Viewer, we are essentially building an XPath query that is parsed by the logging engine to provide the requested data.

Event log filter through GUI
Event log filter in XPath form

XPath query for expected access

Running Get-WinEvent with created XPath

Get-WinEvent script with XML parsing

Results from updated Get-WinEvent script

We could perform LDAP lookups to dynamically retrieve the friendly name of the Access Mask, however this would generate access alerts.

XPath filter to suppress displaying events where the SID matches offsec's SID

Using Honey Tokens

The difference between a honey token and a general honeypot is that a honey token is a collection of different types of objects created throughout the directory. Any traffic destined to these lures should be considered suspect.

Last updated