|
| 1 | +python-libnmap |
| 2 | +============== |
| 3 | + |
| 4 | +Code status |
| 5 | +----------- |
| 6 | + |
| 7 | +|preflight-check| |Coverage Status| |License| |
| 8 | + |
| 9 | +Use cases |
| 10 | +--------- |
| 11 | + |
| 12 | +libnmap is a python library enabling python developers to manipulate |
| 13 | +nmap process and data. |
| 14 | + |
| 15 | +libnmap is what you were looking for if you need to implement the |
| 16 | +following: |
| 17 | + |
| 18 | +- automate or schedule nmap scans on a regular basis |
| 19 | +- manipulate nmap scans results to do reporting |
| 20 | +- compare and diff nmap scans to generate graphs |
| 21 | +- batch process scan reports |
| 22 | +- … |
| 23 | + |
| 24 | +The above uses cases will be easy to implement with the help of the |
| 25 | +libnmap modules. |
| 26 | + |
| 27 | +libnmap modules |
| 28 | +--------------- |
| 29 | + |
| 30 | +The lib currently offers the following modules: |
| 31 | + |
| 32 | +- **process**: enables you to launch nmap scans |
| 33 | +- **parse**: enables you to parse nmap reports or scan results (only |
| 34 | + XML so far) from a file, a string,… |
| 35 | +- **report**: enables you to manipulate a parsed scan result and |
| 36 | + de/serialize scan results in a json format |
| 37 | +- **diff**: enables you to see what changed between two scans |
| 38 | +- **common**: contains basic nmap objects like NmapHost and |
| 39 | + NmapService. It is to note that each object can be “diff()ed” with |
| 40 | + another similar object. |
| 41 | +- **plugins**: enables you to support datastores for your scan results |
| 42 | + directly in the “NmapReport” object. from report module: |
| 43 | + |
| 44 | + - mongodb: insert/get/getAll/delete |
| 45 | + - sqlalchemy: insert/get/getAll/delete |
| 46 | + - aws s3: insert/get/getAll/delete (not supported for python3 since |
| 47 | + boto is not supporting py3) |
| 48 | + - csv: todo (easy to implement) |
| 49 | + - elastic search: todo |
| 50 | + |
| 51 | +Documentation |
| 52 | +------------- |
| 53 | + |
| 54 | +All the documentation is available on `read the |
| 55 | +docs <https://libnmap.readthedocs.org>`__. This documentation contains |
| 56 | +small code samples that you directly reuse. |
| 57 | + |
| 58 | +Dependencies |
| 59 | +------------ |
| 60 | + |
| 61 | +libnmap has by default no dependencies, except defusedxml if you need to |
| 62 | +import untrusted XML scans data. |
| 63 | + |
| 64 | +The only additional python modules you’ll have to install depends if you |
| 65 | +wish to use libnmap to store reports on an exotic data store via |
| 66 | +libnmap’s independents plugins. |
| 67 | + |
| 68 | +Below the list of optional dependencies: |
| 69 | + |
| 70 | +- `sqlalchemy <https://github.com/zzzeek/sqlalchemy>`__ (+the driver |
| 71 | + ie:MySQL-python) |
| 72 | +- `pymongo <https://github.com/mongodb/mongo-python-driver/>`__ |
| 73 | +- `boto <https://github.com/boto/boto>`__ |
| 74 | + |
| 75 | +Security |
| 76 | +-------- |
| 77 | + |
| 78 | +If you are importing/parsing untrusted XML scan outputs with |
| 79 | +python-libnmap, install defusedxml library: |
| 80 | + |
| 81 | +.. code:: bash |
| 82 | +
|
| 83 | + ronald@brouette:~/dev$ pip install defusedxml |
| 84 | +
|
| 85 | +This will prevent you from being vulnerable to `XML External Entities |
| 86 | +attacks <https://owasp.org/www-community/vulnerabilities/XML_External_Entity_(XXE)_Processing>`__. |
| 87 | + |
| 88 | +For more information, read the `official libnmap |
| 89 | +documentation <https://libnmap.readthedocs.io/en/latest/parser.html#security-note-for-libnmap-parser>`__ |
| 90 | + |
| 91 | +This note relates to a cascaded CVE vulnerability from the python core |
| 92 | +library XML ElementTree. Nevertheless, python-libnmap has been assigned |
| 93 | +an `official |
| 94 | +CVE <https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-1010017>`__ |
| 95 | +to track this issue. |
| 96 | + |
| 97 | +This CVE is addressed from v0.7.1. |
| 98 | + |
| 99 | +Python Support |
| 100 | +-------------- |
| 101 | + |
| 102 | +The libnmap code is tested against the following python interpreters: |
| 103 | + |
| 104 | +- Python 2.7 |
| 105 | +- Python 3.6 |
| 106 | +- Python 3.7 |
| 107 | +- Python 3.8 |
| 108 | + |
| 109 | +Install |
| 110 | +------- |
| 111 | + |
| 112 | +You can install libnmap via pip: |
| 113 | + |
| 114 | +.. code:: bash |
| 115 | +
|
| 116 | + ronald@brouette:~$ pip install python-libnmap |
| 117 | +
|
| 118 | +or via git and dist utils (à l’ancienne): |
| 119 | + |
| 120 | +.. code:: bash |
| 121 | +
|
| 122 | + ronald@brouette:~$ git clone https://github.com/savon-noir/python-libnmap.git |
| 123 | + ronald@brouette:~$ cd python-libnmap |
| 124 | + ronald@brouette:~$ python setup.py install |
| 125 | +
|
| 126 | +or via git and pip: |
| 127 | + |
| 128 | +.. code:: bash |
| 129 | +
|
| 130 | + ronald@brouette:~$ git clone https://github.com/savon-noir/python-libnmap.git |
| 131 | + ronald@brouette:~$ cd python-libnmap |
| 132 | + ronald@brouette:~$ pip install . |
| 133 | +
|
| 134 | +Examples |
| 135 | +-------- |
| 136 | + |
| 137 | +Some codes samples are available in the examples directory or in the |
| 138 | +`documentation <https://libnmap.readthedocs.org>`__. |
| 139 | + |
| 140 | +Among other example, you notice an sample code pushing nmap scan reports |
| 141 | +in an ElasticSearch instance and allowing you to create fancy dashboards |
| 142 | +in Kibana like the screenshot below: |
| 143 | + |
| 144 | +.. figure:: https://github.com/savon-noir/python-libnmap/blob/es/examples/kibanalibnmap.png |
| 145 | + :alt: Kibanane |
| 146 | + |
| 147 | + Kibanane |
| 148 | + |
| 149 | +Contributors |
| 150 | +------------ |
| 151 | + |
| 152 | +Mike @bmx0r Boutillier for S3 and SQL-Alechemy plugins and for the |
| 153 | +constructive critics. Thanks! |
| 154 | + |
| 155 | +.. |preflight-check| image:: https://github.com/savon-noir/python-libnmap/workflows/Preflight%20Check/badge.svg |
| 156 | +.. |Coverage Status| image:: https://coveralls.io/repos/github/savon-noir/python-libnmap/badge.svg?branch=master |
| 157 | + :target: https://coveralls.io/github/savon-noir/python-libnmap?branch=master |
| 158 | +.. |License| image:: https://img.shields.io/badge/License-Apache%202.0-blue.svg |
| 159 | + :target: https://opensource.org/licenses/Apache-2.0 |
0 commit comments