Skip to content

Commit a1f3aaa

Browse files
committed
Attempt to resolve and open target user; abort if not found or not accessible. Preventing for trying to change (failed: rpc_x_bad_stub_data)
1 parent 4a5cbf6 commit a1f3aaa

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

nxc/modules/change-password.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def on_login(self, context, connection):
129129
def _smb_samr_change(self, context, connection, target_username, target_domain, oldHash, newPassword, newHash):
130130
# Reset the password for a different user
131131
if target_username != connection.username:
132-
user_handle = self._hSamrOpenUser(connection, target_username)
132+
if not (user_handle := self._hSamrOpenUser(connection, target_username)): return False
133133
samr.hSamrSetNTInternal1(self.dce, user_handle, newPassword, newHash)
134134
context.log.success(f"Successfully changed password for {target_username}")
135135
else:
@@ -139,7 +139,7 @@ def _smb_samr_change(self, context, connection, target_username, target_domain,
139139
samr.hSamrUnicodeChangePasswordUser2(self.dce, "\x00", target_username, self.oldpass, newPassword, "", oldHash)
140140
else:
141141
# Change the password with new hash
142-
user_handle = self._hSamrOpenUser(connection, target_username)
142+
if not (user_handle := self._hSamrOpenUser(connection, target_username)): return False
143143
samr.hSamrChangePasswordUser(self.dce, user_handle, self.oldpass, "", oldHash, "aad3b435b51404eeaad3b435b51404ee", newHash)
144144
context.log.highlight("Note: Target user must change password at next logon.")
145145
context.log.success(f"Successfully changed password for {target_username}")

0 commit comments

Comments
 (0)