Home page logo
/
Intro Reference Guide Book Install Guide
Download Changelog Zenmap GUI Docs
Bug Reports OS Detection Propaganda Related Projects
In the Movies In the News

Sponsors


Library upnp

A UPNP library based on code from upnp-info initially written by Thomas Buchanan. The code was factored out from upnp-info and partly re-written by Patrik Karlsson <patrik@cqure.net> in order to support multicast requests.

The library supports sending UPnP requests and decoding the responses

The library contains the following classes

  • Comm
** A class that handles communication with the UPnP service
  • Helper
** The helper class wraps the Comm class using functions with a more descriptive name.
  • Util
** The Util class contains a number of static functions mainly used to convert and sort data.

The following code snippet queries all UPnP services on the network:

  local helper = upnp.Helper:new()
  helper:setMulticast(true)
  return stdnse.format_output(helper:queryServices())

This next snippet queries a specific host for the same information:

  local helper = upnp.Helper:new(host, port)
  return stdnse.format_output(helper:queryServices())

Author:
"Thomas Buchanan, Patrik Karlsson <patrik@cqure.net>"

Source: http://nmap.org/svn/nselib/upnp.lua

Functions

close (self)

Closes the socket

connect (self)

Connect to the server

decodeResponse (self, response)

Processes a response from a upnp device

ipCompare (a, b)

Compare function used for sorting IP-addresses

new (self, host, port)

Creates a new helper instance

new (self, host, port)

Creates a new helper instance

queryServices (self)

Sends a UPnP queries and collects a single or multiple responses

receiveResponse (self)

Receives one or multiple UPNP responses depending on whether setBroadcast was enabled or not.

retrieveXML (self, location)

Retrieves the XML file that describes the UPNP device

sendRequest (self)

Send the UPNP discovery request to the server

setMulticast (self, mcast)

Enables or disables multicast support

setMulticast (self, mcast)

Enables or disables multicast support

setOverride (self, override)

Enables or disables whether the script will override the IP address is the Location URL



Functions

close (self)

Closes the socket

Parameters

  • self:
connect (self)

Connect to the server

Parameters

  • self:

Return value:

status true on success, false on failure
decodeResponse (self, response)

Processes a response from a upnp device

Parameters

  • self:
  • response: as received over the socket

Return values:

  1. status boolean true on success, false on failure
  2. response table or string suitable for output or error message if status is false
ipCompare (a, b)

Compare function used for sorting IP-addresses

Parameters

  • a: table containing first item
  • b: table containing second item

Return value:

true if a is less than b
new (self, host, port)

Creates a new helper instance

Parameters

  • self:
  • host: string containing the host name or ip
  • port: number containing the port to connect to

Return value:

o a new instance of Helper
new (self, host, port)

Creates a new helper instance

Parameters

  • self:
  • host: string containing the host name or ip
  • port: number containing the port to connect to

Return value:

o a new instance of Helper
queryServices (self)

Sends a UPnP queries and collects a single or multiple responses

Parameters

  • self:

Return values:

  1. status true on success, false on failure
  2. result table or string containing results or error message on failure.
receiveResponse (self)

Receives one or multiple UPNP responses depending on whether setBroadcast was enabled or not.

The function returns the status and a response containing:

  • an array (table) of responses if broadcast is used
  • a single response if broadcast is not in use
  • an error message if status was false

Parameters

  • self:

Return values:

  1. status true on success, false on failure
  2. result table or string containing results or error message on failure.
retrieveXML (self, location)

Retrieves the XML file that describes the UPNP device

Parameters

  • self:
  • location: string containing the location of the XML file from the UPNP response

Return values:

  1. status boolean true on success, false on failure
  2. response table or string suitable for output or error message if status is false
sendRequest (self)

Send the UPNP discovery request to the server

Parameters

  • self:

Return value:

status true on success, false on failure
setMulticast (self, mcast)

Enables or disables multicast support

Parameters

  • self:
  • mcast: boolean true if multicast is to be used, false otherwise
setMulticast (self, mcast)

Enables or disables multicast support

Parameters

  • self:
  • mcast: boolean true if multicast is to be used, false otherwise
setOverride (self, override)

Enables or disables whether the script will override the IP address is the Location URL

Parameters

  • self:
  • override: boolean true if override is to be enabled, false otherwise

Nmap Site Navigation

Intro Reference Guide Book Install Guide
Download Changelog Zenmap GUI Docs
Bug Reports OS Detection Propaganda Related Projects
In the Movies In the News
[ Nmap | Sec Tools | Mailing Lists | Site News | About/Contact | Advertising | Privacy ]