def reply(pkt):
    """
    Reply to the packet which the sniffer capture.
    """
    if pkt[ICMP].type == 8:
        ip = IP()
        ip.dst = pkt[IP].src
        ip.src = pkt[IP].dst

        icmp = ICMP()
        icmp.id = pkt[ICMP].id
        icmp.seq = pkt[ICMP].seq
        icmp.type = 0

        raw = Raw()
        raw.load = pkt[Raw].load

        send(ip / icmp / raw)
def print_pkt(pkt):
    if (pkt[ICMP].type == 8):
        eth = Ether()
        eth.dst = pkt[Ether].src
        eth.src = pkt[Ether].dst

        ip = IP()
        ip.dst = pkt[IP].src
        ip.src = pkt[IP].dst
        ip.ihl = pkt[IP].ihl

        icmp = ICMP()
        icmp.id = pkt[ICMP].id
        icmp.seq = pkt[ICMP].seq
        icmp.type = 0

        raw = Raw()
        raw.load = pkt[Raw].load

        send(eth / ip / icmp / raw)
Beispiel #3
0
def cmd_ping(ip_dst, ip_src, seq, icmp_id):
    conf.verb = False

    layer3 = IP()
    layer3.src = ip_src
    layer3.dst = ip_dst
    layer3.tos = 0
    layer3.id = 1
    layer3.flags = 0
    layer3.frag = 0
    layer3.ttl = 128
    layer3.proto = 1  # icmp

    layer4 = ICMP()
    layer4.type = 8  # echo-request
    layer4.code = 0
    layer4.id = icmp_id
    layer4.seq = seq
    pkt = layer3 / layer4 / b"abcdefghijklmn opqrstuvwabcdefg hi"
    send(pkt)
    print("Ping Sent")
Beispiel #4
0
def generate_icmp_wrapper(plumber_pkt):
    ip_layer = IP(src=plumber_pkt.src_ip, dst=plumber_pkt.ip)
    icmp_layer = ICMP(type="echo-reply")
    icmp_layer.id, icmp_layer.seq = plumber_pkt.id, plumber_pkt.seq
    plumber_pkt.message_target = "client"
    return ip_layer / icmp_layer / plumber_pkt