Getting Started with Nmap Parser
This page gives you a quick introduction to Nmap Parser, and assumes you already have it installed. If you don't, check out the Installation section first.
Generate an Nmap XML File
This guide assumes you have working knowledge of Nmap, so I'm only going to highlight the parts relevant to Nmap Parser.
First, let's run Nmap to generate an XML output (myscan.xml):
$ nmap scanme.org -oX myscan.xml
Starting Nmap 6.00 ( http://nmap.org ) at 2015-03-02 22:39 EST
Nmap scan report for scanme.org (74.207.244.221)
Host is up (0.097s latency).
rDNS record for 74.207.244.221: scanme.nmap.org
Not shown: 991 closed ports
PORT STATE SERVICE
22/tcp open ssh
25/tcp filtered smtp
80/tcp open http
135/tcp filtered msrpc
139/tcp filtered netbios-ssn
445/tcp filtered microsoft-ds
2000/tcp open cisco-sccp
5060/tcp open sip
9929/tcp open nping-echo
Nmap done: 1 IP address (1 host up) scanned in 5.17 seconds
Create a Parser Object
We first create a Parser object and point it to myscan.xml.
>>> from nmap_parser import parser
>>> nmap = parser.Parser('myscan.xml')
Query Your Scan
Now that we have a Parser object, we can extract our scan's info. For example, we find out how many responsive hosts were detected:
>>> responsive_hosts = nmap.hosts(state='up')
>>> len(responsive_hosts)
1
We also want to know which ports were confirmed to be open:
>>> open_ports = nmap.ports('74.207.244.221', 'open')
>>> open_ports
['22', '80', '2000', '5060', '9929']
What's Next?
That's the gist of Nmap Parser. You can use it to quickly query your scan or to help you build reports. Check out the API section for detailed information on the different options available.