From 6ccf5918de8a070ae75e70ea58f3e8f2ff527835 Mon Sep 17 00:00:00 2001 From: SoftAndoWetto <188264635+SoftAndoWetto@users.noreply.github.com> Date: Fri, 13 Nov 2026 09:33:37 +0000 Subject: [PATCH 01/10] Add NTLM signing enforcement check module This module checks if a target enforces NTLM signing by performing two NTLM authentications, one with signing and one without, and logs the results. Signed-off-by: SoftAndoWetto <188264635+SoftAndoWetto@users.noreply.github.com> --- nxc/modules/ntlmsign.py | 114 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 nxc/modules/ntlmsign.py diff --git a/nxc/modules/ntlmsign.py b/nxc/modules/ntlmsign.py new file mode 100644 index 0000000000..f4c2b32567 --- /dev/null +++ b/nxc/modules/ntlmsign.py @@ -0,0 +1,114 @@ + +from impacket.smbconnection import SMBConnection +from impacket.ldap import ldap as ldap_impacket +from impacket.ldap import ldapasn1 as ldapasn1_impacket +from impacket.ntlm import getNTLMSSPType1, getNTLMSSPType3 + +from nxc.helpers.misc import CATEGORY +import contextlib + + +class NXCModule: + """ + Checks whether a target enforces NTLM signing (KB5135557 / ServerRequireNtlmSign) + by doing two NTLM authentications with the same creds, one negotiating signing + and one not. Unsigned rejected + signed accepted = enforced. + """ + + name = "ntlmsign" + description = "Checks NTLM signing enforcement (KB5135557 / ServerRequireNtlmSign)" + supported_protocols = ["smb", "ldap"] + opsec_safe = True + multiple_hosts = True + category = CATEGORY.ENUMERATION + + def options(self, context, module_options): + """No options available""" + + def on_login(self, context, connection): + if getattr(connection.args, "kerberos", False): + context.log.fail(f"{connection.host} - Kerberos auth in use, NTLM check not applicable") + return + + if connection.args.protocol == "smb": + signed_ok, signed_msg = self._bind_smb(context, connection, True) + unsigned_ok, unsigned_msg = self._bind_smb(context, connection, False) + label = "login" + elif connection.args.protocol == "ldap": + signed_ok, signed_msg = self._bind_ldap(context, connection, True) + unsigned_ok, unsigned_msg = self._bind_ldap(context, connection, False) + label = "bind" + else: + context.log.fail(f"{connection.host} - unsupported protocol {connection.args.protocol!r}") + return + + host = connection.host + + if signed_ok and not unsigned_ok: + context.log.success(f"{host} - NTLM signing ENFORCED (unsigned {label} rejected, signed accepted)") + elif signed_ok and unsigned_ok: + context.log.highlight(f"{host} - NTLM signing NOT enforced (signed and unsigned {label}s accepted)") + else: + state = "inconclusive" if not unsigned_ok else "UNEXPECTED (unsigned ok, signed failed)" + context.log.fail(f"{host} - {state}: signed={signed_msg!r} unsigned={unsigned_msg!r}") + + def _bind_smb(self, context, c, sign): + """One full SMB NTLM login. Returns (success, diagnostic_message).""" + label = "signed" if sign else "unsigned" + conn = None + try: + conn = SMBConnection(c.host, c.host, sess_port=getattr(c, "port", 445), timeout=10) + server = conn.getSMBServer() + if not hasattr(server, "_Connection"): + return False, "SMB1 dialect negotiated, not supported" + + # Controls the NTLM Type1 signing flag (and client-side signing after login) + server._Connection["RequireSigning"] = sign + + conn.login( + c.username, + c.password or "", + c.domain or "", + c.lmhash or "", + c.nthash or "", + ) + context.log.debug(f"[smb:{label}] login ok") + return True, "STATUS_SUCCESS" + except Exception as e: + context.log.debug(f"[smb:{label}] login error: {e!r}") + return False, str(e) + finally: + if conn is not None: + with contextlib.suppress(Exception): + conn.close() + + def _bind_ldap(self, context, c, sign): + """One full sicily bind. Returns (success, diagnostic_message).""" + label = "signed" if sign else "unsigned" + try: + conn = ldap_impacket.LDAPConnection(f"ldap://{c.host}", dstIp=c.host) + + negotiate = getNTLMSSPType1(signingRequired=sign) + req = ldapasn1_impacket.BindRequest() + req["version"] = 3 + req["name"] = "" + req["authentication"]["sicilyNegotiate"] = negotiate.getData() + resp = conn.sendReceive(req)[0]["protocolOp"] + challenge = bytes(resp["bindResponse"]["matchedDN"]) + + type3, _ = getNTLMSSPType3( + negotiate, challenge, c.username, c.password or "", c.domain or "", + c.lmhash or "", c.nthash or "", + ) + req = ldapasn1_impacket.BindRequest() + req["version"] = 3 + req["name"] = c.username + req["authentication"]["sicilyResponse"] = type3.getData() + resp = conn.sendReceive(req)[0]["protocolOp"]["bindResponse"] + + code, msg = int(resp["resultCode"]), str(resp["diagnosticMessage"]) + context.log.debug(f"[ldap:{label}] resultCode={code} msg={msg!r}") + return code == 0, msg + except Exception as e: + context.log.debug(f"[ldap:{label}] bind error: {e!r}") + return False, str(e) From 5f06c3f981240c15c54d7cd92a4c66ae4ab2794f Mon Sep 17 00:00:00 2001 From: SoftAndoWetto <188264635+SoftAndoWetto@users.noreply.github.com> Date: Fri, 13 Nov 2026 10:05:07 +0000 Subject: [PATCH 02/10] Add NTLM command to SMB and LDAP tests Signed-off-by: SoftAndoWetto <188264635+SoftAndoWetto@users.noreply.github.com> --- tests/e2e_commands.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/e2e_commands.txt b/tests/e2e_commands.txt index bb70bdd51f..98aa972fb8 100644 --- a/tests/e2e_commands.txt +++ b/tests/e2e_commands.txt @@ -113,6 +113,7 @@ netexec smb TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD KERBEROS -M security netexec smb TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD KERBEROS -M remove-mic netexec smb TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD KERBEROS -M backup_operator netexec smb TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD KERBEROS -M ntlm_reflection +netexec smb TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD -M ntlm netexec smb TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD KERBEROS -M ntds-dump-raw netexec smb TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD KERBEROS -M ntds-dump-raw -o TARGET=SAM,LSA,NTDS # currently hanging indefinitely - TODO: look into this @@ -258,6 +259,7 @@ netexec ldap TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD KERBEROS -M tombsto netexec ldap TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD KERBEROS -M get-network netexec ldap TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD KERBEROS -M groupmembership -o USER=LOGIN_USERNAME netexec ldap TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD KERBEROS -M laps +netexec ldap TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD -M ntlm netexec ldap TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD KERBEROS -M maq netexec ldap TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD KERBEROS -M modify-group -o USER=USERNAME GROUP="Domain Admins" netexec ldap TARGET_HOST -u LOGIN_USERNAME -p LOGIN_PASSWORD KERBEROS -M modify-group -o USER=USERNAME GROUP="Domain Admins" REMOVE=True From d937f60055a8dacb0f79a0ca69320dc8435f5487 Mon Sep 17 00:00:00 2001 From: SoftAndoWetto <188264635+SoftAndoWetto@users.noreply.github.com> Date: Fri, 13 Nov 2026 10:59:07 +0000 Subject: [PATCH 03/10] Added exceptions Signed-off-by: SoftAndoWetto <188264635+SoftAndoWetto@users.noreply.github.com> --- nxc/modules/ntlmsign.py | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/nxc/modules/ntlmsign.py b/nxc/modules/ntlmsign.py index f4c2b32567..e27fcfb749 100644 --- a/nxc/modules/ntlmsign.py +++ b/nxc/modules/ntlmsign.py @@ -26,8 +26,30 @@ def options(self, context, module_options): """No options available""" def on_login(self, context, connection): - if getattr(connection.args, "kerberos", False): - context.log.fail(f"{connection.host} - Kerberos auth in use, NTLM check not applicable") + args = connection.args + method = "NTLM" + + if getattr(args, "kerberos", False) or getattr(args, "use_kcache", False): + method = "Kerberos" + elif any(getattr(args, a, None) for a in ("pfx_cert", "pfx_base64", "pem_cert", "pem_key")): + method = "Schannel/certificate" + elif getattr(args, "simple_bind", False): + method = "LDAP simple bind" + + if method != "NTLM": + context.log.fail(f"Auth method {method} not valid. NTLM signing check not applicable.") + return + + username = (connection.username or "").strip() + password = connection.password or "" + nthash = getattr(connection, "nthash", "") or "" + lmhash = getattr(connection, "lmhash", "") or "" + + is_null_session = not username or (not password and not nthash and not lmhash) + is_guest = username.lower() == "guest" + + if is_null_session or is_guest: + context.log.fail(f"{connection.host} - null/guest auth is exempt from ServerRequireNtlmSign (KB5135557). Re-run with a non-guest account") return if connection.args.protocol == "smb": @@ -42,16 +64,6 @@ def on_login(self, context, connection): context.log.fail(f"{connection.host} - unsupported protocol {connection.args.protocol!r}") return - host = connection.host - - if signed_ok and not unsigned_ok: - context.log.success(f"{host} - NTLM signing ENFORCED (unsigned {label} rejected, signed accepted)") - elif signed_ok and unsigned_ok: - context.log.highlight(f"{host} - NTLM signing NOT enforced (signed and unsigned {label}s accepted)") - else: - state = "inconclusive" if not unsigned_ok else "UNEXPECTED (unsigned ok, signed failed)" - context.log.fail(f"{host} - {state}: signed={signed_msg!r} unsigned={unsigned_msg!r}") - def _bind_smb(self, context, c, sign): """One full SMB NTLM login. Returns (success, diagnostic_message).""" label = "signed" if sign else "unsigned" From 1cd1c3b9cdbf5a5dedfd2f7eaa44e62a7c5d56b5 Mon Sep 17 00:00:00 2001 From: SoftAndoWetto <188264635+SoftAndoWetto@users.noreply.github.com> Date: Sun, 15 Nov 2026 12:05:48 +0000 Subject: [PATCH 04/10] Refactor NTLM authentication process in ntlmsign.py Signed-off-by: SoftAndoWetto <188264635+SoftAndoWetto@users.noreply.github.com> --- nxc/modules/ntlmsign.py | 90 +++++++++++++++++++++++++++++++++++------ 1 file changed, 77 insertions(+), 13 deletions(-) diff --git a/nxc/modules/ntlmsign.py b/nxc/modules/ntlmsign.py index e27fcfb749..d53fd6e6e7 100644 --- a/nxc/modules/ntlmsign.py +++ b/nxc/modules/ntlmsign.py @@ -1,8 +1,9 @@ - from impacket.smbconnection import SMBConnection from impacket.ldap import ldap as ldap_impacket from impacket.ldap import ldapasn1 as ldapasn1_impacket from impacket.ntlm import getNTLMSSPType1, getNTLMSSPType3 +from impacket.spnego import SPNEGO_NegTokenInit, SPNEGO_NegTokenResp, TypesMech +from impacket.smb3structs import SMB2SessionSetup, SMB2SessionSetup_Response, SMB2_SESSION_SETUP from nxc.helpers.misc import CATEGORY import contextlib @@ -64,28 +65,91 @@ def on_login(self, context, connection): context.log.fail(f"{connection.host} - unsupported protocol {connection.args.protocol!r}") return + host = connection.host + + if signed_ok and not unsigned_ok: + context.log.success(f"{host} - NTLM signing ENFORCED (unsigned {label} rejected, signed accepted)") + elif signed_ok and unsigned_ok: + context.log.highlight(f"{host} - NTLM signing NOT enforced (signed and unsigned {label}s both accepted)") + else: + state = "inconclusive" if not unsigned_ok else "UNEXPECTED (unsigned ok, signed failed)" + context.log.fail(f"{host} - {state}: signed={signed_msg!r} unsigned={unsigned_msg!r}") + def _bind_smb(self, context, c, sign): - """One full SMB NTLM login. Returns (success, diagnostic_message).""" + """One full NTLM authentication. Returns (success, status_string).""" label = "signed" if sign else "unsigned" conn = None try: - conn = SMBConnection(c.host, c.host, sess_port=getattr(c, "port", 445), timeout=10) - server = conn.getSMBServer() - if not hasattr(server, "_Connection"): + conn = SMBConnection(remoteName=c.host, remoteHost=c.host, sess_port=getattr(c, "port", 445), timeout=10) + smb = conn.getSMBServer() + if not hasattr(smb, "_Connection"): return False, "SMB1 dialect negotiated, not supported" - - # Controls the NTLM Type1 signing flag (and client-side signing after login) - server._Connection["RequireSigning"] = sign - - conn.login( - c.username, + + # Type 1 + negotiate = getNTLMSSPType1(signingRequired=sign) + blob1 = SPNEGO_NegTokenInit() + blob1["MechTypes"] = [TypesMech["NTLMSSP - Microsoft NTLM Security Support Provider"]] + blob1["MechToken"] = negotiate.getData() + + ss1 = SMB2SessionSetup() + ss1["Flags"] = 0 + ss1["SecurityMode"] = smb._Connection["ClientSecurityMode"] + ss1["Capabilities"] = smb._Connection["Capabilities"] + ss1["Channel"] = 0 + ss1["PreviousSessionId"] = 0 + ss1["SecurityBufferOffset"] = 0x58 + ss1["SecurityBufferLength"] = len(blob1) + ss1["Buffer"] = blob1.getData() + + pkt1 = smb.SMB_PACKET() + pkt1["Command"] = SMB2_SESSION_SETUP + pkt1["SessionID"] = 0 + pkt1["Data"] = ss1 + pkt1_id = smb.sendSMB(pkt1) + resp1 = smb.recvSMB(pkt1_id) + + session_id = resp1["SessionID"] + resp1_data = SMB2SessionSetup_Response(resp1["Data"]) + + spnego_resp = SPNEGO_NegTokenResp(resp1_data["Buffer"]) + + # Type 2 + challenge = bytes(spnego_resp["ResponseToken"]) + + smb._Session["SessionID"] = session_id + + # Type 3 + type3, _ = getNTLMSSPType3( + negotiate, challenge, + c.username or "", c.password or "", c.domain or "", c.lmhash or "", c.nthash or "", ) - context.log.debug(f"[smb:{label}] login ok") - return True, "STATUS_SUCCESS" + auth_token = SPNEGO_NegTokenResp() + auth_token["ResponseToken"] = type3.getData() + blob2 = auth_token.getData() + + ss2 = SMB2SessionSetup() + ss2["Flags"] = 0 + ss2["SecurityMode"] = smb._Connection["ClientSecurityMode"] + ss2["Capabilities"] = smb._Connection["Capabilities"] + ss2["Channel"] = 0 + ss2["PreviousSessionId"] = 0 + ss2["SecurityBufferOffset"] = 0x58 + ss2["SecurityBufferLength"] = len(blob2) + ss2["Buffer"] = blob2 + + pkt2 = smb.SMB_PACKET() + pkt2["Command"] = SMB2_SESSION_SETUP + pkt2["SessionID"] = session_id + pkt2["Data"] = ss2 + pkt2_id = smb.sendSMB(pkt2) + resp2 = smb.recvSMB(pkt2_id) + status = resp2["Status"] + context.log.debug(f"[smb:{label}] status={status:#010x}") + return status == 0, f"STATUS={status:#010x}" except Exception as e: context.log.debug(f"[smb:{label}] login error: {e!r}") return False, str(e) From acd32ee730bacb8e88dd8a461c0a06891aa8490c Mon Sep 17 00:00:00 2001 From: SoftAndoWetto <188264635+SoftAndoWetto@users.noreply.github.com> Date: Tue, 17 Nov 2026 18:48:15 +0000 Subject: [PATCH 05/10] Refactor NTLM signing checks for improved clarity Signed-off-by: SoftAndoWetto <188264635+SoftAndoWetto@users.noreply.github.com> --- nxc/modules/ntlmsign.py | 102 +++++++++++++++++++--------------------- 1 file changed, 49 insertions(+), 53 deletions(-) diff --git a/nxc/modules/ntlmsign.py b/nxc/modules/ntlmsign.py index d53fd6e6e7..63122c3b01 100644 --- a/nxc/modules/ntlmsign.py +++ b/nxc/modules/ntlmsign.py @@ -3,8 +3,7 @@ from impacket.ldap import ldapasn1 as ldapasn1_impacket from impacket.ntlm import getNTLMSSPType1, getNTLMSSPType3 from impacket.spnego import SPNEGO_NegTokenInit, SPNEGO_NegTokenResp, TypesMech -from impacket.smb3structs import SMB2SessionSetup, SMB2SessionSetup_Response, SMB2_SESSION_SETUP - +from impacket.smb3structs import SMB2SessionSetup, SMB2SessionSetup_Response, SMB2_SESSION_SETUP, SMB2_DIALECT_30 from nxc.helpers.misc import CATEGORY import contextlib @@ -14,77 +13,69 @@ class NXCModule: Checks whether a target enforces NTLM signing (KB5135557 / ServerRequireNtlmSign) by doing two NTLM authentications with the same creds, one negotiating signing and one not. Unsigned rejected + signed accepted = enforced. + + Module by @SoftAndoWetto """ name = "ntlmsign" description = "Checks NTLM signing enforcement (KB5135557 / ServerRequireNtlmSign)" supported_protocols = ["smb", "ldap"] - opsec_safe = True - multiple_hosts = True category = CATEGORY.ENUMERATION def options(self, context, module_options): """No options available""" def on_login(self, context, connection): - args = connection.args + self.context = context + self.connection = connection method = "NTLM" - if getattr(args, "kerberos", False) or getattr(args, "use_kcache", False): - method = "Kerberos" - elif any(getattr(args, a, None) for a in ("pfx_cert", "pfx_base64", "pem_cert", "pem_key")): - method = "Schannel/certificate" - elif getattr(args, "simple_bind", False): - method = "LDAP simple bind" - - if method != "NTLM": - context.log.fail(f"Auth method {method} not valid. NTLM signing check not applicable.") + if connection.kerberos or connection.args.use_kcache or connection.args.simple_bind \ + or connection.args.pfx_cert or connection.args.pfx_base64 \ + or connection.args.pem_cert or connection.args.pem_key: + context.log.fail("Non-NTLM auth detected. NTLM signing check not applicable.") return - username = (connection.username or "").strip() - password = connection.password or "" - nthash = getattr(connection, "nthash", "") or "" - lmhash = getattr(connection, "lmhash", "") or "" - - is_null_session = not username or (not password and not nthash and not lmhash) - is_guest = username.lower() == "guest" - - if is_null_session or is_guest: - context.log.fail(f"{connection.host} - null/guest auth is exempt from ServerRequireNtlmSign (KB5135557). Re-run with a non-guest account") + if not connection.username or not (connection.password or connection.nthash or connection.lmhash): + self.context.log.fail(f"{connection.host} - requires a username and credential. Re-run with a non-guest account.") return if connection.args.protocol == "smb": - signed_ok, signed_msg = self._bind_smb(context, connection, True) - unsigned_ok, unsigned_msg = self._bind_smb(context, connection, False) + signed_ok, signed_msg = self._bind_smb(True) + unsigned_ok, unsigned_msg = self._bind_smb(False) label = "login" + elif connection.args.protocol == "ldap": - signed_ok, signed_msg = self._bind_ldap(context, connection, True) - unsigned_ok, unsigned_msg = self._bind_ldap(context, connection, False) + signed_ok, signed_msg = self._bind_ldap(True) + unsigned_ok, unsigned_msg = self._bind_ldap(False) label = "bind" else: - context.log.fail(f"{connection.host} - unsupported protocol {connection.args.protocol!r}") + self.context.log.fail(f"{connection.host} - unsupported protocol {connection.args.protocol!r}") return - host = connection.host - if signed_ok and not unsigned_ok: - context.log.success(f"{host} - NTLM signing ENFORCED (unsigned {label} rejected, signed accepted)") + self.context.log.success(f"{connection.host} - NTLM signing ENFORCED (unsigned {label} rejected, signed accepted)") elif signed_ok and unsigned_ok: - context.log.highlight(f"{host} - NTLM signing NOT enforced (signed and unsigned {label}s both accepted)") + self.context.log.highlight(f"{connection.host} - NTLM signing NOT enforced (signed and unsigned {label}s both accepted)") else: state = "inconclusive" if not unsigned_ok else "UNEXPECTED (unsigned ok, signed failed)" - context.log.fail(f"{host} - {state}: signed={signed_msg!r} unsigned={unsigned_msg!r}") + self.context.log.fail(f"{connection.host} - {state}: signed={signed_msg!r} unsigned={unsigned_msg!r}") - def _bind_smb(self, context, c, sign): + def _bind_smb(self, sign): """One full NTLM authentication. Returns (success, status_string).""" label = "signed" if sign else "unsigned" conn = None try: - conn = SMBConnection(remoteName=c.host, remoteHost=c.host, sess_port=getattr(c, "port", 445), timeout=10) + conn = SMBConnection( + remoteName=self.connection.host, + remoteHost=self.connection.host, + sess_port=445, + preferredDialect=SMB2_DIALECT_30, + timeout=10 + ) + smb = conn.getSMBServer() - if not hasattr(smb, "_Connection"): - return False, "SMB1 dialect negotiated, not supported" - + # Type 1 negotiate = getNTLMSSPType1(signingRequired=sign) blob1 = SPNEGO_NegTokenInit() @@ -121,11 +112,11 @@ def _bind_smb(self, context, c, sign): # Type 3 type3, _ = getNTLMSSPType3( negotiate, challenge, - c.username or "", - c.password or "", - c.domain or "", - c.lmhash or "", - c.nthash or "", + self.connection.username, + self.connection.password, + self.connection.domain, + self.connection.lmhash, + self.connection.nthash, ) auth_token = SPNEGO_NegTokenResp() auth_token["ResponseToken"] = type3.getData() @@ -148,21 +139,21 @@ def _bind_smb(self, context, c, sign): pkt2_id = smb.sendSMB(pkt2) resp2 = smb.recvSMB(pkt2_id) status = resp2["Status"] - context.log.debug(f"[smb:{label}] status={status:#010x}") + self.context.log.debug(f"[smb:{label}] status={status:#010x}") return status == 0, f"STATUS={status:#010x}" except Exception as e: - context.log.debug(f"[smb:{label}] login error: {e!r}") + self.context.log.debug(f"[smb:{label}] login error: {e!r}") return False, str(e) finally: if conn is not None: with contextlib.suppress(Exception): conn.close() - def _bind_ldap(self, context, c, sign): + def _bind_ldap(self, sign): """One full sicily bind. Returns (success, diagnostic_message).""" label = "signed" if sign else "unsigned" try: - conn = ldap_impacket.LDAPConnection(f"ldap://{c.host}", dstIp=c.host) + conn = ldap_impacket.LDAPConnection(f"ldap://{self.connection.host}", dstIp=self.connection.host) negotiate = getNTLMSSPType1(signingRequired=sign) req = ldapasn1_impacket.BindRequest() @@ -173,18 +164,23 @@ def _bind_ldap(self, context, c, sign): challenge = bytes(resp["bindResponse"]["matchedDN"]) type3, _ = getNTLMSSPType3( - negotiate, challenge, c.username, c.password or "", c.domain or "", - c.lmhash or "", c.nthash or "", + negotiate, + challenge, + self.connection.username, + self.connection.password, + self.connection.domain, + self.connection.lmhash, + self.connection.nthash, ) req = ldapasn1_impacket.BindRequest() req["version"] = 3 - req["name"] = c.username + req["name"] = self.connection.username req["authentication"]["sicilyResponse"] = type3.getData() resp = conn.sendReceive(req)[0]["protocolOp"]["bindResponse"] code, msg = int(resp["resultCode"]), str(resp["diagnosticMessage"]) - context.log.debug(f"[ldap:{label}] resultCode={code} msg={msg!r}") + self.context.log.debug(f"[ldap:{label}] resultCode={code} msg={msg!r}") return code == 0, msg except Exception as e: - context.log.debug(f"[ldap:{label}] bind error: {e!r}") + self.context.log.debug(f"[ldap:{label}] bind error: {e!r}") return False, str(e) From ec87e32d11ab533c6acb0533271d5b47354dbb77 Mon Sep 17 00:00:00 2001 From: SoftAndoWetto <188264635+SoftAndoWetto@users.noreply.github.com> Date: Tue, 17 Nov 2026 19:00:45 +0000 Subject: [PATCH 06/10] Refactor NTLM login method for clarity (It was broken) Signed-off-by: SoftAndoWetto <188264635+SoftAndoWetto@users.noreply.github.com> --- nxc/modules/ntlmsign.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nxc/modules/ntlmsign.py b/nxc/modules/ntlmsign.py index 63122c3b01..d360492e48 100644 --- a/nxc/modules/ntlmsign.py +++ b/nxc/modules/ntlmsign.py @@ -28,11 +28,11 @@ def options(self, context, module_options): def on_login(self, context, connection): self.context = context self.connection = connection - method = "NTLM" - if connection.kerberos or connection.args.use_kcache or connection.args.simple_bind \ - or connection.args.pfx_cert or connection.args.pfx_base64 \ - or connection.args.pem_cert or connection.args.pem_key: + if (connection.kerberos or connection.args.use_kcache + or connection.args.pfx_cert or connection.args.pfx_base64 + or connection.args.pem_cert or connection.args.pem_key + or (connection.args.protocol == "ldap" and connection.args.simple_bind)): context.log.fail("Non-NTLM auth detected. NTLM signing check not applicable.") return From ecd1e7102d57a204efff2d7c3a743b3bac6b660e Mon Sep 17 00:00:00 2001 From: Alexander Neff Date: Tue, 17 Nov 2026 21:01:14 +0100 Subject: [PATCH 07/10] Add AGENTS.md instructions --- AGENTS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/AGENTS.md b/AGENTS.md index 618dbe2e27..61b02b75e6 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -31,6 +31,7 @@ - In files under `nxc/modules/`, do not define variables, constants, or helper functions at module scope. - Keep all module-specific state, constants, and helper methods inside the `NXCModule` class. - Module scope should contain only imports and the `NXCModule` class definition. +- The module variables `opsec_safe` and `multiple_hosts` are obsolete and must no longer be added. - When module options are invalid, log the reason with `context.log.fail()` and `return False` from `options()`; do not call `exit()`. - Do not over-validate module options. Check only that required arguments are present, mutually exclusive arguments are not combined, or a value would otherwise cause the module to fail before performing its normal lookup or operation. - Do not validate whether user-supplied object names, identifiers, or similar values are semantically correct when the underlying protocol lookup can handle them; let a misspecified value produce the normal "not found" result. From f14a5d3f913a72432acef5a2c2c3fa0ad4219603 Mon Sep 17 00:00:00 2001 From: Alexander Neff Date: Tue, 17 Nov 2026 21:11:11 +0100 Subject: [PATCH 08/10] Formatting --- nxc/modules/ntlmsign.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/nxc/modules/ntlmsign.py b/nxc/modules/ntlmsign.py index d360492e48..57b2c58772 100644 --- a/nxc/modules/ntlmsign.py +++ b/nxc/modules/ntlmsign.py @@ -29,8 +29,7 @@ def on_login(self, context, connection): self.context = context self.connection = connection - if (connection.kerberos or connection.args.use_kcache - or connection.args.pfx_cert or connection.args.pfx_base64 + if (connection.kerberos or connection.args.pfx_cert or connection.args.pfx_base64 or connection.args.pem_cert or connection.args.pem_key or (connection.args.protocol == "ldap" and connection.args.simple_bind)): context.log.fail("Non-NTLM auth detected. NTLM signing check not applicable.") @@ -49,9 +48,6 @@ def on_login(self, context, connection): signed_ok, signed_msg = self._bind_ldap(True) unsigned_ok, unsigned_msg = self._bind_ldap(False) label = "bind" - else: - self.context.log.fail(f"{connection.host} - unsupported protocol {connection.args.protocol!r}") - return if signed_ok and not unsigned_ok: self.context.log.success(f"{connection.host} - NTLM signing ENFORCED (unsigned {label} rejected, signed accepted)") From b3fe53d6c87788ff3fc908e4cc98a2a7f8a3785f Mon Sep 17 00:00:00 2001 From: Alexander Neff Date: Tue, 17 Nov 2026 22:13:44 +0100 Subject: [PATCH 09/10] Emphasize that we are actively checking the logins --- nxc/modules/ntlmsign.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nxc/modules/ntlmsign.py b/nxc/modules/ntlmsign.py index 57b2c58772..d512a01a78 100644 --- a/nxc/modules/ntlmsign.py +++ b/nxc/modules/ntlmsign.py @@ -18,7 +18,7 @@ class NXCModule: """ name = "ntlmsign" - description = "Checks NTLM signing enforcement (KB5135557 / ServerRequireNtlmSign)" + description = "Actively probes NTLM signing enforcement (KB5135557 / ServerRequireNtlmSign)" supported_protocols = ["smb", "ldap"] category = CATEGORY.ENUMERATION From a8a72f675e74bce88c08a3e8b52e12a265a8b2c2 Mon Sep 17 00:00:00 2001 From: Alexander Neff Date: Tue, 17 Nov 2026 22:22:26 +0100 Subject: [PATCH 10/10] Make the log a display since signing is enforced is not 'success' --- nxc/modules/ntlmsign.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nxc/modules/ntlmsign.py b/nxc/modules/ntlmsign.py index d512a01a78..063779b541 100644 --- a/nxc/modules/ntlmsign.py +++ b/nxc/modules/ntlmsign.py @@ -50,7 +50,7 @@ def on_login(self, context, connection): label = "bind" if signed_ok and not unsigned_ok: - self.context.log.success(f"{connection.host} - NTLM signing ENFORCED (unsigned {label} rejected, signed accepted)") + self.context.log.display(f"{connection.host} - NTLM signing ENFORCED (unsigned {label} rejected, signed accepted)") elif signed_ok and unsigned_ok: self.context.log.highlight(f"{connection.host} - NTLM signing NOT enforced (signed and unsigned {label}s both accepted)") else: