File: rtsp-methods.nse

package info (click to toggle)
nmap 7.70%2Bdfsg1-6%2Bdeb10u2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 52,312 kB
  • sloc: cpp: 60,773; ansic: 56,414; python: 17,768; sh: 16,298; xml: 11,478; perl: 2,679; makefile: 1,211; java: 45; objc: 43; awk: 23
file content (57 lines) | stat: -rw-r--r-- 1,438 bytes parent folder | download | duplicates (2)
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
local rtsp = require "rtsp"
local shortport = require "shortport"
local stdnse = require "stdnse"

description = [[
Determines which methods are supported by the RTSP (real time streaming protocol) server.
]]

---
-- @usage
-- nmap -p 554 --script rtsp-methods <ip>
--
-- @output
-- PORT    STATE SERVICE
-- 554/tcp open  rtsp
-- | rtsp-methods:
-- |_  DESCRIBE, SETUP, PLAY, TEARDOWN, OPTIONS
--
-- @xmloutput
-- <elem>DESCRIBE</elem>
-- <elem>SETUP</elem>
-- <elem>PLAY</elem>
-- <elem>TEARDOWN</elem>
-- <elem>OPTIONS</elem>
--
-- @args rtsp-methods.path the path to query, defaults to "*" which queries
--       the server itself, rather than a specific url.
--

--
-- Version 0.1
-- Created 23/10/2011 - v0.1 - created by Patrik Karlsson <patrik@cqure.net>
--
author = "Patrik Karlsson"
license = "Same as Nmap--See https://nmap.org/book/man-legal.html"
categories = {"default", "safe"}


portrule = shortport.port_or_service(554, "rtsp", "tcp", "open")

action = function(host, port)
  local path = stdnse.get_script_args('rtsp-methods.path') or '*'
  local helper = rtsp.Helper:new(host, port)
  local status = helper:connect()
  if ( not(status) ) then
    stdnse.debug2("ERROR: Failed to connect to RTSP server")
    return
  end

  local response
  status, response = helper:options(path)
  helper:close()
  if ( status ) then
    local opts = response.headers['Public']
    return stdnse.strsplit(",%s*", opts), opts
  end
end