mirror of
https://github.com/nmap/nmap.git
synced 2026-01-02 12:59:02 +00:00
Added IP information to the returned result and added support for collecting multiple
responses.
This commit is contained in:
@@ -8,10 +8,11 @@ Discovers Telldus Technologies TellStickNet devices on the LAN.
|
||||
--
|
||||
-- @output
|
||||
-- | broadcast-tellstick-discover:
|
||||
-- | Product: TellStickNet
|
||||
-- | MAC: ACCA12345678
|
||||
-- | Activation code: 8QABCDEFGH
|
||||
-- |_ Version: 3
|
||||
-- | 192.168.0.100
|
||||
-- | Product: TellStickNet
|
||||
-- | MAC: ACCA12345678
|
||||
-- | Activation code: 8QABCDEFGH
|
||||
-- |_ Version: 3
|
||||
--
|
||||
|
||||
author = "Patrik Karlsson"
|
||||
@@ -20,8 +21,6 @@ categories = {"broadcast", "safe"}
|
||||
|
||||
prerule = function() return ( nmap.address_family() == 'inet' ) end
|
||||
|
||||
local function fail(err) return ("\n ERROR: %s"):format(err or "") end
|
||||
|
||||
action = function()
|
||||
local socket = nmap.new_socket("udp")
|
||||
local host, port = { ip = "255.255.255.255" }, { number = 30303, protocol = "udp" }
|
||||
@@ -31,21 +30,34 @@ action = function()
|
||||
return fail("Failed to send discovery request to server")
|
||||
end
|
||||
|
||||
local status, response = socket:receive()
|
||||
if ( not(status) ) then
|
||||
return fail("Failed to receive response from server")
|
||||
end
|
||||
local output = {}
|
||||
|
||||
local prod, mac, activation, version = response:match("^([^:]*):([^:]*):([^:]*):([^:]*)$")
|
||||
if ( not(prod) or not(mac) or not(activation) or not(version) ) then
|
||||
return
|
||||
while( true ) do
|
||||
local status, response = socket:receive()
|
||||
if ( not(status) ) then
|
||||
break
|
||||
end
|
||||
|
||||
local status, _, _, ip = socket:get_info()
|
||||
if ( not(status) ) then
|
||||
stndse.print_debug(2, "Failed to get socket information")
|
||||
break
|
||||
end
|
||||
|
||||
local prod, mac, activation, version = response:match("^([^:]*):([^:]*):([^:]*):([^:]*)$")
|
||||
if ( prod and mac and activation and version ) then
|
||||
local output_part = {
|
||||
name = ip,
|
||||
("Product: %s"):format(prod),
|
||||
("MAC: %s"):format(mac),
|
||||
("Activation code: %s"):format(activation),
|
||||
("Version: %s"):format(version)
|
||||
}
|
||||
table.insert(output, output_part)
|
||||
end
|
||||
end
|
||||
|
||||
local output = {
|
||||
("Product: %s"):format(prod),
|
||||
("MAC: %s"):format(mac),
|
||||
("Activation code: %s"):format(activation),
|
||||
("Version: %s"):format(version)
|
||||
}
|
||||
return stdnse.format_output(true, output)
|
||||
if ( 0 < #output ) then
|
||||
return stdnse.format_output(true, output)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user