From 41ec64ab14f3685846e9f92484a9119b9b4639e7 Mon Sep 17 00:00:00 2001 From: dmiller Date: Tue, 21 May 2024 18:49:37 +0000 Subject: [PATCH] Enable IPv6 capability for broadcast-bjnp-discover --- scripts/broadcast-bjnp-discover.nse | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/broadcast-bjnp-discover.nse b/scripts/broadcast-bjnp-discover.nse index 45d89bb8a..200ce980d 100644 --- a/scripts/broadcast-bjnp-discover.nse +++ b/scripts/broadcast-bjnp-discover.nse @@ -43,11 +43,11 @@ local printer_port = { number = 8611, protocol = "udp"} local scanner_port = { number = 8612, protocol = "udp"} local arg_timeout = stdnse.parse_timespec(stdnse.get_script_args(SCRIPT_NAME .. ".timeout")) +local bcast_host = { + ip = (nmap.address_family() == 'inet' and "255.255.255.255" or "ff02::1"), +} + prerule = function() - if ( nmap.address_family() ~= 'inet' ) then - stdnse.debug1("is IPv4 compatible only.") - return false - end return true end @@ -100,7 +100,7 @@ end local function getPrinters(devices) local condvar = nmap.condvar(devices) - local helper = bjnp.Helper:new( { ip = "255.255.255.255" }, printer_port, { bcast = true, timeout = arg_timeout } ) + local helper = bjnp.Helper:new( bcast_host, printer_port, { bcast = true, timeout = arg_timeout } ) if ( not(helper:connect()) ) then condvar "signal" return @@ -115,7 +115,7 @@ end local function getScanners(devices) local condvar = nmap.condvar(devices) - local helper = bjnp.Helper:new( { ip = "255.255.255.255" }, scanner_port, { bcast = true, timeout = arg_timeout } ) + local helper = bjnp.Helper:new( bcast_host, scanner_port, { bcast = true, timeout = arg_timeout } ) if ( not(helper:connect()) ) then condvar "signal" return