Exemplo n.º 1
0
class Ether(Packet):
    name = "Ethernet"
    fields_desc = [
        DestMACField("dst"),
        SourceMACField("src"),
        XShortEnumField("type", 0x9000, ETHER_TYPES)
    ]

    def hashret(self):
        return struct.pack("H", self.type) + self.payload.hashret()

    def answers(self, other):
        if isinstance(other, Ether):
            if self.type == other.type:
                return self.payload.answers(other.payload)
        return 0

    def mysummary(self):
        return self.sprintf("%src% > %dst% (%type%)")

    @classmethod
    def dispatch_hook(cls, _pkt=None, *args, **kargs):
        if _pkt and len(_pkt) >= 14:
            if struct.unpack("!H", _pkt[12:14])[0] <= 1500:
                return Dot3
        return cls

    def guess_payload_class(self, payload):
        if self.type == 2054 and len(payload) > 4:
            if payload[2:4] == "\x99\x99":
                return YOARP
            elif payload[2:4] == "\x08\x00":
                return ARP
        return Packet.guess_payload_class(self, payload)
Exemplo n.º 2
0
class NBNSNodeStatusResponse(Packet):
    name = "NBNS Node Status Response"
    fields_desc = [
        NetBIOSNameField("RR_NAME", "windows"),
        ShortEnumField("SUFFIX", 0x4141, _NETBIOS_SUFFIXES),
        ByteField("NULL", 0),
        ShortEnumField("RR_TYPE", 0x21, _NETBIOS_QRTYPES),
        ShortEnumField("RR_CLASS", 1, _NETBIOS_QRCLASS),
        IntField("TTL", 0),
        ShortField("RDLENGTH", 83),
        FieldLenField("NUM_NAMES", None, fmt="B", count_of="NODE_NAME"),
        PacketListField("NODE_NAME", [NBNSNodeStatusResponseService()],
                        NBNSNodeStatusResponseService,
                        count_from=lambda pkt: pkt.NUM_NAMES),
        SourceMACField("MAC_ADDRESS"),
        BitField("STATISTICS", 0, 57 * 8)
    ]
Exemplo n.º 3
0
class MACsecSCI(Packet):
    """
    Secure Channel Identifier.
    """

    #########################################################################
    #
    # IEEE 802.1AE-2006 standard
    # Section 9.9
    #########################################################################
    #

    name = "SCI"
    fields_desc = [
        SourceMACField("system_identifier"),
        ShortField("port_identifier", 0)
    ]

    def extract_padding(self, s):
        return "", s
Exemplo n.º 4
0
class NBNSNodeStatusResponseEnd(Packet):
    name = "NBNS Node Status Response"
    fields_desc = [
        SourceMACField("MAC_ADDRESS"),
        BitField("STATISTICS", 0, 57 * 8)
    ]