Python-通过调用Nmap来进行端口扫描
首先要安装python-nmap库,还要安装配置好nmap
实验机器IP:192.168.220.139
端口开放情况
代码
# -*- coding:utf-8 -*- __author__ = "MuT6 Sch01aR" import nmap def NmapScan(ip,port): Nmapscan = nmap.PortScanner(nmap_search_path=('nmap',r'C:\Program Files (x86)\Nmap\nmap.exe')) Nmapscan.scan(ip,str(port)) state = Nmapscan[ip]['tcp'][port]['state'] print('[*] '+ip+' tcp/'+str(port)+' '+state) if __name__ == '__main__': NmapScan('192.168.220.139',445) NmapScan('192.168.220.139',3389)
nmap.PortScanner()中的nmap_search_path参数后要跟上nmap的绝对路径,才能成功执行
运行结果
filtered为端口被防火墙 IDS/IPS屏蔽,无法确定其状态
相关推荐
清水寺小僧 2020-05-15
furongwei 2019-12-23
zhongzhiwei 2012-09-25
wh0 2020-07-27
huangzonggui 2020-06-08
LychieFan 2020-04-14
colin00 2020-04-14
风语者 2020-01-17
jszy 2019-12-29
sunln00 2019-12-20
sunln00 2019-12-18
YFCEMBEDD 2019-11-09
zhqagp 2015-07-11
kyssfanhui 2019-11-08
付春杰Blog 2019-10-30
过儿古墓 2011-01-05
TuxedoLinux 2009-04-29
kvikon 2019-08-15