mirror of
https://github.com/Pennyw0rth/NetExec
synced 2026-06-06 16:34:30 +00:00
Merge pull request #677 from Pennyw0rth/neff-fix-ldap-kerb-dom-trust
Fix domain trust with kerberos in ldap
This commit is contained in:
+11
-3
@@ -25,6 +25,7 @@ from impacket.dcerpc.v5.samr import (
|
||||
)
|
||||
from impacket.krb5 import constants
|
||||
from impacket.krb5.kerberosv5 import getKerberosTGS, SessionKeyDecryptionError
|
||||
from impacket.krb5.ccache import CCache
|
||||
from impacket.krb5.types import Principal, KerberosException
|
||||
from impacket.ldap import ldap as ldap_impacket
|
||||
from impacket.ldap import ldaptypes
|
||||
@@ -232,7 +233,6 @@ class ldap(connection):
|
||||
def enum_host_info(self):
|
||||
self.hostname = self.target.split(".")[0].upper() if "." in self.target else self.target
|
||||
self.remoteName = self.target
|
||||
self.domain = self.targetDomain
|
||||
|
||||
ntlm_challenge = None
|
||||
bindRequest = ldapasn1_impacket.BindRequest()
|
||||
@@ -250,6 +250,14 @@ class ldap(connection):
|
||||
ntlm_info = parse_challenge(ntlm_challenge)
|
||||
self.server_os = ntlm_info["os_version"]
|
||||
|
||||
if self.args.domain:
|
||||
self.domain = self.args.domain
|
||||
elif self.args.use_kcache: # Fixing domain trust, just pull the auth domain out of the ticket
|
||||
self.domain = CCache.parseFile()[0]
|
||||
self.username = CCache.parseFile()[1]
|
||||
else:
|
||||
self.domain = self.targetDomain
|
||||
|
||||
# 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
|
||||
if not self.kdcHost and self.domain and self.domain == self.targetDomain:
|
||||
result = self.resolver(self.domain)
|
||||
@@ -276,7 +284,7 @@ class ldap(connection):
|
||||
self.logger.display(f"{self.server_os} (name:{self.hostname}) (domain:{self.domain})")
|
||||
|
||||
def kerberos_login(self, domain, username, password="", ntlm_hash="", aesKey="", kdcHost="", useCache=False):
|
||||
self.username = username
|
||||
self.username = username if not self.username else self.username # With ccache we get the username from the ticket
|
||||
self.password = password
|
||||
self.domain = domain
|
||||
self.kdcHost = kdcHost
|
||||
@@ -284,7 +292,7 @@ class ldap(connection):
|
||||
|
||||
lmhash = ""
|
||||
nthash = ""
|
||||
self.username = username
|
||||
|
||||
# This checks to see if we didn't provide the LM Hash
|
||||
if ntlm_hash.find(":") != -1:
|
||||
lmhash, nthash = ntlm_hash.split(":")
|
||||
|
||||
Reference in New Issue
Block a user