博客主页 🐟
Python------nmap端口扫描

Author:

©

Wordage:

共计 942 字

needs:

约 1 分钟

Popular:

213 ℃

Created:

目 录

下面代码仅供学习参考,禁止用于其他非法途径

import optparse
import nmap
def scan(host,port,values):
 n=nmap.PortScanner()
 n.scan(host,port,values)
 for host in n.all_hosts():
    print('***************')
    print('Host: %s (%s)'%(host, n[host].hostname()))
    print('State: %s'%n[host].state())
    for proto in n[host].all_protocols():
        print('--------------')
        print('Protocols: %s'%proto)
        port=n[host][proto].keys()
        port.sort()
        for po in port:
            print('port: %s\tstate: %s'%(po,n[host][proto][po]['state']))
def op():
    p=optparse.OptionParser()
    p.add_option('-H',dest='HOST',type='string')
    p.add_option('-P',dest='PORTS',type='string')
    p.add_option('-V',dest='VALUES',type='string')
    return(p)
p=op()
(options, args)=p.parse_args()
host=options.HOST
ports=options.PORTS
values=options.VALUES
scan(host,ports,values)
文章二维码
Python------nmap端口扫描
共计 0 条评论,点此发表评论
博客主页 哀.net OωO
萌ICP备20238808号 本站已运行 1 年 206 天 21 小时 37 分 Copyright © 2023 ~ 2024. 哀.net All rights reserved.
打赏图
打赏博主
欢迎
搜 索
足 迹
分 类
  • 默认分类
  • 语言分类
  • 其他分类