mirror of
https://github.com/nmap/nmap.git
synced 2026-11-22 07:30:59 +00:00
Add configurable SSDP search target to UPnP discovery
This commit is contained in:
parent
d5134b0181
commit
0bdd1740dc
2 changed files with 33 additions and 5 deletions
|
|
@ -111,11 +111,12 @@ Comm = {
|
|||
sendRequest = function( self )
|
||||
|
||||
-- for details about the UPnP message format, see http://upnp.org/resources/documents.asp
|
||||
local payload = 'M-SEARCH * HTTP/1.1\r\n\z
|
||||
Host:239.255.255.250:1900\r\n\z
|
||||
ST:upnp:rootdevice\r\n\z
|
||||
Man:"ssdp:discover"\r\n\z
|
||||
MX:3\r\n\r\n'
|
||||
local search_target = self.search_target or "upnp:rootdevice"
|
||||
local payload = 'M-SEARCH * HTTP/1.1\r\n' ..
|
||||
'Host:239.255.255.250:1900\r\n' ..
|
||||
'ST:' .. search_target .. '\r\n' ..
|
||||
'Man:"ssdp:discover"\r\n' ..
|
||||
'MX:3\r\n\r\n'
|
||||
|
||||
local status, err
|
||||
|
||||
|
|
@ -364,6 +365,17 @@ Helper = {
|
|||
-- @param mcast boolean true if multicast is to be used, false otherwise
|
||||
setMulticast = function( self, mcast ) self.comm:setMulticast(mcast) end,
|
||||
|
||||
--- Sets the SSDP search target for discovery requests.
|
||||
--
|
||||
-- @param search_target string containing the SSDP search target
|
||||
setSearchTarget = function( self, search_target )
|
||||
assert(type(search_target) == "string" and
|
||||
#search_target > 0 and
|
||||
not search_target:find("%c"),
|
||||
"search_target must be a non-empty string without control characters")
|
||||
self.comm.search_target = search_target
|
||||
end,
|
||||
|
||||
--- Enables or disables whether the script will override the IP address in the Location URL
|
||||
--
|
||||
-- @param override boolean true if override is to be enabled, false otherwise
|
||||
|
|
|
|||
|
|
@ -6,6 +6,13 @@ Attempts to extract system information from the UPnP service by sending a multic
|
|||
]]
|
||||
|
||||
---
|
||||
-- @usage
|
||||
-- nmap --script broadcast-upnp-info
|
||||
-- nmap --script broadcast-upnp-info --script-args 'broadcast-upnp-info.st=ssdp:all'
|
||||
--
|
||||
-- @args broadcast-upnp-info.st SSDP search target used in M-SEARCH requests.
|
||||
-- Defaults to upnp:rootdevice.
|
||||
--
|
||||
-- @output
|
||||
-- | broadcast-upnp-info:
|
||||
-- | 1.2.3.50
|
||||
|
|
@ -42,6 +49,15 @@ prerule = function() return true end
|
|||
action = function()
|
||||
local helper = upnp.Helper:new()
|
||||
helper:setMulticast(true)
|
||||
|
||||
local search_target = stdnse.get_script_args(SCRIPT_NAME .. ".st")
|
||||
if search_target ~= nil then
|
||||
if type(search_target) ~= "string" or
|
||||
search_target == "" or search_target:find("%c") then
|
||||
return "Invalid SSDP search target"
|
||||
end
|
||||
helper:setSearchTarget(search_target)
|
||||
end
|
||||
local status, result = helper:queryServices()
|
||||
|
||||
if ( status ) then
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue