Re: Problem with writing NSE scripts in Lua

Gisle Vanem via dev <[email protected]> Sat, 11 Aug 2018 12:30:23 +0200
Newsgroups gmane.comp.security.nmap.devel
Message-ID <[email protected]>
J A wrote:

> I'm trying to use Lua to develop NSE scripts and other programs using nmaps' collection of Lua files (e.g. stdnse.lua).
> However, every time I go to import/load//require/ a particular file or module so I can use its functions, I keep running 
> into the errors around the existence of nmap.lua.

No, I do not think so. In an "external run" of Lua, a 'require "nmap"'
would mean load a dynamic library call nmap.so / nmap.dll. Alternatively
a 'nmap.lua' that does similar things.

Since Nmap has created such a module (or package?) internally for
itself, it's not needed by a 'require' externally. Could be a hazard
if this was possible. Ref, nse_mainc.cc + init_main() that calls
'luaL_requiref()' to make this magic happen. This creates a "nmap"
object/table in it's global scope.

That's my understanding of this anyway; please
someone correct me if I'm wrong.

-- 
--gv
_______________________________________________
Sent through the dev mailing list
https://nmap.org/mailman/listinfo/dev
Archived at http://seclists.org/nmap-dev/