Skip to content

Commit 71a59a6

Browse files
committed
Fix salt creation when using kerberos auth
1 parent caba5fa commit 71a59a6

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

impacket/examples/regsecrets.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,14 @@ def getMachineKerberosSalt(self):
7676
we have the correct information
7777
"""
7878
if self.__smbConnection.getServerName() == '':
79-
# Todo: figure out an RPC call that gives us the domain FQDN
80-
# instead of the NETBIOS name as NetrWkstaGetInfo does
81-
return b''
79+
host, _ = self.getMachineNameAndDomain()
80+
domain = self.__smbConnection.getRemoteName().split(f"{host}.")[1]
8281
else:
8382
host = self.__smbConnection.getServerName()
8483
domain = self.__smbConnection.getServerDNSDomainName()
85-
salt = b'%shost%s.%s' % (domain.upper().encode('utf-8'), host.lower().encode('utf-8'), domain.lower().encode('utf-8'))
86-
return salt
84+
LOG.debug(f"[Secretsdump][getMachineKerberosSalt] Host: {host} / Domain FQDN: {domain}")
85+
salt = b'%shost%s.%s' % (domain.upper().encode('utf-8'), host.lower().encode('utf-8'), domain.lower().encode('utf-8'))
86+
return salt
8787

8888
def getMachineNameAndDomain(self):
8989
if self.__smbConnection.getServerName() == '':

impacket/examples/secretsdump.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -761,14 +761,14 @@ def getMachineKerberosSalt(self):
761761
we have the correct information
762762
"""
763763
if self.__smbConnection.getServerName() == '':
764-
# Todo: figure out an RPC call that gives us the domain FQDN
765-
# instead of the NETBIOS name as NetrWkstaGetInfo does
766-
return b''
764+
host, _ = self.getMachineNameAndDomain()
765+
domain = self.__smbConnection.getRemoteName().split(f"{host}.")[1]
767766
else:
768767
host = self.__smbConnection.getServerName()
769768
domain = self.__smbConnection.getServerDNSDomainName()
770-
salt = b'%shost%s.%s' % (domain.upper().encode('utf-8'), host.lower().encode('utf-8'), domain.lower().encode('utf-8'))
771-
return salt
769+
LOG.debug(f"[Secretsdump][getMachineKerberosSalt] Host: {host} / Domain FQDN: {domain}")
770+
salt = b'%shost%s.%s' % (domain.upper().encode('utf-8'), host.lower().encode('utf-8'), domain.lower().encode('utf-8'))
771+
return salt
772772

773773
def getMachineNameAndDomain(self):
774774
if self.__smbConnection.getServerName() == '':

0 commit comments

Comments
 (0)