CIDR IP Converter Tools

After you make a port scan with NMAP with the option -oX or -oA, you will have the export in .xml format. However Excel doesn't import it as is.
In order to have each host/ip on a separate Excel row, we need to convert it to CSV.

In this guide we will explain how to have the following columns:

  • Hostname
  • IP Address
  • Protocol
  • Port
  • Service
  • State

Requirements to convert NMAP XML to CSV

  • You need to work on Windows OS
  • MSXLS
  • Microsoft Excel

Instructions

  1. Download the MSXLS tool here
  2. Create a file called nmaptemplate.xsl with the following code:
  3. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format"> <xsl:output method="html" indent="yes" encoding="UTF-8"/> <xsl:template match="/nmaprun">host,address,protocol,port,service,state, <xsl:apply-templates select="host"> </xsl:apply-templates> </xsl:template> <xsl:template match="host"> <xsl:for-each select="ports/port"> <xsl:value-of select="../../hostnames/hostname/@name"/>,<xsl:value-of select="../../address/@addr"/>, <xsl:value-of select="@protocol"/>, <xsl:value-of select="@portid"/>, <xsl:value-of select="service/@name"/>, <xsl:value-of select="state/@state"/>, </xsl:for-each> <xsl:apply-templates/> </xsl:template> </xsl:stylesheet>
  4. Make sure that the MSXSL.exe and the nmaptemplate.xsl are in the same folder where the NMAP xml output file is. For example in c:\
  5. Open CMD and run cd c:\
  6. Then run the following command
  7. msxsl output.txt.xml nmap.xsl -o nmap-out.csv
  8. The CSV file is created in the same directory
   

If you get the following error:

Line: 1 Column: 1 Invalid at the top level of the document.
  • Replace {} with <> in the .xsl file

If you have questions or comments feel free to contact me or leave a comment below

Leave a comment

Your IP Address is

44.220.131.93

Choose the tool and run the magic!

GUIDES

NewTutorial: convert IP to binary and decimal

How to SNMPWALK a device

NMAP - how to find open ports

NMAP - convert output XML to CSV

Convert CIDR manually in binary