Skip to content

Add DCSync rights check to LDAP admin detection (check_if_admin) #1107

@kathan3009

Description

@kathan3009

Please Describe The Problem To Be Solved

LDAP admin detection (check_if_admin) only treats users as admins if they are in privileged groups (Domain Admins, Enterprise Admins, Administrators, etc.). Users who only have DCSync rights (e.g. via delegation or custom ACLs) are not detected as admins, so modules that require admin (e.g. raisechild) never run for them, even though they can perform DCSync.

In scope:

  • Detect users with DCSync rights on the domain object via ACL inspection
  • Set admin_privs = True for these users so they can run admin-only modules
  • Support both direct ACEs and rights granted via group membership

Out of scope:

  • Changes to other protocols’ admin detection
  • Changes to DCSync execution logic

Solution

Add _check_dcsync_rights() to the LDAP protocol and call it from check_if_admin when the user is not in privileged groups.

Technical implementation:

  • User SIDs: Fetch the user’s objectSid, distinguishedName, and primaryGroupID. Build principal_sids = user SID + primary group SID + all group SIDs (via member:1.2.840.113556.1.4.1941).
  • Domain DACL: Fetch the domain root’s nTSecurityDescriptor with security_descriptor_control(sdflags=0x04) and parse the DACL.
  • DCSync ACEs: For each ACE whose trustee is in principal_sids, check:
  • ACCESS_ALLOWED_ACE with GenericAll (0x10000000) → DCSync
  • ACCESS_ALLOWED_OBJECT_ACE with object type:
  • 1131f6aa-9c07-11d1-f79f-00c04fc2dcd2 (Replicating Directory Changes)
  • 1131f6ad-9c07-11d1-f79f-00c04fc2dcd2 (Replicating Directory Changes All)

Result: If any such ACE is found, return True and set admin_privs = True in check_if_admin.

Tradeoffs:

  • Adds LDAP searches and DACL parsing; cost is acceptable for the admin check path.
  • Group membership is transitive via member:1.2.840.113556.1.4.1941.

Caveats:

  • Requires LDAP read access to the domain root and user objects.
  • Does not validate actual DRS replication; it only checks ACLs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions