Home page logo

nmap-dev logo Nmap Development mailing list archives

Accessing Information Between Scripts
From: m k <mpmab1 () gmail com>
Date: Tue, 25 Jan 2011 20:16:35 +1100


This is my first post. If I have any missing information please let me know
for future correspondence.

I was wondering if anyone could help. I have just started writing my first
NSE plugins. I have written a plugin (called *FIRST.nse*) which simply:
Sends a request to a web server, and  examines the HTTP response -
specifically the status code and if it is "200" a specific message is
printed FIRST.nse works fine works as I can print the message within the if

However, I am trying to get the results from "FIRST.nse" to be made
available to another nse called *SECOND.nse*. All the SECOND.nse does is to
get the *status value *from FIRST.nse and print it (so i can see if it can
access the information). For example I think the results of the
smb-brute.nse are available to allow the smb-* scripts.  In a similar
fashion i want the information gathered in the first script to be available
to the second.

I have written the following code embedded with comments below - (snippets
of the code provided for brevity).

Also in case it might help, the command i use to execute the scripts is as
               nmap -p80 script FIRST.nse, SECOND.nse

I am not sure what I am doing incorrectly. Can anyone please help ?

**-- Code not shown are things like description, categories etc

portrule = shortport.port_or_service(80, "http")

action = function(host, port)

     local status = http.get(host, port, "/").status             -- Assigns
the HTTP response status code sent to the server at "/" to "status"
     nmap.registry.status = nmap.registry.status or {}      -- Assigns the
status to the register
     table.insert(nmap.registry.status)                             -- Puts
it in a table

    if  status == 200 then                                              --
Check if HTTP response status code is 200, if yes print hello world
                return ("Hello World");

*dependencies =
{"FIRST.nse"}                                                     --
Include the script that contains the required information
portrule = shortport.port_or_service(80, "http")

action = function(host, port)
    if   (nmap.registry.status == 200)
then                                       -- Attempt to access status code
from the first script
        return "You Passed status from FIRST script to SECOND"
Sent through the nmap-dev mailing list
Archived at http://seclists.org/nmap-dev/

  By Date           By Thread  

Current thread:
[ Nmap | Sec Tools | Mailing Lists | Site News | About/Contact | Advertising | Privacy ]