mirror of
https://github.com/nmap/nmap.git
synced 2025-12-22 07:29:01 +00:00
Add loader for searching nselib/ for ?.lua files. nselib/ can be in multiple
directories that nmap will search, e.g. ~/.nmap/nselib $NMAPDIR/nselib /usr/share/nmap/nselib etc. Resolves Daniel Miller's request [1]. [1] http://seclists.org/nmap-dev/2011/q3/817
This commit is contained in:
15
nse_main.lua
15
nse_main.lua
@@ -117,10 +117,17 @@ local nmap = require "nmap";
|
|||||||
|
|
||||||
local cnse, rules = ...; -- The NSE C library and Script Rules
|
local cnse, rules = ...; -- The NSE C library and Script Rules
|
||||||
|
|
||||||
do -- Append the nselib directory to the Lua search path
|
do -- Add loader to look in nselib/?.lua (nselib/ can be in multiple places)
|
||||||
local t, path = assert(cnse.fetchfile_absolute("nselib/"));
|
local function loader (lib)
|
||||||
assert(t == "directory", "could not locate nselib directory!");
|
local name = "nselib/"..lib..".lua";
|
||||||
package.path = path.."?.lua;"..package.path;
|
local type, path = cnse.fetchfile_absolute(name);
|
||||||
|
if type == "file" then
|
||||||
|
return loadfile(path);
|
||||||
|
else
|
||||||
|
return "\n\tNSE failed to find "..name.." in search paths.";
|
||||||
|
end
|
||||||
|
end
|
||||||
|
insert(package.loaders, loader);
|
||||||
end
|
end
|
||||||
|
|
||||||
local script_database_type, script_database_path =
|
local script_database_type, script_database_path =
|
||||||
|
|||||||
Reference in New Issue
Block a user