Skip to content

Commit 64e78fd

Browse files
committed
Fixing shares function with kerberos and minor database stuff
1 parent 9f3a77c commit 64e78fd

1 file changed

Lines changed: 7 additions & 13 deletions

File tree

nxc/protocols/smb.py

Lines changed: 7 additions & 13 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()}"
@@ -764,10 +758,10 @@ def shares(self):
764758
self.logger.debug(f"domain: {self.domain}")
765759
user_id = self.db.get_user(self.domain.upper(), self.username)[0][0]
766760
except IndexError as e:
767-
if self.use_kcache:
761+
if self.kerberos:
768762
pass
769763
else:
770-
self.logger.fail(f"IndexError: {str(e)}")
764+
self.logger.fail(f"IndexError: {e!s}")
771765
except Exception as e:
772766
error = get_error_string(e)
773767
self.logger.fail(f"Error getting user: {error}")

0 commit comments

Comments
 (0)