Nmap Development mailing list archives

Problem with writing NSE scripts in Lua


From: J A <jwjalexan () gmail com>
Date: Sun, 5 Aug 2018 17:10:30 +0100

Hello,

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.
I have installed, multiple times, the latest version of nmap from GitHub,
and copied the contents of the nselib directory to the appropriate location
of the other .lua files use by Lua (/usr/share/lua/5.3/).
When I then go to require nmap (as in nmap.lua) the system returns a
message stating it cannot find nmap.lua - this is true, as the closest file
to this in nselib is nmap.luadoc.
Due to this when I attempt to use another module such stdnse, which also
uses nmap(.lua), it does not load.

I changed nmap.luadoc to nmap.lua but this had little beneficial effect as
there is no functional code within the file.
Online forums have suggested updating to the latest version of nmap - as
previously stated I have the latest version from GitHub.
I have also examined nmap versions going as far back as 4.90 to locate
nmap.lua with no success
Another possibility it that a particular environment variable within my
setup (and not mentioned in the full installation guide) of nmap is
preventing nmap.lua from being *required* by Lua.

Despite the above nmap scripts appear to run with no problems.
Further, I am unsure whether this potential problem is limited to just
nmap.lua.

Please see the output(s) below for more details:

nmap -V
Nmap version 7.70SVN ( https://nmap.org )
Platform: x86_64-unknown-linux-gnu
Compiled with: liblua-5.3.4 openssl-1.1.0h libssh2-1.8.0 libz-1.2.11
libpcre-8.42 libpcap-1.8.1 nmap-libdnet-1.12 ipv6
Compiled without:
Available nsock engines: epoll poll select

lua -v
Lua 5.3.4  Copyright (C) 1994-2017 Lua.org, PUC-Rio


# After copying the contents of nselib to /usr/share/lua/5.3/

ls -alh /usr/share/lua/5.3/nmap.luadoc
-rw-r--r-- 1 user user 41K Aug  2 17:20 /usr/share/lua/5.3/nmap.luadoc

ls -alh /usr/share/lua/5.3/stdnse.lua
-rw-r--r-- 1 user user 47K Aug  2 17:20 /usr/share/lua/5.3/stdnse.lua

lua
Lua 5.3.4  Copyright (C) 1994-2017 Lua.org, PUC-Rio
local nmap = require "nmap"
stdin:1: module 'nmap' not found:
no field package.preload['nmap']
no file '/usr/share/lua/5.3/nmap.lua'
no file '/usr/share/lua/5.3/nmap/init.lua'
no file '/usr/lib/lua/5.3/nmap.lua'
no file '/usr/lib/lua/5.3/nmap/init.lua'
no file './nmap.lua'
no file './nmap/init.lua'
no file '/usr/lib/lua/5.3/nmap.so'
no file '/usr/lib/lua/5.3/loadall.so'
no file './nmap.so'
stack traceback:
[C]: in function 'require'
stdin:1: in main chunk
[C]: in ?


local stdnse = require "stdnse"
/usr/share/lua/5.3/stdnse.lua:12: module 'nmap' not found:
no field package.preload['nmap']
no file '/usr/share/lua/5.3/nmap.lua'
no file '/usr/share/lua/5.3/nmap/init.lua'
no file '/usr/lib/lua/5.3/nmap.lua'
no file '/usr/lib/lua/5.3/nmap/init.lua'
no file './nmap.lua'
no file './nmap/init.lua'
no file '/usr/lib/lua/5.3/nmap.so'
no file '/usr/lib/lua/5.3/loadall.so'
no file './nmap.so'
stack traceback:
[C]: in function 'require'
/usr/share/lua/5.3/stdnse.lua:12: in main chunk
[C]: in function 'require'
stdin:1: in main chunk
[C]: in ?



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

Current thread: