Skip to content

Commit 4d148da

Browse files
committed
fix: use target FQDN directly for Kerberos SPN when host contains a dot
Reconstructing the remote name as {netbios_hostname}.{targetDomain} produces the wrong SPN when a host's DNS suffix differs from the AD domain name (e.g. host.aepsc.com registered in AD vs the constructed host.corp.aepsc.com), resulting in KDC_ERR_S_PRINCIPAL_UNKNOWN. Use self.host directly when it is already an FQDN, matching Impacket's smbclient behaviour.
1 parent 9a39a07 commit 4d148da

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

nxc/protocols/smb.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,8 @@ def enum_host_info(self):
282282
self.logger.debug(f"Error adding host {self.host} into db: {e!s}")
283283

284284
# DCOM connection with kerberos needed
285-
self.remoteName = self.host if not self.kerberos else f"{self.hostname}.{self.targetDomain}"
285+
# When the target is already an FQDN, use it directly so the SPN matches the host's AD registration (e.g. host.aepsc.com, not host.corp.aepsc.com).
286+
self.remoteName = self.host if (not self.kerberos or "." in self.host) else f"{self.hostname}.{self.targetDomain}"
286287

287288
# using kdcHost is buggy on impacket when using trust relation between ad so we kdcHost must stay to none if targetdomain is not equal to domain
288289
if not self.kdcHost and self.domain and self.domain == self.targetDomain:

0 commit comments

Comments
 (0)