Index: scripts/targets-ipv6-multicast-invalid-dst.nse =================================================================== --- scripts/targets-ipv6-multicast-invalid-dst.nse (revision 26673) +++ scripts/targets-ipv6-multicast-invalid-dst.nse (working copy) @@ -119,6 +119,7 @@ local cur_time = nmap:clock() local found_targets = 0 + local rval = {} repeat local status, length, layer2, layer3 = pcap:pcap_receive() @@ -135,6 +136,7 @@ if not id_set[identifier] then id_set[identifier] = true local target_str = packet.toipv6(target_addr) + table.insert(rval, string.format("%s at %s", target_str, packet.tomac(string.sub(layer2, 7, 13)))) target.add(target_str) end end @@ -144,5 +146,12 @@ dnet:ethernet_close() pcap:pcap_close() - return true + local summary = string.format("Found %d targets", found_targets) + if nmap.verbosity() > 0 then + return summary .. stdnse.format_output(true, rval) + elseif found_targets > 0 then + return summary + else + return true + end end Index: scripts/targets-ipv6-multicast-echo.nse =================================================================== --- scripts/targets-ipv6-multicast-echo.nse (revision 26673) +++ scripts/targets-ipv6-multicast-echo.nse (working copy) @@ -91,6 +91,7 @@ local cur_time = nmap:clock() local found_targets = 0 + local rval = {} repeat local status, length, layer2, layer3 = pcap:pcap_receive() @@ -104,6 +105,7 @@ if not id_set[identifier] then id_set[identifier] = true local target_str = packet.toipv6(reply.ip6_src) + table.insert(rval, string.format("%s at %s", target_str, packet.tomac(string.sub(layer2, 7, 13)))) target.add(target_str) found_targets = found_targets + 1 end @@ -114,5 +116,12 @@ dnet:ethernet_close() pcap:pcap_close() - return true + local summary = string.format("Found %d targets", found_targets) + if nmap.verbosity() > 0 then + return summary .. stdnse.format_output(true, rval) + elseif found_targets > 0 then + return summary + else + return true + end end Index: scripts/targets-ipv6-multicast-slaac.nse =================================================================== --- scripts/targets-ipv6-multicast-slaac.nse (revision 26673) +++ scripts/targets-ipv6-multicast-slaac.nse (working copy) @@ -154,6 +154,7 @@ local cur_time = nmap:clock() local found_targets = 0 + local rval = {} repeat local status, length, layer2, layer3 = pcap:pcap_receive() @@ -168,13 +169,14 @@ 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) + table.insert(rval, string.format("%s at %s", actual_addr_str, packet.tomac(string.sub(layer2, 7, 13)))) + found_targets = found_targets + 1 end end end @@ -183,5 +185,13 @@ dnet:ethernet_close() pcap:pcap_close() - return true + + local summary = string.format("Found %d targets", found_targets) + if nmap.verbosity() > 0 then + return summary .. stdnse.format_output(true, rval) + elseif found_targets > 0 then + return summary + else + return true + end end Index: nselib/packet.lua =================================================================== --- nselib/packet.lua (revision 26673) +++ nselib/packet.lua (working copy) @@ -479,6 +479,15 @@ end return addr_hex end +--- Convert a six-byte raw string to a colon-separated MAC address string. +-- @param raw_mac_addr six-byte string. +-- @return MAC address string. +function tomac(raw_mac_addr) + if not (raw_mac_addr and #raw_mac_addr > 0) then + return "?:?:?:?:?:?" + end + return string.format("%02X:%02X:%02X:%02X:%02X:%02X", string.byte(raw_mac_addr,1,6)) +end --- Convert a four-byte raw string to a dotted-quad IP address string. -- @param raw_ip_addr Four-byte string. -- @return IP address string.