Esempio n. 1
0
def test_radiotap_packet_filter_and_parse_parsing_wrong_encapsulation(
    marine_or_marine_pool: Union[Marine, MarinePool]
):
    src_ip = "78.78.78.255"
    dst_ip = "10.0.0.255"
    expected_output = {
        "radiotap.present.tsft": None,
        "radiotap.present.channel": None,
        "radiotap.present.rate": None,
        "wlan.fc.type_subtype": None,
        "llc.type": None,
        "ip.src": None,
        "ip.dst": None,
    }

    packet = (
        radiotap.Radiotap(present_flags=radiotap.CHANNEL_MASK + radiotap.RATE_MASK)
        + ieee80211.IEEE80211(framectl=0x8801)
        + ieee80211.IEEE80211.Dataframe(sec_param=None)
        + llc.LLC(
            dsap=170, ssap=170, ctrl=3, snap=int.to_bytes(llc.LLC_TYPE_IP, 5, "big")
        )
        + ip.IP(src_s=src_ip, dst_s=dst_ip)
    )

    general_filter_and_parse_test(
        marine_or_marine_pool=marine_or_marine_pool,
        packet=packet.bin(),
        packet_encapsulation=encap_consts.ENCAP_ETHERNET,
        bpf_filter=None,
        display_filter=None,
        field_templates=None,
        expected_passed=True,
        expected_output=expected_output,
    )
Esempio n. 2
0
def test_radiotap_packet_filter_and_parse_with_auto_encap_in_field_template(
    marine_or_marine_pool: Union[Marine, MarinePool]
):
    src_ip = "78.78.78.255"
    dst_ip = "10.0.0.255"
    bpf_filter = "ip"
    display_filter = "ip"
    field_templates = {"macro.dummy": ["radiotap.present.rate"]}
    expected_output = {
        "macro.dummy": 1,
        "ip.src": src_ip,
        "ip.dst": dst_ip,
    }

    packet = (
        radiotap.Radiotap(present_flags=radiotap.CHANNEL_MASK + radiotap.RATE_MASK)
        + ieee80211.IEEE80211(framectl=0x8801)
        + ieee80211.IEEE80211.Dataframe(sec_param=None)
        + llc.LLC(
            dsap=170, ssap=170, ctrl=3, snap=int.to_bytes(llc.LLC_TYPE_IP, 5, "big")
        )
        + ip.IP(src_s=src_ip, dst_s=dst_ip)
    )

    general_filter_and_parse_test(
        marine_or_marine_pool=marine_or_marine_pool,
        packet=packet.bin(),
        packet_encapsulation=None,
        bpf_filter=bpf_filter,
        display_filter=display_filter,
        field_templates=field_templates,
        expected_passed=True,
        expected_output=expected_output,
    )
Esempio n. 3
0
def test_radiotap_packet_filter_and_parse_failing_wrong_encapsulation(
    marine_or_marine_pool: Union[Marine, MarinePool]
):
    src_ip = "78.78.78.255"
    dst_ip = "10.0.0.255"
    bpf_filter = "ip"
    display_filter = "ip"

    packet = (
        radiotap.Radiotap(present_flags=radiotap.CHANNEL_MASK + radiotap.RATE_MASK)
        + ieee80211.IEEE80211(framectl=0x8801)
        + ieee80211.IEEE80211.Dataframe(sec_param=None)
        + llc.LLC(
            dsap=170, ssap=170, ctrl=3, snap=int.to_bytes(llc.LLC_TYPE_IP, 5, "big")
        )
        + ip.IP(src_s=src_ip, dst_s=dst_ip)
    )

    general_filter_and_parse_test(
        marine_or_marine_pool=marine_or_marine_pool,
        packet=packet.bin(),
        packet_encapsulation=encap_consts.ENCAP_ETHERNET,
        bpf_filter=bpf_filter,
        display_filter=display_filter,
        field_templates=None,
        expected_passed=False,
        expected_output={},
    )