设为首页 加入收藏

TOP

Python编写类似nmap的扫描工具(七)
2017-10-10 21:05:51 】 浏览:2473
Tags:Python 编写 类似 nmap 扫描工具
bsp;   if not args.timeout and not args.retry:
            obj_ping = Discovery_Scan(args)
        elif args.timeout and not args.retry:
            obj_ping = Discovery_Scan(args,timeout=args.timeout)
        elif not args.timeout and args.retry:
            obj_ping = Discovery_Scan(args,retry=args.retry)
        else:
            obj_ping = Discovery_Scan(args,args.timeout,args.retry)
        ip_list = obj_ping.targets[0]
        if ip_list:
            #ARP扫描
            if args.ARP:
                for pdst in ip_list:
                    t = threading.Thread(target=obj_ping.arp_scan,args=(pdst,))
                    t.start()
                while threading.activeCount() != 1:    #避免线程还没有运行完就提前输出不全的结果
                    time.sleep(1)
            #ICMP扫描
            elif args.ICMP:
                for dst in ip_list:
                    t = threading.Thread(target=obj_ping.icmp_scan,args=(dst,))
                    t.start()
                while threading.activeCount() != 1:    #避免线程还没有运行完就提前输出不全的结果
                    time.sleep(1)
            #TCP扫描
            elif args.TCP:
                port_list = [80,443,21,22,23,25,53,135,139,137,445,1158,1433,1521,3306,3389,7001,8000,8080,9090]
                print '[+]请稍等,时间较长!'
                for dst in ip_list:
                    print '[!]扫描...',dst
                    for port in port_list:
                        t = threading.Thread(target=obj_ping.tcp_scan,args=(dst,port))
                        t.start()


                print '[+]正在处理扫描信息.'
                while threading.activeCount() != 1:    #避免线程还没有运行完就提前输出不全的结果
                    time.sleep(1)


                if not obj_ping.tcp_info:
                    print '\n'
                    print '=' * 20
                    print '[+]未发现在线主机.'
                else:
      &nb

首页 上一页 4 5 6 7 8 9 下一页 尾页 7/9/9
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Python3 基本数据类型 下一篇Python3基本语法简述

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目