1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-06 12:41:29 +00:00

Show a visible error when targets-ipv6-* are run without an interface.

This commit is contained in:
david
2011-09-08 16:11:21 +00:00
parent 4937b2e063
commit 4d0a8a27b1
3 changed files with 18 additions and 6 deletions

View File

@@ -25,8 +25,7 @@ require 'packet'
local bit = require 'bit' local bit = require 'bit'
prerule = function() prerule = function()
return nmap.is_privileged() and return nmap.is_privileged()
(stdnse.get_script_args(SCRIPT_NAME .. ".interface") or nmap.get_interface())
end end
catch = function() catch = function()
@@ -41,6 +40,11 @@ end
action = function() action = function()
local if_name = stdnse.get_script_args(SCRIPT_NAME .. ".interface") or nmap.get_interface() local if_name = stdnse.get_script_args(SCRIPT_NAME .. ".interface") or nmap.get_interface()
if not if_name then
return "Error: need an interface name.\n"
.. "Use -e <iface> or --script-args " .. SCRIPT_NAME .. ".interface=<iface>."
end
local if_nfo, err = nmap.get_interface_info(if_name) local if_nfo, err = nmap.get_interface_info(if_name)
if not if_nfo then if not if_nfo then
stdnse.print_debug(err) stdnse.print_debug(err)

View File

@@ -26,8 +26,7 @@ require 'packet'
local bit = require 'bit' local bit = require 'bit'
prerule = function() prerule = function()
return nmap.is_privileged() and return nmap.is_privileged()
(stdnse.get_script_args(SCRIPT_NAME .. ".interface") or nmap.get_interface())
end end
catch = function() catch = function()
@@ -58,6 +57,11 @@ end
action = function() action = function()
local if_name = stdnse.get_script_args(SCRIPT_NAME .. ".interface") or nmap.get_interface() local if_name = stdnse.get_script_args(SCRIPT_NAME .. ".interface") or nmap.get_interface()
if not if_name then
return "Error: need an interface name.\n"
.. "Use -e <iface> or --script-args " .. SCRIPT_NAME .. ".interface=<iface>."
end
local if_nfo, err = nmap.get_interface_info(if_name) local if_nfo, err = nmap.get_interface_info(if_name)
if not if_nfo then if not if_nfo then
stdnse.print_debug(err) stdnse.print_debug(err)

View File

@@ -36,8 +36,7 @@ require "os"
require "math" require "math"
prerule = function() prerule = function()
return nmap.is_privileged() and return nmap.is_privileged()
(stdnse.get_script_args(SCRIPT_NAME .. ".interface") or nmap.get_interface())
end end
catch = function() catch = function()
@@ -92,6 +91,11 @@ end
action = function() action = function()
local if_name = stdnse.get_script_args(SCRIPT_NAME .. ".interface") or nmap.get_interface() local if_name = stdnse.get_script_args(SCRIPT_NAME .. ".interface") or nmap.get_interface()
if not if_name then
return "Error: need an interface name.\n"
.. "Use -e <iface> or --script-args " .. SCRIPT_NAME .. ".interface=<iface>."
end
local if_nfo, err = nmap.get_interface_info(if_name) local if_nfo, err = nmap.get_interface_info(if_name)
if not if_nfo then if not if_nfo then
stdnse.print_debug(err) stdnse.print_debug(err)