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:
@@ -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 )
|
||||
|
||||
|
||||
Reference in New Issue
Block a user