Home page logo
/

nmap-dev logo Nmap Development mailing list archives

Re: Accessing Information Between Scripts
From: Toni Ruottu <toni.ruottu () iki fi>
Date: Tue, 25 Jan 2011 11:51:21 +0200

You should do table.insert(nmap.registry.status, status)
On 25 Jan 2011 11:16, "m k" <mpmab1 () gmail com> wrote:
Hi.

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
statement.

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
follows:
nmap 127.0.0.1 -p80 script FIRST.nse, SECOND.nse

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


*FIRST.nse*

________________________________________________________________________________________
**-- 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");
end
end

________________________________________________________________________________________

*SECOND.nse
.....
*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"
end
end

________________________________________________________________________________________
_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://seclists.org/nmap-dev/
_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://seclists.org/nmap-dev/


  By Date           By Thread  

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