From 9e7db09d4087d66afb8298a6c48b5cfb12053a6a Mon Sep 17 00:00:00 2001 From: david Date: Fri, 7 Oct 2011 09:51:05 +0000 Subject: [PATCH] Show found addresses in targets-ipv6-multicast-*. This is similar to a patch submitted by Daniel Miller. --- scripts/targets-ipv6-multicast-echo.nse | 8 +++++--- scripts/targets-ipv6-multicast-invalid-dst.nse | 8 +++++--- scripts/targets-ipv6-multicast-slaac.nse | 9 ++++++--- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/scripts/targets-ipv6-multicast-echo.nse b/scripts/targets-ipv6-multicast-echo.nse index 7db7c12a3..1fac140c2 100644 --- a/scripts/targets-ipv6-multicast-echo.nse +++ b/scripts/targets-ipv6-multicast-echo.nse @@ -87,7 +87,7 @@ action = function() local start_time = nmap:clock() local cur_time = nmap:clock() - local found_targets = 0 + local addrs = {} repeat local status, length, layer2, layer3 = pcap:pcap_receive() @@ -102,7 +102,7 @@ action = function() id_set[identifier] = true local target_str = packet.toipv6(reply.ip6_src) target.add(target_str) - found_targets = found_targets + 1 + addrs[#addrs + 1] = target_str end end end @@ -111,5 +111,7 @@ action = function() dnet:ethernet_close() pcap:pcap_close() - return true + if #addrs > 0 then + return stdnse.format_output(true, addrs) + end end diff --git a/scripts/targets-ipv6-multicast-invalid-dst.nse b/scripts/targets-ipv6-multicast-invalid-dst.nse index e375f3c85..76740c10c 100644 --- a/scripts/targets-ipv6-multicast-invalid-dst.nse +++ b/scripts/targets-ipv6-multicast-invalid-dst.nse @@ -116,7 +116,7 @@ action = function() local start_time = nmap:clock() local cur_time = nmap:clock() - local found_targets = 0 + local addrs = {} repeat local status, length, layer2, layer3 = pcap:pcap_receive() @@ -128,12 +128,12 @@ action = function() if reply.mac_dst == src_mac then reply = packet.Packet:new(layer3) local target_addr = reply.ip6_src - found_targets = found_targets + 1 local identifier = get_identifier(reply.ip6_src) if not id_set[identifier] then id_set[identifier] = true local target_str = packet.toipv6(target_addr) target.add(target_str) + addrs[#addrs + 1] = target_str end end end @@ -142,5 +142,7 @@ action = function() dnet:ethernet_close() pcap:pcap_close() - return true + if #addrs > 0 then + return stdnse.format_output(true, addrs) + end end diff --git a/scripts/targets-ipv6-multicast-slaac.nse b/scripts/targets-ipv6-multicast-slaac.nse index c644ac2c6..18c0a9360 100644 --- a/scripts/targets-ipv6-multicast-slaac.nse +++ b/scripts/targets-ipv6-multicast-slaac.nse @@ -153,7 +153,7 @@ action = function() local start_time = nmap:clock() local cur_time = nmap:clock() - local found_targets = 0 + local addrs = {} repeat local status, length, layer2, layer3 = pcap:pcap_receive() @@ -168,13 +168,13 @@ action = function() string.sub(expected_ip6_dst_prefix,1,12) == string.sub(reply.ip6_dst,1,12) then local ula_target_addr_str = packet.toipv6(reply.ns_target) local identifier = get_identifier(reply.ns_target) - found_targets = found_targets + 1 --Filter out the reduplicative identifiers. --A host will send several NS packets with the same interface identifier if it receives several RA packets with different prefix during the discovery phase. if not id_set[identifier] then id_set[identifier] = true local actual_addr_str = packet.toipv6(actual_prefix .. identifier) target.add(actual_addr_str) + addrs[#addrs + 1] = actual_addr_str end end end @@ -183,5 +183,8 @@ action = function() dnet:ethernet_close() pcap:pcap_close() - return true + + if #addrs > 0 then + return stdnse.format_output(true, addrs) + end end