Package: python-libnmap
Code statusUse caseslibnmap is a python library enabling python developers to manipulate
nmap process and data.libnmap is what you were looking for if you need to implement the
following:automate or schedule nmap scans on a regular basismanipulate nmap scans results to do reportingcompare and diff nmap scans to generate graphsbatch process scan reports…The above uses cases will be easy to implement with the help of the
libnmap modules.libnmap modulesThe lib currently offers the following modules:process: enables you to launch nmap scansparse: enables you to parse nmap reports or scan results (only
XML so far) from a file, a string,…report: enables you to manipulate a parsed scan result and
de/serialize scan results in a json formatdiff: enables you to see what changed between two scanscommon: contains basic nmap objects like NmapHost and
NmapService. It is to note that each object can be “diff()ed” with
another similar object.plugins: enables you to support datastores for your scan results
directly in the “NmapReport” object. from report module:mongodb: insert/get/getAll/deletesqlalchemy: insert/get/getAll/deleteaws s3: insert/get/getAll/delete (not supported for python3 since
boto is not supporting py3)csv: todo (easy to implement)elastic search: todoDocumentationAll the documentation is available onread the
docs. This documentation contains
small code samples that you directly reuse.Dependencieslibnmap has by default no dependencies, except defusedxml if you need to
import untrusted XML scans data.The only additional python modules you’ll have to install depends if you
wish to use libnmap to store reports on an exotic data store via
libnmap’s independents plugins.Below the list of optional dependencies:sqlalchemy(+the driver
ie:MySQL-python)pymongobotoSecurityIf you are importing/parsing untrusted XML scan outputs with
python-libnmap, install defusedxml library:ronald@brouette:~/dev$pipinstalldefusedxmlThis will prevent you from being vulnerable toXML External Entities
attacks.For more information, read theofficial libnmap
documentationThis note relates to a cascaded CVE vulnerability from the python core
library XML ElementTree. Nevertheless, python-libnmap has been assigned
anofficial
CVEto track this issue.This CVE is addressed from v0.7.2.Python SupportThe libnmap code is tested against the following python interpreters:Python 2.7Python 3.6Python 3.7Python 3.8InstallYou can install libnmap via pip:ronald@brouette:~$pipinstallpython-libnmapor via git and dist utils (à l’ancienne):ronald@brouette:~$gitclonehttps://github.com/savon-noir/python-libnmap.gitronald@brouette:~$cdpython-libnmapronald@brouette:~$pythonsetup.pyinstallor via git and pip:ronald@brouette:~$gitclonehttps://github.com/savon-noir/python-libnmap.gitronald@brouette:~$cdpython-libnmapronald@brouette:~$pipinstall.ExamplesSome codes samples are available in the examples directory or in thedocumentation.Among other example, you notice an sample code pushing nmap scan reports
in an ElasticSearch instance and allowing you to create fancy dashboards
in Kibana like the screenshot below:ContributorsMike @bmx0r Boutillier for S3 and SQL-Alechemy plugins and for the
constructive critics. Thanks!