Nmap Development mailing list archives

Re: [NSE] Proposal for adding a target.add_host() function


From: Djalal Harouni <tixxdz () opendz org>
Date: Tue, 31 May 2011 18:17:27 +0100

On 2011-05-27 17:52:50 +0200, Gorjan Petrovski wrote:
Hi,
Hi Gorjan,

It would be really great if we could add a whole host structure as a
target in NSE through the target library. Recently I needed such an
option specifically for passing the MAC address to another script, but
it should benefit script testing purposes too. David mentioned that it
would be useful for linking IPv4 and IPv6 addresses too in a recent
meeting.
I can also think of the ports, services that will be discovered during 
a prerule scan (broadcast scripts), this list can be used to populate the
different fields of the host Target structure like the 'PostList'.

The host tables for the different targets are created in the
run_main() function of the nse_main.cc file, line: 442. they are created
by the set_hostinfo() function.

And remember that Nmap will free the Target structure (see Target.h file)
for every target when the hostgroup scan is finished.


I can't say if this is the best solution but you can do:
create a vector of potentially targets that will be populated by NSE
scripts, each target can have some fields like:
mac_addr, ip_addresses, name, portlist ...

So the NSE scripts will create a small C struct for each target (not the
Target struct), and populate it by the discovered info, and after that
when Nmap tries to scan that same target then try to map the discovered info
from NSE to the real Target struct (Target.h file), since other Nmap scan
methodes would also be interested in it, not only NSE scripts. This also
can avoid some duplicate operations.
And finally remove that struct entry from the previous vector, when we
are done.

You can just start by a struct that will just handle IP and MAC addresses.

What do you guys think?
It's an interesting idea but it needs more work, or perhaps you can find a
better way ?

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


Current thread: