<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: module nmap</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head><body bgcolor="#f0f0f8">
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong>nmap</strong></big></big> (version 0.6.1)</font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/xael/ESPACE_KM/python/python-nmap/nmap/nmap.py">/home/xael/ESPACE_KM/python/python-nmap/nmap/nmap.py</a></font></td></tr></table>
<p><tt>nmap.py - version and date, see below<br>
<br>
Source code : https://bitbucket.org/xael/python-nmap<br>
<br>
Author :<br>
<br>
* Alexandre Norman - norman at xael.org<br>
<br>
Contributors:<br>
<br>
* Steve 'Ashcrow' Milner - steve at gnulinux.net<br>
* Brian Bustin - brian at bustin.us<br>
* old.schepperhand<br>
* Johan Lundberg<br>
* Thomas D. maaaaz<br>
* Robert Bost<br>
* David Peltier<br>
<br>
Licence: GPL v3 or any later version for python-nmap<br>
<br>
<br>
This program is free software: you can redistribute it and/or modify<br>
it under the terms of the GNU General Public License as published by<br>
the Free Software Foundation, either version 3 of the License, or<br>
any later version.<br>
<br>
This program is distributed in the hope that it will be useful,<br>
but WITHOUT ANY WARRANTY; without even the implied warranty of<br>
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the<br>
GNU General Public License for more details.<br>
<br>
You should have received a copy of the GNU General Public License<br>
along with this program. If not, see <<a href="http://www.gnu.org/licenses/">http://www.gnu.org/licenses/</a>>.<br>
<br>
<br>
**************<br>
IMPORTANT NOTE<br>
**************<br>
<br>
The Nmap Security Scanner used by python-nmap is distributed<br>
under it's own licence that you can find at https://svn.nmap.org/nmap/COPYING<br>
<br>
Any redistribution of python-nmap along with the Nmap Security Scanner<br>
must conform to the Nmap Security Scanner licence</tt></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#aa55cc">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
<tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td>
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="xml.etree.ElementTree.html">xml.etree.ElementTree</a><br>
<a href="csv.html">csv</a><br>
</td><td width="25%" valign=top><a href="io.html">io</a><br>
<a href="os.html">os</a><br>
</td><td width="25%" valign=top><a href="re.html">re</a><br>
<a href="shlex.html">shlex</a><br>
</td><td width="25%" valign=top><a href="subprocess.html">subprocess</a><br>
<a href="sys.html">sys</a><br>
</td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ee77aa">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
<tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td>
<td width="100%"><dl>
<dt><font face="helvetica, arial"><a href="builtins.html#Exception">builtins.Exception</a>(<a href="builtins.html#BaseException">builtins.BaseException</a>)
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="nmap.html#PortScannerError">PortScannerError</a>
</font></dt></dl>
</dd>
<dt><font face="helvetica, arial"><a href="builtins.html#dict">builtins.dict</a>(<a href="builtins.html#object">builtins.object</a>)
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="nmap.html#PortScannerHostDict">PortScannerHostDict</a>
</font></dt></dl>
</dd>
<dt><font face="helvetica, arial"><a href="builtins.html#object">builtins.object</a>
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="nmap.html#PortScanner">PortScanner</a>
</font></dt><dt><font face="helvetica, arial"><a href="nmap.html#PortScannerAsync">PortScannerAsync</a>
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="nmap.html#PortScannerYield">PortScannerYield</a>
</font></dt></dl>
</dd>
</dl>
</dd>
</dl>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="PortScanner">class <strong>PortScanner</strong></a>(<a href="builtins.html#object">builtins.object</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt><a href="#PortScanner">PortScanner</a> class allows to use nmap from python<br> </tt></td></tr>
<tr><td> </td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="PortScanner-__getitem__"><strong>__getitem__</strong></a>(self, host)</dt><dd><tt>returns a host detail</tt></dd></dl>
<dl><dt><a name="PortScanner-__init__"><strong>__init__</strong></a>(self, nmap_search_path=('nmap', '/usr/bin/nmap', '/usr/local/bin/nmap', '/sw/bin/nmap', '/opt/local/bin/nmap'))</dt><dd><tt>Initialize <a href="#PortScanner">PortScanner</a> module<br>
<br>
* detects nmap on the system and nmap version<br>
* may raise <a href="#PortScannerError">PortScannerError</a> exception if nmap is not found in the path<br>
<br>
:param nmap_search_path: tupple of string where to search for nmap executable. Change this if you want to use a specific version of nmap.<br>
:returns: nothing</tt></dd></dl>
<dl><dt><a name="PortScanner-all_hosts"><strong>all_hosts</strong></a>(self)</dt><dd><tt>returns a sorted list of all hosts</tt></dd></dl>
<dl><dt><a name="PortScanner-analyse_nmap_xml_scan"><strong>analyse_nmap_xml_scan</strong></a>(self, nmap_xml_output=None, nmap_err='', nmap_err_keep_trace='', nmap_warn_keep_trace='')</dt><dd><tt>Analyses NMAP xml scan ouput<br>
<br>
May raise <a href="#PortScannerError">PortScannerError</a> exception if nmap output was not xml<br>
<br>
Test existance of the following key to know if something went wrong : ['nmap']['scaninfo']['error']<br>
If not present, everything was ok.<br>
<br>
:param nmap_xml_output: xml string to analyse<br>
:returns: scan_result as dictionnary</tt></dd></dl>
<dl><dt><a name="PortScanner-command_line"><strong>command_line</strong></a>(self)</dt><dd><tt>returns command line used for the scan<br>
<br>
may raise AssertionError exception if called before scanning</tt></dd></dl>
<dl><dt><a name="PortScanner-csv"><strong>csv</strong></a>(self)</dt><dd><tt>returns CSV output as text<br>
<br>
Example :<br>
host;hostname;hostname_type;protocol;port;name;state;product;extrainfo;reason;version;conf;cpe<br>
127.0.0.1;localhost;PTR;tcp;22;ssh;open;OpenSSH;protocol 2.0;syn-ack;5.9p1 Debian 5ubuntu1;10;cpe<br>
127.0.0.1;localhost;PTR;tcp;23;telnet;closed;;;conn-refused;;3;<br>
127.0.0.1;localhost;PTR;tcp;24;priv-mail;closed;;;conn-refused;;3;</tt></dd></dl>
<dl><dt><a name="PortScanner-get_nmap_last_output"><strong>get_nmap_last_output</strong></a>(self)</dt><dd><tt>Returns the last text output of nmap in raw text<br>
this may be used for debugging purpose<br>
<br>
:returns: string containing the last text output of nmap in raw text</tt></dd></dl>
<dl><dt><a name="PortScanner-has_host"><strong>has_host</strong></a>(self, host)</dt><dd><tt>returns True if host has result, False otherwise</tt></dd></dl>
<dl><dt><a name="PortScanner-listscan"><strong>listscan</strong></a>(self, hosts='127.0.0.1')</dt><dd><tt>do not scan but interpret target hosts and return a list a hosts</tt></dd></dl>
<dl><dt><a name="PortScanner-nmap_version"><strong>nmap_version</strong></a>(self)</dt><dd><tt>returns nmap version if detected (int version, int subversion)<br>
or (0, 0) if unknown<br>
:returns: (nmap_version_number, nmap_subversion_number)</tt></dd></dl>
<dl><dt><a name="PortScanner-scan"><strong>scan</strong></a>(self, hosts='127.0.0.1', ports=None, arguments='-sV', sudo=False)</dt><dd><tt>Scan given hosts<br>
<br>
May raise <a href="#PortScannerError">PortScannerError</a> exception if nmap output was not xml<br>
<br>
Test existance of the following key to know<br>
if something went wrong : ['nmap']['scaninfo']['error']<br>
If not present, everything was ok.<br>
<br>
:param hosts: string for hosts as nmap use it 'scanme.nmap.org' or '198.116.0-255.1-127' or '216.163.128.20/20'<br>
:param ports: string for ports as nmap use it '22,53,110,143-4564'<br>
:param arguments: string of arguments for nmap '-sU -sX -sC'<br>
:param sudo: launch nmap with sudo if True<br>
<br>
:returns: scan_result as dictionnary</tt></dd></dl>
<dl><dt><a name="PortScanner-scaninfo"><strong>scaninfo</strong></a>(self)</dt><dd><tt>returns scaninfo structure<br>
{'tcp': {'services': '22', 'method': 'connect'}}<br>
<br>
may raise AssertionError exception if called before scanning</tt></dd></dl>
<dl><dt><a name="PortScanner-scanstats"><strong>scanstats</strong></a>(self)</dt><dd><tt>returns scanstats structure<br>
{'uphosts': '3', 'timestr': 'Thu Jun 3 21:45:07 2010', 'downhosts': '253', 'totalhosts': '256', 'elapsed': '5.79'}<br>
<br>
may raise AssertionError exception if called before scanning</tt></dd></dl>
<hr>
Data descriptors defined here:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list of weak references to the object (if defined)</tt></dd>
</dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="PortScannerAsync">class <strong>PortScannerAsync</strong></a>(<a href="builtins.html#object">builtins.object</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt><a href="#PortScannerAsync">PortScannerAsync</a> allows to use nmap from python asynchronously<br>
for each host scanned, callback is called with scan result for the host<br> </tt></td></tr>
<tr><td> </td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="PortScannerAsync-__del__"><strong>__del__</strong></a>(self)</dt><dd><tt>Cleanup when deleted</tt></dd></dl>
<dl><dt><a name="PortScannerAsync-__init__"><strong>__init__</strong></a>(self)</dt><dd><tt>Initialize the module<br>
<br>
* detects nmap on the system and nmap version<br>
* may raise <a href="#PortScannerError">PortScannerError</a> exception if nmap is not found in the path</tt></dd></dl>
<dl><dt><a name="PortScannerAsync-scan"><strong>scan</strong></a>(self, hosts='127.0.0.1', ports=None, arguments='-sV', callback=None, sudo=False)</dt><dd><tt>Scan given hosts in a separate process and return host by host result using callback function<br>
<br>
<a href="#PortScannerError">PortScannerError</a> exception from standard nmap is catched and you won't know about but get None as scan_data<br>
<br>
:param hosts: string for hosts as nmap use it 'scanme.nmap.org' or '198.116.0-255.1-127' or '216.163.128.20/20'<br>
:param ports: string for ports as nmap use it '22,53,110,143-4564'<br>
:param arguments: string of arguments for nmap '-sU -sX -sC'<br>
:param callback: callback function which takes (host, scan_data) as arguments<br>
:param sudo: launch nmap with sudo if true</tt></dd></dl>
<dl><dt><a name="PortScannerAsync-still_scanning"><strong>still_scanning</strong></a>(self)</dt><dd><tt>:returns: True if a scan is currently running, False otherwise</tt></dd></dl>
<dl><dt><a name="PortScannerAsync-stop"><strong>stop</strong></a>(self)</dt><dd><tt>Stop the current scan process</tt></dd></dl>
<dl><dt><a name="PortScannerAsync-wait"><strong>wait</strong></a>(self, timeout=None)</dt><dd><tt>Wait for the current scan process to finish, or timeout<br>
<br>
:param timeout: default = None, wait timeout seconds</tt></dd></dl>
<hr>
Data descriptors defined here:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list of weak references to the object (if defined)</tt></dd>
</dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="PortScannerError">class <strong>PortScannerError</strong></a>(<a href="builtins.html#Exception">builtins.Exception</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt><a href="builtins.html#Exception">Exception</a> error class for <a href="#PortScanner">PortScanner</a> class<br> </tt></td></tr>
<tr><td> </td>
<td width="100%"><dl><dt>Method resolution order:</dt>
<dd><a href="nmap.html#PortScannerError">PortScannerError</a></dd>
<dd><a href="builtins.html#Exception">builtins.Exception</a></dd>
<dd><a href="builtins.html#BaseException">builtins.BaseException</a></dd>
<dd><a href="builtins.html#object">builtins.object</a></dd>
</dl>
<hr>
Methods defined here:<br>
<dl><dt><a name="PortScannerError-__init__"><strong>__init__</strong></a>(self, value)</dt></dl>
<dl><dt><a name="PortScannerError-__repr__"><strong>__repr__</strong></a>(self)</dt></dl>
<dl><dt><a name="PortScannerError-__str__"><strong>__str__</strong></a>(self)</dt></dl>
<hr>
Data descriptors defined here:<br>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list of weak references to the object (if defined)</tt></dd>
</dl>
<hr>
Methods inherited from <a href="builtins.html#Exception">builtins.Exception</a>:<br>
<dl><dt><a name="PortScannerError-__new__"><strong>__new__</strong></a>(*args, **kwargs)<font color="#909090"><font face="helvetica, arial"> from <a href="builtins.html#type">builtins.type</a></font></font></dt><dd><tt>Create and return a new <a href="builtins.html#object">object</a>. See help(type) for accurate signature.</tt></dd></dl>
<hr>
Methods inherited from <a href="builtins.html#BaseException">builtins.BaseException</a>:<br>
<dl><dt><a name="PortScannerError-__delattr__"><strong>__delattr__</strong></a>(self, name, /)</dt><dd><tt>Implement delattr(self, name).</tt></dd></dl>
<dl><dt><a name="PortScannerError-__getattribute__"><strong>__getattribute__</strong></a>(self, name, /)</dt><dd><tt>Return getattr(self, name).</tt></dd></dl>
<dl><dt><a name="PortScannerError-__reduce__"><strong>__reduce__</strong></a>(...)</dt></dl>
<dl><dt><a name="PortScannerError-__setattr__"><strong>__setattr__</strong></a>(self, name, value, /)</dt><dd><tt>Implement setattr(self, name, value).</tt></dd></dl>
<dl><dt><a name="PortScannerError-__setstate__"><strong>__setstate__</strong></a>(...)</dt></dl>
<dl><dt><a name="PortScannerError-with_traceback"><strong>with_traceback</strong></a>(...)</dt><dd><tt><a href="builtins.html#Exception">Exception</a>.<a href="#PortScannerError-with_traceback">with_traceback</a>(tb) --<br>
set self.<strong>__traceback__</strong> to tb and return self.</tt></dd></dl>
<hr>
Data descriptors inherited from <a href="builtins.html#BaseException">builtins.BaseException</a>:<br>
<dl><dt><strong>__cause__</strong></dt>
<dd><tt>exception cause</tt></dd>
</dl>
<dl><dt><strong>__context__</strong></dt>
<dd><tt>exception context</tt></dd>
</dl>
<dl><dt><strong>__dict__</strong></dt>
</dl>
<dl><dt><strong>__suppress_context__</strong></dt>
</dl>
<dl><dt><strong>__traceback__</strong></dt>
</dl>
<dl><dt><strong>args</strong></dt>
</dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="PortScannerHostDict">class <strong>PortScannerHostDict</strong></a>(<a href="builtins.html#dict">builtins.dict</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt>Special dictionnary class for storing and accessing host scan result<br> </tt></td></tr>
<tr><td> </td>
<td width="100%"><dl><dt>Method resolution order:</dt>
<dd><a href="nmap.html#PortScannerHostDict">PortScannerHostDict</a></dd>
<dd><a href="builtins.html#dict">builtins.dict</a></dd>
<dd><a href="builtins.html#object">builtins.object</a></dd>
</dl>
<hr>
Methods defined here:<br>
<dl><dt><a name="PortScannerHostDict-all_ip"><strong>all_ip</strong></a>(self)</dt><dd><tt>:returns: list of ip ports</tt></dd></dl>
<dl><dt><a name="PortScannerHostDict-all_protocols"><strong>all_protocols</strong></a>(self)</dt><dd><tt>:returns: a list of all scanned protocols</tt></dd></dl>
<dl><dt><a name="PortScannerHostDict-all_sctp"><strong>all_sctp</strong></a>(self)</dt><dd><tt>:returns: list of sctp ports</tt></dd></dl>
<dl><dt><a name="PortScannerHostDict-all_tcp"><strong>all_tcp</strong></a>(self)</dt><dd><tt>:returns: list of tcp ports</tt></dd></dl>
<dl><dt><a name="PortScannerHostDict-all_udp"><strong>all_udp</strong></a>(self)</dt><dd><tt>:returns: list of udp ports</tt></dd></dl>
<dl><dt><a name="PortScannerHostDict-has_ip"><strong>has_ip</strong></a>(self, port)</dt><dd><tt>:param port: (int) ip port<br>
:returns: True if ip port has info, False otherwise</tt></dd></dl>
<dl><dt><a name="PortScannerHostDict-has_sctp"><strong>has_sctp</strong></a>(self, port)</dt><dd><tt>:returns: True if sctp port has info, False otherwise</tt></dd></dl>
<dl><dt><a name="PortScannerHostDict-has_tcp"><strong>has_tcp</strong></a>(self, port)</dt><dd><tt>:param port: (int) tcp port<br>
:returns: True if tcp port has info, False otherwise</tt></dd></dl>
<dl><dt><a name="PortScannerHostDict-has_udp"><strong>has_udp</strong></a>(self, port)</dt><dd><tt>:param port: (int) udp port<br>
:returns: True if udp port has info, False otherwise</tt></dd></dl>
<dl><dt><a name="PortScannerHostDict-hostname"><strong>hostname</strong></a>(self)</dt><dd><tt>For compatibility purpose...<br>
:returns: try to return the user record or the first hostname of the list hostnames</tt></dd></dl>
<dl><dt><a name="PortScannerHostDict-hostnames"><strong>hostnames</strong></a>(self)</dt><dd><tt>:returns: list of hostnames</tt></dd></dl>
<dl><dt><a name="PortScannerHostDict-ip"><strong>ip</strong></a>(self, port)</dt><dd><tt>:param port: (int) ip port<br>
:returns: info for ip port</tt></dd></dl>
<dl><dt><a name="PortScannerHostDict-sctp"><strong>sctp</strong></a>(self, port)</dt><dd><tt>:returns: info for sctp port</tt></dd></dl>
<dl><dt><a name="PortScannerHostDict-state"><strong>state</strong></a>(self)</dt><dd><tt>:returns: host state</tt></dd></dl>
<dl><dt><a name="PortScannerHostDict-tcp"><strong>tcp</strong></a>(self, port)</dt><dd><tt>:param port: (int) tcp port<br>
:returns: info for tpc port</tt></dd></dl>
<dl><dt><a name="PortScannerHostDict-udp"><strong>udp</strong></a>(self, port)</dt><dd><tt>:param port: (int) udp port<br>
:returns: info for udp port</tt></dd></dl>
<dl><dt><a name="PortScannerHostDict-uptime"><strong>uptime</strong></a>(self)</dt><dd><tt>:returns: host state</tt></dd></dl>
<hr>
Data descriptors defined here:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list of weak references to the object (if defined)</tt></dd>
</dl>
<hr>
Methods inherited from <a href="builtins.html#dict">builtins.dict</a>:<br>
<dl><dt><a name="PortScannerHostDict-__contains__"><strong>__contains__</strong></a>(self, key, /)</dt><dd><tt>True if D has a key k, else False.</tt></dd></dl>
<dl><dt><a name="PortScannerHostDict-__delitem__"><strong>__delitem__</strong></a>(self, key, /)</dt><dd><tt>Delete self[key].</tt></dd></dl>
<dl><dt><a name="PortScannerHostDict-__eq__"><strong>__eq__</strong></a>(self, value, /)</dt><dd><tt>Return self==value.</tt></dd></dl>
<dl><dt><a name="PortScannerHostDict-__ge__"><strong>__ge__</strong></a>(self, value, /)</dt><dd><tt>Return self>=value.</tt></dd></dl>
<dl><dt><a name="PortScannerHostDict-__getattribute__"><strong>__getattribute__</strong></a>(self, name, /)</dt><dd><tt>Return getattr(self, name).</tt></dd></dl>
<dl><dt><a name="PortScannerHostDict-__getitem__"><strong>__getitem__</strong></a>(...)</dt><dd><tt>x.<a href="#PortScannerHostDict-__getitem__">__getitem__</a>(y) <==> x[y]</tt></dd></dl>
<dl><dt><a name="PortScannerHostDict-__gt__"><strong>__gt__</strong></a>(self, value, /)</dt><dd><tt>Return self>value.</tt></dd></dl>
<dl><dt><a name="PortScannerHostDict-__init__"><strong>__init__</strong></a>(self, /, *args, **kwargs)</dt><dd><tt>Initialize self. See help(type(self)) for accurate signature.</tt></dd></dl>
<dl><dt><a name="PortScannerHostDict-__iter__"><strong>__iter__</strong></a>(self, /)</dt><dd><tt>Implement iter(self).</tt></dd></dl>
<dl><dt><a name="PortScannerHostDict-__le__"><strong>__le__</strong></a>(self, value, /)</dt><dd><tt>Return self<=value.</tt></dd></dl>
<dl><dt><a name="PortScannerHostDict-__len__"><strong>__len__</strong></a>(self, /)</dt><dd><tt>Return len(self).</tt></dd></dl>
<dl><dt><a name="PortScannerHostDict-__lt__"><strong>__lt__</strong></a>(self, value, /)</dt><dd><tt>Return self<value.</tt></dd></dl>
<dl><dt><a name="PortScannerHostDict-__ne__"><strong>__ne__</strong></a>(self, value, /)</dt><dd><tt>Return self!=value.</tt></dd></dl>
<dl><dt><a name="PortScannerHostDict-__new__"><strong>__new__</strong></a>(*args, **kwargs)<font color="#909090"><font face="helvetica, arial"> from <a href="builtins.html#type">builtins.type</a></font></font></dt><dd><tt>Create and return a new <a href="builtins.html#object">object</a>. See help(type) for accurate signature.</tt></dd></dl>
<dl><dt><a name="PortScannerHostDict-__repr__"><strong>__repr__</strong></a>(self, /)</dt><dd><tt>Return repr(self).</tt></dd></dl>
<dl><dt><a name="PortScannerHostDict-__setitem__"><strong>__setitem__</strong></a>(self, key, value, /)</dt><dd><tt>Set self[key] to value.</tt></dd></dl>
<dl><dt><a name="PortScannerHostDict-__sizeof__"><strong>__sizeof__</strong></a>(...)</dt><dd><tt>D.<a href="#PortScannerHostDict-__sizeof__">__sizeof__</a>() -> size of D in memory, in bytes</tt></dd></dl>
<dl><dt><a name="PortScannerHostDict-clear"><strong>clear</strong></a>(...)</dt><dd><tt>D.<a href="#PortScannerHostDict-clear">clear</a>() -> None. Remove all items from D.</tt></dd></dl>
<dl><dt><a name="PortScannerHostDict-copy"><strong>copy</strong></a>(...)</dt><dd><tt>D.<a href="#PortScannerHostDict-copy">copy</a>() -> a shallow copy of D</tt></dd></dl>
<dl><dt><a name="PortScannerHostDict-fromkeys"><strong>fromkeys</strong></a>(iterable, value=None, /)<font color="#909090"><font face="helvetica, arial"> from <a href="builtins.html#type">builtins.type</a></font></font></dt><dd><tt>Returns a new <a href="builtins.html#dict">dict</a> with keys from iterable and values equal to value.</tt></dd></dl>
<dl><dt><a name="PortScannerHostDict-get"><strong>get</strong></a>(...)</dt><dd><tt>D.<a href="#PortScannerHostDict-get">get</a>(k[,d]) -> D[k] if k in D, else d. d defaults to None.</tt></dd></dl>
<dl><dt><a name="PortScannerHostDict-items"><strong>items</strong></a>(...)</dt><dd><tt>D.<a href="#PortScannerHostDict-items">items</a>() -> a set-like <a href="builtins.html#object">object</a> providing a view on D's items</tt></dd></dl>
<dl><dt><a name="PortScannerHostDict-keys"><strong>keys</strong></a>(...)</dt><dd><tt>D.<a href="#PortScannerHostDict-keys">keys</a>() -> a set-like <a href="builtins.html#object">object</a> providing a view on D's keys</tt></dd></dl>
<dl><dt><a name="PortScannerHostDict-pop"><strong>pop</strong></a>(...)</dt><dd><tt>D.<a href="#PortScannerHostDict-pop">pop</a>(k[,d]) -> v, remove specified key and return the corresponding value.<br>
If key is not found, d is returned if given, otherwise KeyError is raised</tt></dd></dl>
<dl><dt><a name="PortScannerHostDict-popitem"><strong>popitem</strong></a>(...)</dt><dd><tt>D.<a href="#PortScannerHostDict-popitem">popitem</a>() -> (k, v), remove and return some (key, value) pair as a<br>
2-tuple; but raise KeyError if D is empty.</tt></dd></dl>
<dl><dt><a name="PortScannerHostDict-setdefault"><strong>setdefault</strong></a>(...)</dt><dd><tt>D.<a href="#PortScannerHostDict-setdefault">setdefault</a>(k[,d]) -> D.<a href="#PortScannerHostDict-get">get</a>(k,d), also set D[k]=d if k not in D</tt></dd></dl>
<dl><dt><a name="PortScannerHostDict-update"><strong>update</strong></a>(...)</dt><dd><tt>D.<a href="#PortScannerHostDict-update">update</a>([E, ]**F) -> None. Update D from <a href="builtins.html#dict">dict</a>/iterable E and F.<br>
If E is present and has a .<a href="#PortScannerHostDict-keys">keys</a>() method, then does: for k in E: D[k] = E[k]<br>
If E is present and lacks a .<a href="#PortScannerHostDict-keys">keys</a>() method, then does: for k, v in E: D[k] = v<br>
In either case, this is followed by: for k in F: D[k] = F[k]</tt></dd></dl>
<dl><dt><a name="PortScannerHostDict-values"><strong>values</strong></a>(...)</dt><dd><tt>D.<a href="#PortScannerHostDict-values">values</a>() -> an <a href="builtins.html#object">object</a> providing a view on D's values</tt></dd></dl>
<hr>
Data and other attributes inherited from <a href="builtins.html#dict">builtins.dict</a>:<br>
<dl><dt><strong>__hash__</strong> = None</dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="PortScannerYield">class <strong>PortScannerYield</strong></a>(<a href="nmap.html#PortScannerAsync">PortScannerAsync</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt><a href="#PortScannerYield">PortScannerYield</a> allows to use nmap from python with a generator<br>
for each host scanned, yield is called with scan result for the host<br> </tt></td></tr>
<tr><td> </td>
<td width="100%"><dl><dt>Method resolution order:</dt>
<dd><a href="nmap.html#PortScannerYield">PortScannerYield</a></dd>
<dd><a href="nmap.html#PortScannerAsync">PortScannerAsync</a></dd>
<dd><a href="builtins.html#object">builtins.object</a></dd>
</dl>
<hr>
Methods defined here:<br>
<dl><dt><a name="PortScannerYield-__init__"><strong>__init__</strong></a>(self)</dt><dd><tt>Initialize the module<br>
<br>
* detects nmap on the system and nmap version<br>
* may raise <a href="#PortScannerError">PortScannerError</a> exception if nmap is not found in the path</tt></dd></dl>
<dl><dt><a name="PortScannerYield-scan"><strong>scan</strong></a>(self, hosts='127.0.0.1', ports=None, arguments='-sV', sudo=False)</dt><dd><tt>Scan given hosts in a separate process and return host by host result using callback function<br>
<br>
<a href="#PortScannerError">PortScannerError</a> exception from standard nmap is catched and you won't know about it<br>
<br>
:param hosts: string for hosts as nmap use it 'scanme.nmap.org' or '198.116.0-255.1-127' or '216.163.128.20/20'<br>
:param ports: string for ports as nmap use it '22,53,110,143-4564'<br>
:param arguments: string of arguments for nmap '-sU -sX -sC'<br>
:param callback: callback function which takes (host, scan_data) as arguments<br>
:param sudo: launch nmap with sudo if true</tt></dd></dl>
<dl><dt><a name="PortScannerYield-still_scanning"><strong>still_scanning</strong></a>(self)</dt></dl>
<dl><dt><a name="PortScannerYield-stop"><strong>stop</strong></a>(self)</dt></dl>
<dl><dt><a name="PortScannerYield-wait"><strong>wait</strong></a>(self, timeout=None)</dt></dl>
<hr>
Methods inherited from <a href="nmap.html#PortScannerAsync">PortScannerAsync</a>:<br>
<dl><dt><a name="PortScannerYield-__del__"><strong>__del__</strong></a>(self)</dt><dd><tt>Cleanup when deleted</tt></dd></dl>
<hr>
Data descriptors inherited from <a href="nmap.html#PortScannerAsync">PortScannerAsync</a>:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list of weak references to the object (if defined)</tt></dd>
</dl>
</td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#eeaa77">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
<tr><td bgcolor="#eeaa77"><tt> </tt></td><td> </td>
<td width="100%"><dl><dt><a name="-__scan_progressive__"><strong>__scan_progressive__</strong></a>(self, hosts, ports, arguments, callback, sudo)</dt><dd><tt>Used by <a href="#PortScannerAsync">PortScannerAsync</a> for callback</tt></dd></dl>
<dl><dt><a name="-convert_nmap_output_to_encoding"><strong>convert_nmap_output_to_encoding</strong></a>(value, code='ascii')</dt><dd><tt>Change encoding for scan_result <a href="builtins.html#object">object</a> from unicode to whatever<br>
<br>
:param value: scan_result as dictionnary<br>
:param code: default = "ascii", encoding destination<br>
<br>
:returns: scan_result as dictionnary with new encoding</tt></dd></dl>
</td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#55aa55">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
<tr><td bgcolor="#55aa55"><tt> </tt></td><td> </td>
<td width="100%"><strong>__last_modification__</strong> = '2016.07.29'</td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#7799ee">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Author</strong></big></font></td></tr>
<tr><td bgcolor="#7799ee"><tt> </tt></td><td> </td>
<td width="100%">Alexandre Norman (norman@xael.org)</td></tr></table>
</body></html>