当前位置: 首页>>代码示例>>Python>>正文


Python process.NmapProcess方法代码示例

本文整理汇总了Python中libnmap.process.NmapProcess方法的典型用法代码示例。如果您正苦于以下问题:Python process.NmapProcess方法的具体用法?Python process.NmapProcess怎么用?Python process.NmapProcess使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在libnmap.process的用法示例。


在下文中一共展示了process.NmapProcess方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: nmap_scan

# 需要导入模块: from libnmap import process [as 别名]
# 或者: from libnmap.process import NmapProcess [as 别名]
def nmap_scan(hosts, output_dir):
    """
    if user chooses to start from an nmap scan, run the scan and then return an nmap_report object
    :param hosts:
    :param output_dir:
    :return:
    """
    print("[+] Kicking off nmap scan. I don't have  any feedback working, so just be patient")
    nm = NmapProcess(hosts, options="-sC -sV -Pn -p1-65535")
    rc = nm.run()
    nmap_report = NmapParser.parse(nm.stdout)
    nmap_xml = output_dir + "/" + hosts.replace("/","_") + "_nmap.xml"
    f = open(nmap_xml, 'a')
    f.write(nm.stdout)
    f.close()
    print("[+] Nmap scan saved to: {0}".format(nmap_xml))
    return nmap_report 
开发者ID:sethsec,项目名称:celerystalk,代码行数:19,代码来源:utils.py

示例2: do_scan

# 需要导入模块: from libnmap import process [as 别名]
# 或者: from libnmap.process import NmapProcess [as 别名]
def do_scan(targets, options, fqp=None):
    parsed = None
    nm = NmapProcess(targets, options, fqp=fqp)
    rc = nm.run()
    if rc != 0:
        print("nmap scan failed: {0}".format(nm.stderr))

    try:
        parsed = NmapParser.parse(nm.stdout)
    except NmapParserException as e:
        print("Exception raised while parsing scan: {0}".format(e.msg))

    return parsed


# print scan results from a nmap report 
开发者ID:imiyoo2010,项目名称:teye_scanner_for_book,代码行数:18,代码来源:check_fqp_nmap.py

示例3: do_scan

# 需要导入模块: from libnmap import process [as 别名]
# 或者: from libnmap.process import NmapProcess [as 别名]
def do_scan(host, options):
    # uncomment line below to manually input target IP
    #host = input("Enter Target Host Address: ")
    parsed = None
    nmproc = NmapProcess(host, options)
    rc = nmproc.run()
    if rc != 0:
        print("nmap scan failed: {0}".format(nmproc.stderr))
    print(type(nmproc.stdout))

    try:
        parsed = NmapParser.parse(nmproc.stdout)
    except NmapParserException as e:
        print("Exception raised while parsing scan: {0}".format(e.msg))

    return parsed 
开发者ID:tlkh,项目名称:prowler,代码行数:18,代码来源:nmap_0.7.0_process.py

示例4: scan_ranges

# 需要导入模块: from libnmap import process [as 别名]
# 或者: from libnmap.process import NmapProcess [as 别名]
def scan_ranges(ranges, dns=None):
    '''
    Performs a list scan on the provided ranges and returns an NmapReport object
    '''
    if dns is None: 
        dns = "-sL -R" 
    else:
        dns = "-sL -R --dns-server " + dns
    logger.info('DNS Value for scan_ranges: ' + str(dns))
    logger.info('Provided Ranges for scan_ranges: ' + str(ranges))
    print("Starting nmap scan against: " + ranges)
    nm = NmapProcess(ranges, options=dns)
    rc = nm.run()
    # use the nmap parser to return an object containing all the hosts
    parsed = NmapParser.parse(nm.stdout)
    logger.info('Returning {} hosts from scan_ranges'.format(len(parsed.hosts)))
    return parsed 
开发者ID:lixmk,项目名称:Concierge,代码行数:19,代码来源:hostname-discovery.py

示例5: nmap_follow_up_scan

# 需要导入模块: from libnmap import process [as 别名]
# 或者: from libnmap.process import NmapProcess [as 别名]
def nmap_follow_up_scan(hosts, port):
    """
    This needs to be reworked.  If nmap service scan can't determine the service, i run an nmap scan without service
    detection to get the default port.  I should just read the IANA ports file instead and grep for the port, or maybe
    even the nmap version of the IANA ports list.
    :param hosts:
    :param port:
    :return:
    """
    nm = NmapProcess(hosts, options="-Pn -p %d" % port)
    rc = nm.run()
    nmap_report = NmapParser.parse(nm.stdout)
    return nmap_report 
开发者ID:sethsec,项目名称:celerystalk,代码行数:15,代码来源:utils.py

示例6: do_scan

# 需要导入模块: from libnmap import process [as 别名]
# 或者: from libnmap.process import NmapProcess [as 别名]
def do_scan(self, targets, options):
        """
        start a new nmap scan on localhost with some specific options
        :param targets:
        :param options:
        :return:
        """
        logger.info('do scan %s %s' % (targets, options))
        parsed = None
        if isinstance(options, basestring):
            options = options.encode('utf-8')
        if isinstance(targets, basestring):
            targets = targets.encode('utf-8')
        nmproc = NmapProcess(targets, options)
        rc = nmproc.run()
        if rc != 0:
            logger.error("nmap scan failed: {0}".format(nmproc.stderr))
        # print(type(nmproc.stdout))

        try:
            parsed = NmapParser.parse(nmproc.stdout)
        except NmapParserException as e:
            logger.error("Exception raised while parsing scan: {0}".format(e.msg))

        self.done_data[targets] = parsed
        return parsed

    # print scan results from a nmap report 
开发者ID:restran,项目名称:hacker-scripts,代码行数:30,代码来源:nmap_scanner.py

示例7: do_task

# 需要导入模块: from libnmap import process [as 别名]
# 或者: from libnmap.process import NmapProcess [as 别名]
def do_task(self,task):
        """
        TODO: multiple ip address for same domain name
        """
        try:
            taskl=task.split('|')
            nmap_task=NmapProcess(taskl[0],taskl[1]+' '+' '.join(self._args.nmap_options))
            rc=nmap_task.run()
            if rc!=0:
                return '|'.join([taskl[0],'f',str(rc)+' '+nmap_task.stderr])
            return '|'.join([taskl[0],'s',nmap_task.stdout])
        # if there is no nmap on current host, quit quietly
        except EnvironmentError, e:
            raise SwarmUseException(str(e)) 
开发者ID:a7vinx,项目名称:swarm,代码行数:16,代码来源:nmap.py

示例8: do_scan

# 需要导入模块: from libnmap import process [as 别名]
# 或者: from libnmap.process import NmapProcess [as 别名]
def do_scan(targets, options):
    nm = NmapProcess(targets, options)
    rc = nm.run()
    if rc != 0:
        print("nmap scan failed: {0}".format(nm.stderr))

    try:
        parsed = NmapParser.parse(nm.stdout)
    except NmapParserException as e:
        print("Exception raised while parsing scan: {0}".format(e.msg))

    return parsed


# print scan results from a nmap report 
开发者ID:imiyoo2010,项目名称:teye_scanner_for_book,代码行数:17,代码来源:proc_nmap_like.py

示例9: make_nmproc_obj

# 需要导入模块: from libnmap import process [as 别名]
# 或者: from libnmap.process import NmapProcess [as 别名]
def make_nmproc_obj(targets, options):
  return NmapProcess(targets=targets, options=options) 
开发者ID:imiyoo2010,项目名称:teye_scanner_for_book,代码行数:4,代码来源:multi_nmap_process_background.py

示例10: make_nmproc_obj

# 需要导入模块: from libnmap import process [as 别名]
# 或者: from libnmap.process import NmapProcess [as 别名]
def make_nmproc_obj(targets, options):
    return NmapProcess(targets=targets, options=options) 
开发者ID:imiyoo2010,项目名称:teye_scanner_for_book,代码行数:4,代码来源:multi_nmap_process.py

示例11: nmap_scan

# 需要导入模块: from libnmap import process [as 别名]
# 或者: from libnmap.process import NmapProcess [as 别名]
def nmap_scan(hosts):
    '''
    Do Nmap scan
    '''
    nmap_args = '-sS -T4 --script smb-vuln-ms17-010,smb-vuln-ms08-067 -n --max-retries 5 -p 445 -oA smb-scan'
    nmap_proc = NmapProcess(targets=hosts, options=nmap_args, safe_mode=False)
    rc = nmap_proc.sudo_run_background()
    nmap_status_printer(nmap_proc)
    report = NmapParser.parse_fromfile(os.getcwd()+'/smb-scan.xml')

    return report 
开发者ID:DanMcInerney,项目名称:smb-autopwn,代码行数:13,代码来源:smb-autopwn.py

示例12: run

# 需要导入模块: from libnmap import process [as 别名]
# 或者: from libnmap.process import NmapProcess [as 别名]
def run(self):

        # Wait until all active devices have been populated during boot
        time.sleep(30)

        while 1:
            ip_list = ','.join(homenet.hosts.keys())

            log.debug('FG-INFO: Port scan started')

            nm = NmapProcess(targets=ip_list, options='-sU -sS --min-rate 5000 --max-retries 1 --max-rtt-timeout 100ms -p1-10000 ')
            nm.run()

            try:
                nmap_report = NmapParser.parse(nm.stdout)

                with lock:
                    for host in nmap_report.hosts:
                        if host.address in homenet.hosts.keys():
                            for serv in host.services:
                                if (serv.protocol == 'tcp') and (serv.state == 'open'):
                                    if serv.port not in homenet.hosts[host.address].tcp_ports:
                                        homenet.hosts[host.address].tcp_ports.append(serv.port)
                                if (serv.protocol == 'udp') and (serv.state == 'open'):
                                    if serv.port not in homenet.hosts[host.address].udp_ports:
                                        homenet.hosts[host.address].udp_ports.append(serv.port)
            except Exception as e:
                log.debug('FG-WARN: ' + str(e.__doc__) + " - " + str(e))

            log.debug('FG-INFO: Port scan finished')

            time.sleep(86400) 
开发者ID:A3sal0n,项目名称:FalconGate,代码行数:34,代码来源:recon.py

示例13: nmap_scan

# 需要导入模块: from libnmap import process [as 别名]
# 或者: from libnmap.process import NmapProcess [as 别名]
def nmap_scan(hosts, outfile, add_args):
    '''
    Do Nmap scan
    '''
    nmap_args = '-sS -O -T4 -sV -n {} --max-retries 5 -oA {}'.format(add_args, outfile)
    print_info('Running: nmap {}'.format(nmap_args))
    nmap_proc = NmapProcess(targets=hosts, options=nmap_args, safe_mode=False)
    rc = nmap_proc.sudo_run_background()
    nmap_status_printer(nmap_proc)
    report = NmapParser.parse_fromfile(os.getcwd()+'/{}.xml'.format(outfile))

    return report 
开发者ID:DanMcInerney,项目名称:msf-autopwn,代码行数:14,代码来源:msf-autopwn.py

示例14: run

# 需要导入模块: from libnmap import process [as 别名]
# 或者: from libnmap.process import NmapProcess [as 别名]
def run(self):
        nm = NmapProcess(targets=str(self.artifact['name']), options='-sT -sV -Pn -T5 -p21,22,23,25,80,6667,1337')
        nm.run()

        if nm.is_successful():
            report = NmapParser.parse_fromstring(nm.stdout)
            for host in report.hosts:
                if host.is_up():
                    results = {
                        'ports': host.get_open_ports(),
                        'services': []
                    }

                    for service in host.services:
                        if service.state == 'open':
                            serv = {
                                'banner': service.banner,
                                'protocol': service.protocol,
                                'service': service.service,
                                'port': service.port}
                            results['services'].append(serv)

                    if self.artifact['subtype'] == 'ipv4':
                        results['hostnames'] = host.hostnames
                        for h in host.hostnames:
                            self.artifact['children'].append({
                                'name': h,
                                'type': 'host',
                                'subtype': 'fqdn',
                                'source': 'Nmap'
                            })

                    elif self.artifact['subtype'] == 'fqdn':
                        results['ipv4'] = host.address
                        self.artifact['children'].append({
                            'name': host.address,
                            'type': 'host',
                            'subtype': 'ipv4',
                            'source': 'Nmap'
                        })

                    self.artifact['data']['nmap'] = results

        else:
            warning('Nmap scanner failed - no results') 
开发者ID:InQuest,项目名称:omnibus,代码行数:47,代码来源:nmap.py


注:本文中的libnmap.process.NmapProcess方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。