Skip to content

Commit 5e9e06b

Browse files
committed
Formating
1 parent 17ef18e commit 5e9e06b

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

nxc/modules/change-password.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from impacket.dcerpc.v5 import samr, epm, transport
33
from impacket.dcerpc.v5.rpcrt import DCERPCException
44

5+
56
class NXCModule:
67
"""
78
Module for changing or resetting user passwords
@@ -30,7 +31,7 @@ def options(self, context, module_options):
3031
If STATUS_PASSWORD_MUST_CHANGE or STATUS_PASSWORD_EXPIRED (Change password for current user)
3132
netexec smb <DC_IP> -u username -p oldpass -M change-password -o OLDPASS='oldpass' NEWPASS='newpass'
3233
netexec smb <DC_IP> -u username -H oldnthash -M change-password -o OLDNTHASH='oldnthash' NEWPASS='newpass'
33-
34+
3435
If want to change other user's password (with forcechangepassword priv or admin rights)
3536
netexec smb <DC_IP> -u username -p password -M change-password -o USER='target_user' NEWPASS='target_user_newpass'
3637
netexec smb <DC_IP> -u username -p password -M change-password -o USER='target_user' NEWNTHASH='target_user_newnthash'
@@ -85,14 +86,13 @@ def authenticate(self, context, connection, protocol, anonymous=False):
8586
def on_login(self, context, connection):
8687
target_username = self.target_user or connection.username
8788
target_domain = connection.domain
88-
89+
8990
# If OLDPASS or OLDHASH are not specified, default to the credentials used for authentication.
9091
if not self.oldpass:
9192
self.oldpass = connection.password
9293
if not self.oldhash:
9394
self.oldhash = connection.nthash
94-
95-
95+
9696
new_lmhash, new_nthash = "", ""
9797

9898
# Parse new hash values if provided
@@ -156,7 +156,7 @@ def mustchangePassword(self, target_username, targetDomain, oldPassword, newPass
156156
# Change password using old and new plaintext passwords
157157
samr.hSamrUnicodeChangePasswordUser2(self.dce, "\x00", target_username, oldPassword, newPassword, "", "")
158158
self.context.log.success(f"Successfully changed password for {target_username}")
159-
elif newPassword and oldPwdHashNT:
159+
elif newPassword and oldPwdHashNT:
160160
# Change password using hash for authentication
161161
samr.hSamrUnicodeChangePasswordUser2(self.dce, "\x00", target_username, oldPassword, newPassword, "", oldPwdHashNT)
162162
self.context.log.success(f"Successfully changed password for {target_username}")

0 commit comments

Comments
 (0)