Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions nxc/protocols/ldap.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
from nxc.helpers.ntlm_parser import parse_challenge
from nxc.helpers.misc import get_bloodhound_info
from nxc.paths import CONFIG_PATH, NXC_PATH
from nxc.protocols.ldap.ldap3_conn import Ldap3Connection

ldap_error_status = {
"1": "STATUS_NOT_SUPPORTED",
Expand Down Expand Up @@ -157,6 +158,7 @@ def __init__(self, args, db, host):
self.no_ntlm = False
self.sid_domain = ""
self.scope = None
self.ldap3_conn = None

connection.__init__(self, args, db, host)

Expand Down Expand Up @@ -488,6 +490,37 @@ def kerberos_login(self, domain, username, password="", ntlm_hash="", aesKey="",
)
return False

def get_ldap3_connection(self):
if self.ldap3_conn:
return self.ldap3_conn

ldap3_wrapper = Ldap3Connection(
host=self.host,
port=self.port,
hostname=self.hostname,
domain=self.domain,
username=self.username,
password=self.password,
lmhash=self.lmhash,
nthash=self.nthash,
aesKey=getattr(self, "aesKey", ""),
kdcHost=self.kdcHost,
kerberos=getattr(self, "kerberos", False),
use_kcache=getattr(self, "use_kcache", False),
port_explicitly_set=getattr(self, "port_explicitly_set", False),
logger=self.logger,
)

self.ldap3_conn = ldap3_wrapper.create_conn()

# Sync back username/domain if resolved from ccache
if ldap3_wrapper.username and not self.username:
self.username = ldap3_wrapper.username
if ldap3_wrapper.domain and not self.domain:
self.domain = ldap3_wrapper.domain

return self.ldap3_conn

def plaintext_login(self, domain, username, password):
self.username = username
self.password = password
Expand Down
Loading