Skip to content

Commit aa8b1fd

Browse files
committed
Add debug logging for exceptions
1 parent e99e5c2 commit aa8b1fd

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

nxc/modules/daclread.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from ldap3.utils.conv import escape_filter_chars
1212
from ldap3.protocol.microsoft import security_descriptor_control
1313
import sys
14+
import traceback
1415

1516
OBJECT_TYPES_GUID = {}
1617
OBJECT_TYPES_GUID.update(SCHEMA_OBJECTS)
@@ -287,9 +288,10 @@ def on_login(self, context, connection):
287288
)[0][1][0][1][0]
288289
)
289290
context.log.highlight(f"Found principal SID to filter on: {self.principal_sid}")
290-
except Exception:
291+
except Exception as e:
291292
context.log.fail(f"Principal SID not found in LDAP ({_lookedup_principal})")
292-
sys.exit(1)
293+
context.log.debug(f"Exception: {e}, {traceback.format_exc()}")
294+
return
293295

294296
# Searching for the targets SID and their Security Descriptors
295297
# If there is only one target
@@ -302,9 +304,10 @@ def on_login(self, context, connection):
302304
self.principal_raw_security_descriptor = str(self.target_principal[1][0][1][0]).encode("latin-1")
303305
self.principal_security_descriptor = ldaptypes.SR_SECURITY_DESCRIPTOR(data=self.principal_raw_security_descriptor)
304306
context.log.highlight(f"Target principal found in LDAP ({self.target_principal[0]})")
305-
except Exception:
307+
except Exception as e:
306308
context.log.fail(f"Target SID not found in LDAP ({self.target_sAMAccountName})")
307-
sys.exit(1)
309+
context.log.exception(e)
310+
return
308311

309312
if self.action == "read":
310313
self.read(context)

0 commit comments

Comments
 (0)