Exemplo n.º 1
0
# scapy.contrib.description = SEND
# scapy.contrib.status = loads

import socket

from scapy.packet import *
from scapy.fields import *
from scapy.layers.inet6 import icmp6typescls, _ICMPv6NDGuessPayload, Net6

send_icmp6typescls = {
    11: "ICMPv6NDOptCGA",
    12: "ICMPv6NDOptRsaSig",
    13: "ICMPv6NDOptTmstp",
    14: "ICMPv6NDOptNonce"
}
icmp6typescls.update(send_icmp6typescls)


class HashField(Field):
    def __init__(self, name, default):
        Field.__init__(self, name, default, "16s")

    def h2i(self, pkt, x):
        if type(x) is str:
            try:
                x = in6_ptop(x)
            except socket.error:
                x = Net6(x)
        elif type(x) is list:
            x = map(Net6, x)
        return x
Exemplo n.º 2
0
## This program is published under a GPLv2 license

# Partial support of RFC3971
# scapy.contrib.description = SEND
# scapy.contrib.status = loads

from scapy.packet import *
from scapy.fields import *
from scapy.layers.inet6 import icmp6typescls, _ICMPv6NDGuessPayload

send_icmp6typescls = { 11: "ICMPv6NDOptCGA",
                       12: "ICMPv6NDOptRsaSig",
                       13: "ICMPv6NDOptTmstp",
                       14: "ICMPv6NDOptNonce"
                     }
icmp6typescls.update(send_icmp6typescls)

class HashField(Field):
    def __init__(self, name, default):
        Field.__init__(self, name, default, "16s")
    def h2i(self, pkt, x):
        if type(x) is str:
            try:
                x = in6_ptop(x)
            except socket.error:
                x = Net6(x)
        elif type(x) is list:
            x = map(Net6, x)
        return x
    def i2m(self, pkt, x):
        return inet_pton(socket.AF_INET6, x)