1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-24 16:39:03 +00:00

o [NSE] Added sorting on port number to dns-service-discovery script. [Patrik]

This commit is contained in:
patrik
2010-04-12 10:43:06 +00:00
parent 112f8f5340
commit bd5e91ffcc
2 changed files with 21 additions and 1 deletions

View File

@@ -89,6 +89,21 @@ function getRecordType( dtype, response, retAll )
end
--- Function used to compare discovered DNS services so they can be sorted
--
-- @param a table containing first item
-- @param b table containing second item
-- @return true if the port of a is less than the port of b
local function serviceCompare(a, b)
local port_a = a.name:match("^(%d+)")
local port_b = b.name:match("^(%d+)")
if ( tonumber(port_a) < tonumber(port_b) ) then
return true
end
return false
end
action = function(host, port)
local result = {}
@@ -171,6 +186,9 @@ action = function(host, port)
end
-- sort the tables per port
table.sort( result, serviceCompare )
-- we want the device information at the end
table.insert( result, deviceinfo )