Nmap Development mailing list archives

prerule and reading files


From: Carlos Pantelides <carlos_pantelides () yahoo com>
Date: Tue, 16 Nov 2010 14:55:32 -0800 (PST)

Estimad@s:

I've been studying the code of *brute.nse, unpwdb.lua, the documentation and the sample-script.nse. Then I analyzed the 
behavior of telnet-brute.nse
 and confirmed that usernames and passwords files are read for every action() call.

I think that there is no need to reread, as every time the scripts will run the same set. Fix me if I am wrong, please.

During my http-vhosts.nse script I run into the same issue and deal with it simple calling a function during script 
load that saves the contents of the file in nmap.registry.mydata

I tried to put this call inside prerule, but seems that nmap.registry.mydata does not survive until action(). Is that a 
bug or am I missing something?

I suppose that nmap's bottleneck is the network, not the local filesystem, so this is not really a big problem, but I 
want to know.

Thank you

Carlos Pantelides

----------------------------------------------------------

local userfile = function()
...
io.write("usernames read\n")
...
end

local passfile = function()
...
io.write("passwords read\n")
...
end

----------------------------------------------------------

nmap localhost -p 40000-40005 -sV --script telnet-brute.nse

Starting Nmap 5.35DC18 ( http://nmap.org ) at 2010-11-16 19:36 ART
usernames read
passwords read
usernames read
passwords read
usernames read
passwords read
usernames read
passwords read
Nmap scan report for localhost (127.0.0.1)
Host is up (0.000018s latency).
PORT      STATE  SERVICE VERSION
40000/tcp closed unknown
40001/tcp open   telnet  Linux telnetd
|_telnet-brute: xxxxx - xxxxx
40002/tcp open   telnet  Linux telnetd
|_telnet-brute: xxxxx - xxxxx
40003/tcp open   telnet  Linux telnetd
|_telnet-brute: xxxxx - xxxxx
40004/tcp open   telnet  Linux telnetd
|_telnet-brute: xxxxx - xxxxx
40005/tcp closed unknown
Service Info: OS: Linux

----------------------------------------------------

[sample-script.nse]
-- The next section is rules that will cause the script to execute. These can be any one or more of:
-- * portrule: triggered by a specific port being in a given state. Script will run for every port that matches.
-- * hostrule: triggered by any characteristic about the host, including OS, ports, software version, etc. Runs once 
per ho
st that matches.
-- * prerule:  runs before a hostgroup
-- * postrule: runs after a hostgroup






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


Current thread: