Skip to content

Commit ccbeb4e

Browse files
authored
Merge pull request Pennyw0rth#357 from termanix/patch-3
Small Bug Fix on Listing SMB Shares with Kerberos Auth
2 parents d8f0f41 + 64e78fd commit ccbeb4e

1 file changed

Lines changed: 10 additions & 11 deletions

File tree

nxc/protocols/smb.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -397,11 +397,11 @@ def plaintext_login(self, domain, username, password):
397397
self.logger.debug(f"{self.is_guest=}")
398398
if "Unix" not in self.server_os:
399399
self.check_if_admin()
400+
400401
self.logger.debug(f"Adding credential: {domain}/{self.username}:{self.password}")
401402
self.db.add_credential("plaintext", domain, self.username, self.password)
402403
user_id = self.db.get_credential("plaintext", domain, self.username, self.password)
403404
host_id = self.db.get_hosts(self.host)[0].id
404-
405405
self.db.add_loggedin_relation(user_id, host_id)
406406

407407
out = f"{domain}\\{self.username}:{process_secret(self.password)} {self.mark_guest()}{self.mark_pwned()}"
@@ -411,14 +411,7 @@ def plaintext_login(self, domain, username, password):
411411
add_user_bh(self.username, self.domain, self.logger, self.config)
412412
if self.admin_privs:
413413
self.logger.debug(f"Adding admin user: {self.domain}/{self.username}:{self.password}@{self.host}")
414-
self.db.add_admin_user(
415-
"plaintext",
416-
domain,
417-
self.username,
418-
self.password,
419-
self.host,
420-
user_id=user_id,
421-
)
414+
self.db.add_admin_user("plaintext", domain, self.username, self.password, self.host, user_id=user_id)
422415
add_user_bh(f"{self.hostname}$", domain, self.logger, self.config)
423416

424417
# check https://github.com/byt3bl33d3r/CrackMapExec/issues/321
@@ -469,9 +462,10 @@ def hash_login(self, domain, username, ntlm_hash):
469462
self.logger.debug(f"{self.is_guest=}")
470463
if "Unix" not in self.server_os:
471464
self.check_if_admin()
472-
user_id = self.db.add_credential("hash", domain, self.username, self.hash)
473-
host_id = self.db.get_hosts(self.host)[0].id
474465

466+
self.db.add_credential("hash", domain, self.username, self.hash)
467+
user_id = self.db.get_credential("hash", domain, self.username, self.hash)
468+
host_id = self.db.get_hosts(self.host)[0].id
475469
self.db.add_loggedin_relation(user_id, host_id)
476470

477471
out = f"{domain}\\{self.username}:{process_secret(self.hash)} {self.mark_guest()}{self.mark_pwned()}"
@@ -763,6 +757,11 @@ def shares(self):
763757
try:
764758
self.logger.debug(f"domain: {self.domain}")
765759
user_id = self.db.get_user(self.domain.upper(), self.username)[0][0]
760+
except IndexError as e:
761+
if self.kerberos:
762+
pass
763+
else:
764+
self.logger.fail(f"IndexError: {e!s}")
766765
except Exception as e:
767766
error = get_error_string(e)
768767
self.logger.fail(f"Error getting user: {error}")

0 commit comments

Comments
 (0)