Skip to main content
Updated the lin to Dradis to point to the correct site and domain
Source Link

If you want another program (database, etc.) to use Nmap output, always use the XML output (-oX). Depending on your preferred programming languages, there will often be a parser library already written: Nmap::Parser for Perl, Nmap::Parser for Ruby, ndiff (comes with Nmap) for Python. If you really need to use command pipelines, there are a few XML utilities that could be made to work (XmlStarlet seems to be fairly popular).

Depending on your needs, you could make use of an existing project that supports Nmap XML import. Metasploit, DradisDradis, and OpenVAS are a few very different tools that support importing from Nmap and storing in a database.

Even if you insist on using the "Grepable" output (which is deprecated), I would highly recommend using a real scripting/programming language (Perl, Python, Ruby, etc.) to do the parsing, especially for things like putting the date on every line or stripping parentheses. Command pipelines involving Nmap usually end up as monstrosities like this:

nmap -sn -oG - 192.168.0.50-100 | perl -lanE 'if(/initiated (.*?) as:/){$d=$1;$,=","}else{print@F[1,4],$d,$F[2]=~/\((.*)\)/ if/Status:/}'

If you want another program (database, etc.) to use Nmap output, always use the XML output (-oX). Depending on your preferred programming languages, there will often be a parser library already written: Nmap::Parser for Perl, Nmap::Parser for Ruby, ndiff (comes with Nmap) for Python. If you really need to use command pipelines, there are a few XML utilities that could be made to work (XmlStarlet seems to be fairly popular).

Depending on your needs, you could make use of an existing project that supports Nmap XML import. Metasploit, Dradis, and OpenVAS are a few very different tools that support importing from Nmap and storing in a database.

Even if you insist on using the "Grepable" output (which is deprecated), I would highly recommend using a real scripting/programming language (Perl, Python, Ruby, etc.) to do the parsing, especially for things like putting the date on every line or stripping parentheses. Command pipelines involving Nmap usually end up as monstrosities like this:

nmap -sn -oG - 192.168.0.50-100 | perl -lanE 'if(/initiated (.*?) as:/){$d=$1;$,=","}else{print@F[1,4],$d,$F[2]=~/\((.*)\)/ if/Status:/}'

If you want another program (database, etc.) to use Nmap output, always use the XML output (-oX). Depending on your preferred programming languages, there will often be a parser library already written: Nmap::Parser for Perl, Nmap::Parser for Ruby, ndiff (comes with Nmap) for Python. If you really need to use command pipelines, there are a few XML utilities that could be made to work (XmlStarlet seems to be fairly popular).

Depending on your needs, you could make use of an existing project that supports Nmap XML import. Metasploit, Dradis, and OpenVAS are a few very different tools that support importing from Nmap and storing in a database.

Even if you insist on using the "Grepable" output (which is deprecated), I would highly recommend using a real scripting/programming language (Perl, Python, Ruby, etc.) to do the parsing, especially for things like putting the date on every line or stripping parentheses. Command pipelines involving Nmap usually end up as monstrosities like this:

nmap -sn -oG - 192.168.0.50-100 | perl -lanE 'if(/initiated (.*?) as:/){$d=$1;$,=","}else{print@F[1,4],$d,$F[2]=~/\((.*)\)/ if/Status:/}'
Source Link
bonsaiviking
  • 2.8k
  • 18
  • 15

If you want another program (database, etc.) to use Nmap output, always use the XML output (-oX). Depending on your preferred programming languages, there will often be a parser library already written: Nmap::Parser for Perl, Nmap::Parser for Ruby, ndiff (comes with Nmap) for Python. If you really need to use command pipelines, there are a few XML utilities that could be made to work (XmlStarlet seems to be fairly popular).

Depending on your needs, you could make use of an existing project that supports Nmap XML import. Metasploit, Dradis, and OpenVAS are a few very different tools that support importing from Nmap and storing in a database.

Even if you insist on using the "Grepable" output (which is deprecated), I would highly recommend using a real scripting/programming language (Perl, Python, Ruby, etc.) to do the parsing, especially for things like putting the date on every line or stripping parentheses. Command pipelines involving Nmap usually end up as monstrosities like this:

nmap -sn -oG - 192.168.0.50-100 | perl -lanE 'if(/initiated (.*?) as:/){$d=$1;$,=","}else{print@F[1,4],$d,$F[2]=~/\((.*)\)/ if/Status:/}'