In my SANSFire presentation I described how and why to automate parts of the security testing process. The slides are posted here (handlers.dshield.org/adebeaupre/deBeaupre-SANSFire2010v011.pdf). Part of the process involves taking tool outputs, parsing them, and then importing the results to a database. In the example I am giving here we are taking nmap XML output, parsing it using a perl script and the nmap::parser (code.google.com/p/nmap-parser/) module, and then importing it to a MySQL database. The script I’m using is based on work by Paul Haas found here (www.redspin.com/blog/2009/10/27/nmap-database-output-xml-to-sql/). The table schema he uses is one of the better ones I have seen for nmap data storage. One of the major things the script lacks is the ability to parse nmap NSE output, still a work in progress. In any case the script is found here (handlers.dshield.org/adebeaupre/nmap_xml2mysql-v011.pl). The structure of the script is straight forward:
Main – reads command line arguments and calls the other functions
Usage – prints out a usage message if no command line arguments are provided
CreateTables – creats the database tables
Nmap_info – reads in the xml file and populates the tables
Db_output – outputs a success message
Unfortunately it needs some more work, but does the trick. I am more than open to suggestions, or better ways of doing things. Part II will be a script to import v2 .nessus files into a MySQL database, also in perl. Let us know if you use this script, something like it, or some other technique to manage security test data. Contact us or use the comment fields below.
Cheers,
Adrien de Beaupr
EWA-Canada.com
(c) SANS Internet Storm Center. http://isc.sans.org Creative Commons Attribution-Noncommercial 3.0 United States License.
View full post on SANS Internet Storm Center, InfoCON: green