Home > IT, Python, Security, Tools > Playing with Python – nmap XML port frequency

Playing with Python – nmap XML port frequency

December 16th, 2008 Leave a comment Go to comments

Two Python libraries have caught my attention lately, the first is lxml and the second is matplotlib. Ideally I wanted to write something short, just to get a feel for the basics of them. The goal was figuring out what I could do quickly so that I could play around with arguments and output, yet still have an actual result. I also wanted a nicely formatted useful XML file to parse. I ended up going with nmap's XML output. I also decided that I would plot the frequency of ports in the file.

Is this useful... perhaps? I could see a sys admin wanting a count of specific open ports on the network or a pen tester wanting to know the most common ports on a target network.

The python script is extremely basic and is called via nmap_port_frequency.py <XML Input> <png Output>. The result is an image similar to this:

The above image is the output from scanning three hosts.

Categories: IT, Python, Security, Tools Tags: , , , , ,
  1. Marco Ramilli
    January 19th, 2009 at 14:20 | #1

    Great ! I like your script, it's very useful ! Thanks for sharing.

  1. No trackbacks yet.