Nmap Development mailing list archives

Accessing NSE library functions


From: Gary Madarm <gmadarm () gmail com>
Date: Mon, 16 May 2016 16:58:19 +0300

I'm trying to write my first NSE script. However, when I run my test.nse
script (details below) I get the following error message:

/opt/nmap/scripts/test.nse:12: attempt to index upvalue 'testlib' (a
boolean value)
stack traceback:
    /opt/nmap/scripts/test.nse:12: in function
</opt/nmap/scripts/test.nse:11>
    (...tail calls...)

Can anyone explain what I'm doing wrong?

I created the following basic NSE library:

# cat nselib/testlib.lua
local stdnse = require "stdnse"
function hello(world)
  return stdnse.format("Hello '%s'", world)
end

Then used the following NSE script:

# cat scripts/test.nse
description = "This is my first NSE script."
author = "me"
license = "Same as Nmap--See http://nmap.org/book/man-legal.html";
categories = { "safe" }

local shortport = require 'shortport'
local testlib = require "testlib"

portrule = function() return true end

action = function( host, port )
  testlib.hello("foo")
end
_______________________________________________
Sent through the dev mailing list
https://nmap.org/mailman/listinfo/dev
Archived at http://seclists.org/nmap-dev/

Current thread: