mirror of
https://github.com/nmap/nmap.git
synced 2025-12-07 13:11:28 +00:00
Improve parsing of CLUSTER NODES responses
- Avoid crash due to potentially unrecognized format - Fix parsing of node flags, which may contain non-alphabetic characters Example: "failed?" - Fix parsing of field ip:port@cport - Add support for IPv6 nodes - Remove parsing of unused node ID field
This commit is contained in:
@@ -4,7 +4,7 @@ o [GH#2331][GH#2471] Script oracle-tns-version was not reporting the version
|
|||||||
correctly for Oracle 19c or newer [linholmes]
|
correctly for Oracle 19c or newer [linholmes]
|
||||||
|
|
||||||
o [GH#2296][GH#2342] Script redis-info was crashing or producing inaccurate
|
o [GH#2296][GH#2342] Script redis-info was crashing or producing inaccurate
|
||||||
information about client connections. [nnposter]
|
information about client connections and/or cluster nodes. [nnposter]
|
||||||
|
|
||||||
o [GH#2379] Nmap and Nping were unable to obtain system routes on FreeBSD
|
o [GH#2379] Nmap and Nping were unable to obtain system routes on FreeBSD
|
||||||
[benpratt, nnposter]
|
[benpratt, nnposter]
|
||||||
|
|||||||
@@ -152,20 +152,23 @@ local extras = {
|
|||||||
end
|
end
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
-- https://redis.io/commands/cluster-nodes/
|
||||||
"Cluster nodes", {"CLUSTER", "NODES"}, function(data)
|
"Cluster nodes", {"CLUSTER", "NODES"}, function(data)
|
||||||
local restab = stringaux.strsplit("\n", data)
|
if not data then
|
||||||
if not restab or 0 == #restab then
|
stdnse.debug1("Failed to parse response from server")
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
local ips = {}
|
local out = {}
|
||||||
for _, item in ipairs(restab) do
|
for node in data:gmatch("[^\n]+") do
|
||||||
local id, ip, port, flags = item:match("^([a-f0-9]+) ([0-9.:a-f]+):([0-9]+) ([a-z,]+)")
|
local ipport, flags = node:match("^%x+%s+([%x.:%[%]]+)@?%d*%s+(%S+)")
|
||||||
stdnse.debug1("ip=%s port=%s flags=%s", ip, port, flags)
|
if ipport then
|
||||||
table.insert(ips, ip .. ":" .. port .. " (" .. flags .. ")")
|
table.insert(out, ("%s (%s)"):format(ipport, flags))
|
||||||
|
else
|
||||||
|
stdnse.debug1("Unable to parse cluster node info")
|
||||||
end
|
end
|
||||||
|
end
|
||||||
return ips
|
return #out > 0 and out or nil
|
||||||
end
|
end
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user