diff --git a/CHANGELOG b/CHANGELOG index 2e0b8fb72..9f4eac867 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,8 @@ # Nmap Changelog ($Id$); -*-text-*- -o [NSE] Added snmpWalk function to SNMP library and updated scripts to use it +o [NSE] Added sorting on port number to dns-service-discovery script. [Patrik] + +o [NSE] Added snmpWalk function to SNMP library and updated scripts to use it. [Patrik] o Updated IANA IP address space assignment list for random IP (-iR) diff --git a/scripts/dns-service-discovery.nse b/scripts/dns-service-discovery.nse index bc310c68d..6e22e2aa9 100644 --- a/scripts/dns-service-discovery.nse +++ b/scripts/dns-service-discovery.nse @@ -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 )