Nmap Development mailing list archives

Re: Accessing NSE library functions


From: Paulino Calderon <paulino () calderonpale com>
Date: Mon, 16 May 2016 11:29:47 -0500

Hello Gary,

I think you are missing some parts. To achieve what you want try the following:

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 )
  return testlib.hello("foo")
end


testlib.lua

local stdnse = require "stdnse"
_ENV = stdnse.module("testlib", stdnse.seeall)

function hello(world)
  return string.format("Hello '%s'", world)
end

return _ENV;


PORT   STATE SERVICE REASON
80/tcp open  http    syn-ack
|_test: Hello 'foo'


On May 16, 2016, at 8:58 AM, Gary Madarm <gmadarm () gmail com> wrote:

description = "This is my first NSE script."
author = "me"
license = "Same as Nmap--See http://nmap.org/book/man-legal.html <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: