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/auxiliary/scanner/amqp/amqp_version.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Auxiliary6include Msf::Auxiliary::Scanner7include Msf::Auxiliary::Report89def initialize10super(11'Name' => 'AMQP 0-9-1 Version Scanner',12'Description' => 'Detect AMQP version information.',13'Author' => 'Spencer McIntyre',14'License' => MSF_LICENSE,15'References' => [16[ 'URL', 'https://www.rabbitmq.com/amqp-0-9-1-reference.html' ]17]18)1920register_options([21Opt::RPORT(5671)22])2324register_advanced_options(25[26OptBool.new('SSL', [ true, 'Negotiate SSL/TLS for outgoing connections', true ]),27Opt::SSLVersion28]29)30end3132def peer33rhost = datastore['RHOST']34rport = datastore['RPORT']35if Rex::Socket.is_ipv6?(rhost)36"[#{rhost}]:#{rport}"37else38"#{rhost}:#{rport}"39end40end4142def print_prefix43peer.ljust(21) + ' - '44end4546def run_host(target_host)47amqp_client = Rex::Proto::Amqp::Version091::Client.new(48target_host,49port: datastore['RPORT'],50context: { 'Msf' => framework, 'MsfExploit' => self },51ssl: datastore['SSL'],52ssl_version: datastore['SSLVersion']53)5455amqp_client.connect56amqp_client.send_protocol_header57amqp_client.recv_connection_start58server_info = amqp_client.server_info5960info_line = 'AMQP Detected'61unless server_info[:properties]['product'].blank? || server_info[:properties]['version'].blank?62info_line << " (version:#{server_info[:properties]['product']} #{server_info[:properties]['version']})"63end64unless server_info[:properties]['cluster_name'].blank?65info_line << " (cluster:#{server_info[:properties]['cluster_name']})"66end67unless server_info[:properties]['platform'].blank?68info_line << " (platform:#{server_info[:properties]['platform']})"69end70info_line << " (authentication:#{server_info[:security_mechanisms].join(', ')})"71print_status(info_line)72report_service(73host: target_host,74port: datastore['RPORT'],75name: "amqp#{datastore['SSL'] ? 's' : ''}",76info: info_line77)78rescue Rex::Proto::Amqp::Error::UnexpectedReplyError => e79fail_with(Failure::UnexpectedReply, e.message)80rescue Rex::Proto::Amqp::Error::AmqpError => e81fail_with(Failure::Unknown, e.message)82ensure83amqp_client.close84end85end868788