@@ -27,7 +27,7 @@ def options(self, context, module_options):
2727 Examples
2828 --------
2929 If STATUS_PASSWORD_MUST_CHANGE or STATUS_PASSWORD_EXPIRED (Change password for current user)
30- netexec smb <DC_IP> -u username -p oldpass -M change-password -o NEWPASS='newpass '
30+ netexec smb <DC_IP> -u username -p oldpass -M change-password -o NEWNTHASH='nthash '
3131 netexec smb <DC_IP> -u username -H oldnthash -M change-password -o NEWPASS='newpass'
3232
3333 If want to change other user's password (with forcechangepassword priv or admin rights)
@@ -73,7 +73,6 @@ def authenticate(self, context, connection, protocol, anonymous=False):
7373 dce .bind (samr .MSRPC_UUID_SAMR )
7474 context .log .info ("[+] Successfully bound to SAMR" )
7575 return dce
76-
7776 except DCERPCException as e :
7877 context .log .fail (f"DCE/RPC Exception: { e !s} " )
7978 raise
@@ -120,7 +119,7 @@ def _smb_samr_change(self, context, connection, target_username, target_domain,
120119 try :
121120 # Reset the password for a different user
122121 if target_username != connection .username :
123- user_handle = self .hSamrOpenUser (connection , target_username )
122+ user_handle = self ._hSamrOpenUser (connection , target_username )
124123 samr .hSamrSetNTInternal1 (self .dce , user_handle , newPassword , newHash )
125124 context .log .success (f"Successfully changed password for { target_username } " )
126125 else :
@@ -130,7 +129,7 @@ def _smb_samr_change(self, context, connection, target_username, target_domain,
130129 samr .hSamrUnicodeChangePasswordUser2 (self .dce , "\x00 " , target_username , self .oldpass , newPassword , "" , oldHash )
131130 else :
132131 # Change the password with new hash
133- user_handle = self .hSamrOpenUser (connection , target_username )
132+ user_handle = self ._hSamrOpenUser (connection , target_username )
134133 samr .hSamrChangePasswordUser (self .dce , user_handle , self .oldpass , "" , oldHash , "aad3b435b51404eeaad3b435b51404ee" , newHash )
135134 context .log .highlight ("Note: Target user must change password at next logon." )
136135 context .log .success (f"Successfully changed password for { target_username } " )
@@ -139,7 +138,7 @@ def _smb_samr_change(self, context, connection, target_username, target_domain,
139138 finally :
140139 self .dce .disconnect ()
141140
142- def hSamrOpenUser (self , connection , username ):
141+ def _hSamrOpenUser (self , connection , username ):
143142 """Get handle to the user object"""
144143 try :
145144 # Connect to the target server and retrieve handles
@@ -149,4 +148,4 @@ def hSamrOpenUser(self, connection, username):
149148 user_rid = samr .hSamrLookupNamesInDomain (self .dce , domain_handle , (username ,))["RelativeIds" ]["Element" ][0 ]
150149 return samr .hSamrOpenUser (self .dce , domain_handle , userId = user_rid )["UserHandle" ]
151150 except Exception as e :
152- self .context .log .fail (f"Failed to open user: { e } " )
151+ self .context .log .fail (f"Failed to open user: { e } " )
0 commit comments