1
0
mirror of https://github.com/nmap/nmap.git synced 2026-01-02 04:49:02 +00:00

o [NSE] Applied patch from Andrew Orr that fixes the recent changes in the

BitCoin protocol. [Patrik]
This commit is contained in:
patrik
2012-02-20 19:12:38 +00:00
parent 10add7e606
commit bd2c9e01f6
3 changed files with 174 additions and 35 deletions

View File

@@ -24,6 +24,7 @@ categories = {"discovery", "safe"}
require 'shortport'
require 'bitcoin'
require 'tab'
require 'target'
--
-- Version 0.1
@@ -35,9 +36,9 @@ portrule = shortport.port_or_service(8333, "bitcoin", "tcp" )
action = function(host, port)
local bcoin = bitcoin.Helper:new(host, port, { timeout = 10000 })
local bcoin = bitcoin.Helper:new(host, port, { timeout = 20000 })
local status = bcoin:connect()
if ( not(status) ) then
return "\n ERROR: Failed to connect to server"
end
@@ -49,16 +50,21 @@ action = function(host, port)
local status, nodes = bcoin:getNodes()
if ( not(status) ) then
return "\n ERROR: Failed to extract version information"
return "\n ERROR: Failed to extract address information"
end
bcoin:close()
local response = tab.new(2)
tab.addrow(response, "ip", "timestamp")
for _, node in ipairs(nodes.addresses) do
for _, node in ipairs(nodes.addresses or {}) do
if ( target.ALLOW_NEW_TARGETS ) then
target.add(node.address.host)
end
tab.addrow(response, ("%s:%d"):format(node.address.host, node.address.port), os.date("%x %X", node.ts))
end
return stdnse.format_output(true, tab.dump(response) )
if ( #response > 1 ) then
return stdnse.format_output(true, tab.dump(response) )
end
end