示例#1
0
def test_icmp_packet_filter_and_parse(marine_or_marine_pool: Union[Marine, MarinePool]):
    src_mac = "00:00:00:12:34:ff"
    dst_mac = "00:00:00:ff:00:1e"
    src_ip = "21.53.78.255"
    dst_ip = "10.0.0.255"
    icmp_echo_type = 8
    bpf_filter = "ip"
    display_filter = "icmp"
    expected_output = {
        "eth.src": src_mac,
        "eth.dst": dst_mac,
        "ip.src": src_ip,
        "ip.dst": dst_ip,
        "icmp.type": icmp_echo_type,
    }

    packet = (
        ethernet.Ethernet(src_s=src_mac, dst_s=dst_mac)
        + ip.IP(src_s=src_ip, dst_s=dst_ip, p=ip.IP_PROTO_ICMP)
        + icmp.ICMP(type=icmp_echo_type)
        + icmp.ICMP.Echo()
    )

    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=True,
        expected_output=expected_output,
    )
示例#2
0
def icmp_cb(pargs):
    """ICMP DoS"""
    pkt_icmpreq = ethernet.Ethernet(dst_s=pargs.mac_dst, src_s=pargs.mac_src) +\
     ip.IP(src_s=pargs.ip_src, dst_s=pargs.ip_dst, p=ip.IP_PROTO_ICMP) +\
     icmp.ICMP(type=8) +\
     icmp.ICMP.Echo(id=1, ts=123456789, body_bytes=b"A" * 1460)

    psock = psocket.SocketHndl(iface_name=pargs.iface_name)

    for cnt in range(pargs.count):
        psock.send(pkt_icmpreq.bin())

    psock.close()
示例#3
0
from pypacker import psocket
from pypacker.layer12 import ethernet
from pypacker.layer3 import ip, icmp

# send ICMP request
psock = psocket.SocketHndl(iface_name="wlan0")
icmpreq = ethernet.Ethernet(src_s="20:16:d8:ef:1f:49", dst_s="24:65:11:85:e9:00", type=ethernet.ETH_TYPE_IP) +\
 ip.IP(p=ip.IP_PROTO_ICMP, src_s="192.168.178.27", dst_s="192.168.178.24") +\
 icmp.ICMP(type=8) +\
 icmp.ICMP.Echo(id=1, ts=123456789, body_bytes=b"12345678901234567890")
psock.send(icmpreq.bin())