mirror of
https://github.com/nmap/nmap.git
synced 2025-12-06 20:51:30 +00:00
Added privilege checks to the prerules to prevent scripts from failing at
action() time when executed unprivileged. Removed the check which was performed by broadcast-dhcp-discover.nse in its action() function, so that users can force execution if desired.
This commit is contained in:
@@ -37,11 +37,24 @@ author = "Patrik Karlsson"
|
|||||||
license = "Same as Nmap--See http://nmap.org/book/man-legal.html"
|
license = "Same as Nmap--See http://nmap.org/book/man-legal.html"
|
||||||
categories = {"broadcast", "safe"}
|
categories = {"broadcast", "safe"}
|
||||||
|
|
||||||
prerule = function() return not( nmap.address_family() == "inet6") end
|
|
||||||
|
|
||||||
require 'dhcp'
|
require 'dhcp'
|
||||||
require 'ipOps'
|
require 'ipOps'
|
||||||
require 'packet'
|
require 'packet'
|
||||||
|
require 'nmap'
|
||||||
|
|
||||||
|
prerule = function()
|
||||||
|
if not nmap.is_privileged() then
|
||||||
|
stdnse.print_verbose("%s not running for lack of privileges.", SCRIPT_NAME)
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
if nmap.address_family() ~= 'inet' then
|
||||||
|
stdnse.print_debug("%s is IPv4 compatible only.", SCRIPT_NAME)
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
-- Creates a random MAC address
|
-- Creates a random MAC address
|
||||||
--
|
--
|
||||||
@@ -116,10 +129,6 @@ end
|
|||||||
|
|
||||||
action = function()
|
action = function()
|
||||||
|
|
||||||
if not nmap.is_privileged() then
|
|
||||||
return ("\n ERROR: %s needs to be run as a privileged user (root)."):format(SCRIPT_NAME)
|
|
||||||
end
|
|
||||||
|
|
||||||
local host, port = "255.255.255.255", 67
|
local host, port = "255.255.255.255", 67
|
||||||
local timeout = stdnse.get_script_args("broadcast-dhcp-discover.timeout")
|
local timeout = stdnse.get_script_args("broadcast-dhcp-discover.timeout")
|
||||||
timeout = tonumber(timeout) or 10
|
timeout = tonumber(timeout) or 10
|
||||||
|
|||||||
@@ -74,10 +74,19 @@ author = "Patrik Karlsson"
|
|||||||
license = "Same as Nmap--See http://nmap.org/book/man-legal.html"
|
license = "Same as Nmap--See http://nmap.org/book/man-legal.html"
|
||||||
categories = {"broadcast", "safe"}
|
categories = {"broadcast", "safe"}
|
||||||
|
|
||||||
prerule = function() return true end
|
|
||||||
|
|
||||||
require('packet')
|
require('packet')
|
||||||
require('tab')
|
require('tab')
|
||||||
|
require('nmap')
|
||||||
|
|
||||||
|
|
||||||
|
prerule = function()
|
||||||
|
if not nmap.is_privileged() then
|
||||||
|
stdnse.print_verbose("%s not running for lack of privileges.", SCRIPT_NAME)
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
---
|
---
|
||||||
-- loads the decoders from file
|
-- loads the decoders from file
|
||||||
|
|||||||
@@ -28,8 +28,15 @@ license = "Same as Nmap--See http://nmap.org/book/man-legal.html"
|
|||||||
categories = {"broadcast", "safe"}
|
categories = {"broadcast", "safe"}
|
||||||
|
|
||||||
require 'pppoe'
|
require 'pppoe'
|
||||||
|
require 'nmap'
|
||||||
|
|
||||||
prerule = function() return true end
|
prerule = function()
|
||||||
|
if not nmap.is_privileged() then
|
||||||
|
stdnse.print_verbose("%s not running for lack of privileges.", SCRIPT_NAME)
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
local function fail(err)
|
local function fail(err)
|
||||||
if ( err ) then
|
if ( err ) then
|
||||||
|
|||||||
Reference in New Issue
Block a user