You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: modules/auxiliary/admin/smb/change_password.rb
+73-30Lines changed: 73 additions & 30 deletions
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,6 @@
2
2
##
3
3
4
4
require'ruby_smb/dcerpc/client'
5
-
require'pry-byebug'
6
5
7
6
classMetasploitModule < Msf::Auxiliary
8
7
includeMsf::Exploit::Remote::SMB::Client
@@ -35,16 +34,16 @@ def initialize(info = {})
35
34
['RESET',{'Description'=>"Reset the target's password without knowing the existing one (requires appropriate permissions)"}],
36
35
['RESET_NTLM',{'Description'=>"Reset the target's NTLM hash, without knowing the existing password. This will not update kerberos keys."}],
37
36
['CHANGE',{'Description'=>'Change the password, knowing the existing one.'}],
38
-
['CHANGE_NTLM',{'Description'=>'Change the password to a NTLM hash value, knowing the existing password. Can be either an NT hash or a colon-delimited NTLM hash'}]
37
+
['CHANGE_NTLM',{'Description'=>'Change the password to a NTLM hash value, knowing the existing password. This will not update kerberos keys.'}]
39
38
],
40
39
'DefaultAction'=>'RESET'
41
40
)
42
41
)
43
42
44
43
register_options(
45
44
[
46
-
OptString.new('NEW_PASSWORD',[false,'The new password to change to','']),
47
-
OptString.new('NEW_NTLM',[false,'The new NTLM hash to change to','']),
45
+
OptString.new('NEW_PASSWORD',[false,'The new password to change to',''],conditions: ['ACTION','in',%w[CHANGERESET]]),
46
+
OptString.new('NEW_NTLM',[false,'The new NTLM hash to change to. Can be either an NT hash or a colon-delimited NTLM hash',''],conditions: ['ACTION','in',%w[CHANGE_NTLMRESET_NTLM]]),
48
47
OptString.new('TARGET_USER',[false,'The user to change the password of. If not provided, will change for the account provided in SMBUser'],conditions: ['ACTION','in',%w[RESETRESET_NTLM]])
49
48
]
50
49
)
@@ -69,8 +68,6 @@ def connect_samr
69
68
end
70
69
71
70
defrun
72
-
fail_with('Must set NEW_PASSWORD on NEW_NTLM')ifdatastore['NEW_PASSWORD'].blank? && datastore['NEW_NTLM'].blank?
73
-
74
71
caseaction.name
75
72
when'CHANGE'
76
73
run_change
@@ -82,11 +79,25 @@ def run
82
79
run_change_ntlm
83
80
end
84
81
85
-
# Don't disconnect the client if it's coming from the session so it can be reused
fail_with(Module::Failure::BadConfig,'Must set NEW_NTLM')ifdatastore['NEW_NTLM'].blank?
195
+
fail_with(Module::Failure::BadConfig,'Must set SMBUser to change password')ifdatastore['SMBUser'].blank?
196
+
fail_with(Module::Failure::BadConfig,'Must set SMBPass to change password, or use RESET/RESET_NTLM to force-change a password without knowing the existing password')ifdatastore['SMBPass'].blank?
print_good("Successfully changed password for #{datastore['SMBUser']}")
209
+
print_warning("AES Kerberos keys will not be available until user changes their password")
210
+
end
211
+
212
+
defrun_reset_ntlm
213
+
fail_with(Module::Failure::BadConfig,"Must set TARGET_USER, or use CHANGE/CHANGE_NTLM to reset this user's own password")ifdatastore['TARGET_USER'].blank?
print_good("Successfully reset password for #{datastore['TARGET_USER']}")
236
+
print_warning("AES Kerberos keys will not be available until user changes their password")
190
237
end
191
238
192
239
defrun_reset
193
-
fail_with('Must set TARGET_USER')ifdatastore['TARGET_USER'].blank?
240
+
fail_with(Module::Failure::BadConfig,"Must set TARGET_USER, or use CHANGE/CHANGE_NTLM to reset this user's own password")ifdatastore['TARGET_USER'].blank?
241
+
fail_with(Module::Failure::BadConfig,'Must set NEW_PASSWORD')ifdatastore['NEW_PASSWORD'].blank?
print_good("Successfully reset password for #{datastore['TARGET_USER']}")
218
267
end
219
268
220
269
defrun_change
270
+
fail_with(Module::Failure::BadConfig,'Must set NEW_PASSWORD')ifdatastore['NEW_PASSWORD'].blank?
271
+
fail_with(Module::Failure::BadConfig,'Must set SMBUser to change password')ifdatastore['SMBUser'].blank?
272
+
fail_with(Module::Failure::BadConfig,'Must set SMBPass to change password, or use RESET/RESET_NTLM to force-change a password without knowing the existing password')ifdatastore['SMBPass'].blank?
0 commit comments