From 34f624fdc83c6dc5954bc861ea4836fc3f911574 Mon Sep 17 00:00:00 2001 From: Stefan Walter Date: Sun, 2 Nov 2025 16:52:24 +0100 Subject: [PATCH 1/2] Add LDAP signing and LDAPS channel binding info to db Closes #731 --- nxc/protocols/ldap.py | 4 +++- nxc/protocols/ldap/database.py | 16 +++++++++++++--- nxc/protocols/ldap/db_navigator.py | 22 ++++++++++++++++++---- 3 files changed, 34 insertions(+), 8 deletions(-) diff --git a/nxc/protocols/ldap.py b/nxc/protocols/ldap.py index f06f52a7..75cd5c63 100644 --- a/nxc/protocols/ldap.py +++ b/nxc/protocols/ldap.py @@ -337,7 +337,9 @@ class ldap(connection): self.host, self.hostname, self.domain, - self.server_os + self.server_os, + self.signing_required, + self.cbt_status ) except Exception as e: self.logger.debug(f"Error adding host {self.host} into db: {e!s}") diff --git a/nxc/protocols/ldap/database.py b/nxc/protocols/ldap/database.py index b3a2ae75..d9a88018 100644 --- a/nxc/protocols/ldap/database.py +++ b/nxc/protocols/ldap/database.py @@ -38,7 +38,9 @@ class database(BaseDB): "ip" text, "hostname" text, "domain" text, - "os" text + "os" text, + "signing_required" bool, + "channel_binding" text )""" ) @@ -57,7 +59,7 @@ class database(BaseDB): ) sys.exit() - def add_host(self, ip, hostname, domain, os): + def add_host(self, ip, hostname, domain, os, signing_required, channel_binding): """Check if this host has already been added to the database, if not, add it in.""" hosts = [] updated_ids = [] @@ -71,7 +73,9 @@ class database(BaseDB): "ip": ip, "hostname": hostname, "domain": domain, - "os": os + "os": os, + "signing_required": signing_required, + "channel_binding": channel_binding } hosts = [new_host] # update existing hosts data @@ -85,6 +89,12 @@ class database(BaseDB): host_data["hostname"] = hostname if domain is not None: host_data["domain"] = domain + if os is not None: + host_data["os"] = os + if signing_required is not None: + host_data["signing_required"] = signing_required + if channel_binding is not None: + host_data["channel_binding"] = channel_binding # only add host to be updated if it has changed if host_data not in hosts: hosts.append(host_data) diff --git a/nxc/protocols/ldap/db_navigator.py b/nxc/protocols/ldap/db_navigator.py index 18a02be3..52c21efd 100644 --- a/nxc/protocols/ldap/db_navigator.py +++ b/nxc/protocols/ldap/db_navigator.py @@ -10,7 +10,9 @@ class navigator(DatabaseNavigator): "IP", "Hostname", "Domain", - "OS" + "OS", + "LDAP signing required", + "LDAPS channel binding" ] ] @@ -25,13 +27,18 @@ class navigator(DatabaseNavigator): except Exception: os = host[4] + signing_required = host[5] + channel_binding = host[6] + data.append( [ host_id, ip, hostname, domain, - os + os, + signing_required, + channel_binding ] ) print_table(data, title="Hosts") @@ -54,7 +61,9 @@ class navigator(DatabaseNavigator): "IP", "Hostname", "Domain", - "OS" + "OS", + "LDAP signing required", + "LDAPS channel binding" ] ] host_id_list = [] @@ -71,13 +80,18 @@ class navigator(DatabaseNavigator): except Exception: os = host[4] + signing_required = host[5] + channel_binding = host[6] + data.append( [ host_id, ip, hostname, domain, - os + os, + signing_required, + channel_binding ] ) print_table(data, title="Host") From 1ea2d8ce1c83f967fa8f868a2dcef9b86c9c3b72 Mon Sep 17 00:00:00 2001 From: Alexander Neff Date: Wed, 12 Nov 2025 09:04:27 -0500 Subject: [PATCH 2/2] Readd table columns for signing&cbt --- nxc/protocols/ldap/database.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nxc/protocols/ldap/database.py b/nxc/protocols/ldap/database.py index 8ab87762..466b1d5e 100644 --- a/nxc/protocols/ldap/database.py +++ b/nxc/protocols/ldap/database.py @@ -1,5 +1,5 @@ -from sqlalchemy import Column, ForeignKeyConstraint, Integer, PrimaryKeyConstraint, String, func, select, delete +from sqlalchemy import Boolean, Column, ForeignKeyConstraint, Integer, PrimaryKeyConstraint, String, func, select, delete from sqlalchemy.dialects.sqlite import Insert # used for upsert from sqlalchemy.ext.declarative import declarative_base @@ -37,6 +37,8 @@ class database(BaseDB): hostname = Column(String) domain = Column(String) os = Column(String) + signing_required = Column(Boolean) + channel_binding = Column(String) __table_args__ = ( PrimaryKeyConstraint("id"),