This happened over the weekend. I was in a mood of taking a break from work after so many working weekends. As usual I was about to wind up my day at a coffee shop near by on a Friday evening, and I got a call from a fellow researcher seeking help to solve a problem at his work desk. He had to scan hundreds of IP addresses with multiple ranges, both internal and external. This gave him a lot of nmap scan result files. Now the challenge here is to convert all these scan result into a single XLS file that can help the customer to track the network status in single look.
Well, some of you might have got what I’m coming into. This is about automating XML parsing on a massive scale. Nmap XML files are quite easy to understand and parse using any language. The idea for me was to make it scalable and flexible at the same time depending on pentester’s requirement.
Here are the scenarios,
XML nodes can be ip address, host, mac, port, service, os, version etc.
The script is available here https://github.com/s4n7h0/Nmap-XML-Parser
usage: nmap-xml-parser_v2.0.py \[-h\] \[-i IFILE\] \[-iF IFOLDER\] \[-o OFILE\] [-c COL]
$ python nmap-xml-parser_v2.0.py -i nmap-scan-result.xml -o output.csv $ python nmap-xml-parser_v2.0.py -iF xml/ -o xml/result.csv
The output CSV file can be opened in Excel with delimiters split as shown below.