| 9 | nmap (version 0.2.4) | index /home/xael/ESPACE_KM/python/python-nmap/nmap/nmap.py |
nmap.py - version and date, see below
13 |
14 | Author : Alexandre Norman - norman at xael.org
15 | Contributors: Steve 'Ashcrow' Milner - steve at gnulinux.net
16 | Brian Bustin - brian at bustin.us
17 | Licence : GPL v3 or any later version
18 |
19 |
20 | This program is free software: you can redistribute it and/or modify
21 | it under the terms of the GNU General Public License as published by
22 | the Free Software Foundation, either version 3 of the License, or
23 | any later version.
24 |
25 | This program is distributed in the hope that it will be useful,
26 | but WITHOUT ANY WARRANTY; without even the implied warranty of
27 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 | GNU General Public License for more details.
29 |
30 | You should have received a copy of the GNU General Public License
31 | along with this program. If not, see <http://www.gnu.org/licenses/>.
32 |
33 |
34 | Test strings :
35 | ^^^^^^^^^^^^
36 | >>> import nmap
37 | >>> if __get_last_online_version() != __version__:
38 | ... raise ValueError('Current version is {0} - Last published version is {1}'.format(__version__, __get_last_online_version()))
39 | >>> nm = nmap.PortScanner()
40 | >>> try:
41 | ... nm.scan(arguments='-wrongargs')
42 | ... except nmap.PortScannerError:
43 | ... pass
44 | >>> r=nm.scan('127.0.0.1', '22-443')
45 | >>> nm.command_line()
46 | 'nmap -oX - -p 22-443 -sV 127.0.0.1'
47 | >>> nm.scaninfo()
48 | {'tcp': {'services': '22-443', 'method': 'connect'}}
49 | >>> nm.all_hosts()
50 | ['127.0.0.1']
51 | >>> nm['127.0.0.1'].hostname()
52 | 'localhost.localdomain'
53 | >>> nm['127.0.0.1'].state()
54 | 'up'
55 | >>> nm['127.0.0.1'].all_protocols()
56 | ['tcp']
57 | >>> nm['127.0.0.1']['tcp'].keys()
58 | dict_keys([80, 25, 443, 22, 111])
59 | >>> nm['127.0.0.1'].has_tcp(22)
60 | True
61 | >>> nm['127.0.0.1'].has_tcp(23)
62 | False
63 | >>> nm['127.0.0.1']['tcp'][22]
64 | {'state': 'open', 'reason': 'syn-ack', 'name': 'ssh'}
65 | >>> nm['127.0.0.1'].tcp(22)
66 | {'state': 'open', 'reason': 'syn-ack', 'name': 'ssh'}
67 | >>> nm['127.0.0.1']['tcp'][22]['state']
68 | 'open'
69 | >>> nm.scanstats()['uphosts']
70 | '1'
71 | >>> nm.scanstats()['downhosts']
72 | '0'
73 | >>> nm.scanstats()['totalhosts']
74 | '1'
75 | >>> 'timestr' in nm.scanstats().keys()
76 | True
77 | >>> 'elapsed' in nm.scanstats().keys()
78 | True
79 | >>> nm.listscan('192.168.1.0/30')
80 | ['192.168.1.0', '192.168.1.1', '192.168.1.2', '192.168.1.3']
81 | >>> nm.listscan('localhost/30')
82 | ['127.0.0.0', '127.0.0.1', '127.0.0.2', '127.0.0.3']
83 | >>> r=nm.scan('127.0.0.1', arguments='-O')
84 | >>> nm['127.0.0.1']['osclass']
85 | [{'vendor': u'Linux', 'osfamily': u'Linux', 'type': u'general purpose', 'osgen': u'2.6.X', 'accuracy': u'98'}, {'vendor': u'Netgear', 'osfamily': u'embedded', 'type': u'WAP', 'osgen': '', 'accuracy': ''}, {'vendor': u'Gemtek', 'osfamily': u'embedded', 'type': u'WAP', 'osgen': '', 'accuracy': ''}, {'vendor': u'Siemens', 'osfamily': u'embedded', 'type': u'WAP', 'osgen': '', 'accuracy': ''}, {'vendor': u'Linux', 'osfamily': u'Linux', 'type': u'general purpose', 'osgen': u'2.4.X', 'accuracy': u'90'}, {'vendor': u'Linksys', 'osfamily': u'embedded', 'type': u'WAP', 'osgen': '', 'accuracy': ''}, {'vendor': u'Linux', 'osfamily': u'Linux', 'type': u'WAP', 'osgen': u'2.4.X', 'accuracy': u'90'}, {'vendor': u'Nokia', 'osfamily': u'Linux', 'type': u'general purpose', 'osgen': u'2.6.X', 'accuracy': u'89'}]
86 | >>> nm['127.0.0.1']['fingerprint']
87 | 'OS:SCAN(V=5.50%D=11/9%OT=22%CT=1%CU=37937%PV=N%DS=0%DC=L%G=Y%TM=4EBAE79D%P=\nOS:i686-pc-linux-gnu)SEQ(SP=103%GCD=1%ISR=10D%TI=Z%CI=Z%II=I%TS=8)OPS(O1=M4\nOS:00CST11NW6%O2=M400CST11NW6%O3=M400CNNT11NW6%O4=M400CST11NW6%O5=M400CST11\nOS:NW6%O6=M400CST11)WIN(W1=8000%W2=8000%W3=8000%W4=8000%W5=8000%W6=8000)ECN\nOS:(R=Y%DF=Y%T=40%W=8018%O=M400CNNSNW6%CC=Y%Q=)T1(R=Y%DF=Y%T=40%S=O%A=S+%F=\nOS:AS%RD=0%Q=)T2(R=N)T3(R=Y%DF=Y%T=40%W=8000%S=O%A=S+%F=AS%O=M400CST11NW6%R\nOS:D=0%Q=)T4(R=Y%DF=Y%T=40%W=0%S=A%A=Z%F=R%O=%RD=0%Q=)T5(R=Y%DF=Y%T=40%W=0%\nOS:S=Z%A=S+%F=AR%O=%RD=0%Q=)T6(R=Y%DF=Y%T=40%W=0%S=A%A=Z%F=R%O=%RD=0%Q=)T7(\nOS:R=Y%DF=Y%T=40%W=0%S=Z%A=S+%F=AR%O=%RD=0%Q=)U1(R=Y%DF=N%T=40%IPL=164%UN=0\nOS:%RIPL=G%RID=G%RIPCK=G%RUCK=G%RUD=G)IE(R=Y%DFI=N%T=40%CD=S)\n'
89 |
| 92 | Modules | ||||||
| 95 | |
| |||||
105 |
| 108 | Classes | ||||||||||||||||||||||||||||||||||
| 111 | |
133 |
193 |
233 |
294 |
| |||||||||||||||||||||||||||||||||
416 |
| 419 | Data | ||
| 422 | | __last_modification__ = '2011.11.09' | |
423 |
| 426 | Author | ||
| 429 | | Alexandre Norman (norman@xael.org) | |