Exemplo n.º 1
0
class NTLMSSPLE(Packet):
    name = 'NTLM Secure Service Provider'
    fields_desc = [
        StrFixedLenField('identifier', 'NTLMSSP', length=8),
        LEIntEnumField('messageType', 3, {3: 'NTLMSSP_AUTH'}),
        LEShortField('lanManagerLen', 0),
        LEShortField('lanManagerMax', 0),
        LEIntField('lanManagerOffset', 0),
        LEShortField('NTLMRepLen', 0),
        LEShortField('NTLMRepMax', 0),
        LEIntField('NTLMRepOffset', 0),
        LEShortField('domainNameLen', 0),
        LEShortField('domainNameMax', 0),
        LEIntField('domainNameOffset', 0),
        LEShortField('userNameLen', 0),
        LEShortField('userNameMax', 0),
        LEIntField('userNameOffset', 0),
        LEShortField('hostNameLen', 0),
        LEShortField('hostNameMax', 0),
        LEIntField('hostNameOffset', 0),
        LEShortField('sessionKeyLen', 0),
        LEShortField('sessionKeyMax', 0),
        LEIntField('sessionKeyOffset', 0),
        FlagsField('negociateFlags', 0, 32, _negociate_flags),
        ByteField('versionMajor', 0),
        ByteField('versionMinor', 0),
        LEShortField('buildNumber', 0),
        ByteField('reserved', 0),
        ShortField('reserved2', 0),
        ByteField('NTLMCurrentRevision', 0),
        StrFixedLenField('MIC', '', 16),
        StrLenField('domainName',
                    '',
                    length_from=lambda pkt: pkt.domainNameLen),
        StrLenField('userName', '', length_from=lambda pkt: pkt.userNameLen),
        StrLenField('hostName', '', length_from=lambda pkt: pkt.hostNameLen),
        StrLenField('lanManager',
                    '',
                    length_from=lambda pkt: pkt.lanManagerLen),
        StrFixedLenField('NTLMRep', '', length=16),
        ByteField('responseVersion', 0),
        ByteField('hiResponseVersion', 0),
        StrFixedLenField('Z', '', 6),
        LELongField('timestamp', 0),  # Time in nanosecond
        StrFixedLenField('clientChallenge', '', 8),
        LEIntField('Z', 0),
        PacketField('attribute1', None, AttributeNameLE),
        PacketField('attribute2', None, AttributeNameLE),
        PacketField('attribute3', None, AttributeNameLE),
        PacketField('attribute4', None, AttributeNameLE),
        PacketField('attribute5', None, AttributeNameLE),
        PacketField('attribute6', None, AttributeNameLE),
        PacketField('attribute7', None, AttributeNameLE),
        PacketField('attribute8', None, AttributeNameLE),
        PacketField('attribute9', None, AttributeNameLE),
        PacketField('attribute10', None, AttributeNameLE),
        LEIntField('Z', 0),
        LEIntField('padding', 0),
        StrLenField('sessionKey',
                    '',
                    length_from=lambda pkt: pkt.sessionKeyLen),
    ]

    def extract_padding(self, p):
        return b"", p
Exemplo n.º 2
0
class Dot11(Packet):
    name = "802.11"
    fields_desc = [
        BitField("subtype", 0, 4),
        BitEnumField("type", 0, 2,
                     ["Management", "Control", "Data", "Reserved"]),
        BitField("proto", 0, 2),
        FlagsField("FCfield", 0, 8, [
            "to-DS", "from-DS", "MF", "retry", "pw-mgt", "MD", "protected",
            "order"
        ]),
        ShortField("ID", 0),
        MACField("addr1", ETHER_ANY),
        ConditionalField(
            MACField("addr2", ETHER_ANY),
            lambda pkt:
            (pkt.type != 1 or pkt.subtype in [0x8, 0x9, 0xa, 0xb, 0xe, 0xf]),
        ),
        ConditionalField(
            MACField("addr3", ETHER_ANY),
            lambda pkt: pkt.type in [0, 2],
        ),
        ConditionalField(LEShortField("SC", 0), lambda pkt: pkt.type != 1),
        ConditionalField(
            MACField("addr4", ETHER_ANY),
            lambda pkt:
            (pkt.type == 2 and pkt.FCfield & 3 == 3),  # from-DS+to-DS
        )
    ]

    def mysummary(self):
        # Supports both Dot11 and Dot11FCS
        return self.sprintf(
            "802.11 %%%s.type%% %%%s.subtype%% %%%s.addr2%% > %%%s.addr1%%" %
            ((self.__class__.__name__, ) * 4))  # noqa: E501

    def guess_payload_class(self, payload):
        if self.type == 0x02 and (0x08 <= self.subtype <= 0xF
                                  and self.subtype != 0xD):  # noqa: E501
            return Dot11QoS
        elif self.FCfield.protected:
            # When a frame is handled by encryption, the Protected Frame bit
            # (previously called WEP bit) is set to 1, and the Frame Body
            # begins with the appropriate cryptographic header.
            return Dot11Encrypted
        else:
            return Packet.guess_payload_class(self, payload)

    def answers(self, other):
        if isinstance(other, Dot11):
            if self.type == 0:  # management
                if self.addr1.lower() != other.addr2.lower(
                ):  # check resp DA w/ req SA  # noqa: E501
                    return 0
                if (other.subtype, self.subtype) in [(0, 1), (2, 3), (4, 5)]:
                    return 1
                if self.subtype == other.subtype == 11:  # auth
                    return self.payload.answers(other.payload)
            elif self.type == 1:  # control
                return 0
            elif self.type == 2:  # data
                return self.payload.answers(other.payload)
            elif self.type == 3:  # reserved
                return 0
        return 0

    def unwep(self, key=None, warn=1):
        if self.FCfield & 0x40 == 0:
            if warn:
                warning("No WEP to remove")
            return
        if isinstance(self.payload.payload, NoPayload):
            if key or conf.wepkey:
                self.payload.decrypt(key)
            if isinstance(self.payload.payload, NoPayload):
                if warn:
                    warning("Dot11 can't be decrypted. Check conf.wepkey.")
                return
        self.FCfield &= ~0x40
        self.payload = self.payload.payload
Exemplo n.º 3
0
class Dot11AssoReq(Packet):
    name = "802.11 Association Request"
    fields_desc = [
        FlagsField("cap", 0, 16, capability_list),
        LEShortField("listen_interval", 0x00c8)
    ]
Exemplo n.º 4
0
class Dot11AssoResp(Packet):
    name = "802.11 Association Response"
    fields_desc = [FlagsField("cap", 0, 16, capability_list),
                   LEShortField("status", 0),
                   LEShortField("AID", 0)]
Exemplo n.º 5
0
class RadioTap(Packet):
    name = "RadioTap dummy"
    fields_desc = [
        ByteField('version', 0),
        ByteField('pad', 0),
        LEShortField('len', None),
        FlagsField(
            'present',
            None,
            -32,
            [
                'TSFT',
                'Flags',
                'Rate',
                'Channel',
                'FHSS',
                'dBm_AntSignal',  # noqa: E501
                'dBm_AntNoise',
                'Lock_Quality',
                'TX_Attenuation',
                'dB_TX_Attenuation',  # noqa: E501
                'dBm_TX_Power',
                'Antenna',
                'dB_AntSignal',
                'dB_AntNoise',  # noqa: E501
                'RXFlags',
                'b16',
                'b17',
                'b18',
                'ChannelPlus',
                'MCS',
                'A_MPDU',  # noqa: E501
                'VHT',
                'timestamp',
                'b24',
                'b25',
                'b26',
                'b27',
                'b28',
                'b29',  # noqa: E501
                'RadiotapNS',
                'VendorNS',
                'Ext'
            ]),  # noqa: E501
        # Extended presence mask
        ConditionalField(
            PacketListField("Ext", [], next_cls_cb=_next_radiotap_extpm),
            lambda pkt: pkt.present and pkt.present.Ext),  # noqa: E501
        # Default fields
        ConditionalField(
            _RadiotapReversePadField(BitField("mac_timestamp", 0, -64)),
            lambda pkt: pkt.present and pkt.present.TSFT),  # noqa: E501
        ConditionalField(
            _RadiotapReversePadField(
                FlagsField(
                    "Flags",
                    None,
                    -8,
                    [
                        'CFP',
                        'ShortPreamble',
                        'wep',
                        'fragment',  # noqa: E501
                        'FCS',
                        'pad',
                        'badFCS',
                        'ShortGI'
                    ])  # noqa: E501
            ),
            lambda pkt: pkt.present and pkt.present.Flags),
        ConditionalField(
            _RadiotapReversePadField(ByteField("Rate", 0)),
            lambda pkt: pkt.present and pkt.present.Rate),  # noqa: E501
        ConditionalField(
            _RadiotapReversePadField(LEShortField("Channel", 0)),
            lambda pkt: pkt.present and pkt.present.Channel),  # noqa: E501
        ConditionalField(
            _RadiotapReversePadField(
                FlagsField(
                    "ChannelFlags",
                    None,
                    -16,
                    [
                        'res1',
                        'res2',
                        'res3',
                        'res4',
                        'Turbo',
                        'CCK',  # noqa: E501
                        'OFDM',
                        '2GHz',
                        '5GHz',
                        'Passive',
                        'Dynamic_CCK_OFDM',  # noqa: E501
                        'GFSK',
                        'GSM',
                        'StaticTurbo',
                        '10MHz',
                        '5MHz'
                    ])  # noqa: E501
            ),
            lambda pkt: pkt.present and pkt.present.Channel),
        ConditionalField(
            _RadiotapReversePadField(_dbmField("dBm_AntSignal", -256)), lambda
            pkt: pkt.present and pkt.present.dBm_AntSignal),  # noqa: E501
        ConditionalField(
            _RadiotapReversePadField(_dbmField("dBm_AntNoise", -256)), lambda
            pkt: pkt.present and pkt.present.dBm_AntNoise),  # noqa: E501
        ConditionalField(
            _RadiotapReversePadField(ByteField("Antenna", 0)),
            lambda pkt: pkt.present and pkt.present.Antenna),  # noqa: E501
        # ChannelPlus
        ConditionalField(
            _RadiotapReversePadField(
                FlagsField(
                    "ChannelFlags2",
                    None,
                    -32,
                    [
                        'res1',
                        'res2',
                        'res3',
                        'res4',
                        'Turbo',
                        'CCK',  # noqa: E501
                        'OFDM',
                        '2GHz',
                        '5GHz',
                        'Passive',
                        'Dynamic_CCK_OFDM',  # noqa: E501
                        'GFSK',
                        'GSM',
                        'StaticTurbo',
                        '10MHz',
                        '5MHz',  # noqa: E501
                        '20MHz',
                        '40MHz_ext_channel_above',
                        '40MHz_ext_channel_below',  # noqa: E501
                        'res5',
                        'res6',
                        'res7',
                        'res8',
                        'res9'
                    ])  # noqa: E501
            ),
            lambda pkt: pkt.present and pkt.present.ChannelPlus),
        ConditionalField(
            _RadiotapReversePadField(LEShortField("ChannelFrequency", 0)),
            lambda pkt: pkt.present and pkt.present.ChannelPlus),  # noqa: E501
        ConditionalField(
            _RadiotapReversePadField(ByteField("ChannelNumber", 0)),
            lambda pkt: pkt.present and pkt.present.ChannelPlus),  # noqa: E501
        # A_MPDU
        ConditionalField(
            _RadiotapReversePadField(LEIntField("A_MPDU_ref", 0)),
            lambda pkt: pkt.present and pkt.present.A_MPDU),  # noqa: E501
        ConditionalField(
            _RadiotapReversePadField(
                FlagsField(
                    "A_MPDU_flags",
                    None,
                    -32,
                    [
                        'Report0Subframe',
                        'Is0Subframe',
                        'KnownLastSubframe',  # noqa: E501
                        'LastSubframe',
                        'CRCerror',
                        'EOFsubframe',
                        'KnownEOF',  # noqa: E501
                        'res1',
                        'res2',
                        'res3',
                        'res4',
                        'res5',
                        'res6',
                        'res7',
                        'res8'
                    ])  # noqa: E501
            ),
            lambda pkt: pkt.present and pkt.present.A_MPDU),
        # VHT
        ConditionalField(
            _RadiotapReversePadField(
                FlagsField(
                    "KnownVHT",
                    None,
                    -16,
                    [
                        'STBC',
                        'TXOP_PS_NOT_ALLOWED',
                        'GuardInterval',
                        'SGINsysmDis',  # noqa: E501
                        'LDPCextraOFDM',
                        'Beamformed',
                        'Bandwidth',
                        'GroupID',
                        'PartialAID',  # noqa: E501
                        'res1',
                        'res2',
                        'res3',
                        'res4',
                        'res5',
                        'res6',
                        'res7'
                    ])  # noqa: E501
            ),
            lambda pkt: pkt.present and pkt.present.VHT),
        ConditionalField(
            _RadiotapReversePadField(
                FlagsField(
                    "PresentVHT",
                    None,
                    -8,
                    [
                        'STBC',
                        'TXOP_PS_NOT_ALLOWED',
                        'GuardInterval',
                        'SGINsysmDis',  # noqa: E501
                        'LDPCextraOFDM',
                        'Beamformed',
                        'res1',
                        'res2'
                    ])  # noqa: E501
            ),
            lambda pkt: pkt.present and pkt.present.VHT),
        ConditionalField(
            _RadiotapReversePadField(
                ByteEnumField("bandwidth", 0, _vht_bandwidth)),
            lambda pkt: pkt.present and pkt.present.VHT),  # noqa: E501
        ConditionalField(
            _RadiotapReversePadField(StrFixedLenField("mcs_nss", 0, length=5)),
            lambda pkt: pkt.present and pkt.present.VHT),  # noqa: E501
        ConditionalField(
            _RadiotapReversePadField(ByteField("GroupID", 0)),
            lambda pkt: pkt.present and pkt.present.VHT),  # noqa: E501
        ConditionalField(
            _RadiotapReversePadField(ShortField("PartialAID", 0)),
            lambda pkt: pkt.present and pkt.present.VHT),  # noqa: E501
        StrLenField('notdecoded',
                    "",
                    length_from=lambda pkt: pkt.len - pkt._tmp_dissect_pos)
    ]  # noqa: E501

    def guess_payload_class(self, payload):
        if self.present and self.present.Flags and self.Flags.FCS:
            return Dot11FCS
        return Dot11

    def post_build(self, p, pay):
        if self.len is None:
            p = p[:2] + struct.pack("!H", len(p))[::-1] + p[4:]
        return p + pay
Exemplo n.º 6
0
class ATT_ReadBlobReq(Packet):
    fields_desc = [XLEShortField("handle", 0), LEShortField("offset", 0)]
Exemplo n.º 7
0
class HCI_Cmd_LE_Long_Term_Key_Request_Negative_Reply(Packet):
    name = "LE Long Term Key Request Negative Reply"
    fields_desc = [
        LEShortField("handle", 0),
    ]
Exemplo n.º 8
0
class PAS5211GetOnusRange(PAS5211Msg):
    opcode = 116
    name = "PAS5211GetOnusRange"
    fields_desc = [LEShortField("nothing", None)]
Exemplo n.º 9
0
class PAS5211MsgGetActivationAuthMode(PAS5211Msg):
    opcode = 145
    name = "PAS5211MsgGetActivationAuthMode"
    fields_desc = [
        LEShortField("nothing", 0) # no idea why this is here
    ]
Exemplo n.º 10
0
class PAS5211MsgGetOnuIdByPortIdResponse(PAS5211Msg):
    opcode = 196
    name = "PAS5211MsgGetOnuIdByPortIdResponse"
    fields_desc = [LEShortField("valid", None), LEShortField("onu_id", None)]
Exemplo n.º 11
0
class PAS5211GetOnuAllocs(PAS5211Msg):
    opcode = 9
    name = "PAS5211GetOnuAllocs"
    fields_desc = [
        LEShortField("nothing", None)  # It's in the PMC code... so yeah.
    ]
Exemplo n.º 12
0
class PAS5211MsgGetOnuIdByPortId(PAS5211Msg):
    opcode = 196
    name = "PAS5211MsgGetOnuIdByPortId"
    fields_desc = [LEShortField("port_id", None), LEShortField("reserved", 0)]
Exemplo n.º 13
0
class PAS5211MsgSwitchToInboundMode(PAS5211Msg):
    opcode = 0xec
    name = "PAS5211MsgSwitchToInboundMode"
    fields_desc = [MACField("mac", None), LEShortField("mode", 0)]
Exemplo n.º 14
0
class Dot11Beacon(_Dot11EltUtils):
    name = "802.11 Beacon"
    fields_desc = [LELongField("timestamp", 0),
                   LEShortField("beacon_interval", 0x0064),
                   FlagsField("cap", 0, 16, capability_list)]
Exemplo n.º 15
0
class ATT_Exchange_MTU_Response(Packet):
    name = "Exchange MTU Response"
    fields_desc = [
        LEShortField("mtu", 0),
    ]
Exemplo n.º 16
0
class EtherCatType12DLPDU(Packet):
    """
    Type12 message base class
    """
    def post_build(self, pkt, pay):
        """

        set next attr automatically if not set explicitly by user

        :param pkt: raw string containing the current layer
        :param pay: raw string containing the payload
        :return: <new current layer> + payload
        """

        data_len = len(self.data)
        if data_len > 2047:
            raise ValueError('payload size {} exceeds maximum length {} '
                             'of data size.'.format(data_len, 2047))

        if self.next is not None:
            has_next = True if self.next else False
        else:
            if pay:
                has_next = True
            else:
                has_next = False

        if has_next:
            next_flag = bytearray([pkt[7] | 0b10000000])
        else:
            next_flag = bytearray([pkt[7] & 0b01111111])

        return pkt[:7] + next_flag + pkt[8:] + pay

    def guess_payload_class(self, payload):

        try:
            dlpdu_type = payload[0]
            return EtherCat.ETHERCAT_TYPE12_DLPDU_TYPES[dlpdu_type]

        except KeyError:
            log_runtime.error('{}.guess_payload_class() - unknown or invalid '
                              'DLPDU type'.format(self.__class__.__name__))
            return Packet.guess_payload_class(self, payload)

    # structure templates lacking leading cmd-attribute
    PHYSICAL_ADDRESSING_DESC = [
        ByteField('idx', 0),
        LEShortField('adp', 0),
        LEShortField('ado', 0),
        LEBitFieldLenField('len', None, 11, count_of='data'),
        LEBitField('_reserved', 0, 3),
        LEBitEnumField('c', 0, 1, ETHERCAT_TYPE_12_CIRCULATING_FRAME),
        LEBitEnumField('next', None, 1, ETHERCAT_TYPE_12_NEXT_FRAME),
        LEShortField('irq', 0),
        FieldListField('data', [],
                       ByteField('', 0x00),
                       count_from=lambda pkt: pkt.len),
        LEShortField('wkc', 0)
    ]

    BROADCAST_ADDRESSING_DESC = PHYSICAL_ADDRESSING_DESC

    LOGICAL_ADDRESSING_DESC = [
        ByteField('idx', 0),
        LEIntField('adr', 0),
        LEBitFieldLenField('len', None, 11, count_of='data'),
        LEBitField('_reserved', 0, 3),
        LEBitEnumField('c', 0, 1, ETHERCAT_TYPE_12_CIRCULATING_FRAME),
        LEBitEnumField('next', None, 1, ETHERCAT_TYPE_12_NEXT_FRAME),
        LEShortField('irq', 0),
        FieldListField('data', [],
                       ByteField('', 0x00),
                       count_from=lambda pkt: pkt.len),
        LEShortField('wkc', 0)
    ]
Exemplo n.º 17
0
class ATT_PrepareWriteReq(Packet):
    fields_desc = [
        XLEShortField("handle", 0),
        LEShortField("offset", 0),
        StrField("value", "")
    ]
Exemplo n.º 18
0
class EncapsulatedPacket(Packet):
    """Encapsulated Packet"""
    name = "Encapsulated Packet"
    fields_desc = [LEShortField("itemCount", 2), PacketListField(
        "item", None, ItemData, count_from=lambda pkt: pkt.itemCount), ]
Exemplo n.º 19
0
class HCI_Cmd_Connect_Accept_Timeout(Packet):
    name = "Connection Attempt Timeout"
    fields_desc = [LEShortField("timeout", 32000)]  # 32000 slots is 20000 msec
Exemplo n.º 20
0
class L2CAP_CmdRej(Packet):
    name = "L2CAP Command Rej"
    fields_desc = [
        LEShortField("reason", 0),
    ]
Exemplo n.º 21
0
class HCI_Cmd_LE_Long_Term_Key_Request_Reply(Packet):
    name = "LE Long Term Key Request Reply"
    fields_desc = [
        LEShortField("handle", 0),
        StrFixedLenField("ltk", b'\x00' * 16, 16),
    ]
Exemplo n.º 22
0
class L2CAP_ConfReq(Packet):
    name = "L2CAP Conf Req"
    fields_desc = [
        LEShortField("dcid", 0),
        LEShortField("flags", 0),
    ]
Exemplo n.º 23
0
class Dot11ReassoReq(Packet):
    name = "802.11 Reassociation Request"
    fields_desc = [FlagsField("cap", 0, 16, capability_list),
                   LEShortField("listen_interval", 0x00c8),
                   MACField("current_AP", ETHER_ANY)]
Exemplo n.º 24
0
class L2CAP_DisconnReq(Packet):
    name = "L2CAP Disconn Req"
    fields_desc = [
        LEShortField("dcid", 0),
        LEShortField("scid", 0),
    ]
Exemplo n.º 25
0
class RadioTap(Packet):
    name = "RadioTap dummy"
    deprecated_fields = {
        "Channel": ("ChannelFrequency", "2.4.3"),
        "ChannelFlags2": ("ChannelPlusFlags", "2.4.3"),
        "ChannelNumber": ("ChannelPlusNumber", "2.4.3"),
    }
    fields_desc = [
        ByteField('version', 0),
        ByteField('pad', 0),
        LEShortField('len', None),
        FlagsField('present', None, -32, _rt_present),  # noqa: E501
        # Extended presence mask
        ConditionalField(
            PacketListField("Ext", [], next_cls_cb=_next_radiotap_extpm),
            lambda pkt: pkt.present and pkt.present.Ext),  # noqa: E501
        # RadioTap fields - each starts with a _RadiotapReversePadField
        # to handle padding

        # TSFT
        ConditionalField(
            _RadiotapReversePadField(LELongField("mac_timestamp", 0)),
            lambda pkt: pkt.present and pkt.present.TSFT),
        # Flags
        ConditionalField(
            _RadiotapReversePadField(FlagsField("Flags", None, -8, _rt_flags)),
            lambda pkt: pkt.present and pkt.present.Flags),
        # Rate
        ConditionalField(_RadiotapReversePadField(ByteField("Rate", 0)),
                         lambda pkt: pkt.present and pkt.present.Rate),
        # Channel
        ConditionalField(
            _RadiotapReversePadField(LEShortField("ChannelFrequency", 0)),
            lambda pkt: pkt.present and pkt.present.Channel),
        ConditionalField(
            FlagsField("ChannelFlags", None, -16, _rt_channelflags),
            lambda pkt: pkt.present and pkt.present.Channel),
        # dBm_AntSignal
        ConditionalField(
            _RadiotapReversePadField(_dbmField("dBm_AntSignal", -256)),
            lambda pkt: pkt.present and pkt.present.dBm_AntSignal),
        # dBm_AntNoise
        ConditionalField(
            _RadiotapReversePadField(_dbmField("dBm_AntNoise", -256)),
            lambda pkt: pkt.present and pkt.present.dBm_AntNoise),
        # Lock_Quality
        ConditionalField(
            _RadiotapReversePadField(LEShortField("Lock_Quality", 0), ),
            lambda pkt: pkt.present and pkt.present.Lock_Quality),
        # Antenna
        ConditionalField(_RadiotapReversePadField(ByteField("Antenna", 0)),
                         lambda pkt: pkt.present and pkt.present.Antenna),
        # RX Flags
        ConditionalField(
            _RadiotapReversePadField(
                FlagsField("RXFlags", None, -16, _rt_rxflags)),
            lambda pkt: pkt.present and pkt.present.RXFlags),
        # TX Flags
        ConditionalField(
            _RadiotapReversePadField(
                FlagsField("TXFlags", None, -16, _rt_txflags)),
            lambda pkt: pkt.present and pkt.present.TXFlags),
        # ChannelPlus
        ConditionalField(
            _RadiotapReversePadField(
                FlagsField("ChannelPlusFlags", None, -32, _rt_channelflags2)),
            lambda pkt: pkt.present and pkt.present.ChannelPlus),
        ConditionalField(LEShortField("ChannelPlusFrequency", 0),
                         lambda pkt: pkt.present and pkt.present.ChannelPlus),
        ConditionalField(ByteField("ChannelPlusNumber", 0),
                         lambda pkt: pkt.present and pkt.present.ChannelPlus),
        # MCS
        ConditionalField(
            _RadiotapReversePadField(
                FlagsField("knownMCS", None, -8, _rt_knownmcs)),
            lambda pkt: pkt.present and pkt.present.MCS),
        ConditionalField(BitField("Ness_LSB", 0, 1),
                         lambda pkt: pkt.present and pkt.present.MCS),
        ConditionalField(BitField("STBC_streams", 0, 2),
                         lambda pkt: pkt.present and pkt.present.MCS),
        ConditionalField(BitEnumField("FEC_type", 0, 1, {
            0: "BCC",
            1: "LDPC"
        }), lambda pkt: pkt.present and pkt.present.MCS),
        ConditionalField(
            BitEnumField("HT_format", 0, 1, {
                0: "mixed",
                1: "greenfield"
            }), lambda pkt: pkt.present and pkt.present.MCS),
        ConditionalField(
            BitEnumField("guard_interval", 0, 1, {
                0: "Long_GI",
                1: "Short_GI"
            }),  # noqa: E501
            lambda pkt: pkt.present and pkt.present.MCS),
        ConditionalField(BitEnumField("MCS_bandwidth", 0, 2, _rt_bandwidth),
                         lambda pkt: pkt.present and pkt.present.MCS),
        ConditionalField(ByteField("MCS_index", 0),
                         lambda pkt: pkt.present and pkt.present.MCS),
        # A_MPDU
        ConditionalField(_RadiotapReversePadField(LEIntField("A_MPDU_ref", 0)),
                         lambda pkt: pkt.present and pkt.present.A_MPDU),
        ConditionalField(
            FlagsField("A_MPDU_flags", None, -32, _rt_a_mpdu_flags),
            lambda pkt: pkt.present and pkt.present.A_MPDU),
        # VHT
        ConditionalField(
            _RadiotapReversePadField(
                FlagsField("KnownVHT", None, -16, _rt_knownvht)),
            lambda pkt: pkt.present and pkt.present.VHT),
        ConditionalField(FlagsField("PresentVHT", None, -8, _rt_presentvht),
                         lambda pkt: pkt.present and pkt.present.VHT),
        ConditionalField(ByteEnumField("VHT_bandwidth", 0, _rt_vhtbandwidth),
                         lambda pkt: pkt.present and pkt.present.VHT),
        ConditionalField(StrFixedLenField("mcs_nss", 0, length=5),
                         lambda pkt: pkt.present and pkt.present.VHT),
        ConditionalField(ByteField("GroupID", 0),
                         lambda pkt: pkt.present and pkt.present.VHT),
        ConditionalField(ShortField("PartialAID", 0),
                         lambda pkt: pkt.present and pkt.present.VHT),
        # timestamp
        ConditionalField(_RadiotapReversePadField(LELongField("timestamp", 0)),
                         lambda pkt: pkt.present and pkt.present.timestamp),
        ConditionalField(LEShortField("ts_accuracy", 0),
                         lambda pkt: pkt.present and pkt.present.timestamp),
        ConditionalField(ByteField("ts_position", 0),
                         lambda pkt: pkt.present and pkt.present.timestamp),
        ConditionalField(ByteField("ts_flags", 0),
                         lambda pkt: pkt.present and pkt.present.timestamp),
        # HE - XXX not complete
        ConditionalField(_RadiotapReversePadField(ShortField("he_data1", 0)),
                         lambda pkt: pkt.present and pkt.present.HE),
        ConditionalField(ShortField("he_data2", 0),
                         lambda pkt: pkt.present and pkt.present.HE),
        ConditionalField(ShortField("he_data3", 0),
                         lambda pkt: pkt.present and pkt.present.HE),
        ConditionalField(ShortField("he_data4", 0),
                         lambda pkt: pkt.present and pkt.present.HE),
        ConditionalField(ShortField("he_data5", 0),
                         lambda pkt: pkt.present and pkt.present.HE),
        ConditionalField(ShortField("he_data6", 0),
                         lambda pkt: pkt.present and pkt.present.HE),
        # HE_MU
        ConditionalField(
            _RadiotapReversePadField(LEShortField("hemu_flags1", 0)),
            lambda pkt: pkt.present and pkt.present.HE_MU),
        ConditionalField(LEShortField("hemu_flags2", 0),
                         lambda pkt: pkt.present and pkt.present.HE_MU),
        ConditionalField(
            FieldListField("RU_channel1", [],
                           ByteField,
                           count_from=lambda x: 4),
            lambda pkt: pkt.present and pkt.present.HE_MU),
        ConditionalField(
            FieldListField("RU_channel2", [],
                           ByteField,
                           count_from=lambda x: 4),
            lambda pkt: pkt.present and pkt.present.HE_MU),
        # HE_MU_other_user
        ConditionalField(
            _RadiotapReversePadField(LEShortField("hemuou_per_user_1",
                                                  0x7fff)),
            lambda pkt: pkt.present and pkt.present.HE_MU_other_user),
        ConditionalField(
            LEShortField("hemuou_per_user_2", 0x003f),
            lambda pkt: pkt.present and pkt.present.HE_MU_other_user),
        ConditionalField(
            ByteField("hemuou_per_user_position", 0),
            lambda pkt: pkt.present and pkt.present.HE_MU_other_user),
        ConditionalField(
            FlagsField("hemuou_per_user_known", 0, -16,
                       _rt_hemuother_per_user_known),
            lambda pkt: pkt.present and pkt.present.HE_MU_other_user),
        # L_SIG
        ConditionalField(
            _RadiotapReversePadField(
                FlagsField("lsig_data1", 0, -16, ["rate", "length"])),
            lambda pkt: pkt.present and pkt.present.L_SIG),
        ConditionalField(BitField("lsig_length", 0, 12),
                         lambda pkt: pkt.present and pkt.present.L_SIG),
        ConditionalField(BitField("lsig_rate", 0, 4),
                         lambda pkt: pkt.present and pkt.present.L_SIG),
        # Remaining
        StrLenField(
            'notdecoded',
            "",
            length_from=lambda pkt: max(pkt.len - pkt._tmp_dissect_pos, 0))
    ]

    def guess_payload_class(self, payload):
        if self.present and self.present.Flags and self.Flags.FCS:
            return Dot11FCS
        return Dot11

    def post_build(self, p, pay):
        if self.len is None:
            p = p[:2] + struct.pack("!H", len(p))[::-1] + p[4:]
        return p + pay
Exemplo n.º 26
0
class L2CAP_Connection_Parameter_Update_Response(Packet):
    name = "L2CAP Connection Parameter Update Response"
    fields_desc = [
        LEShortField("move_result", 0),
    ]
Exemplo n.º 27
0
class PrismHeader(Packet):
    """ iwpriv wlan0 monitor 3 """
    name = "Prism header"
    fields_desc = [
        LEIntField("msgcode", 68),
        LEIntField("len", 144),
        StrFixedLenField("dev", "", 16),
        LEIntField("hosttime_did", 0),
        LEShortField("hosttime_status", 0),
        LEShortField("hosttime_len", 0),
        LEIntField("hosttime", 0),
        LEIntField("mactime_did", 0),
        LEShortField("mactime_status", 0),
        LEShortField("mactime_len", 0),
        LEIntField("mactime", 0),
        LEIntField("channel_did", 0),
        LEShortField("channel_status", 0),
        LEShortField("channel_len", 0),
        LEIntField("channel", 0),
        LEIntField("rssi_did", 0),
        LEShortField("rssi_status", 0),
        LEShortField("rssi_len", 0),
        LEIntField("rssi", 0),
        LEIntField("sq_did", 0),
        LEShortField("sq_status", 0),
        LEShortField("sq_len", 0),
        LEIntField("sq", 0),
        LEIntField("signal_did", 0),
        LEShortField("signal_status", 0),
        LEShortField("signal_len", 0),
        LESignedIntField("signal", 0),
        LEIntField("noise_did", 0),
        LEShortField("noise_status", 0),
        LEShortField("noise_len", 0),
        LEIntField("noise", 0),
        LEIntField("rate_did", 0),
        LEShortField("rate_status", 0),
        LEShortField("rate_len", 0),
        LEIntField("rate", 0),
        LEIntField("istx_did", 0),
        LEShortField("istx_status", 0),
        LEShortField("istx_len", 0),
        LEIntField("istx", 0),
        LEIntField("frmlen_did", 0),
        LEShortField("frmlen_status", 0),
        LEShortField("frmlen_len", 0),
        LEIntField("frmlen", 0),
    ]

    def answers(self, other):
        if isinstance(other, PrismHeader):
            return self.payload.answers(other.payload)
        else:
            return self.payload.answers(other)
Exemplo n.º 28
0
class ATT_Exchange_MTU_Request(Packet):
    name = "Exchange MTU Request"
    fields_desc = [
        LEShortField("mtu", 0),
    ]
Exemplo n.º 29
0
class IEC104_IE_CP56TIME2A(IEC104_IE_CommonQualityFlags):
    """
    CP56Time2a - dual time, 7 octets
                 (milliseconds, valid flag, minutes, hours,
                  summer-time-indicator, day of month, weekday, years)

    well, someone should have talked to them about the idea of the
    unix timestamp...

    EN 60870-5-101:2003, sec. 7.2.6.18 (p. 50)

    time representation format according IEC 60870-5-4:1993, sec. 6.8, p. 23
    """
    WEEK_DAY_FLAG_UNUSED = 0
    WEEK_DAY_FLAG_MONDAY = 1
    WEEK_DAY_FLAG_TUESDAY = 2
    WEEK_DAY_FLAG_WEDNESDAY = 3
    WEEK_DAY_FLAG_THURSDAY = 4
    WEEK_DAY_FLAG_FRIDAY = 5
    WEEK_DAY_FLAG_SATURDAY = 6
    WEEK_DAY_FLAG_SUNDAY = 7
    WEEK_DAY_FLAGS = {
        WEEK_DAY_FLAG_UNUSED: 'unused',
        WEEK_DAY_FLAG_MONDAY: 'Monday',
        WEEK_DAY_FLAG_TUESDAY: 'Tuesday',
        WEEK_DAY_FLAG_WEDNESDAY: 'Wednesday',
        WEEK_DAY_FLAG_THURSDAY: 'Thursday',
        WEEK_DAY_FLAG_FRIDAY: 'Friday',
        WEEK_DAY_FLAG_SATURDAY: 'Saturday',
        WEEK_DAY_FLAG_SUNDAY: 'Sunday'
    }

    GEN_FLAG_REALTIME = 0
    GEN_FLAG_SUBSTITUTED_TIME = 1
    GEN_FLAGS = {
        GEN_FLAG_REALTIME: 'real time',
        GEN_FLAG_SUBSTITUTED_TIME: 'substituted time'
    }

    SU_FLAG_NORMAL_TIME = 0
    SU_FLAG_SUMMER_TIME = 1
    SU_FLAGS = {
        SU_FLAG_NORMAL_TIME: 'normal time',
        SU_FLAG_SUMMER_TIME: 'summer time'
    }

    informantion_element_fields = [
        LEShortField('sec_milli', 0),
        BitEnumField('iv_time', 0, 1, IEC104_IE_CommonQualityFlags.IV_FLAGS),
        BitEnumField('gen', 0, 1, GEN_FLAGS),
        # only valid in monitor direction ToDo: special treatment needed?
        BitField('minutes', 0, 6),
        BitEnumField('su', 0, 1, SU_FLAGS),
        BitField('reserved_2', 0, 2),
        BitField('hours', 0, 5),
        BitEnumField('weekday', 0, 3, WEEK_DAY_FLAGS),
        BitField('day_of_month', 0, 5),
        BitField('reserved_3', 0, 4),
        BitField('month', 0, 4),
        BitField('reserved_4', 0, 1),
        BitField('year', 0, 7),
    ]
Exemplo n.º 30
0
class StringBinding(Packet):
    name = 'String Binding'
    fields_desc = [
        LEShortField('wTowerId', 0),
        # Not enough information to continue
    ]