1 #coding=utf-8
2
3 importnmap4 importoptparse5 importthreading6 importsys7 importre8 '''
9 需安装python_nmap包,支持2.x以及3.x10 python_nmap包提供了python调用nmap的一系列接口11
12 (一)重要类及方法:13 1.创建nmap扫描器14 class PortScanner()15 __init__(self, nmap_search_path=('nmap', '/usr/bin/nmap', '/usr/local/bin/nmap', '/sw/bin/nmap', '/opt/local/bin/nmap'))16 Initialize PortScanner module17
18 * detects nmap on the system and nmap version19 * may raise PortScannerError exception if nmap is not found in the path20
21 :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.22 :returns: nothing23 2.扫描器方法24 scan(self, hosts='127.0.0.1', ports=None, arguments='-sV', sudo=False)25 Scan given hosts26
27 May raise PortScannerError exception if