++ed by:

1 PAUSE user
1 non-PAUSE user.

Anthony Persaud
and 1 contributors


nmap2db - store nmap scan data into entries in SQLite/MySQL database


 nmap2db.pl [options] --xml  <XML_FILE> [<XML_FILE> ...]
 nmap2db.pl [options] --scan <IP_ADDR>  [<IP_ADDR> ...]

Examples connecting to a MySQL database (Robin Bowes):

 nmap2db.pl --dbtype mysql --dbname netdb --dbuser netuser --dbpass secret --xml


This script uses the nmap security scanner with the Nmap::Parser module in order to take an xml output scan file from nmap (-oX option), and place the information into a SQLite database (ip.db), into table (hosts).

This is a modified version of the nmap2sqlite.pl script written originally by Anthony Persaud but modified by Robin Bowes to support MySQL databases.

Here is the schema for the table stored in the SQLite database

  ip              TEXT       PRIMARY  KEY NOT NULL,
  mac             TEXT,
  status          TEXT,
  hostname        TEXT,
  open_ports      TEXT,
  filtered_ports  TEXT,
  osname          TEXT,
  osfamily        TEXT,
  osgen           TEXT,
  UNIQUE (ip))


These options are passed as command line parameters. Please use EITHER --scan or --xml. NOT both.

--dbhost DBHOST

Connect to the DB on server DBHOST.

Default: localhost.


Sets the database name to DBNAME.

Default: ip.db

--dbtype DBTYPE

Sets the type of databases to use. Currently supported values are: mysql, SQLite

Default: SQLite

--table TABLE_NAME

Sets the table name to use in the database as TABLE_NAME.

Default: hosts

--dbuser DBUSER

Connect to the database as user DBUSER.

Default: current user

--dbpass DBPASS

Connect to the database with password DBPASS

Default: no password


Shows this help information.


The path to the nmap executable. This should be used if nmap is not on your path.


This will use parsescan() for the scan and take the arguments as IP addreses.


This will use parsefile() for the input and take the arguments as nmap scan xml files.


This documentation was taken from the nmap man page. The IP address inputs to this scripts should be in the nmap target specification format.

The simplest case is listing single hostnames or IP addresses onthe command line. If you want to scan a subnet of IP addresses, you can append '/mask' to the hostname or IP address. mask must be between 0 (scan the whole internet) and 32 (scan the single host specified). Use /24 to scan a class 'C' address and /16 for a class 'B'.

You can use a more powerful notation which lets you specify an IP address using lists/ranges for each element. Thus you can scan the whole class 'B' network 128.210.*.* by specifying '128.210.*.*' or '128.210.0-255.0-255' or even use the mask notation: ''. These are all equivalent. If you use asterisks ('*'), remember that most shells require you to escape them with back slashes or protect them with quotes.

Another interesting thing to do is slice the Internet the other way.


 nmap2db.pl --scan
 nmap2db.pl --scan target.example.com
 nmap2db.pl --scan target.example.com/24
 nmap2db.pl --scan 10.210.*.1-127
 nmap2db.pl --scan *.*.2.3-5
 nmap2db.pl --scan 10.[10-15].10.[2-254]

Examples connecting to a MySQL database:

 nmap2db.pl --dbtype mysql --dbname netdb --dbuser netuser --dbpass secret --xml


See the SQLite database that is created. Default ip.db


Discussion Forum

If you have questions about how to use the module, or any of its features, you can post messages to the Nmap::Parser module forum on CPAN::Forum. http://www.cpanforum.com/dist/Nmap-Parser

Bug Reports

Please submit any bugs to: https://github.com/apersaud/Nmap-Parser/issues

Please make sure that you submit the xml-output file of the scan which you are having trouble. This can be done by running your scan with the -oX filename.xml nmap switch. Please remove any important IP addresses for security reasons.

Feature Requests

Please submit any requests to: https://github.com/apersaud/Nmap-Parser/issues



The Nmap::Parser page can be found at: https://github.com/apersaud/Nmap-Parser. It contains the latest developments on the module. The nmap security scanner homepage can be found at: http://www.insecure.org/nmap/.


Anthony Persaud <apersaud[at]gmail.com> http://modernistik.com

Additional features and improvements by: Robin Bowes <robin[at]robinbowes.com> http://robinbowes.com Daniel Miller http://bonsaiviking.com/


This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.


1 POD Error

The following errors were encountered while parsing the POD:

Around line 317:

=back doesn't take any parameters, but you said =back 4