From cf2d0b5e5c4bc8f7c744e11f6c2afde9a0d95062 Mon Sep 17 00:00:00 2001 From: david Date: Fri, 7 Oct 2011 07:51:50 +0000 Subject: [PATCH] Use tab instead of manually counting spaces. --- scripts/broadcast-ping.nse | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/scripts/broadcast-ping.nse b/scripts/broadcast-ping.nse index a315e4fef..1f19abbce 100755 --- a/scripts/broadcast-ping.nse +++ b/scripts/broadcast-ping.nse @@ -36,8 +36,8 @@ is 0. The payload is consisted of random bytes. -- -- @output -- | broadcast-ping: --- | IP: 192.168.1.1 MAC: 00:23:69:2a:b1:25 --- | IP: 192.168.1.106 MAC: 1c:65:9d:88:d8:36 +-- | IP: 192.168.1.1 MAC: 00:23:69:2a:b1:25 +-- | IP: 192.168.1.106 MAC: 1c:65:9d:88:d8:36 -- |_ Use the newtargets script-arg to add the results as targets -- -- @@ -51,6 +51,7 @@ require "stdnse" require "packet" require "openssl" require "bin" +require "tab" require "target" prerule = function() @@ -256,16 +257,18 @@ action = function() until next(threads) == nil -- generate output - local output = {} + local output = tab.new() for ip_addr, mac_addr in pairs(icmp_responders) do if target.ALLOW_NEW_TARGETS then target.add(ip_addr) end - table.insert(output,"IP: "..ip_addr..string.rep(" ",15-#ip_addr).." MAC: "..mac_addr) + tab.addrow(output, "IP: " .. ip_addr, "MAC: " .. mac_addr) end - if #output > 0 and not target.ALLOW_NEW_TARGETS then - table.insert(output,"Use the newtargets script-arg to add the results as targets") + if #output > 0 then + output = { tab.dump(output) } + if not target.ALLOW_NEW_TARGETS then + output[#output + 1] = "Use the newtargets script-arg to add the results as targets" + end + return stdnse.format_output(true, output) end - - return stdnse.format_output( (#output>0), output ) end