Nmap Development mailing list archives

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


From: Daniel Miller <bonsaiviking () gmail com>
Date: Tue, 19 Apr 2011 07:23:48 -0500

On Mon, Apr 18, 2011 at 11:36 PM, David Fifield <david () bamsoftware com>wrote:

Do we really need to link with libyaml? It seems like emitting YAML, as
opposed to parsing it, would be easy enough to implement in stdnse.

David Fifield


No, we really don't, especially if we want to have an intermediate form (C++
data structure) to hand off to output.cc for XML output. I've been working
on this angle (scrapped the YAML for now), and I have a decent first go at
it. I've been using stdnse.format_output as a model, since script authors
should be used to that, and it means the least changes to existing scripts.
Here's example output:

Normal:
Pre-scan script results:
| test:
|
|     Apple pie
|   DOMAINS
|         Domain 1
|         Domain 2
|   NAMES (WARNING: Not all names could be determined!)
|_        Name 1

XML:
<prescript><script id="test"><container name=""><elem>Apple
pie</elem><container name="DOMAINS"><elem>Domain 1</elem><elem>Domain
2</elem></container><container name="NAMES" warning="Not all names could be
determined!"><elem>Name
1</elem></container></container></script></prescript>

I'm currently in debug mode, and having a rough time. I can't get that blank
first line to go away. I know exactly which function is generating it, but
if I change the function to return a blank string instead of "\n", it
mangles the rest of the text output in a way that doesn't make any sense.
I'm also fighting with a function that returns different values based on if
there is a comment in it.

I'm attaching a patch with my current progress. I'd appreciate any input you
have at this point, but I realize it's not robust code yet.

Dan

Attachment: script-output.diff
Description:

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

Current thread: