-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnmap.html
583 lines (480 loc) · 40.1 KB
/
nmap.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
<!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.4)</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>
* Ed Jones<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><dd>
<dl>
<dt><font face="helvetica, arial"><a href="nmap.html#PortScannerTimeout">PortScannerTimeout</a>
</font></dt></dl>
</dd>
</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, timeout=0)</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>
:param timeout: int, if > zero, will terminate scan after seconds, otherwise will wait indefintely<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, timeout=0)</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<br>
:param timeout: int, if > zero, will terminate scan after seconds, otherwise will wait indefintely</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="PortScannerTimeout">class <strong>PortScannerTimeout</strong></a>(<a href="nmap.html#PortScannerError">PortScannerError</a>)</font></td></tr>
<tr><td bgcolor="#ffc8d8"><tt> </tt></td><td> </td>
<td width="100%"><dl><dt>Method resolution order:</dt>
<dd><a href="nmap.html#PortScannerTimeout">PortScannerTimeout</a></dd>
<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 inherited from <a href="nmap.html#PortScannerError">PortScannerError</a>:<br>
<dl><dt><a name="PortScannerTimeout-__init__"><strong>__init__</strong></a>(self, value)</dt></dl>
<dl><dt><a name="PortScannerTimeout-__repr__"><strong>__repr__</strong></a>(self)</dt></dl>
<dl><dt><a name="PortScannerTimeout-__str__"><strong>__str__</strong></a>(self)</dt></dl>
<hr>
Data descriptors inherited from <a href="nmap.html#PortScannerError">PortScannerError</a>:<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="PortScannerTimeout-__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="PortScannerTimeout-__delattr__"><strong>__delattr__</strong></a>(self, name, /)</dt><dd><tt>Implement delattr(self, name).</tt></dd></dl>
<dl><dt><a name="PortScannerTimeout-__getattribute__"><strong>__getattribute__</strong></a>(self, name, /)</dt><dd><tt>Return getattr(self, name).</tt></dd></dl>
<dl><dt><a name="PortScannerTimeout-__reduce__"><strong>__reduce__</strong></a>(...)</dt></dl>
<dl><dt><a name="PortScannerTimeout-__setattr__"><strong>__setattr__</strong></a>(self, name, value, /)</dt><dd><tt>Implement setattr(self, name, value).</tt></dd></dl>
<dl><dt><a name="PortScannerTimeout-__setstate__"><strong>__setstate__</strong></a>(...)</dt></dl>
<dl><dt><a name="PortScannerTimeout-with_traceback"><strong>with_traceback</strong></a>(...)</dt><dd><tt><a href="builtins.html#Exception">Exception</a>.<a href="#PortScannerTimeout-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="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, timeout=0)</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<br>
:param timeout: int, if > zero, will terminate scan after seconds, otherwise will wait indefintely</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, timeout)</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> = '2021.02.28'</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>