python脚本基于UDP主机信息收集
1.源码如下:
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import nmap
import optparse
def NmapScan(targetIP):
# 实例化PortScanner对象
nm = nmap.PortScanner()
try:
# hosts为目标IP地址,argusments为Nmap的扫描参数
# -PU:向目标主机发现UDP报文进行探测
result = nm.scan(hosts=targetIP, arguments='-PU')
# 对结果进行切片,提取主机状态信息
state = result['scan'][targetIP]['status']['state']
print("[{}] is [{}]".format(targetIP, state))
except Exception as e:
pass
if __name__ == '__main__':
parser = optparse.Opt
共有 0 条评论