當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。