Nmap Development mailing list archives
Suggestion: Using script output - Human-readable and machine-parseable
From: Daniel Miller <bonsaiviking () gmail com>
Date: Thu, 31 Mar 2011 15:46:41 -0500
Hey list, From the Nmap TODO:
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)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.
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.
I was going to submit this idea with a patch, but I realized I don't have the first clue as to how to integrate a new Lua library binding into the Nmap source. Instead, here's some examples of YAML-formatted script output.
Old:
smb-system-info: | OS Details | | Microsoft Windows 2000 Service Pack 4 (ServerNT 5.0 build 2195) | | Installed on 2008-10-10 05:47:19 | | Registered to Ron (organization: Government of Manitoba)| | Path: %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Graphviz2.20\Bin;| | Systemroot: C:\WINNT | |_ Page files: C:\pagefile.sys 192 384 (cleared at shutdown => 0) | Hardware | | CPU 0: Intel(R) Xeon(TM) CPU 2.80GHz [2800mhz GenuineIntel] | | |_ Identifier 0: x86 Family 15 Model 3 Stepping 8 | |_ Video driver: VMware SVGA II | Browsers | | Internet Explorer 6.0000 |_ |_ Firefox 3.0.12 (en-US)
New:
smb-system-info: | OS Details:| Version: Microsoft Windows 2000 Service Pack 4 (ServerNT 5.0 build 2195)| Installed: 2008-10-10 05:47:19 | Registered to: | Name: Ron | Organization: Government of Manitoba| Path: %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Graphviz2.20\Bin;| Systemroot: C:\WINNT | Page files: C:\pagefile.sys 192 384 (cleared at shutdown => 0) | Hardware: | CPU: | - Name: Intel(R) Xeon(TM) CPU 2.80GHz [2800mhz GenuineIntel] | Identifier: x86 Family 15 Model 3 Stepping 8 | Video driver: VMware SVGA II | Browsers: | - Internet Explorer 6.0000 |_ - Firefox 3.0.12 (en-US)
Old:
-- | afp-showmount: -- | Yoda's Public Folder -- | Owner: Search,Read,Write -- | Group: Search,Read -- | Everyone: Search,Read -- | User: Search,Read -- | Vader's Public Folder -- | Owner: Search,Read,Write -- | Group: Search,Read -- | Everyone: Search,Read -- | User: Search,Read -- |_ Options: IsOwner
New:
-- | afp-showmount: -- | - name: Yoda's Public Folder -- | Owner: [Search,Read,Write] -- | Group: [Search,Read] -- | Everyone: [Search,Read] -- | User: [Search,Read] -- | - name: Vader's Public Folder -- | Owner: [Search,Read,Write] -- | Group: [Search,Read] -- | Everyone: [Search,Read] -- | User: [Search,Read] -- |_ Options: [IsOwner]
Old:
-- |_auth-spoof: Spoofed reply: 0, 0 : USERID : UNIX : OGJdvM
New:
-- |_auth-spoof: {Spoofed reply: "0, 0 : USERID : UNIX : OGJdvM"}
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:
- Suggestion: Using script output - Human-readable and machine-parseable Daniel Miller (Mar 31)
- Re: Suggestion: Using script output - Human-readable and machine-parseable David Fifield (Mar 31)
- Re: Suggestion: Using script output - Human-readable and machine-parseable Daniel Miller (Mar 31)
- Re: Suggestion: Using script output - Human-readable and machine-parseable David Fifield (Mar 31)