Skip to content

Commit fc018eb

Browse files
committed
Initial commit
1 parent e9c7866 commit fc018eb

File tree

2 files changed

+109
-0
lines changed

2 files changed

+109
-0
lines changed

lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_netapi32.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@ def self.create_dll(dll_path = 'netapi32')
6868
["PDWORD","totalentries","out"]
6969
])
7070

71+
dll.add_function('NetUserChangePassword', 'DWORD', [
72+
["PWCHAR","domainname","in"],
73+
["PWCHAR","username","in"],
74+
["PWCHAR","oldpassword","in"],
75+
["PWCHAR","newpassword","in"]
76+
])
77+
7178
return dll
7279
end
7380

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
##
2+
# This module requires Metasploit: http//metasploit.com/download
3+
# Current source: https://github.com/rapid7/metasploit-framework
4+
##
5+
6+
require 'msf/core'
7+
8+
class Metasploit3 < Msf::Post
9+
10+
include Msf::Auxiliary::Report
11+
12+
def initialize(info={})
13+
super(update_info(info,
14+
'Name' => "Windows Manage Change Password",
15+
'Description' => %q{
16+
This module will attempt to change the password of the targetted account.
17+
Its main purpose is when you have valid credentials on a remote host but
18+
they require a password change before you can login e.g.
19+
'System error 1907 has occurred.'
20+
},
21+
'License' => MSF_LICENSE,
22+
'Platform' => ['win'],
23+
'SessionTypes' => ['meterpreter'],
24+
'Author' => ['Ben Campbell']
25+
))
26+
27+
register_options(
28+
[
29+
OptString.new('SMBDomain', [false, 'Domain or Host to change password on, if not set will use the current login domain', nil]),
30+
OptString.new('SMBUser', [true, 'Username to change password of']),
31+
OptString.new('OLD_PASSWORD', [true, 'Original password' ]),
32+
OptString.new('NEW_PASSWORD', [true, 'New password' ]),
33+
], self.class)
34+
end
35+
36+
def run
37+
unless client.railgun
38+
print_error('This module requires a native windows payload that supports railgun.')
39+
return
40+
end
41+
42+
domain = datastore['SMBDomain']
43+
username = datastore['SMBUser']
44+
old_password = datastore['OLD_PASSWORD']
45+
new_password = datastore['NEW_PASSWORD']
46+
print_status("Changing #{domain}\\#{username} password to #{new_password}...")
47+
result = client.railgun.netapi32.NetUserChangePassword(
48+
domain,
49+
username,
50+
old_password,
51+
new_password
52+
)
53+
54+
case result['return']
55+
when 0x05
56+
err_msg = 'ERROR_ACCESS_DENIED'
57+
when 0x56
58+
err_msg = 'ERROR_INVALID_PASSWORD'
59+
when 0x92f
60+
err_msg = 'NERR_InvalidComputer'
61+
when 0x8b2
62+
err_msg = 'NERR_NotPrimary'
63+
when 0x8ad
64+
err_msg = 'NERR_UserNotFound'
65+
when 0x8c5
66+
err_msg = 'NERR_PasswordTooShort'
67+
when 0
68+
print_good('Password change successful.')
69+
report_creds(username, new_password, domain)
70+
else
71+
err_msg = "unknown error code: #{result['return']}"
72+
end
73+
74+
if err_msg
75+
print_error("Password change failed, #{err_msg}.")
76+
end
77+
78+
end
79+
80+
def report_creds(user, pass, domain)
81+
if session.db_record
82+
source_id = session.db_record.id
83+
else
84+
source_id = nil
85+
end
86+
87+
unless domain
88+
domain = session.sock.peerhost
89+
end
90+
91+
report_auth_info(
92+
:host => domain,
93+
:port => 445,
94+
:sname => 'smb',
95+
:proto => 'tcp',
96+
:source_id => source_id,
97+
:source_type => "exploit",
98+
:user => user,
99+
:pass => pass)
100+
end
101+
end
102+

0 commit comments

Comments
 (0)