===========
python-nmap
===========
|PyPI latest| |PyPI Version| |PyPI License|
python-nmap is a python library which helps in using nmap port scanner. It allows to easilly manipulate nmap scan results and will be a perfect tool for systems administrators who want to automatize scanning task and reports. It also supports nmap script outputs.
It can even be used asynchronously. Results are returned one host at a time to a callback function defined by the user.
Download latest
===============
python-nmap-0.4.1.tar.gz - 2015-08-21
md5sum is b466e4b2ef30a0b9c0cb80aac215fb79
Warning : this version is intended to work with Python 3.x. For Python 2.x, please use python-nmap-0.1.4.tar.gz
Download development version
============================
.. code-block:: bash
$ hg clone https://bitbucket.org/xael/python-nmap
Installation
============
From the shell, uncompress python-nmap-0.4.1.tar.gz and then run make :
.. code-block:: bash
$ tar xvzf python-nmap-0.4.1.tar.gz
$ cd python-nmap-0.4.1
$ python setup.py install
or using Pip
.. code-block:: bash
$ pip install python-nmap
Now you may invoke nmap from python
.. code-block:: bash
$ python
Python 2.6.4 (r264:75706, Dec 7 2009, 18:45:15)
[GCC 4.4.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>> import nmap
Usage
=====
From python/ipython:
--------------------
.. code-block:: python
>>> import nmap
>>> nm = nmap.PortScanner()
>>> nm.scan('127.0.0.1', '22-443')
>>> nm.command_line()
'nmap -oX - -p 22-443 -sV 127.0.0.1'
>>> nm.scaninfo()
{'tcp': {'services': '22-443', 'method': 'connect'}}
>>> nm.all_hosts()
['127.0.0.1']
>>> nm['127.0.0.1'].hostname()
'localhost'
>>> nm['127.0.0.1'].state()
'up'
>>> nm['127.0.0.1'].all_protocols()
['tcp']
>>> nm['127.0.0.1']['tcp'].keys()
[80, 25, 443, 22, 111]
>>> nm['127.0.0.1'].has_tcp(22)
True
>>> nm['127.0.0.1'].has_tcp(23)
False
>>> nm['127.0.0.1']['tcp'][22]
{'state': 'open', 'reason': 'syn-ack', 'name': 'ssh'}
>>> nm['127.0.0.1'].tcp(22)
{'state': 'open', 'reason': 'syn-ack', 'name': 'ssh'}
>>> nm['127.0.0.1']['tcp'][22]['state']
'open'
>>> for host in nm.all_hosts():
>>> print('----------------------------------------------------')
>>> print('Host : %s (%s)' % (host, nm[host].hostname()))
>>> print('State : %s' % nm[host].state())
>>> for proto in nm[host].all_protocols():
>>> print('----------')
>>> print('Protocol : %s' % proto)
>>>
>>> lport = nm[host][proto].keys()
>>> lport.sort()
>>> for port in lport:
>>> print ('port : %s\tstate : %s' % (port, nm[host][proto][port]['state']))
----------------------------------------------------
Host : 127.0.0.1 (localhost)
State : up
----------
Protocol : tcp
port : 22 state : open
port : 25 state : open
port : 80 state : open
port : 111 state : open
port : 443 state : open
To export to a file
-------------------
.. code-block:: python
>>> print(nm.csv())
host;protocol;port;name;state;product;extrainfo;reason;version;conf
127.0.0.1;tcp;22;ssh;open;OpenSSH;protocol 2.0;syn-ack;5.9p1 Debian 5ubuntu1;10
127.0.0.1;tcp;25;smtp;open;Exim smtpd;;syn-ack;4.76;10
127.0.0.1;tcp;53;domain;open;dnsmasq;;syn-ack;2.59;10
127.0.0.1;tcp;80;http;open;Apache httpd;(Ubuntu);syn-ack;2.2.22;10
127.0.0.1;tcp;111;rpcbind;open;;;syn-ack;;10
127.0.0.1;tcp;139;netbios-ssn;open;Samba smbd;workgroup: WORKGROUP;syn-ack;3.X;10
127.0.0.1;tcp;443;;open;;;syn-ack;;
To check the network status
---------------------------
.. code-block:: python
>>> nm.scan(hosts='192.168.1.0/24', arguments='-n -sP -PE -PA21,23,80,3389')
>>> hosts_list = [(x, nm[x]['status']['state']) for x in nm.all_hosts()]
>>> for host, status in hosts_list:
>>> print('{0}:{1}'.host)
192.168.1.0:down
192.168.1.1:up
192.168.1.10:down
192.168.1.100:down
192.168.1.101:down
192.168.1.102:down
192.168.1.103:down
192.168.1.104:down
192.168.1.105:down
[...]
Using a Scanner Async
---------------------
.. code-block:: python
>>> nma = nmap.PortScannerAsync()
>>> def callback_result(host, scan_result):
>>> print '------------------'
>>> print host, scan_result
>>>
>>> nma.scan(hosts='192.168.1.0/30', arguments='-sP', callback=callback_result)
>>> while nma.still_scanning():
>>> print("Waiting >>>")
>>> nma.wait(2) # you can do whatever you want but I choose to wait after the end of the scan
>>>
192.168.1.1 {'nmap': {'scanstats': {'uphosts': '1', 'timestr': 'Mon Jun 7 11:31:11 2010', 'downhosts': '0', 'totalhosts': '1', 'elapsed': '0.43'}, 'scaninfo': {}, 'command_line': 'nmap -oX - -sP 192.168.1.1'}, 'scan': {'192.168.1.1': {'status': {'state': 'up', 'reason': 'arp-response'}, 'hostname': 'neufbox'}}}
------------------
192.168.1.2 {'nmap': {'scanstats': {'uphosts': '0', 'timestr': 'Mon Jun 7 11:31:11 2010', 'downhosts': '1', 'totalhosts': '1', 'elapsed': '0.29'}, 'scaninfo': {}, 'command_line': 'nmap -oX - -sP 192.168.1.2'}, 'scan': {'192.168.1.2': {'status': {'state': 'down', 'reason': 'no-response'}, 'hostname': ''}}}
------------------
192.168.1.3 {'nmap': {'scanstats': {'uphosts': '0', 'timestr': 'Mon Jun 7 11:31:11 2010', 'downhosts': '1', 'totalhosts': '1', 'elapsed': '0.29'}, 'scaninfo': {}, 'command_line': 'nmap -oX - -sP 192.168.1.3'}, 'scan': {'192.168.1.3': {'status': {'state': 'down', 'reason': 'no-response'}, 'hostname': ''}}}
>>> nm = nmap.PortScannerYield() >>> for progressive_result in nm.scan('127.0.0.1/24', '22-25'): >>> print(progressive_result)
See also example.py in archive file.
Using a Scanner Async
---------------------
.. code-block:: python
>>> nm = nmap.PortScanner()
>>> nm.scan('127.0.0.1', '22-40043', timeout=10)
PortScannerTimeout: 'Timeout from nmap process'
Contributors
============
.. code-block:: text
Steve 'Ashcrow' Milner
Brian Bustin
old.schepperhand
Johan Lundberg
Thomas D. maaaaz
Robert Bost
David Peltier
Ed Jones
Homepage
========
http://xael.org/norman/python/python-nmap/
.. |PyPI Version| image:: https://img.shields.io/pypi/pyversions/python-nmap.svg?maxAge=2592000
:target: https://pypi.python.org/pypi/python-nmap
.. |PyPI License| image:: https://img.shields.io/pypi/l/python-nmap.svg?maxAge=2592000
:target: https://pypi.python.org/pypi/python-nmap
.. |PyPI latest| image:: https://img.shields.io/pypi/v/python-nmap.svg?maxAge=360
:target: https://pypi.python.org/pypi/python-nmap
Changelog
=========
2021/10/26 (v0.7.1)
-------------------
- Fix setup.cfg
- Fix build tools
2020/03/02 (v0.7.0)
-------------------
- Add black and flake8 for development
- Drop support for python2.7
2020/02/28 (v0.6.4)
-------------------
- Add timeout parameter and PortScannerTimeout exception
2018/09/23 (v0.6.3)
-------------------
- Refactor Readme and changelog files for the Pypi pattern and applying styles to the blocks for better visualization
- Change setup.py to use an explicit version of python, since asynchronous tasks are not available for python 2.x
- Add clean method to the Makefile
- Update Manifest file
- Update version and Fix PEP8 on nmap/nmap.py
2017/01/07 (v0.6.2)
-------------------
2016/07/29 (v0.6.1)
-------------------
- Fix bug #22 UnboundLocalError in scan_progressive
- Fix bug #23 Scanning fails on nmap warnings
- Fix bug #20: Fix for empty <hostnames> values which results in blank CSV output
- Fix bug #18: print(nm.csv()) does not return any results
- Fix bug #19: nmap program was not found in path
- Fix bug #17: hostname is no longer reported
2016/03/15 (v0.6.0)
-------------------
- Add information about Nmap special licence
- Licence precision for distributing python-nmap along with nmap
2016/03/15 (v0.5.2)
-------------------
- add hostname to csv export
2015/12/05 (v0.5.0-1)
---------------------
- updating example.py
2015/11/18 (v0.5.0)
-------------------
- Closes bugs :
- #11 Display only one osclass/osmatch instead of multiple
- Change in data structure :
- osmatch is a list of osclass
- osclass is a list of dictionnary
- added cpe which is a list of string
- added portused which is a list of dictionnary
Data structure for a host looks like :
.. code-block:: python
{'addresses': {'ipv4': '127.0.0.1'},
'hostnames': [],
'osmatch': [{'accuracy': '98',
'line': '36241',
'name': 'Juniper SA4000 SSL VPN gateway (IVE OS 7.0)',
'osclass': [{'accuracy': '98',
'cpe': ['cpe:/h:juniper:sa4000',
'cpe:/o:juniper:ive_os:7'],
'osfamily': 'IVE OS',
'osgen': '7.X',
'type': 'firewall',
'vendor': 'Juniper'}]},
{'accuracy': '91',
'line': '17374',
'name': 'Citrix Access Gateway VPN gateway',
'osclass': [{'accuracy': '91',
'cpe': [],
'osfamily': 'embedded',
'osgen': None,
'type': 'proxy server',
'vendor': 'Citrix'}]}],
'portused': [{'portid': '443', 'proto': 'tcp', 'state': 'open'},
{'portid': '113', 'proto': 'tcp', 'state': 'closed'}],
'status': {'reason': 'syn-ack', 'state': 'up'},
'tcp': {113: {'conf': '3',
'cpe': '',
'extrainfo': '',
'name': 'ident',
'product': '',
'reason': 'conn-refused',
'state': 'closed',
'version': ''},
443: {'conf': '10',
'cpe': '',
'extrainfo': '',
'name': 'http',
'product': 'Juniper SA2000 or SA4000 VPN gateway http config',
'reason': 'syn-ack',
'state': 'open',
'version': ''}},
'vendor': {}}
2015/11/17 (v0.4.7)
-------------------
- Closes bugs:
- #10 Error when trying to parse 'osclass' , 'osmatch'
removed addresses, hostnames, status, vendor, osclass, uptime, osmatch
from all_protocols()
- Changed shebang line from python3 to python as it works with python2
2015/11/13 (v0.4.6)
-------------------
- Closes bugs :
- #10 Error when trying to parse 'osclass' , 'osmatch'
2015/10/25 (v0.4.5)
-------------------
- Closes bugs :
- #9 Can not pass ports with unicode string at scan function
2015/10/17 (v0.4.4)
-------------------
- Closes bugs :
- #8 IPv6 Async scanner doesn't work
2015/09/11 (v0.4.3)
-------------------
- Change in url for __get_last_online_version
2015/09/11 (v0.4.2)
-------------------
- Closes bugs :
- #7: Error with empty hostname
- #6: Windows support of close_fds if you redirect stdin/stdout/stderr
2015/08/21 (v0.4.1)
-------------------
- Closes bugs :
- #5: only one hostname stored per host
- Add hostnames() method which return the list of hostnames as a list of
dict [{'name':'hostname1', 'type':'PTR'}, {'name':'hostname2', 'type':'user'}]
2015/08/01 (v0.4.0)
-------------------
- Closes bugs :
- #2: use close_fds in subprocess.Popen
- #3: memory leak parsing xml using xml.dom.minidom
- Corrects a bug in parsing osclass
- Add nosetests for case testing
- Removed test case in docstring
2015/05/08 (v0.3.7)
-------------------
- adding sudo parameter for scanning (idea from scupython)
2015/05/08 (v0.3.6)
-------------------
- correcting issue 7 : Issues under windows
2015/05/08 (v0.3.5)
-------------------
- correcting a bug in all_protocols()
- correcting issue 8 : PortScannerAsync Doesn't work in windows...
2014/06/22 (v0.3.4)
-------------------
- adding PortScannerYield class with generator
>>> nm = nmap.PortScannerYield()
>>> for i in nm.scan('127.0.0.1/24', '22-25'):
>>> print(i)
2014/03/13 (v0.3.3)
-------------------
- moving file example.py
- adding function convert_nmap_output_to_encoding
- adding vendor for mac address
2013/09/23 (v0.3.2)
-------------------
- adding acces to CPE values under [host][proto][port]['cpe'] key
2013/07/27 (v0.3.1)
-------------------
- Bug correction on callback's assert in PortScannerAsync.scan
proposed by Robert Bost
2013/06/23 (v0.3.0)
-------------------
- added support for NMAP SCRIPT ENGINE
.. code-block:: python
>>> r=nm.scan(hosts='127.0.0.1', ports='139', arguments="-sC ")
>>> print(nm._scan_result['scan']['127.0.0.1']['hostscript'])
2013/02/24 (v0.2.7)
-------------------
- added an address block in host scan result which contains ipv4, mac and other addresses :
.. code-block:: python
nm = nmap.PortScanner()
r = nm.scan(arguments='-sS -p T:22', hosts='192.168.1.3')
print r['scan']['192.168.1.3']['addresses']
{u'mac': u'02:50:43:F4:02:B1', u'ipv4': u'192.168.1.3'}
- Adding a CSV scan output as a string.
- Changes examples.py to make it python3 compliant
2012/12/13 (v0.2.6)
-------------------
- patch from lundberg.johan
- bug correction : when nmap doesn't work displays stderr instead of stdout
2012/11/23 (v0.2.5)
-------------------
- corrected : Issue 2: "map.nmap.PortScannerError: 'nmap program was not found in path'" on CentOS
- corrected : Issue 3: nmap.scan() short-circuits prematurely
2011/11/09 (v0.2.4)
-------------------
- implemented a request from Santhosh Edukulla <santhosh.edukulla@gmail.com> :
parse OS scanning output
- Error with multiple host specifications :
bug and patch from old.schepperhand@gmail.com
2011/11/04
----------
- bug in example.py : if no tcp port was open between 22-443
2010/12/17 (v0.2.3)
-------------------
- adding __get_last_online_version to check if current version is the last published
2010/12/17 (v0.2.2)
-------------------
- bug in handling nmap_error output (returned value was bin, string was expected)
- removed test strings form __init__.py file.
2010/12/15 (v0.2.1)
-------------------
- corrected bug in __init__.py about scope problem
- try to find nmap executable in known directories
- raise AssertionError when trying to call command_line, scaninfo, scanstats, has_host before scanning
2010/12/14 (v0.2.0)
-------------------
- Make python-nmap works with Python 3.x
- Contribution from Brian Bustin <brian at bustin.us>
2010/06/07 (v0.1.4)
-------------------
- Patches from Steve 'Ashcrow' Milner <steve at gnulinux.net>
- remove shebang from __init__.py as it is not a runnable script
- allow use with ALPHA and BETA nmap releases
- .has_key() is deprecated, replaced instances with in
- move to using the print function for python2 and 3 usage
2010/06/04
----------
- adding PortScanner.listscan
- PortScanner.scan now returns scan_result
- adding class PortScannerAsync (idea from Steve 'Ashcrow' Milner <steve at gnulinux.net>)
2010/06/03
----------
- Import on google code
svn checkout https://python-nmap.googlecode.com/svn/trunk/ python-nmap --username XXXXX
- added PortScanner.scanstats method
- updated example.py and documentation for pingsweep
- updated Makefile for generating documentation
2010/03/09
----------
- Modified packaging. v0.1.1 [norman]
2010/03/08
----------
- Initial release. v0.1.0 [norman]
Raw data
{
"_id": null,
"home_page": "http://xael.org/pages/python-nmap-en.html",
"name": "python-nmap",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "nmap",
"author": "Alexandre Norman",
"author_email": "norman@xael.org",
"download_url": "https://files.pythonhosted.org/packages/f7/1b/8e6b3d1461331e4e8600faf099e7c62ba3c1603987dafdd558681fb8ba37/python-nmap-0.7.1.tar.gz",
"platform": "Operating System :: OS Independent",
"description": "\n===========\npython-nmap\n===========\n\n|PyPI latest| |PyPI Version| |PyPI License|\n\npython-nmap is a python library which helps in using nmap port scanner. It allows to easilly manipulate nmap scan results and will be a perfect tool for systems administrators who want to automatize scanning task and reports. It also supports nmap script outputs.\n\nIt can even be used asynchronously. Results are returned one host at a time to a callback function defined by the user.\n\nDownload latest\n===============\n\n python-nmap-0.4.1.tar.gz - 2015-08-21\n md5sum is b466e4b2ef30a0b9c0cb80aac215fb79\n\nWarning : this version is intended to work with Python 3.x. For Python 2.x, please use python-nmap-0.1.4.tar.gz\n\nDownload development version\n============================\n\n\n.. code-block:: bash\n\n $ hg clone https://bitbucket.org/xael/python-nmap\n\nInstallation\n============\n\nFrom the shell, uncompress python-nmap-0.4.1.tar.gz and then run make :\n\n.. code-block:: bash\n\n $ tar xvzf python-nmap-0.4.1.tar.gz\n $ cd python-nmap-0.4.1\n $ python setup.py install\n\nor using Pip\n\n.. code-block:: bash\n\n $ pip install python-nmap\n\nNow you may invoke nmap from python\n\n\n.. code-block:: bash\n\n $ python\n Python 2.6.4 (r264:75706, Dec 7 2009, 18:45:15)\n [GCC 4.4.1] on linux2\n Type \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n >> import nmap\n\n\nUsage\n=====\n\nFrom python/ipython:\n--------------------\n\n.. code-block:: python\n\n >>> import nmap\n >>> nm = nmap.PortScanner()\n >>> nm.scan('127.0.0.1', '22-443')\n >>> nm.command_line()\n 'nmap -oX - -p 22-443 -sV 127.0.0.1'\n >>> nm.scaninfo()\n {'tcp': {'services': '22-443', 'method': 'connect'}}\n >>> nm.all_hosts()\n ['127.0.0.1']\n >>> nm['127.0.0.1'].hostname()\n 'localhost'\n >>> nm['127.0.0.1'].state()\n 'up'\n >>> nm['127.0.0.1'].all_protocols()\n ['tcp']\n >>> nm['127.0.0.1']['tcp'].keys()\n [80, 25, 443, 22, 111]\n >>> nm['127.0.0.1'].has_tcp(22)\n True\n >>> nm['127.0.0.1'].has_tcp(23)\n False\n >>> nm['127.0.0.1']['tcp'][22]\n {'state': 'open', 'reason': 'syn-ack', 'name': 'ssh'}\n >>> nm['127.0.0.1'].tcp(22)\n {'state': 'open', 'reason': 'syn-ack', 'name': 'ssh'}\n >>> nm['127.0.0.1']['tcp'][22]['state']\n 'open'\n\n >>> for host in nm.all_hosts():\n >>> print('----------------------------------------------------')\n >>> print('Host : %s (%s)' % (host, nm[host].hostname()))\n >>> print('State : %s' % nm[host].state())\n >>> for proto in nm[host].all_protocols():\n >>> print('----------')\n >>> print('Protocol : %s' % proto)\n >>>\n >>> lport = nm[host][proto].keys()\n >>> lport.sort()\n >>> for port in lport:\n >>> print ('port : %s\\tstate : %s' % (port, nm[host][proto][port]['state']))\n ----------------------------------------------------\n Host : 127.0.0.1 (localhost)\n State : up\n ----------\n Protocol : tcp\n port : 22\tstate : open\n port : 25\tstate : open\n port : 80\tstate : open\n port : 111\tstate : open\n port : 443\tstate : open\n\n\nTo export to a file\n-------------------\n\n.. code-block:: python\n\n >>> print(nm.csv())\n host;protocol;port;name;state;product;extrainfo;reason;version;conf\n 127.0.0.1;tcp;22;ssh;open;OpenSSH;protocol 2.0;syn-ack;5.9p1 Debian 5ubuntu1;10\n 127.0.0.1;tcp;25;smtp;open;Exim smtpd;;syn-ack;4.76;10\n 127.0.0.1;tcp;53;domain;open;dnsmasq;;syn-ack;2.59;10\n 127.0.0.1;tcp;80;http;open;Apache httpd;(Ubuntu);syn-ack;2.2.22;10\n 127.0.0.1;tcp;111;rpcbind;open;;;syn-ack;;10\n 127.0.0.1;tcp;139;netbios-ssn;open;Samba smbd;workgroup: WORKGROUP;syn-ack;3.X;10\n 127.0.0.1;tcp;443;;open;;;syn-ack;;\n\n\nTo check the network status\n---------------------------\n\n.. code-block:: python\n\n >>> nm.scan(hosts='192.168.1.0/24', arguments='-n -sP -PE -PA21,23,80,3389')\n >>> hosts_list = [(x, nm[x]['status']['state']) for x in nm.all_hosts()]\n >>> for host, status in hosts_list:\n >>> print('{0}:{1}'.host)\n 192.168.1.0:down\n 192.168.1.1:up\n 192.168.1.10:down\n 192.168.1.100:down\n 192.168.1.101:down\n 192.168.1.102:down\n 192.168.1.103:down\n 192.168.1.104:down\n 192.168.1.105:down\n [...]\n\n\nUsing a Scanner Async\n---------------------\n\n.. code-block:: python\n\n >>> nma = nmap.PortScannerAsync()\n >>> def callback_result(host, scan_result):\n >>> print '------------------'\n >>> print host, scan_result\n >>>\n >>> nma.scan(hosts='192.168.1.0/30', arguments='-sP', callback=callback_result)\n >>> while nma.still_scanning():\n >>> print(\"Waiting >>>\")\n >>> nma.wait(2) # you can do whatever you want but I choose to wait after the end of the scan\n >>>\n 192.168.1.1 {'nmap': {'scanstats': {'uphosts': '1', 'timestr': 'Mon Jun 7 11:31:11 2010', 'downhosts': '0', 'totalhosts': '1', 'elapsed': '0.43'}, 'scaninfo': {}, 'command_line': 'nmap -oX - -sP 192.168.1.1'}, 'scan': {'192.168.1.1': {'status': {'state': 'up', 'reason': 'arp-response'}, 'hostname': 'neufbox'}}}\n ------------------\n 192.168.1.2 {'nmap': {'scanstats': {'uphosts': '0', 'timestr': 'Mon Jun 7 11:31:11 2010', 'downhosts': '1', 'totalhosts': '1', 'elapsed': '0.29'}, 'scaninfo': {}, 'command_line': 'nmap -oX - -sP 192.168.1.2'}, 'scan': {'192.168.1.2': {'status': {'state': 'down', 'reason': 'no-response'}, 'hostname': ''}}}\n ------------------\n 192.168.1.3 {'nmap': {'scanstats': {'uphosts': '0', 'timestr': 'Mon Jun 7 11:31:11 2010', 'downhosts': '1', 'totalhosts': '1', 'elapsed': '0.29'}, 'scaninfo': {}, 'command_line': 'nmap -oX - -sP 192.168.1.3'}, 'scan': {'192.168.1.3': {'status': {'state': 'down', 'reason': 'no-response'}, 'hostname': ''}}}\n >>> nm = nmap.PortScannerYield() >>> for progressive_result in nm.scan('127.0.0.1/24', '22-25'): >>> print(progressive_result)\n\n\nSee also example.py in archive file.\n\n\nUsing a Scanner Async\n---------------------\n\n.. code-block:: python\n\n >>> nm = nmap.PortScanner() \n >>> nm.scan('127.0.0.1', '22-40043', timeout=10)\n PortScannerTimeout: 'Timeout from nmap process'\n\nContributors\n============\n\n.. code-block:: text\n\n Steve 'Ashcrow' Milner\n Brian Bustin\n old.schepperhand\n Johan Lundberg\n Thomas D. maaaaz\n Robert Bost\n David Peltier\n Ed Jones\n\n\nHomepage\n========\n\nhttp://xael.org/norman/python/python-nmap/\n\n\n.. |PyPI Version| image:: https://img.shields.io/pypi/pyversions/python-nmap.svg?maxAge=2592000\n :target: https://pypi.python.org/pypi/python-nmap\n.. |PyPI License| image:: https://img.shields.io/pypi/l/python-nmap.svg?maxAge=2592000\n :target: https://pypi.python.org/pypi/python-nmap\n.. |PyPI latest| image:: https://img.shields.io/pypi/v/python-nmap.svg?maxAge=360\n :target: https://pypi.python.org/pypi/python-nmap\n\n\nChangelog\n=========\n\n2021/10/26 (v0.7.1)\n-------------------\n\n - Fix setup.cfg\n - Fix build tools\n\n2020/03/02 (v0.7.0)\n-------------------\n\n - Add black and flake8 for development\n - Drop support for python2.7\n\n2020/02/28 (v0.6.4)\n-------------------\n\n - Add timeout parameter and PortScannerTimeout exception\n\n2018/09/23 (v0.6.3)\n-------------------\n\n - Refactor Readme and changelog files for the Pypi pattern and applying styles to the blocks for better visualization\n - Change setup.py to use an explicit version of python, since asynchronous tasks are not available for python 2.x\n - Add clean method to the Makefile\n - Update Manifest file\n - Update version and Fix PEP8 on nmap/nmap.py\n\n2017/01/07 (v0.6.2)\n-------------------\n\n\n2016/07/29 (v0.6.1)\n-------------------\n\n - Fix bug #22 UnboundLocalError in scan_progressive\n - Fix bug #23 Scanning fails on nmap warnings\n - Fix bug #20: Fix for empty <hostnames> values which results in blank CSV output\n - Fix bug #18: print(nm.csv()) does not return any results\n - Fix bug #19: nmap program was not found in path\n - Fix bug #17: hostname is no longer reported\n\n\n2016/03/15 (v0.6.0)\n-------------------\n\n - Add information about Nmap special licence\n - Licence precision for distributing python-nmap along with nmap\n\n2016/03/15 (v0.5.2)\n-------------------\n\n - add hostname to csv export\n\n2015/12/05 (v0.5.0-1)\n---------------------\n\n - updating example.py\n\n2015/11/18 (v0.5.0)\n-------------------\n\n - Closes bugs :\n - #11 Display only one osclass/osmatch instead of multiple\n\n - Change in data structure :\n - osmatch is a list of osclass\n - osclass is a list of dictionnary\n - added cpe which is a list of string\n - added portused which is a list of dictionnary\n\n Data structure for a host looks like :\n\n.. code-block:: python\n\n {'addresses': {'ipv4': '127.0.0.1'},\n 'hostnames': [],\n 'osmatch': [{'accuracy': '98',\n 'line': '36241',\n 'name': 'Juniper SA4000 SSL VPN gateway (IVE OS 7.0)',\n 'osclass': [{'accuracy': '98',\n 'cpe': ['cpe:/h:juniper:sa4000',\n 'cpe:/o:juniper:ive_os:7'],\n 'osfamily': 'IVE OS',\n 'osgen': '7.X',\n 'type': 'firewall',\n 'vendor': 'Juniper'}]},\n {'accuracy': '91',\n 'line': '17374',\n 'name': 'Citrix Access Gateway VPN gateway',\n 'osclass': [{'accuracy': '91',\n 'cpe': [],\n 'osfamily': 'embedded',\n 'osgen': None,\n 'type': 'proxy server',\n 'vendor': 'Citrix'}]}],\n 'portused': [{'portid': '443', 'proto': 'tcp', 'state': 'open'},\n {'portid': '113', 'proto': 'tcp', 'state': 'closed'}],\n 'status': {'reason': 'syn-ack', 'state': 'up'},\n 'tcp': {113: {'conf': '3',\n 'cpe': '',\n 'extrainfo': '',\n 'name': 'ident',\n 'product': '',\n 'reason': 'conn-refused',\n 'state': 'closed',\n 'version': ''},\n 443: {'conf': '10',\n 'cpe': '',\n 'extrainfo': '',\n 'name': 'http',\n 'product': 'Juniper SA2000 or SA4000 VPN gateway http config',\n 'reason': 'syn-ack',\n 'state': 'open',\n 'version': ''}},\n 'vendor': {}}\n\n\n2015/11/17 (v0.4.7)\n-------------------\n\n - Closes bugs:\n - #10 Error when trying to parse 'osclass' , 'osmatch'\n removed addresses, hostnames, status, vendor, osclass, uptime, osmatch\n from all_protocols()\n - Changed shebang line from python3 to python as it works with python2\n\n2015/11/13 (v0.4.6)\n-------------------\n\n - Closes bugs :\n - #10 Error when trying to parse 'osclass' , 'osmatch'\n\n2015/10/25 (v0.4.5)\n-------------------\n\n - Closes bugs :\n - #9 Can not pass ports with unicode string at scan function\n\n2015/10/17 (v0.4.4)\n-------------------\n\n - Closes bugs :\n - #8 IPv6 Async scanner doesn't work\n\n2015/09/11 (v0.4.3)\n-------------------\n\n - Change in url for __get_last_online_version\n\n2015/09/11 (v0.4.2)\n-------------------\n\n - Closes bugs :\n - #7: Error with empty hostname\n - #6: Windows support of close_fds if you redirect stdin/stdout/stderr\n\n2015/08/21 (v0.4.1)\n-------------------\n\n - Closes bugs :\n - #5: only one hostname stored per host\n - Add hostnames() method which return the list of hostnames as a list of\n dict [{'name':'hostname1', 'type':'PTR'}, {'name':'hostname2', 'type':'user'}]\n\n2015/08/01 (v0.4.0)\n-------------------\n\n - Closes bugs :\n - #2: use close_fds in subprocess.Popen\n - #3: memory leak parsing xml using xml.dom.minidom\n - Corrects a bug in parsing osclass\n - Add nosetests for case testing\n - Removed test case in docstring\n\n2015/05/08 (v0.3.7)\n-------------------\n\n - adding sudo parameter for scanning (idea from scupython)\n\n2015/05/08 (v0.3.6)\n-------------------\n\n - correcting issue 7 : Issues under windows\n\n2015/05/08 (v0.3.5)\n-------------------\n\n - correcting a bug in all_protocols()\n - correcting issue 8 : PortScannerAsync Doesn't work in windows...\n\n2014/06/22 (v0.3.4)\n-------------------\n\n - adding PortScannerYield class with generator\n >>> nm = nmap.PortScannerYield()\n >>> for i in nm.scan('127.0.0.1/24', '22-25'):\n >>> print(i)\n\n2014/03/13 (v0.3.3)\n-------------------\n\n - moving file example.py\n - adding function convert_nmap_output_to_encoding\n - adding vendor for mac address\n\n2013/09/23 (v0.3.2)\n-------------------\n\n - adding acces to CPE values under [host][proto][port]['cpe'] key\n\n2013/07/27 (v0.3.1)\n-------------------\n\n - Bug correction on callback's assert in PortScannerAsync.scan\n proposed by Robert Bost\n\n2013/06/23 (v0.3.0)\n-------------------\n\n - added support for NMAP SCRIPT ENGINE\n\n.. code-block:: python\n\n >>> r=nm.scan(hosts='127.0.0.1', ports='139', arguments=\"-sC \")\n >>> print(nm._scan_result['scan']['127.0.0.1']['hostscript'])\n\n\n2013/02/24 (v0.2.7)\n-------------------\n\n - added an address block in host scan result which contains ipv4, mac and other addresses :\n\n.. code-block:: python\n\n nm = nmap.PortScanner()\n r = nm.scan(arguments='-sS -p T:22', hosts='192.168.1.3')\n print r['scan']['192.168.1.3']['addresses']\n {u'mac': u'02:50:43:F4:02:B1', u'ipv4': u'192.168.1.3'}\n\n - Adding a CSV scan output as a string.\n - Changes examples.py to make it python3 compliant\n\n2012/12/13 (v0.2.6)\n-------------------\n\n - patch from lundberg.johan\n - bug correction : when nmap doesn't work displays stderr instead of stdout\n\n2012/11/23 (v0.2.5)\n-------------------\n\n - corrected : Issue 2: \"map.nmap.PortScannerError: 'nmap program was not found in path'\" on CentOS\n - corrected : Issue 3: nmap.scan() short-circuits prematurely\n\n2011/11/09 (v0.2.4)\n-------------------\n\n - implemented a request from Santhosh Edukulla <santhosh.edukulla@gmail.com> :\n parse OS scanning output\n - Error with multiple host specifications :\n bug and patch from old.schepperhand@gmail.com\n\n2011/11/04\n----------\n\n - bug in example.py : if no tcp port was open between 22-443\n\n2010/12/17 (v0.2.3)\n-------------------\n\n - adding __get_last_online_version to check if current version is the last published\n\n2010/12/17 (v0.2.2)\n-------------------\n\n - bug in handling nmap_error output (returned value was bin, string was expected)\n - removed test strings form __init__.py file.\n\n2010/12/15 (v0.2.1)\n-------------------\n\n - corrected bug in __init__.py about scope problem\n - try to find nmap executable in known directories\n - raise AssertionError when trying to call command_line, scaninfo, scanstats, has_host before scanning\n\n2010/12/14 (v0.2.0)\n-------------------\n\n - Make python-nmap works with Python 3.x\n - Contribution from Brian Bustin <brian at bustin.us>\n\n2010/06/07 (v0.1.4)\n-------------------\n\n - Patches from Steve 'Ashcrow' Milner <steve at gnulinux.net>\n - remove shebang from __init__.py as it is not a runnable script\n - allow use with ALPHA and BETA nmap releases\n - .has_key() is deprecated, replaced instances with in\n - move to using the print function for python2 and 3 usage\n\n2010/06/04\n----------\n\n - adding PortScanner.listscan\n - PortScanner.scan now returns scan_result\n - adding class PortScannerAsync (idea from Steve 'Ashcrow' Milner <steve at gnulinux.net>)\n\n2010/06/03\n----------\n\n - Import on google code\n svn checkout https://python-nmap.googlecode.com/svn/trunk/ python-nmap --username XXXXX\n - added PortScanner.scanstats method\n - updated example.py and documentation for pingsweep\n - updated Makefile for generating documentation\n\n2010/03/09\n----------\n\n - Modified packaging. v0.1.1 [norman]\n\n2010/03/08\n----------\n\n - Initial release. v0.1.0 [norman]\n",
"bugtrack_url": null,
"license": "gpl-3.0.txt",
"summary": "This is a python class to use nmap and access scan results from python3",
"version": "0.7.1",
"project_urls": {
"Homepage": "http://xael.org/pages/python-nmap-en.html"
},
"split_keywords": [
"nmap"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "f71b8e6b3d1461331e4e8600faf099e7c62ba3c1603987dafdd558681fb8ba37",
"md5": "1a97c59260678a2fa186e4d99f3ecb75",
"sha256": "f75af6b91dd8e3b0c31f869db32163f62ada686945e5b7c25f84bc0f7fad3b64"
},
"downloads": -1,
"filename": "python-nmap-0.7.1.tar.gz",
"has_sig": false,
"md5_digest": "1a97c59260678a2fa186e4d99f3ecb75",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 44366,
"upload_time": "2021-10-26T18:40:26",
"upload_time_iso_8601": "2021-10-26T18:40:26.488885Z",
"url": "https://files.pythonhosted.org/packages/f7/1b/8e6b3d1461331e4e8600faf099e7c62ba3c1603987dafdd558681fb8ba37/python-nmap-0.7.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2021-10-26 18:40:26",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "python-nmap"
}