1
0
mirror of https://github.com/nmap/nmap.git synced 2026-01-20 05:09:02 +00:00

Get more than one address. Fixes #1114. Closes #1115

This commit is contained in:
dmiller
2018-03-09 06:26:46 +00:00
parent 4ef8fcc363
commit 8d46f720a5
3 changed files with 18 additions and 5 deletions

View File

@@ -1,5 +1,8 @@
#Nmap Changelog ($Id$); -*-text-*-
o [NSE][GH#1114] Update bitcoin-getaddr to receive more than one response
message, since the first message usually only has one address in it. [h43z]
o [Ncat][GH#1139] Ncat now selects the correct default port for a given proxy
type. [Pavel Zhukov]

View File

@@ -463,7 +463,7 @@ Response = {
elseif ( "alert" == cmd ) then
return true, Response.Alert:new(data)
else
return false, ("Unknown command (%s)"):format(cmd)
return true, ("Unknown command (%s)"):format(cmd)
end
end,
}
@@ -577,13 +577,23 @@ Helper = {
return false, "Failed to send \"GetAddr\" request to server"
end
-- take care of any alerts that may be incoming
local status, response = Response.recvPacket(self.socket, self.version)
while ( status and response and response.type == "Alert" ) do
local all_addrs = {}
local limit = 10
-- Usually sends an addr response with 1 address,
-- then some other stuff like getheaders or ping,
-- then one with hundreds of addrs.
while status and #all_addrs <= 1 and limit > 0 do
limit = limit - 1
status, response = Response.recvPacket(self.socket, self.version)
if status and response.cmd == "addr" then
for _, addr in ipairs(response.addresses) do
all_addrs[#all_addrs+1] = addr
end
end
end
return status, response
return #all_addrs > 0, all_addrs
end,
-- Reads a message from the server

View File

@@ -63,7 +63,7 @@ action = function(host, port)
local response = tab.new(2)
tab.addrow(response, "ip", "timestamp")
for _, node in ipairs(nodes.addresses or {}) do
for _, node in ipairs(nodes or {}) do
if ( target.ALLOW_NEW_TARGETS ) then
target.add(node.address.host)
end