Nmap Development mailing list archives

Re: Suggestion: Using script output - Human-readable and machine-parseable


From: Daniel Miller <bonsaiviking () gmail com>
Date: Thu, 31 Mar 2011 23:05:35 -0500

On Thu, Mar 31, 2011 at 10:02 PM, David Fifield <david () bamsoftware com> wrote:
On Thu, Mar 31, 2011 at 03:46:41PM -0500, Daniel Miller wrote:
Hey list,

From the Nmap TODO:
o Nmap should have a better way to handle XML script output.
o We currently just stick the current script output text into an XML tag.
May I make a suggestion? If we format script output as YAML
(http://www.yaml.org/), it will be machine-readable, while
preserving the human-readable nature. There are a couple of YAML
bindings for Lua: libyaml (http://yaml.luaforge.net/) and libsyck
(https://github.com/indeyets/syck/tree/master/ext/lua)

The quickest way to support this straight off would be to modify
stdnse.format_output to output YAML. The NSE runtime could quote
non-YAML return values as block-literal scalars, until such time as
they are rewritten to return more useful formatted output. A
downside would be that output would take a few more lines than
before, though this could be overcome by using "flow styles," of
which JSON is a proper subset.

Benefits of doing this are:
* extensibility without requiring modifications to Nmap XML schema
* Human-readable nature of YAML means a single output format for
human and machine consumers
* existing structured-output using stdnse.format_output means very
few changes for script authors
* YAML bindings available for Lua, Python, Perl, Ruby, C, and many
other languages.

At first blush, I like this YAML idea. How might it handle tabular data,
like that of nfs-ls?

|   NFS Export: /mnt/nfs/files
|   NFS Access: Read Lookup NoModify NoExtend NoDelete NoExecute
|
|     PERMISSION  UID   GID   SIZE     MODIFICATION TIME  FILENAME
|     drwxr-xr-x  1000  100   4096     2010-06-17 12:28   /mnt/nfs/files
|     drwxr--r--  1000  1002  4096     2010-05-14 12:58   sources
|     -rw-------  1000  1002  23606    2010-06-17 12:28   notes

David Fifield


Here's how I would propose to output the same information:

| nfs-ls:
|   Arguments:
|     maxfiles: 10 # file listing output limited
|   /mnt/nfs/files:
|     NFS Access: [Read, Lookup, NoModify, NoExtend, NoDelete, NoExecute]
|     Listing:
|       h: [PERMISSION,  UID,  GID, SIZE, MODIFICATION TIME, FILENAME]
|       t:
|         -[drwxr-xr-x, 1000,  100, 4096,  2010-06-17 12:28, /mnt/nfs/files]
|         -[drwxr--r--, 1000, 1002, 4096,  2010-05-14 12:58, sources]
|         -[-rw-------, 1000, 1002, 23606, 2010-06-17 12:28, notes]
|   /home/storage/backup:
|     NFS Access: [Read, Lookup, Modify, Extend, Delete, NoExecute]
|     Listing:
|       h: [PERMISSION,  UID,  GID,  SIZE, MODIFICATION TIME, FILENAME]
|       t:
|         -[drwxr-xr-x, 1000,  100,  4096,  2010-06-11 22:31,
/home/storage/backup]
|         -[-rw-r--r--, 1000, 1002,     0,  2010-06-10 08:34, filetest]
|         -[drwx------, 1000,  100, 16384,  2010-02-05 17:05, lost+found]
|         -[-rw-r--r--,    0,    0,     5,  2010-06-10 11:32, rootfile]
|_        -[lrwxrwxrwx, 1000, 1002,     8,  2010-06-10 08:34, symlink]

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


Current thread: