nmap (version 0.3.1) | index /home/xael/ESPACE_KM/python/python-nmap/nmap/nmap.py |
nmap.py - version and date, see below
Source code : https://code.google.com/p/python-nmap/
Author :
* Alexandre Norman - norman at xael.org
Contributors:
* Steve 'Ashcrow' Milner - steve at gnulinux.net
* Brian Bustin - brian at bustin.us
* old.schepperhand
* Johan Lundberg
* Thomas D. maaaaz
* Robert Bost
Licence : GPL v3 or any later version
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 3 of the License, or
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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Test strings :
^^^^^^^^^^^^
>>> import nmap
>>> if __get_last_online_version() != __version__:
... raise ValueError('Current version is {0} - Last published version is {1}'.format(__version__, __get_last_online_version()))
>>> nm = nmap.PortScanner()
>>> try:
... nm.scan(arguments='-wrongargs')
... except nmap.PortScannerError:
... pass
>>> 'error' in nm.scan('yahoo.fs', arguments='-sP')['nmap']['scaninfo']
True
>>> r=nm.scan('127.0.0.1', '22-25')
>>> r=nm.analyse_nmap_xml_scan(open('nmap_output.xml').read())
>>> nm.command_line()
'nmap -oX - -p 22-443 -sV 127.0.0.1'
>>> nm.scaninfo()
{'tcp': {'services': '22-443', 'method': 'syn'}}
>>> 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()
['addresses', 'tcp']
>>> nm['127.0.0.1']['tcp'].keys()
dict_keys([139, 111, 80, 53, 22, 25, 443])
>>> 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]
{'product': 'OpenSSH', 'name': 'ssh', 'extrainfo': 'protocol 2.0', 'reason': 'syn-ack', 'state': 'open', 'version': '5.9p1 Debian 5ubuntu1', 'conf': '10'}
>>> nm['127.0.0.1'].tcp(22)
{'product': 'OpenSSH', 'name': 'ssh', 'extrainfo': 'protocol 2.0', 'reason': 'syn-ack', 'state': 'open', 'version': '5.9p1 Debian 5ubuntu1', 'conf': '10'}
>>> nm['127.0.0.1']['tcp'][22]['state']
'open'
>>> nm.scanstats()['uphosts']
'1'
>>> nm.scanstats()['downhosts']
'0'
>>> nm.scanstats()['totalhosts']
'1'
>>> 'timestr' in nm.scanstats().keys()
True
>>> 'elapsed' in nm.scanstats().keys()
True
>>> nm.listscan('192.168.1.0/30')
['192.168.1.0', '192.168.1.1', '192.168.1.2', '192.168.1.3']
>>> nm.listscan('localhost/30')
['127.0.0.0', '127.0.0.1', '127.0.0.2', '127.0.0.3']
>>> r=nm.scan('127.0.0.1', arguments='-O')
>>> len(nm['127.0.0.1']['osclass'])>0
True
>>> r=nm['127.0.0.1']['fingerprint']
>>> r[:7]
'OS:SCAN'
>>> nm.csv()
'host;protocol;port;name;state;product;extrainfo;reason;version;conf\r\n127.0.0.1;tcp;22;ssh;open;;;syn-ack;;3\r\n127.0.0.1;tcp;25;smtp;open;;;syn-ack;;3\r\n127.0.0.1;tcp;53;domain;open;;;syn-ack;;3\r\n127.0.0.1;tcp;80;http;open;;;syn-ack;;3\r\n127.0.0.1;tcp;111;rpcbind;open;;;syn-ack;;3\r\n127.0.0.1;tcp;139;netbios-ssn;open;;;syn-ack;;3\r\n127.0.0.1;tcp;443;https;open;;;syn-ack;;3\r\n127.0.0.1;tcp;445;microsoft-ds;open;;;syn-ack;;3\r\n127.0.0.1;tcp;631;ipp;open;;;syn-ack;;3\r\n127.0.0.1;tcp;2049;nfs;open;;;syn-ack;;3\r\n127.0.0.1;tcp;3306;mysql;open;;;syn-ack;;3\r\n127.0.0.1;tcp;5222;unknown;open;;;syn-ack;;3\r\n127.0.0.1;tcp;5269;unknown;open;;;syn-ack;;3\r\n'
>>> r=nm.scan(hosts='127.0.0.1', ports='139', arguments="-sC -T4")
>>> nm['127.0.0.1']['hostscript'][0].keys()
dict_keys(['output', 'id'])
Modules | ||||||
|
Classes | ||||||||||||||||||||||||||||||||||
|
Data | ||
__last_modification__ = '2013.07.27' |
Author | ||
Alexandre Norman (norman@xael.org) |