summaryrefslogtreecommitdiffstats
path: root/scripts/amqp-info.nse
blob: d0d299f43043357744b3788931e2eb1b277257ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
local amqp = require "amqp"
local nmap = require "nmap"
local shortport = require "shortport"
local stdnse = require "stdnse"

description = [[
Gathers information (a list of all server properties) from an AMQP (advanced message queuing protocol) server.

See http://www.rabbitmq.com/extensions.html for details on the
<code>server-properties</code> field.
]]

---
-- @usage
-- nmap --script amqp-info -p5672 <target>
---
-- @output
-- 5672/tcp open  amqp
-- | amqp-info:
-- |   capabilities:
-- |     publisher_confirms: YES
-- |     exchange_exchange_bindings: YES
-- |     basic.nack: YES
-- |     consumer_cancel_notify: YES
-- |   copyright: Copyright (C) 2007-2011 VMware, Inc.
-- |   information: Licensed under the MPL.  See http://www.rabbitmq.com/
-- |   platform: Erlang/OTP
-- |   product: RabbitMQ
-- |   version: 2.4.0
-- |   mechanisms: PLAIN AMQPLAIN
-- |_  locales: en_US

author = "Sebastian Dragomir"

license = "Same as Nmap--See https://nmap.org/book/man-legal.html"

categories = {"default", "discovery", "safe", "version"}


portrule = shortport.version_port_or_service(5672, "amqp", "tcp", "open")

action = function(host, port)
  local cli = amqp.AMQP:new( host, port )

  local status, data = cli:connect()
  if not status then return "Unable to open connection: " .. data end

  status, data = cli:handshake()
  if not status then return data end

  cli:disconnect()

  port.version.name = "amqp"
  port.version.product = cli:getServerProduct()
  port.version.extrainfo = cli:getProtocolVersion()
  port.version.version = cli:getServerVersion()
  nmap.set_port_version(host, port)

  return stdnse.format_output(status, cli:getServerProperties())
end