コード例 #1
0
ファイル: wpa_eapol.py プロジェクト: Hem1700/packet_sniffer
class WPA_key(Packet):
    name = "WPA_key"
    fields_desc = [
        ByteField("descriptor_type", 1),
        ShortField("key_info", 0),
        LenField("len", None, "H"),
        StrFixedLenField("replay_counter", "", 8),
        StrFixedLenField("nonce", "", 32),
        StrFixedLenField("key_iv", "", 16),
        StrFixedLenField("wpa_key_rsc", "", 8),
        StrFixedLenField("wpa_key_id", "", 8),
        StrFixedLenField("wpa_key_mic", "", 16),
        LenField("wpa_key_length", None, "H"),
        StrLenField("wpa_key", "", length_from=lambda pkt: pkt.wpa_key_length)
    ]  # noqa: E501

    def extract_padding(self, s):
        tmp_len = self.len
        return s[:tmp_len], s[tmp_len:]

    def hashret(self):
        return chr(self.type) + self.payload.hashret()

    def answers(self, other):
        if isinstance(other, WPA_key):
            return 1
        return 0
コード例 #2
0
class SAPEnqueue(PacketNoPadded):
    """SAP Enqueue Server packet

    This packet is used for general Enqueue packets.
    """

    name = "SAP Enqueue"
    fields_desc = [
        StrFixedLenField("magic_bytes", "\xab\xcd\xe1\x23", 4),
        IntField("id", 0),
        LenField("len", None, fmt="!I"),
        LenField("len_frag", None, fmt="!I"),
        ByteEnumKeysField("dest", 0x00, enqueue_dest_values),
        ByteEnumKeysField("opcode", 0x00, enqueue_conn_admin_opcode_values),
        ByteField("more_frags", 0),
        ByteEnumKeysField("type", 0x00, enqueue_type_values),

        # Server Admin fields
        ConditionalField(StrNullFixedLenField("adm_eyecatcher1", "ENC", 3), lambda pkt:pkt.dest == 3),
        ConditionalField(ByteField("adm_version", 1), lambda pkt:pkt.dest == 3),
        ConditionalField(ByteField("adm_padd1", 0), lambda pkt:pkt.dest == 3),
        ConditionalField(ByteField("adm_padd2", 0), lambda pkt:pkt.dest == 3),
        ConditionalField(ByteField("adm_padd3", 0), lambda pkt:pkt.dest == 3),
        ConditionalField(StrFixedLenField("adm_eyecatcher2", "#EAA", 4), lambda pkt:pkt.dest == 3),
        ConditionalField(ByteField("adm_1", 1), lambda pkt:pkt.dest == 3),
        ConditionalField(IntField("adm_len", 0), lambda pkt:pkt.dest == 3),
        ConditionalField(ByteEnumKeysField("adm_opcode", 0, enqueue_server_admin_opcode_values), lambda pkt:pkt.dest == 3),
        ConditionalField(ByteField("adm_flags", 0), lambda pkt:pkt.dest == 3),
        ConditionalField(IntField("adm_rc", 0), lambda pkt:pkt.dest == 3),
        ConditionalField(StrFixedLenField("adm_eyecatcher3", "#EAE", 4), lambda pkt:pkt.dest == 3),

        # Server Admin Trace fields
        ConditionalField(ByteField("adm_trace_protocol_version", 1), lambda pkt:pkt.dest == 3 and pkt.adm_opcode in [0x06]),
        ConditionalField(ByteEnumKeysField("adm_trace_action", 3, enqueue_server_admin_trace_action_values), lambda pkt:pkt.dest == 3 and pkt.adm_opcode in [0x06]),
        ConditionalField(ByteEnumKeysField("adm_trace_limit", 0, enqueue_server_admin_trace_limit_values), lambda pkt:pkt.dest == 3 and pkt.adm_opcode in [0x06]),
        ConditionalField(ByteEnumKeysField("adm_trace_thread", 0, enqueue_server_admin_trace_thread_values), lambda pkt:pkt.dest == 3 and pkt.adm_opcode in [0x06]),
        ConditionalField(IntField("adm_trace_unknown1", 0), lambda pkt:pkt.dest == 3 and pkt.adm_opcode in [0x06]),
        ConditionalField(IntField("adm_trace_level", 1), lambda pkt:pkt.dest == 3 and pkt.adm_opcode in [0x06]),
        ConditionalField(IntField("adm_trace_level1", 1), lambda pkt:pkt.dest == 3 and pkt.adm_opcode in [0x06]),
        ConditionalField(ByteField("adm_trace_logging", 0), lambda pkt:pkt.dest == 3 and pkt.adm_opcode in [0x06]),
        ConditionalField(IntField("adm_trace_max_file_size", 20 * 1024 * 1024), lambda pkt:pkt.dest == 3 and pkt.adm_opcode in [0x06]),
        ConditionalField(FieldLenField("adm_trace_nopatterns", 0, count_of="adm_trace_patterns", fmt="!I"), lambda pkt:pkt.dest == 3 and pkt.adm_opcode in [0x06]),
        ConditionalField(FieldLenField("adm_trace_nopatterns1", 0, count_of="adm_trace_patterns", fmt="!I"), lambda pkt:pkt.dest == 3 and pkt.adm_opcode in [0x06]),
        ConditionalField(IntField("adm_trace_unknown3", 37), lambda pkt:pkt.dest == 3 and pkt.adm_opcode in [0x06]),
        ConditionalField(StrFixedLenField("adm_trace_eyecatcher4", "#EAH", 4), lambda pkt:pkt.dest == 3 and pkt.adm_opcode in [0x06]),
        ConditionalField(PacketListField("adm_trace_patterns", None, SAPEnqueueTracePattern, count_from=lambda pkt:pkt.adm_trace_nopatterns), lambda pkt:pkt.dest == 3 and pkt.adm_opcode in [0x06]),
        ConditionalField(StrFixedLenField("adm_trace_eyecatcher5", "#EAD", 4), lambda pkt:pkt.dest == 3 and pkt.adm_opcode in [0x06]),

        # Connection Admin fields
        ConditionalField(FieldLenField("params_count", None, count_of="params", fmt="!I"), lambda pkt:pkt.dest == 6 and pkt.opcode in [1, 2]),
        ConditionalField(PacketListField("params", None, SAPEnqueueParam, count_from=lambda pkt:pkt.params_count), lambda pkt:pkt.dest == 6 and pkt.opcode in [1, 2]),
    ]

    def post_build(self, pkt, pay):
        """Adjust the len and len_frags fields after the build of the whole
        packet. """
        l = struct.pack("!I", len(pkt) + len(pay))
        pkt = pkt[:8] + l + l + pkt[16:]
        return pkt + pay
コード例 #3
0
ファイル: http2.py プロジェクト: secvalve/scapy-http2
 def __init__(self, name, default=None, fmt="I", width=None):
     self.name = name
     self.width = width
     self.default = self.any2i(None, default)
     if fmt[0] in "@=<>!":
         self.fmt = fmt
     else:
         self.fmt = "!" + fmt
     self.size = self.width or struct.calcsize(self.fmt)
     # Scapy uses old style classes. No super() here
     # super(ByteLenField, self).__init__(name, default, fmt)
     LenField.__init__(self, name, default, fmt)
コード例 #4
0
class DCPFullIPBlock(Packet):
    fields_desc = [
        ByteEnumField("option", 1, DCP_OPTIONS),
        MultiEnumField("sub_option",
                       3,
                       DCP_SUBOPTIONS,
                       fmt='B',
                       depends_on=lambda p: p.option),
        LenField("dcp_block_length", None),
        ShortEnumField("block_info", 1, IP_BLOCK_INFOS),
        IPField("ip", "192.168.0.2"),
        IPField("netmask", "255.255.255.0"),
        IPField("gateway", "192.168.0.1"),
        FieldListField("dnsaddr", [],
                       IPField("", "0.0.0.0"),
                       count_from=lambda x: 4),
        PadField(StrLenField("padding",
                             b"\x00",
                             length_from=lambda p: p.dcp_block_length % 2),
                 1,
                 padwith=b"\x00")
    ]

    def extract_padding(self, s):
        return '', s
コード例 #5
0
class Apple_BLE_Submessage(Packet, LowEnergyBeaconHelper):
    """
    A basic Apple submessage.
    """

    name = "Apple BLE submessage"
    fields_desc = [
        ByteEnumField(
            "subtype", None, {
                0x02: "ibeacon",
                0x05: "airdrop",
                0x07: "airpods",
                0x09: "airplay_sink",
                0x0a: "airplay_src",
                0x0c: "handoff",
                0x10: "nearby",
            }),
        LenField("len", None, fmt="B")
    ]

    def extract_padding(self, s):
        # Needed to end each EIR_Element packet and make PacketListField work.
        return s[:self.len], s[self.len:]

    # These methods are here in case you only want to send 1 submessage.
    # It creates an Apple_BLE_Frame to wrap your (single) Apple_BLE_Submessage.
    def build_frame(self):
        """Wraps this submessage in a Apple_BLE_Frame."""
        return Apple_BLE_Frame(plist=[self])

    def build_eir(self):
        """See Apple_BLE_Frame.build_eir."""
        return self.build_frame().build_eir()
コード例 #6
0
ファイル: usb.py プロジェクト: william-stearns/scapy
class USBpcap(Packet):
    name = "USBpcap URB"
    fields_desc = [ByteField("headerLen", None),
                   ByteField("res", 0),
                   XLELongField("irpId", 0),
                   LEIntEnumField("usbd_status", 0x0, _usbd_status_codes),
                   LEShortEnumField("function", 0, _urb_functions),
                   XByteField("info", 0),
                   LEShortField("bus", 0),
                   LEShortField("device", 0),
                   XByteField("endpoint", 0),
                   ByteEnumField("transfer", 0, _transfer_types),
                   LenField("dataLength", None, fmt="<I")]

    def post_build(self, p, pay):
        if self.headerLen is None:
            headerLen = len(p)
            if isinstance(self.payload, (USBpcapTransferIsochronous,
                                         USBpcapTransferInterrupt,
                                         USBpcapTransferControl)):
                headerLen += len(self.payload) - len(self.payload.payload)
            p = chb(headerLen) + p[1:]
        return p + pay

    def guess_payload_class(self, payload):
        if self.headerLen == 27:
            # No Transfer layer
            return super(USBpcap, self).guess_payload_class(payload)
        if self.transfer == 0:
            return USBpcapTransferIsochronous
        elif self.transfer == 1:
            return USBpcapTransferInterrupt
        elif self.transfer == 2:
            return USBpcapTransferControl
        return super(USBpcap, self).guess_payload_class(payload)
コード例 #7
0
class DCPControlBlock(Packet):
    fields_desc = [
        ByteEnumField("option", 5, DCP_OPTIONS),
        MultiEnumField("sub_option",
                       4,
                       DCP_SUBOPTIONS,
                       fmt='B',
                       depends_on=lambda p: p.option),
        LenField("dcp_block_length", 3),
        ByteEnumField("response", 2, DCP_OPTIONS),
        MultiEnumField("response_sub_option",
                       2,
                       DCP_SUBOPTIONS,
                       fmt='B',
                       depends_on=lambda p: p.option),
        ByteEnumField("block_error", 0, BLOCK_ERRORS),
        PadField(StrLenField("padding",
                             b"\x00",
                             length_from=lambda p: p.dcp_block_length % 2),
                 1,
                 padwith=b"\x00")
    ]

    def extract_padding(self, s):
        return '', s
コード例 #8
0
class SignalHeader(CAN):
    """Special implementation of a CAN Packet to allow dynamic binding.

    This class can be provided to CANSockets as basecls.

    Example:
        >>> class floatSignals(SignalPacket):
        >>>     fields_desc = [
        >>>         LEFloatSignalField("floatSignal2", default=0, start=32),
        >>>         BEFloatSignalField("floatSignal1", default=0, start=7)]
        >>>
        >>> bind_layers(SignalHeader, floatSignals, identifier=0x321)
        >>>
        >>> dbc_sock = CANSocket("can0", basecls=SignalHeader)

    All CAN messages received from this dbc_sock CANSocket will be interpreted
    as SignalHeader. Through Scapys ``bind_layers`` mechanism, all CAN messages
    with CAN identifier 0x321 will interpret the payload bytes of these
    CAN messages as floatSignals packet.
    """
    fields_desc = [
        FlagsField('flags', 0, 3, ['error',
                                   'remote_transmission_request',
                                   'extended']),
        XBitField('identifier', 0, 29),
        LenField('length', None, fmt='B'),
        ThreeBytesField('reserved', 0)
    ]

    def extract_padding(self, s):
        # type: (bytes) -> Tuple[bytes, Optional[bytes]]
        return s, None
コード例 #9
0
class Dot3(Packet):
    name = "802.3"
    fields_desc = [
        DestMACField("dst"),
        SourceMACField("src"),
        LenField("len", None, "H")
    ]

    def extract_padding(self, s):
        # type: (bytes) -> Tuple[bytes, bytes]
        tmp_len = self.len
        return s[:tmp_len], s[tmp_len:]

    def answers(self, other):
        # type: (Ether) -> int
        if isinstance(other, Dot3):
            return self.payload.answers(other.payload)
        return 0

    def mysummary(self):
        # type: () -> str
        return "802.3 %s > %s" % (self.src, self.dst)

    @classmethod
    def dispatch_hook(cls, _pkt=None, *args, **kargs):
        # type: (Optional[Any], *Any, **Any) -> Type[Packet]
        if _pkt and len(_pkt) >= 14:
            if struct.unpack("!H", _pkt[12:14])[0] > 1500:
                return Ether
        return cls
コード例 #10
0
class SAPNI(Packet):
    """SAP NI (Network Interface) packet

    This packet is used for craft Network Interface packets. It serves only
    as a container for packets in the different protocols. As this protocol
    is used by different protocols and the only way to differentiate each one
    is by the TCP port used, each script using the NI protocol must bind the
    respective layer with the respective protocol.

    For example, a script using the SAP Diag protocol must include the
    following binds::

        bind_layers(SAPNI,      SAPDiag, )
        bind_layers(SAPNI,      SAPDiagDP, )
        bind_layers(SAPDiagDP,  SAPDiag, )
        bind_layers(SAPDiag,    SAPDiagItem, )
        bind_layers(SAPDiagItem,SAPDiagItem, )

    """
    name = "SAP NI (Network Interface) protocol"
    fields_desc = [LenField("length", None, fmt="!I")]

    # Constants for keep-alive messages
    SAPNI_PING = "NI_PING\x00"
    """ :cvar: Constant for keep-alive request messages (NI_PING)
        :type: C{string} """

    SAPNI_PONG = "NI_PONG\x00"
    """ :cvar: Constant for keep-alive response messages (NI_PONG)
コード例 #11
0
ファイル: l2.py プロジェクト: yvyshneva/scapy
class Dot3(Packet):
    name = "802.3"
    fields_desc = [
        DestMACField("dst"),
        MACField("src", ETHER_ANY),
        LenField("len", None, "H")
    ]

    def extract_padding(self, s):
        tmp_len = self.len
        return s[:tmp_len], s[tmp_len:]

    def answers(self, other):
        if isinstance(other, Dot3):
            return self.payload.answers(other.payload)
        return 0

    def mysummary(self):
        return "802.3 %s > %s" % (self.src, self.dst)

    @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 Ether
        return cls
コード例 #12
0
ファイル: pnio_rpc.py プロジェクト: william-stearns/scapy
class IODWriteReq(Block):
    """IODWrite request block"""
    fields_desc = [
        BlockHeader,
        ShortField("seqNum", 0),
        UUIDField("ARUUID", None),
        XIntField("API", 0),
        XShortField("slotNumber", 0),
        XShortField("subslotNumber", 0),
        StrFixedLenField("padding", "", length=2),
        XShortEnumField("index", 0, IOD_WRITE_REQ_INDEX),
        LenField("recordDataLength", None, fmt="I"),
        StrFixedLenField("RWPadding", "", length=24),
    ]
    # default block_type value
    block_type = 0x0008

    def payload_length(self):
        return self.recordDataLength

    def get_response(self):
        """Generate the response block of this request.
        Careful: it only sets the fields which can be set from the request
        """
        res = IODWriteRes()
        for field in ["seqNum", "ARUUID", "API", "slotNumber",
                      "subslotNumber", "index"]:
            res.setfieldval(field, self.getfieldval(field))
        return res
コード例 #13
0
class EAPOL(Packet):
    """
    EAPOL - IEEE Std 802.1X-2010
    """

    name = "EAPOL"
    fields_desc = [
        ByteEnumField("version", 1, eapol_versions),
        ByteEnumField("type", 0, eapol_types),
        LenField("len", None, "H")
    ]

    EAP_PACKET = 0
    START = 1
    LOGOFF = 2
    KEY = 3
    ASF = 4

    def extract_padding(self, s):
        tmp_len = self.len
        return s[:tmp_len], s[tmp_len:]

    def hashret(self):
        return chb(self.type) + self.payload.hashret()

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

    def mysummary(self):
        return self.sprintf("EAPOL %EAPOL.type%")
コード例 #14
0
ファイル: rtcp.py プロジェクト: william-stearns/scapy
class RTCP(Packet):
    name = "RTCP"

    fields_desc = [
        # HEADER
        BitField('version', 2, 2),
        BitField('padding', 0, 1),
        BitFieldLenField('count', 0, 5, count_of='report_blocks'),
        ByteEnumField('packet_type', 0, _rtcp_packet_types),
        LenField('length', None, fmt='!h'),
        # SR/RR
        ConditionalField(IntField('sourcesync', 0),
                         lambda pkt: pkt.packet_type in (200, 201)),
        ConditionalField(PacketField('sender_info', SenderInfo(), SenderInfo),
                         lambda pkt: pkt.packet_type == 200),
        ConditionalField(
            PacketListField('report_blocks',
                            None,
                            pkt_cls=ReceptionReport,
                            count_from=lambda pkt: pkt.count),
            lambda pkt: pkt.packet_type in (200, 201)),
        # SDES
        ConditionalField(
            PacketListField('sdes_chunks',
                            None,
                            pkt_cls=SDESChunk,
                            count_from=lambda pkt: pkt.count),
            lambda pkt: pkt.packet_type == 202),
    ]

    def post_build(self, pkt, pay):
        pkt += pay
        if self.length is None:
            pkt = pkt[:2] + struct.pack("!h", len(pkt) // 4 - 1) + pkt[4:]
        return pkt
コード例 #15
0
ファイル: pptp.py プロジェクト: Hem1700/packet_sniffer
class PPTPEchoRequest(PPTP):
    name = "PPTP Echo Request"
    fields_desc = [LenField("len", 16),
                   ShortEnumField("type", 1, _PPTP_msg_type),
                   XIntField("magic_cookie", _PPTP_MAGIC_COOKIE),
                   ShortEnumField("ctrl_msg_type", 5, _PPTP_ctrl_msg_type),
                   XShortField("reserved_0", 0x0000),
                   IntField("identifier", None)]
コード例 #16
0
ファイル: http2.py プロジェクト: secvalve/scapy-http2
class HTTP2Headers(HTTP2PaddedFrame):
    name = "HTTP2 %s Frame" % HTTP2_FRAME_TYPES[HTTP2FrameTypes.HEADERS]
    fields_desc = [ConditionalField(LenField("padding_length", None, fmt="B"), underlayer_has_padding_flag_set),
                   ConditionalField(BitField("E", 0, 1), underlayer_has_priority_flag_set),
                   ConditionalField(BitField("stream_dependency", 0, 31), underlayer_has_priority_flag_set),
                   ConditionalField(ByteField("weight", 0), underlayer_has_priority_flag_set),
                   # Encoding for => :method: GET, :scheme: https, :path: /, host: localhost
                   StrField("headers", "\x87\x84f\x86\xa0\xe4\x1d\x13\x9d\t\x82")]
コード例 #17
0
class HCI_Command_Hdr(Packet):
    name = "HCI Command header"
    fields_desc = [
        XLEShortField("opcode", 0),
        LenField("len", None, fmt="B"),
    ]

    def answers(self, other):
        return False
コード例 #18
0
class ISO_8327_1_Session_Accept(Packet):
    name = "ISO 8327-1 Session Accept"
    fields_desc = [ByteField("spdu_type", 0x0e),
                   LenField("length", None,
                            fmt="!B", adjust=lambda pkt, x: len(pkt) + x),
                   PacketListField("parameters", None,
                                   ISO_8327_1_Session_Protocol_Parameter,
                                   count_from=lambda x: 3),
                   PacketField("user_data", None, ISO_8327_1_Session_User_Data)]
コード例 #19
0
ファイル: pptp.py プロジェクト: Hem1700/packet_sniffer
class PPTPCallClearRequest(PPTP):
    name = "PPTP Call Clear Request"
    fields_desc = [LenField("len", 16),
                   ShortEnumField("type", 1, _PPTP_msg_type),
                   XIntField("magic_cookie", _PPTP_MAGIC_COOKIE),
                   ShortEnumField("ctrl_msg_type", 12, _PPTP_ctrl_msg_type),
                   XShortField("reserved_0", 0x0000),
                   ShortField("call_id", 1),
                   XShortField("reserved_1", 0x0000)]
コード例 #20
0
ファイル: ppi.py プロジェクト: Hem1700/packet_sniffer
class PPI_Hdr(Packet):
    name = 'PPI Header'
    fields_desc = [
        LEShortEnumField('pfh_type', 0, PPI_TYPES),
        LenField('pfh_length', None, fmt='<H'),
    ]

    def mysummary(self):
        return self.sprintf('PPI %pfh_type%')
コード例 #21
0
class EIR_Hdr(Packet):
    name = "EIR Header"
    fields_desc = [
        LenField("len", None, fmt="B",
                 adjust=lambda x: x + 1),  # Add bytes mark  # noqa: E501
        # https://www.bluetooth.com/specifications/assigned-numbers/generic-access-profile
        ByteEnumField(
            "type", 0, {
                0x01: "flags",
                0x02: "incomplete_list_16_bit_svc_uuids",
                0x03: "complete_list_16_bit_svc_uuids",
                0x04: "incomplete_list_32_bit_svc_uuids",
                0x05: "complete_list_32_bit_svc_uuids",
                0x06: "incomplete_list_128_bit_svc_uuids",
                0x07: "complete_list_128_bit_svc_uuids",
                0x08: "shortened_local_name",
                0x09: "complete_local_name",
                0x0a: "tx_power_level",
                0x0d: "class_of_device",
                0x0e: "simple_pairing_hash",
                0x0f: "simple_pairing_rand",
                0x10: "sec_mgr_tk",
                0x11: "sec_mgr_oob_flags",
                0x12: "slave_conn_intvl_range",
                0x14: "list_16_bit_svc_sollication_uuids",
                0x15: "list_128_bit_svc_sollication_uuids",
                0x16: "svc_data_16_bit_uuid",
                0x17: "pub_target_addr",
                0x18: "rand_target_addr",
                0x19: "appearance",
                0x1a: "adv_intvl",
                0x1b: "le_addr",
                0x1c: "le_role",
                0x1d: "simple_pairing_hash_256",
                0x1e: "simple_pairing_rand_256",
                0x1f: "list_32_bit_svc_sollication_uuids",
                0x20: "svc_data_32_bit_uuid",
                0x21: "svc_data_128_bit_uuid",
                0x22: "sec_conn_confirm",
                0x23: "sec_conn_rand",
                0x24: "uri",
                0x25: "indoor_positioning",
                0x26: "transport_discovery",
                0x27: "le_supported_features",
                0x28: "channel_map_update",
                0x29: "mesh_pb_adv",
                0x2a: "mesh_message",
                0x2b: "mesh_beacon",
                0x3d: "3d_information",
                0xff: "mfg_specific_data",
            }),
    ]

    def mysummary(self):
        return self.sprintf("EIR %type%")
コード例 #22
0
ファイル: pptp.py プロジェクト: Hem1700/packet_sniffer
class PPTPStopControlConnectionRequest(PPTP):
    name = "PPTP Stop Control Connection Request"
    fields_desc = [LenField("len", 16),
                   ShortEnumField("type", 1, _PPTP_msg_type),
                   XIntField("magic_cookie", _PPTP_MAGIC_COOKIE),
                   ShortEnumField("ctrl_msg_type", 3, _PPTP_ctrl_msg_type),
                   XShortField("reserved_0", 0x0000),
                   ByteEnumField("reason", 1,
                                 _PPTP_stop_control_connection_reason),
                   XByteField("reserved_1", 0x00),
                   XShortField("reserved_2", 0x0000)]
コード例 #23
0
ファイル: can.py プロジェクト: pokhrelsishir/scapy-1
class SignalHeader(CAN):
    fields_desc = [
        FlagsField('flags', 0, 3,
                   ['error', 'remote_transmission_request', 'extended']),
        XBitField('identifier', 0, 29),
        LenField('length', None, fmt='B'),
        ThreeBytesField('reserved', 0)
    ]

    def extract_padding(self, s):
        return s, None
コード例 #24
0
ファイル: pptp.py プロジェクト: Hem1700/packet_sniffer
class PPTPSetLinkInfo(PPTP):
    name = "PPTP Set Link Info"
    fields_desc = [LenField("len", 24),
                   ShortEnumField("type", 1, _PPTP_msg_type),
                   XIntField("magic_cookie", _PPTP_MAGIC_COOKIE),
                   ShortEnumField("ctrl_msg_type", 15, _PPTP_ctrl_msg_type),
                   XShortField("reserved_0", 0x0000),
                   ShortField("peer_call_id", 1),
                   XShortField("reserved_1", 0x0000),
                   XIntField("send_accm", 0x00000000),
                   XIntField("receive_accm", 0x00000000)]
コード例 #25
0
ファイル: cotp.py プロジェクト: rhelmke/iec61850_mms_scapy
class COTP_Connection_Request(Packet):
    name = "COTP Connection Request (CR)"
    fields_desc = [
        LenField("length", None, fmt="!B", adjust=lambda x: x + 5),
        ByteField("tpdu_code", 0xd0),
        ShortField("destination_reference", None),
        ShortField("source_reference", None),
        BitField("class", 0, 4),
        BitField("reserved", 0, 2),
        BitField("extended_format", 0, 1),
        BitField("explicit", 0, 1),
        PacketListField("parameters", None, COTP_Parameter)
    ]
コード例 #26
0
class HCI_Event_Hdr(Packet):
    name = "HCI Event header"
    fields_desc = [
        XByteField("code", 0),
        LenField("len", None, fmt="B"),
    ]

    def answers(self, other):
        if HCI_Command_Hdr not in other:
            return False

        # Delegate answers to event types
        return self.payload.answers(other)
コード例 #27
0
ファイル: pptp.py プロジェクト: Hem1700/packet_sniffer
class PPTPStopControlConnectionReply(PPTP):
    name = "PPTP Stop Control Connection Reply"
    fields_desc = [LenField("len", 16),
                   ShortEnumField("type", 1, _PPTP_msg_type),
                   XIntField("magic_cookie", _PPTP_MAGIC_COOKIE),
                   ShortEnumField("ctrl_msg_type", 4, _PPTP_ctrl_msg_type),
                   XShortField("reserved_0", 0x0000),
                   ByteEnumField("result_code", 1,
                                 _PPTP_stop_control_connection_result),
                   ByteEnumField("error_code", 0, _PPTP_general_error_code),
                   XShortField("reserved_2", 0x0000)]

    def answers(self, other):
        return isinstance(other, PPTPStopControlConnectionRequest)
コード例 #28
0
ファイル: pptp.py プロジェクト: Hem1700/packet_sniffer
class PPTPEchoReply(PPTP):
    name = "PPTP Echo Reply"
    fields_desc = [LenField("len", 20),
                   ShortEnumField("type", 1, _PPTP_msg_type),
                   XIntField("magic_cookie", _PPTP_MAGIC_COOKIE),
                   ShortEnumField("ctrl_msg_type", 6, _PPTP_ctrl_msg_type),
                   XShortField("reserved_0", 0x0000),
                   IntField("identifier", None),
                   ByteEnumField("result_code", 1, _PPTP_echo_result),
                   ByteEnumField("error_code", 0, _PPTP_general_error_code),
                   XShortField("reserved_1", 0x0000)]

    def answers(self, other):
        return isinstance(other, PPTPEchoRequest) and other.identifier == self.identifier  # noqa: E501
コード例 #29
0
ファイル: pptp.py プロジェクト: Hem1700/packet_sniffer
class PPTPCallDisconnectNotify(PPTP):
    name = "PPTP Call Disconnect Notify"
    fields_desc = [LenField("len", 148),
                   ShortEnumField("type", 1, _PPTP_msg_type),
                   XIntField("magic_cookie", _PPTP_MAGIC_COOKIE),
                   ShortEnumField("ctrl_msg_type", 13, _PPTP_ctrl_msg_type),
                   XShortField("reserved_0", 0x0000),
                   ShortField("call_id", 1),
                   ByteEnumField("result_code", 1,
                                 _PPTP_call_disconnect_result),
                   ByteEnumField("error_code", 0, _PPTP_general_error_code),
                   ShortField("cause_code", 0),
                   XShortField("reserved_1", 0x0000),
                   StrFixedLenField("call_statistic", "", 128)]
コード例 #30
0
ファイル: bluetooth.py プロジェクト: yinduren/scapy
class HCI_Command_Hdr(Packet):
    name = "HCI Command header"
    fields_desc = [
        XLEShortField("opcode", 0),
        LenField("len", None, fmt="B"),
    ]

    def answers(self, other):
        return False

    def post_build(self, p, pay):
        p += pay
        if self.len is None:
            p = p[:2] + struct.pack("B", len(pay)) + p[3:]
        return p
コード例 #31
0
ファイル: sdnv.py プロジェクト: commial/scapy
 def addfield(self, pkt, s, val):
     return s + raw(SDNVUtil.encode(LenField.i2m(self, pkt, val)))