Nmap Development mailing list archives

Small patch to add "add port" output from -v -v -v to XML format


From: "Max Schubert" <nmap () webwizarddesign com>
Date: Fri, 08 Nov 2002 08:06:11 -0500

Hi,

    I finally sat down with the nmap source to look at adding some of the "verbose"
    LOG_STDOUT output that happens with -v -v -v to XML output .. so that people like me
    who want to write script wrappers that parse nmap from language X can get port
    info for event-driven APIs ... mine is in perl and is at

    http://webwizarddesign.com/nmap/

    But is only works with a given nmap version as the LOG_STDOUT output has changed
    between versions :( .. and the parsing is complex and breaks easily .. blech.

    The most important messages I was missing in order to change from parsing LOG_STDOUT 
    format to LOG_XML format were the live "Adding <state> port ... " messages.

    Here is a small patch to add that functionality to nmap.  I hope, Fyodor, that you
    will be willing to add this to the main development branch of nmap ... so that
    people like me who want to make nmap scanning functionality accessible through
    scripting languages can use the XML output format ... I had been using LOG_STDOUT
    but that changes often and parsing it is a pain.

    I know this is a rather minor change, but it will make a huge difference for modules
    like mine .. in terms of stability and utility :).

Max

--- portlist.c  Fri Nov  8 07:35:28 2002
+++ nmap-3.00/portlist.c        Sat Jul 27 23:06:16 2002
@@ -72,13 +72,6 @@
              statenum2str(state), portno, 
              (protocol == IPPROTO_TCP)? "tcp" : "udp", msg);
     log_flush(LOG_STDOUT);
-    /* Write out add port messages for XML format so wrapper libraries can
-       use it and not have to parse LOG_STDOUT ;), which is a pain! */
-       
-    log_write(LOG_XML, "<add-port state=\"%s\" number=\"%hu\" protocol=\"%s\" msg=\"%s\"/>\n",
-             statenum2str(state), portno, 
-             (protocol == IPPROTO_TCP)? "tcp" : "udp", msg);
-    log_flush(LOG_XML);
    }
 
/* Make sure state is OK */

---------------------------------------------------------------------
For help using this (nmap-dev) mailing list, send a blank email to 
nmap-dev-help () insecure org . List run by ezmlm-idx (www.ezmlm.org).



Current thread: