Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] Support for "LDAP Signing" and "Channel Binding"? #5

Open
corsch opened this issue Oct 20, 2021 · 3 comments
Open

[bug] Support for "LDAP Signing" and "Channel Binding"? #5

corsch opened this issue Oct 20, 2021 · 3 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@corsch
Copy link

corsch commented Oct 20, 2021

This is a great tool, but unfortunately is is not working if the DC enforces "LDAP Signing" and "Channel Binding".

[+]======================================================
[+]    LDAP live monitor v1.1        @podalirius_
[+]======================================================

[>] Trying to connect to <DC IP> ...
Traceback (most recent call last):
  File "<PATH>/tools/LDAPmonitor/python/pyLDAPmonitor.py", line 513, in <module>
    raise e
  File "<PATH>/tools/LDAPmonitor/python/pyLDAPmonitor.py", line 478, in <module>
    ldap_server, ldap_session = init_ldap_session(
  File "<PATH>/tools/LDAPmonitor/python/pyLDAPmonitor.py", line 213, in init_ldap_session
    return init_ldap_connection(target, None, args, domain, username, password, lmhash, nthash)
  File "<PATH>/tools/LDAPmonitor/python/pyLDAPmonitor.py", line 193, in init_ldap_connection
    ldap_session = ldap3.Connection(ldap_server, user=user, password=password, authentication=ldap3.NTLM, auto_bind=True)
  File "/usr/local/lib/python3.9/dist-packages/ldap3/core/connection.py", line 363, in __init__
    self._do_auto_bind()
  File "/usr/local/lib/python3.9/dist-packages/ldap3/core/connection.py", line 412, in _do_auto_bind
    raise LDAPBindError(error)
ldap3.core.exceptions.LDAPBindError: automatic bind not successful - strongerAuthRequired
@p0dalirius p0dalirius added this to the 1.3 milestone Dec 31, 2021
@p0dalirius p0dalirius self-assigned this Dec 31, 2021
@p0dalirius p0dalirius added the bug Something isn't working label Jan 3, 2022
@p0dalirius p0dalirius changed the title Support for "LDAP Signing" and "Channel Binding"? [bug] Support for "LDAP Signing" and "Channel Binding"? Jan 3, 2022
@p0dalirius p0dalirius modified the milestones: 1.3, 1.4 Jan 3, 2022
@p0dalirius
Copy link
Owner

p0dalirius commented Jan 4, 2022

In order to solve this problem, I recreated a test environment:

Test environment

Setting registry keys in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NTDS\Parameters to the following values:

  • LDAPServerIntegrity : 2 (Require Signing)
  • LdapEnforceChannelBinding : 2 (Always)

Source: https://support.microsoft.com/en-us/topic/2020-ldap-channel-binding-and-ldap-signing-requirements-for-windows-ef185fb8-00f7-167d-744c-f299a66fc00a

We now have the following values:

image

Open ports on the target DC:

Nmap scan report for 192.168.2.1
Host is up (0.00033s latency).
Not shown: 65510 closed ports
PORT      STATE SERVICE       VERSION
53/tcp    open  domain        Simple DNS Plus
88/tcp    open  kerberos-sec  Microsoft Windows Kerberos (server time: 2022-01-04 22:32:27Z)
135/tcp   open  msrpc         Microsoft Windows RPC
139/tcp   open  netbios-ssn   Microsoft Windows netbios-ssn
389/tcp   open  ldap          Microsoft Windows Active Directory LDAP (Domain: LAB.local0., Site: Paris)
445/tcp   open  microsoft-ds?
464/tcp   open  kpasswd5?
593/tcp   open  ncacn_http    Microsoft Windows RPC over HTTP 1.0
636/tcp   open  tcpwrapped
3268/tcp  open  ldap          Microsoft Windows Active Directory LDAP (Domain: LAB.local0., Site: Paris)
3269/tcp  open  tcpwrapped
5985/tcp  open  http          Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)
9389/tcp  open  mc-nmf        .NET Message Framing
47001/tcp open  http          Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)
49664/tcp open  msrpc         Microsoft Windows RPC
49665/tcp open  msrpc         Microsoft Windows RPC
49666/tcp open  msrpc         Microsoft Windows RPC
49668/tcp open  msrpc         Microsoft Windows RPC
49671/tcp open  msrpc         Microsoft Windows RPC
49674/tcp open  ncacn_http    Microsoft Windows RPC over HTTP 1.0
49675/tcp open  msrpc         Microsoft Windows RPC
49676/tcp open  msrpc         Microsoft Windows RPC
49686/tcp open  msrpc         Microsoft Windows RPC
49693/tcp open  msrpc         Microsoft Windows RPC
49698/tcp open  msrpc         Microsoft Windows RPC
MAC Address: 08:00:27:88:B4:2F (Oracle VirtualBox virtual NIC)
Service Info: Host: DC01; OS: Windows; CPE: cpe:/o:microsoft:windows

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 568.72 seconds

Bug

./ldapmonitor.py -d LAB.local -u Administrator -p 'Admin123!' --dc-ip 192.168.2.1
[+]======================================================
[+]    LDAP live monitor v1.3        @podalirius_        
[+]======================================================

[>] Trying to connect to 192.168.2.1 ...
Traceback (most recent call last):
  File "/data/./ldapmonitor.py", line 532, in <module>
    raise e
  File "/data/./ldapmonitor.py", line 501, in <module>
    ldap_server, ldap_session = init_ldap_session(
  File "/data/./ldapmonitor.py", line 217, in init_ldap_session
    return init_ldap_connection(target, None, args, domain, username, password, lmhash, nthash)
  File "/data/./ldapmonitor.py", line 197, in init_ldap_connection
    ldap_session = ldap3.Connection(ldap_server, user=user, password=password, authentication=ldap3.NTLM, auto_bind=True)
  File "/usr/lib/python3/dist-packages/ldap3/core/connection.py", line 356, in __init__
    self._do_auto_bind()
  File "/usr/lib/python3/dist-packages/ldap3/core/connection.py", line 405, in _do_auto_bind
    raise LDAPBindError(error)
[trace.pcapng.zip](https://github.com/p0dalirius/LDAPmonitor/files/7810613/trace.pcapng.zip)

ldap3.core.exceptions.LDAPBindError: automatic bind not successful - strongerAuthRequired

Wireshark trace

During this bug, a Wireshark capture of the traffic was made from the domain controller:

image

@p0dalirius
Copy link
Owner

The problem seems to come from the required LDAP signing (in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NTDS\Parameters):

Property Value LDAPmonitor can connect?
LDAPServerIntegrity 1 (None) Yes ✔️
LDAPServerIntegrity 2 (Require Signing) Nope ❌

image

And LDAPmonitor works fine with LDAPServerIntegrity set to 1 (None) which does not require signing:

image

@LightxR
Copy link

LightxR commented Aug 14, 2024

This issue could be solved by using ldap3 dev branch (nice PR for ldap signing and channel binding) or waiting the merge on the main branch.
I tested it out by modifying sectools librairy, see : p0dalirius/sectools#10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants