How to use the networkml.parsers.pcap.pcap_utils.is_private function in networkml

To help you get started, we’ve selected a few networkml examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github CyberReboot / NetworkML / tests / test_utils_pcap_utils.py View on Github external
def test_is_private():
    private = is_private('10.10.10.10')
    assert private == True
    private = is_private('1.2.3.4')
    assert private == False
    private = is_private('192.168.1.1')
    assert private == True
    private = is_private('192.169.1.1')
    assert private == False
    private = is_private('172.16.4.4')
    assert private == True
    private = is_private('172.15.1.3')
    assert private == False
    private = is_private('172.32.3.1')
    assert private == False
    private = is_private('2014::1')
    assert private == False
    private = is_private('fe80::1')
    assert private == True
    private = is_private('fd13::13')
    assert private == True
    private = is_private('asdf')
github CyberReboot / NetworkML / tests / test_utils_pcap_utils.py View on Github external
def test_is_private():
    private = is_private('10.10.10.10')
    assert private == True
    private = is_private('1.2.3.4')
    assert private == False
    private = is_private('192.168.1.1')
    assert private == True
    private = is_private('192.169.1.1')
    assert private == False
    private = is_private('172.16.4.4')
    assert private == True
    private = is_private('172.15.1.3')
    assert private == False
    private = is_private('172.32.3.1')
    assert private == False
    private = is_private('2014::1')
    assert private == False
    private = is_private('fe80::1')
    assert private == True
    private = is_private('fd13::13')
    assert private == True
    private = is_private('asdf')
    assert private == False
github CyberReboot / NetworkML / tests / test_utils_pcap_utils.py View on Github external
def test_is_private():
    private = is_private('10.10.10.10')
    assert private == True
    private = is_private('1.2.3.4')
    assert private == False
    private = is_private('192.168.1.1')
    assert private == True
    private = is_private('192.169.1.1')
    assert private == False
    private = is_private('172.16.4.4')
    assert private == True
    private = is_private('172.15.1.3')
    assert private == False
    private = is_private('172.32.3.1')
    assert private == False
    private = is_private('2014::1')
    assert private == False
    private = is_private('fe80::1')
    assert private == True
    private = is_private('fd13::13')
    assert private == True
    private = is_private('asdf')
    assert private == False
github CyberReboot / NetworkML / tests / test_utils_pcap_utils.py View on Github external
def test_is_private():
    private = is_private('10.10.10.10')
    assert private == True
    private = is_private('1.2.3.4')
    assert private == False
    private = is_private('192.168.1.1')
    assert private == True
    private = is_private('192.169.1.1')
    assert private == False
    private = is_private('172.16.4.4')
    assert private == True
    private = is_private('172.15.1.3')
    assert private == False
    private = is_private('172.32.3.1')
    assert private == False
    private = is_private('2014::1')
    assert private == False
    private = is_private('fe80::1')
    assert private == True
    private = is_private('fd13::13')
    assert private == True
    private = is_private('asdf')
    assert private == False
github CyberReboot / NetworkML / tests / test_utils_pcap_utils.py View on Github external
def test_is_private():
    private = is_private('10.10.10.10')
    assert private == True
    private = is_private('1.2.3.4')
    assert private == False
    private = is_private('192.168.1.1')
    assert private == True
    private = is_private('192.169.1.1')
    assert private == False
    private = is_private('172.16.4.4')
    assert private == True
    private = is_private('172.15.1.3')
    assert private == False
    private = is_private('172.32.3.1')
    assert private == False
    private = is_private('2014::1')
    assert private == False
    private = is_private('fe80::1')
    assert private == True
    private = is_private('fd13::13')
    assert private == True
    private = is_private('asdf')
    assert private == False
github CyberReboot / NetworkML / tests / test_utils_pcap_utils.py View on Github external
assert private == True
    private = is_private('1.2.3.4')
    assert private == False
    private = is_private('192.168.1.1')
    assert private == True
    private = is_private('192.169.1.1')
    assert private == False
    private = is_private('172.16.4.4')
    assert private == True
    private = is_private('172.15.1.3')
    assert private == False
    private = is_private('172.32.3.1')
    assert private == False
    private = is_private('2014::1')
    assert private == False
    private = is_private('fe80::1')
    assert private == True
    private = is_private('fd13::13')
    assert private == True
    private = is_private('asdf')
    assert private == False
github CyberReboot / NetworkML / tests / test_utils_pcap_utils.py View on Github external
def test_is_private():
    private = is_private('10.10.10.10')
    assert private == True
    private = is_private('1.2.3.4')
    assert private == False
    private = is_private('192.168.1.1')
    assert private == True
    private = is_private('192.169.1.1')
    assert private == False
    private = is_private('172.16.4.4')
    assert private == True
    private = is_private('172.15.1.3')
    assert private == False
    private = is_private('172.32.3.1')
    assert private == False
    private = is_private('2014::1')
    assert private == False
    private = is_private('fe80::1')
    assert private == True
    private = is_private('fd13::13')
    assert private == True
    private = is_private('asdf')
    assert private == False
github CyberReboot / NetworkML / tests / test_utils_pcap_utils.py View on Github external
def test_is_private():
    private = is_private('10.10.10.10')
    assert private == True
    private = is_private('1.2.3.4')
    assert private == False
    private = is_private('192.168.1.1')
    assert private == True
    private = is_private('192.169.1.1')
    assert private == False
    private = is_private('172.16.4.4')
    assert private == True
    private = is_private('172.15.1.3')
    assert private == False
    private = is_private('172.32.3.1')
    assert private == False
    private = is_private('2014::1')
    assert private == False
    private = is_private('fe80::1')
    assert private == True
    private = is_private('fd13::13')
github CyberReboot / NetworkML / networkml / parsers / pcap / featurizer.py View on Github external
num_sessions_init += 1
            num_external_init += is_external(address_1, address_2)
            num_tcp_sess_init += is_protocol(session, '06')
            num_udp_sess_init += is_protocol(session, '11')
            num_icmp_sess_init += is_protocol(session, '01')

            if int(port_1) < max_port:
                num_sport_init[int(port_1)] += 1

            if int(port_2) < max_port:
                num_dport_init[int(port_2)] += 1

        # If the destination is the capture source
        if (destination_mac == capture_source
                or address_2 == capture_source):
            if is_private(address_1):
                other_ips[address_1] += 1

            num_sessions_rec += 1
            num_external_rec += is_external(address_2, address_1)
            num_tcp_sess_rec += is_protocol(session, '06')
            num_udp_sess_rec += is_protocol(session, '11')
            num_icmp_sess_rec += is_protocol(session, '01')

            if int(port_1) < max_port:
                num_sport_rec[int(port_1)] += 1
            if int(port_2) < max_port:
                num_dport_rec[int(port_2)] += 1

    num_port_sess = np.concatenate(
        (
            num_sport_init,
github CyberReboot / NetworkML / networkml / parsers / pcap / featurizer.py View on Github external
# Iterate over all sessions and aggregate the info
    other_ips = defaultdict(int)
    for key, session in session_dict.items():
        address_1, port_1 = get_ip_port(key[0])
        address_2, port_2 = get_ip_port(key[1])

        # Get the first packet and grab the macs from it
        first_packet = session[0][1]
        source_mac, destination_mac = extract_macs(first_packet)

        # If the source is the cpature source
        if (source_mac == capture_source
                or address_1 == capture_source):

            if is_private(address_2):
                other_ips[address_2] += 1

            num_sessions_init += 1
            num_external_init += is_external(address_1, address_2)
            num_tcp_sess_init += is_protocol(session, '06')
            num_udp_sess_init += is_protocol(session, '11')
            num_icmp_sess_init += is_protocol(session, '01')

            if int(port_1) < max_port:
                num_sport_init[int(port_1)] += 1

            if int(port_2) < max_port:
                num_dport_init[int(port_2)] += 1

        # If the destination is the capture source
        if (destination_mac == capture_source