Пример #1
0
def first_round(hosts, ports):
    """Function to realize a first nmap dicovery"""
    # structure to stock results from nmap
    results = {}
    # structure to stock tasks of nmap
    tasks = []

    # set of hosts by type
    ipv4_hosts = helper_parser.get_ipv4(hosts)
    ipv6_hosts = helper_parser.get_ipv6(hosts)
    hostname = helper_parser.get_hostname(hosts)
    ipv4_cidr = helper_parser.get_ipv4_cidr(hosts)
    ipv6_cidr = helper_parser.get_ipv6_cidr(hosts)
    # get valide ports
    ports = helper_parser.get_port(ports)

    if ipv6_cidr or ipv6_hosts:
        # put ipv6 and ipv6 cidr in a set
        s_hostsipv6 = helper_parser.merge_two_set(ipv6_hosts, ipv6_cidr)
        # convert dictionnary to list
        l_hostsipv6 = list(s_hostsipv6)
        # append task
        tasks.append((nmap.run, (IPV6_BASIC, l_hostsipv6, ports)))

    if ipv4_hosts or hostname or ipv4_cidr:
        # put ipv4, hostname and ipv4 cidr in a set
        s_hostsipv4 = helper_parser.merge_three_set(ipv4_hosts, hostname,
                                                    ipv4_cidr)
        # convert dictionnary to list
        l_hostsipv4 = list(s_hostsipv4)
        # create task
        tasks.append((nmap.run, (IPV4_BASIC, l_hostsipv4, ports)))

    # make a first basic scan for discovery open port
    results = multi_process.run(results, tasks)

    return second_round(results)
Пример #2
0
 def test_bad_port2(self):
     test = '65536'
     value = helper_parser.get_port(test)
     self.assertEqual(None, value)
Пример #3
0
 def test_bad_port1(self):
     test = 0
     value = helper_parser.get_port(test)
     self.assertEqual(None, value)
Пример #4
0
 def test_port3(self):
     test = '1,65535'
     value = helper_parser.get_port(test)
     self.assertEqual('1,65535', value)
Пример #5
0
 def test_bad_port4(self):
     test = '1,65535,'
     value = helper_parser.get_port(test)
     self.assertEqual(None, value)