scapy.layers.bluetooth

Bluetooth layers, sockets and send/receive functions.

class scapy.layers.bluetooth.ATT_Error_Response

Bases: scapy.packet.Packet

aliastypes
fields_desc
ATT_Error_Response fields

request

XByteField

0

handle

LEShortField

0

ecode

ByteEnumField

0

class scapy.layers.bluetooth.ATT_Exchange_MTU_Request

Bases: scapy.packet.Packet

aliastypes
fields_desc
ATT_Exchange_MTU_Request fields

mtu

LEShortField

0

class scapy.layers.bluetooth.ATT_Exchange_MTU_Response

Bases: scapy.packet.Packet

aliastypes
fields_desc
ATT_Exchange_MTU_Response fields

mtu

LEShortField

0

class scapy.layers.bluetooth.ATT_Execute_Write_Request

Bases: scapy.packet.Packet

aliastypes
fields_desc
ATT_Execute_Write_Request fields

flags

ByteEnumField

1

class scapy.layers.bluetooth.ATT_Execute_Write_Response

Bases: scapy.packet.Packet

aliastypes
class scapy.layers.bluetooth.ATT_Find_By_Type_Value_Request

Bases: scapy.packet.Packet

aliastypes
fields_desc
ATT_Find_By_Type_Value_Request fields

start

XLEShortField

1

end

XLEShortField

65535

uuid

XLEShortField

None

data

StrField

b''

class scapy.layers.bluetooth.ATT_Find_By_Type_Value_Response

Bases: scapy.packet.Packet

aliastypes
fields_desc
ATT_Find_By_Type_Value_Response fields

handles

PacketListField

[]

class scapy.layers.bluetooth.ATT_Find_Information_Request

Bases: scapy.packet.Packet

aliastypes
fields_desc
ATT_Find_Information_Request fields

start

XLEShortField

0

end

XLEShortField

65535

class scapy.layers.bluetooth.ATT_Find_Information_Response

Bases: scapy.packet.Packet

aliastypes
fields_desc
ATT_Find_Information_Response fields

format

XByteField

1

handles

PacketListField (Cond)

[]

handles

PacketListField (Cond)

[]

class scapy.layers.bluetooth.ATT_Handle

Bases: scapy.packet.Packet

aliastypes
extract_padding(s)
fields_desc
ATT_Handle fields

handle

XLEShortField

0

value

XLEShortField

0

class scapy.layers.bluetooth.ATT_Handle_UUID128

Bases: scapy.packet.Packet

aliastypes
extract_padding(s)
fields_desc
ATT_Handle_UUID128 fields

handle

XLEShortField

0

value

UUIDField

None

class scapy.layers.bluetooth.ATT_Handle_Value_Indication

Bases: scapy.packet.Packet

aliastypes
fields_desc
ATT_Handle_Value_Indication fields

gatt_handle

XLEShortField

0

value

StrField

b''

class scapy.layers.bluetooth.ATT_Handle_Value_Notification

Bases: scapy.packet.Packet

aliastypes
fields_desc
ATT_Handle_Value_Notification fields

gatt_handle

XLEShortField

0

value

StrField

b''

class scapy.layers.bluetooth.ATT_Handle_Variable(_pkt=b'', val_length=2, **kwargs)

Bases: scapy.packet.Packet

aliastypes
extract_padding(s)
fields_desc
ATT_Handle_Variable fields

handle

XLEShortField

0

value

XStrLenField

0

val_length
class scapy.layers.bluetooth.ATT_Hdr

Bases: scapy.packet.Packet

aliastypes
fields_desc
ATT_Hdr fields

opcode

XByteField

None

payload_guess

Possible sublayers: ATT_Error_Response, ATT_Exchange_MTU_Request, ATT_Exchange_MTU_Response, ATT_Execute_Write_Request, ATT_Execute_Write_Response, ATT_Find_By_Type_Value_Request, ATT_Find_By_Type_Value_Response, ATT_Find_Information_Request, ATT_Find_Information_Response, ATT_Handle_Value_Indication, ATT_Handle_Value_Notification, ATT_Prepare_Write_Request, ATT_Prepare_Write_Response, ATT_Read_Blob_Request, ATT_Read_Blob_Response, ATT_Read_By_Group_Type_Request, ATT_Read_By_Group_Type_Response, ATT_Read_By_Type_Request_128bit, ATT_Read_By_Type_Request, ATT_Read_By_Type_Response, ATT_Read_Multiple_Request, ATT_Read_Multiple_Response, ATT_Read_Request, ATT_Read_Response, ATT_Write_Command, ATT_Write_Request, ATT_Write_Response

class scapy.layers.bluetooth.ATT_Prepare_Write_Request

Bases: scapy.packet.Packet

aliastypes
fields_desc
ATT_Prepare_Write_Request fields

gatt_handle

XLEShortField

0

offset

LEShortField

0

data

StrField

b''

class scapy.layers.bluetooth.ATT_Prepare_Write_Response

Bases: scapy.layers.bluetooth.ATT_Prepare_Write_Request

aliastypes
fields_desc
ATT_Prepare_Write_Response fields

gatt_handle

XLEShortField

0

offset

LEShortField

0

data

StrField

b''

class scapy.layers.bluetooth.ATT_Read_Blob_Request

Bases: scapy.packet.Packet

aliastypes
fields_desc
ATT_Read_Blob_Request fields

gatt_handle

XLEShortField

0

offset

LEShortField

0

class scapy.layers.bluetooth.ATT_Read_Blob_Response

Bases: scapy.packet.Packet

aliastypes
fields_desc
ATT_Read_Blob_Response fields

value

StrField

b''

class scapy.layers.bluetooth.ATT_Read_By_Group_Type_Request

Bases: scapy.packet.Packet

aliastypes
fields_desc
ATT_Read_By_Group_Type_Request fields

start

XLEShortField

0

end

XLEShortField

65535

uuid

XLEShortField

0

class scapy.layers.bluetooth.ATT_Read_By_Group_Type_Response

Bases: scapy.packet.Packet

aliastypes
fields_desc
ATT_Read_By_Group_Type_Response fields

length

XByteField

0

data

StrField

b''

class scapy.layers.bluetooth.ATT_Read_By_Type_Request

Bases: scapy.packet.Packet

aliastypes
fields_desc
ATT_Read_By_Type_Request fields

start

XLEShortField

1

end

XLEShortField

65535

uuid

XLEShortField

None

class scapy.layers.bluetooth.ATT_Read_By_Type_Request_128bit

Bases: scapy.packet.Packet

aliastypes
classmethod dispatch_hook(_pkt=None, *args, **kargs)
fields_desc
ATT_Read_By_Type_Request_128bit fields

start

XLEShortField

1

end

XLEShortField

65535

uuid1

XLELongField

None

uuid2

XLELongField

None

class scapy.layers.bluetooth.ATT_Read_By_Type_Response

Bases: scapy.packet.Packet

aliastypes
fields_desc
ATT_Read_By_Type_Response fields

len

ByteField

4

handles

PacketListField

[]

class scapy.layers.bluetooth.ATT_Read_Multiple_Request

Bases: scapy.packet.Packet

aliastypes
fields_desc
ATT_Read_Multiple_Request fields

handles

FieldListField

[]

class scapy.layers.bluetooth.ATT_Read_Multiple_Response

Bases: scapy.packet.Packet

aliastypes
fields_desc
ATT_Read_Multiple_Response fields

values

StrField

b''

class scapy.layers.bluetooth.ATT_Read_Request

Bases: scapy.packet.Packet

aliastypes
fields_desc
ATT_Read_Request fields

gatt_handle

XLEShortField

0

class scapy.layers.bluetooth.ATT_Read_Response

Bases: scapy.packet.Packet

aliastypes
fields_desc
ATT_Read_Response fields

value

StrField

b''

class scapy.layers.bluetooth.ATT_Write_Command

Bases: scapy.packet.Packet

aliastypes
fields_desc
ATT_Write_Command fields

gatt_handle

XLEShortField

0

data

StrField

b''

class scapy.layers.bluetooth.ATT_Write_Request

Bases: scapy.packet.Packet

aliastypes
fields_desc
ATT_Write_Request fields

gatt_handle

XLEShortField

0

data

StrField

b''

class scapy.layers.bluetooth.ATT_Write_Response

Bases: scapy.packet.Packet

aliastypes
exception scapy.layers.bluetooth.BluetoothCommandError

Bases: BaseException

class scapy.layers.bluetooth.BluetoothHCISocket(iface=65536, type=None)

Bases: scapy.supersocket.SuperSocket

desc = 'read/write on a BlueTooth HCI socket'
recv(x=65535)
class scapy.layers.bluetooth.BluetoothL2CAPSocket(bt_address)

Bases: scapy.supersocket.SuperSocket

desc = 'read/write packets on a connected L2CAP socket'
recv(x=65535)
class scapy.layers.bluetooth.BluetoothRFCommSocket(bt_address, port=0)

Bases: scapy.layers.bluetooth.BluetoothL2CAPSocket

read/write packets on a connected RFCOMM socket

exception scapy.layers.bluetooth.BluetoothSocketError

Bases: BaseException

class scapy.layers.bluetooth.BluetoothUserSocket(adapter_index=0)

Bases: scapy.supersocket.SuperSocket

close()
desc = 'read/write H4 over a Bluetooth user channel'
flush()
readable(timeout=0)
recv(x=65535)
send_command(cmd)
class scapy.layers.bluetooth.EIR_CompleteList128BitServiceUUIDs

Bases: scapy.layers.bluetooth.EIR_Element

aliastypes
fields_desc
EIR_CompleteList128BitServiceUUIDs fields

svc_uuids

FieldListField

[]

class scapy.layers.bluetooth.EIR_CompleteList16BitServiceUUIDs

Bases: scapy.layers.bluetooth.EIR_Element

aliastypes
fields_desc
EIR_CompleteList16BitServiceUUIDs fields

svc_uuids

FieldListField

[]

class scapy.layers.bluetooth.EIR_CompleteLocalName

Bases: scapy.layers.bluetooth.EIR_Element

aliastypes
fields_desc
EIR_CompleteLocalName fields

local_name

StrLenField

b''

class scapy.layers.bluetooth.EIR_Device_ID

Bases: scapy.layers.bluetooth.EIR_Element

aliastypes
fields_desc
EIR_Device_ID fields

vendor_id_source

XLEShortField

0

vendor_id

XLEShortField

0

product_id

XLEShortField

0

version

XLEShortField

0

class scapy.layers.bluetooth.EIR_Element

Bases: scapy.packet.Packet

aliastypes
extract_padding(s)
static length_from(pkt)
class scapy.layers.bluetooth.EIR_Flags

Bases: scapy.layers.bluetooth.EIR_Element

aliastypes
fields_desc
EIR_Flags fields

flags

FlagsField (8 bits)

<Flag 2 (general_disc_mode)>

class scapy.layers.bluetooth.EIR_Hdr

Bases: scapy.packet.Packet

aliastypes
fields_desc
EIR_Hdr fields

len

LenField

None

type

ByteEnumField

0

mysummary()
payload_guess

Possible sublayers: EIR_CompleteList128BitServiceUUIDs, EIR_CompleteList16BitServiceUUIDs, EIR_CompleteLocalName, EIR_Device_ID, EIR_Flags, EIR_IncompleteList128BitServiceUUIDs, EIR_IncompleteList16BitServiceUUIDs, EIR_Manufacturer_Specific_Data, EIR_Raw, EIR_ServiceData16BitUUID, EIR_ShortenedLocalName, EIR_TX_Power_Level

class scapy.layers.bluetooth.EIR_IncompleteList128BitServiceUUIDs

Bases: scapy.layers.bluetooth.EIR_CompleteList128BitServiceUUIDs

aliastypes
fields_desc
EIR_IncompleteList128BitServiceUUIDs fields

svc_uuids

FieldListField

[]

class scapy.layers.bluetooth.EIR_IncompleteList16BitServiceUUIDs

Bases: scapy.layers.bluetooth.EIR_CompleteList16BitServiceUUIDs

aliastypes
fields_desc
EIR_IncompleteList16BitServiceUUIDs fields

svc_uuids

FieldListField

[]

class scapy.layers.bluetooth.EIR_Manufacturer_Specific_Data

Bases: scapy.layers.bluetooth.EIR_Element

aliastypes
default_payload_class(payload)
extract_padding(s)
fields_desc
EIR_Manufacturer_Specific_Data fields

company_id

XLEShortField

None

payload_guess

Possible sublayers: Apple_BLE_Frame

classmethod register_magic_payload(payload_cls, magic_check=None)

Registers a payload type that uses magic data.

Traditional payloads require registration of a Bluetooth Company ID (requires company membership of the Bluetooth SIG), or a Bluetooth Short UUID (requires a once-off payment).

There are alternatives which don’t require registration (such as 128-bit UUIDs), but the biggest consumer of energy in a beacon is the radio – so the energy consumption of a beacon is proportional to the number of bytes in a beacon frame.

Some beacon formats side-step this issue by using the Company ID of their beacon hardware manufacturer, and adding a “magic data sequence” at the start of the Manufacturer Specific Data field.

Examples of this are AltBeacon and GeoBeacon.

For an example of this method in use, see scapy.contrib.altbeacon.

Parameters
  • payload_cls (Type[scapy.packet.Packet]) – A reference to a Packet subclass to register as a payload.

  • bool] magic_check (Callable[[bytes],) – (optional) callable to use to if a payload should be associated with this type. If not supplied, payload_cls.magic_check is used instead.

Raises

TypeError – If magic_check is not specified, and payload_cls.magic_check is not implemented.

registered_magic_payloads = {<class 'scapy.contrib.altbeacon.AltBeacon'>: <bound method AltBeacon.magic_check of <class 'scapy.contrib.altbeacon.AltBeacon'>>}
class scapy.layers.bluetooth.EIR_Raw

Bases: scapy.layers.bluetooth.EIR_Element

aliastypes
fields_desc
EIR_Raw fields

data

StrLenField

b''

class scapy.layers.bluetooth.EIR_ServiceData16BitUUID

Bases: scapy.layers.bluetooth.EIR_Element

aliastypes
extract_padding(s)
fields_desc
EIR_ServiceData16BitUUID fields

svc_uuid

XLEShortField

None

payload_guess

Possible sublayers: Eddystone_Frame

class scapy.layers.bluetooth.EIR_ShortenedLocalName

Bases: scapy.layers.bluetooth.EIR_CompleteLocalName

aliastypes
fields_desc
EIR_ShortenedLocalName fields

local_name

StrLenField

b''

class scapy.layers.bluetooth.EIR_TX_Power_Level

Bases: scapy.layers.bluetooth.EIR_Element

aliastypes
fields_desc
EIR_TX_Power_Level fields

level

SignedByteField

0

class scapy.layers.bluetooth.HCI_ACL_Hdr

Bases: scapy.packet.Packet

aliastypes
fields_desc
HCI_ACL_Hdr fields

BC

BitField (2 bits)

0

PB

BitField (2 bits)

0

handle

BitField (12 bits)

0

len

LEShortField

None

payload_guess

Possible sublayers: L2CAP_Hdr

post_build(p, pay)
post_dissect(s)
pre_dissect(s)
class scapy.layers.bluetooth.HCI_Cmd_Complete_LE_Read_White_List_Size

Bases: scapy.packet.Packet

aliastypes
fields_desc
HCI_Cmd_Complete_LE_Read_White_List_Size fields

status

ByteField

0

size

ByteField

0

class scapy.layers.bluetooth.HCI_Cmd_Complete_Read_BD_Addr

Bases: scapy.packet.Packet

aliastypes
fields_desc
HCI_Cmd_Complete_Read_BD_Addr fields

addr

LEMACField

None

class scapy.layers.bluetooth.HCI_Cmd_Connect_Accept_Timeout

Bases: scapy.packet.Packet

aliastypes
fields_desc
HCI_Cmd_Connect_Accept_Timeout fields

timeout

LEShortField

32000

class scapy.layers.bluetooth.HCI_Cmd_Disconnect

Bases: scapy.packet.Packet

aliastypes
fields_desc
HCI_Cmd_Disconnect fields

handle

XLEShortField

0

reason

ByteField

19

class scapy.layers.bluetooth.HCI_Cmd_LE_Add_Device_To_White_List

Bases: scapy.packet.Packet

aliastypes
fields_desc
HCI_Cmd_LE_Add_Device_To_White_List fields

atype

ByteEnumField

0

address

LEMACField

None

class scapy.layers.bluetooth.HCI_Cmd_LE_Clear_White_List

Bases: scapy.packet.Packet

aliastypes
class scapy.layers.bluetooth.HCI_Cmd_LE_Connection_Update

Bases: scapy.packet.Packet

aliastypes
fields_desc
HCI_Cmd_LE_Connection_Update fields

handle

XLEShortField

0

min_interval

XLEShortField

0

max_interval

XLEShortField

0

latency

XLEShortField

0

timeout

XLEShortField

0

min_ce

LEShortField

0

max_ce

LEShortField

65535

class scapy.layers.bluetooth.HCI_Cmd_LE_Create_Connection

Bases: scapy.packet.Packet

aliastypes
fields_desc
HCI_Cmd_LE_Create_Connection fields

interval

LEShortField

96

window

LEShortField

48

filter

ByteEnumField

0

patype

ByteEnumField

0

paddr

LEMACField

None

atype

ByteEnumField

0

min_interval

LEShortField

40

max_interval

LEShortField

56

latency

LEShortField

0

timeout

LEShortField

42

min_ce

LEShortField

0

max_ce

LEShortField

0

class scapy.layers.bluetooth.HCI_Cmd_LE_Create_Connection_Cancel

Bases: scapy.packet.Packet

aliastypes
class scapy.layers.bluetooth.HCI_Cmd_LE_Host_Supported

Bases: scapy.packet.Packet

aliastypes
fields_desc
HCI_Cmd_LE_Host_Supported fields

supported

ByteField

1

simultaneous

ByteField

1

class scapy.layers.bluetooth.HCI_Cmd_LE_Long_Term_Key_Request_Negative_Reply

Bases: scapy.packet.Packet

aliastypes
fields_desc
HCI_Cmd_LE_Long_Term_Key_Request_Negative_Reply fields

handle

LEShortField

0

class scapy.layers.bluetooth.HCI_Cmd_LE_Long_Term_Key_Request_Reply

Bases: scapy.packet.Packet

aliastypes
fields_desc
HCI_Cmd_LE_Long_Term_Key_Request_Reply fields

handle

LEShortField

0

ltk

StrFixedLenField

b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'

class scapy.layers.bluetooth.HCI_Cmd_LE_Read_Buffer_Size

Bases: scapy.packet.Packet

aliastypes
class scapy.layers.bluetooth.HCI_Cmd_LE_Read_Remote_Used_Features

Bases: scapy.packet.Packet

aliastypes
fields_desc
HCI_Cmd_LE_Read_Remote_Used_Features fields

handle

LEShortField

64

class scapy.layers.bluetooth.HCI_Cmd_LE_Read_White_List_Size

Bases: scapy.packet.Packet

aliastypes
class scapy.layers.bluetooth.HCI_Cmd_LE_Remove_Device_From_White_List

Bases: scapy.layers.bluetooth.HCI_Cmd_LE_Add_Device_To_White_List

aliastypes
fields_desc
HCI_Cmd_LE_Remove_Device_From_White_List fields

atype

ByteEnumField

0

address

LEMACField

None

class scapy.layers.bluetooth.HCI_Cmd_LE_Set_Advertise_Enable

Bases: scapy.packet.Packet

aliastypes
fields_desc
HCI_Cmd_LE_Set_Advertise_Enable fields

enable

ByteField

0

class scapy.layers.bluetooth.HCI_Cmd_LE_Set_Advertising_Data

Bases: scapy.packet.Packet

aliastypes
fields_desc
HCI_Cmd_LE_Set_Advertising_Data fields

len

FieldLenField

None

data

PadField

[]

class scapy.layers.bluetooth.HCI_Cmd_LE_Set_Advertising_Parameters

Bases: scapy.packet.Packet

aliastypes
fields_desc
HCI_Cmd_LE_Set_Advertising_Parameters fields

interval_min

LEShortField

2048

interval_max

LEShortField

2048

adv_type

ByteEnumField

0

oatype

ByteEnumField

0

datype

ByteEnumField

0

daddr

LEMACField

None

channel_map

ByteField

7

filter_policy

ByteEnumField

0

class scapy.layers.bluetooth.HCI_Cmd_LE_Set_Random_Address

Bases: scapy.packet.Packet

aliastypes
fields_desc
HCI_Cmd_LE_Set_Random_Address fields

address

LEMACField

None

class scapy.layers.bluetooth.HCI_Cmd_LE_Set_Scan_Enable

Bases: scapy.packet.Packet

aliastypes
fields_desc
HCI_Cmd_LE_Set_Scan_Enable fields

enable

ByteField

1

filter_dups

ByteField

1

class scapy.layers.bluetooth.HCI_Cmd_LE_Set_Scan_Parameters

Bases: scapy.packet.Packet

aliastypes
fields_desc
HCI_Cmd_LE_Set_Scan_Parameters fields

type

ByteEnumField

1

interval

XLEShortField

16

window

XLEShortField

16

atype

ByteEnumField

0

policy

ByteEnumField

0

class scapy.layers.bluetooth.HCI_Cmd_LE_Set_Scan_Response_Data

Bases: scapy.packet.Packet

aliastypes
fields_desc
HCI_Cmd_LE_Set_Scan_Response_Data fields

len

FieldLenField

None

data

StrLenField

b''

class scapy.layers.bluetooth.HCI_Cmd_LE_Start_Encryption_Request

Bases: scapy.packet.Packet

aliastypes
fields_desc
HCI_Cmd_LE_Start_Encryption_Request fields

handle

LEShortField

0

rand

StrFixedLenField

None

ediv

XLEShortField

0

ltk

StrFixedLenField

b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'

class scapy.layers.bluetooth.HCI_Cmd_Read_BD_Addr

Bases: scapy.packet.Packet

aliastypes
class scapy.layers.bluetooth.HCI_Cmd_Reset

Bases: scapy.packet.Packet

aliastypes
class scapy.layers.bluetooth.HCI_Cmd_Set_Event_Filter

Bases: scapy.packet.Packet

aliastypes
fields_desc
HCI_Cmd_Set_Event_Filter fields

type

ByteEnumField

0

class scapy.layers.bluetooth.HCI_Cmd_Set_Event_Mask

Bases: scapy.packet.Packet

aliastypes
fields_desc
HCI_Cmd_Set_Event_Mask fields

mask

StrFixedLenField

b'\xff\xff\xfb\xff\x07\xf8\xbf='

class scapy.layers.bluetooth.HCI_Cmd_Write_Extended_Inquiry_Response

Bases: scapy.packet.Packet

aliastypes
fields_desc
HCI_Cmd_Write_Extended_Inquiry_Response fields

fec_required

ByteField

0

eir_data

PacketListField

[]

class scapy.layers.bluetooth.HCI_Cmd_Write_Local_Name

Bases: scapy.packet.Packet

aliastypes
fields_desc
HCI_Cmd_Write_Local_Name fields

name

StrField

'Write Local Name'

class scapy.layers.bluetooth.HCI_Command_Hdr

Bases: scapy.packet.Packet

aliastypes
answers(other)
fields_desc
HCI_Command_Hdr fields

opcode

XLEShortField

0

len

LenField

None

payload_guess

Possible sublayers: HCI_Cmd_Connect_Accept_Timeout, HCI_Cmd_Disconnect, HCI_Cmd_LE_Add_Device_To_White_List, HCI_Cmd_LE_Clear_White_List, HCI_Cmd_LE_Connection_Update, HCI_Cmd_LE_Create_Connection_Cancel, HCI_Cmd_LE_Create_Connection, HCI_Cmd_LE_Host_Supported, HCI_Cmd_LE_Long_Term_Key_Request_Negative_Reply, HCI_Cmd_LE_Long_Term_Key_Request_Reply, HCI_Cmd_LE_Read_Buffer_Size, HCI_Cmd_LE_Read_Remote_Used_Features, HCI_Cmd_LE_Read_White_List_Size, HCI_Cmd_LE_Remove_Device_From_White_List, HCI_Cmd_LE_Set_Advertise_Enable, HCI_Cmd_LE_Set_Advertising_Data, HCI_Cmd_LE_Set_Advertising_Parameters, HCI_Cmd_LE_Set_Random_Address, HCI_Cmd_LE_Set_Scan_Enable, HCI_Cmd_LE_Set_Scan_Parameters, HCI_Cmd_LE_Set_Scan_Response_Data, HCI_Cmd_LE_Start_Encryption_Request, HCI_Cmd_Read_BD_Addr, HCI_Cmd_Reset, HCI_Cmd_Set_Event_Filter, HCI_Cmd_Set_Event_Mask, HCI_Cmd_Write_Extended_Inquiry_Response, HCI_Cmd_Write_Local_Name

post_build(p, pay)
class scapy.layers.bluetooth.HCI_Event_Command_Complete

Bases: scapy.packet.Packet

aliastypes
answers(other)
fields_desc
HCI_Event_Command_Complete fields

number

ByteField

0

opcode

XLEShortField

0

status

ByteEnumField

0

payload_guess

Possible sublayers: HCI_Cmd_Complete_LE_Read_White_List_Size, HCI_Cmd_Complete_Read_BD_Addr

class scapy.layers.bluetooth.HCI_Event_Command_Status

Bases: scapy.packet.Packet

aliastypes
answers(other)
fields_desc
HCI_Event_Command_Status fields

status

ByteEnumField

0

number

ByteField

0

opcode

XLEShortField

None

class scapy.layers.bluetooth.HCI_Event_Disconnection_Complete

Bases: scapy.packet.Packet

aliastypes
fields_desc
HCI_Event_Disconnection_Complete fields

status

ByteEnumField

0

handle

LEShortField

0

reason

XByteField

0

class scapy.layers.bluetooth.HCI_Event_Encryption_Change

Bases: scapy.packet.Packet

aliastypes
fields_desc
HCI_Event_Encryption_Change fields

status

ByteEnumField

0

handle

LEShortField

0

enabled

ByteEnumField

0

class scapy.layers.bluetooth.HCI_Event_Hdr

Bases: scapy.packet.Packet

aliastypes
answers(other)
fields_desc
HCI_Event_Hdr fields

code

XByteField

0

len

LenField

None

payload_guess

Possible sublayers: HCI_Event_Command_Complete, HCI_Event_Command_Status, HCI_Event_Disconnection_Complete, HCI_Event_Encryption_Change, HCI_Event_LE_Meta, HCI_Event_Number_Of_Completed_Packets

class scapy.layers.bluetooth.HCI_Event_LE_Meta

Bases: scapy.packet.Packet

aliastypes
answers(other)
fields_desc
HCI_Event_LE_Meta fields

event

ByteEnumField

0

payload_guess

Possible sublayers: HCI_LE_Meta_Advertising_Reports, HCI_LE_Meta_Connection_Complete, HCI_LE_Meta_Connection_Update_Complete, HCI_LE_Meta_Long_Term_Key_Request

class scapy.layers.bluetooth.HCI_Event_Number_Of_Completed_Packets

Bases: scapy.packet.Packet

aliastypes
fields_desc
HCI_Event_Number_Of_Completed_Packets fields

number

ByteField

0

class scapy.layers.bluetooth.HCI_Hdr

Bases: scapy.packet.Packet

aliastypes
fields_desc
HCI_Hdr fields

type

ByteEnumField

2

mysummary()
payload_guess

Possible sublayers: HCI_ACL_Hdr, HCI_Command_Hdr, HCI_Event_Hdr, Raw

class scapy.layers.bluetooth.HCI_LE_Meta_Advertising_Report

Bases: scapy.packet.Packet

aliastypes
extract_padding(s)
fields_desc
HCI_LE_Meta_Advertising_Report fields

type

ByteEnumField

0

atype

ByteEnumField

0

addr

LEMACField

None

len

FieldLenField

None

data

PacketListField

[]

rssi

SignedByteField

0

class scapy.layers.bluetooth.HCI_LE_Meta_Advertising_Reports

Bases: scapy.packet.Packet

aliastypes
fields_desc
HCI_LE_Meta_Advertising_Reports fields

len

FieldLenField

None

reports

PacketListField

[]

class scapy.layers.bluetooth.HCI_LE_Meta_Connection_Complete

Bases: scapy.packet.Packet

aliastypes
answers(other)
fields_desc
HCI_LE_Meta_Connection_Complete fields

status

ByteEnumField

0

handle

LEShortField

0

role

ByteEnumField

0

patype

ByteEnumField

0

paddr

LEMACField

None

interval

LEShortField

54

latency

LEShortField

0

supervision

LEShortField

42

clock_latency

XByteField

5

class scapy.layers.bluetooth.HCI_LE_Meta_Connection_Update_Complete

Bases: scapy.packet.Packet

aliastypes
fields_desc
HCI_LE_Meta_Connection_Update_Complete fields

status

ByteEnumField

0

handle

LEShortField

0

interval

LEShortField

54

latency

LEShortField

0

timeout

LEShortField

42

class scapy.layers.bluetooth.HCI_LE_Meta_Long_Term_Key_Request

Bases: scapy.packet.Packet

aliastypes
fields_desc
HCI_LE_Meta_Long_Term_Key_Request fields

handle

LEShortField

0

rand

StrFixedLenField

None

ediv

XLEShortField

0

class scapy.layers.bluetooth.HCI_PHDR_Hdr

Bases: scapy.packet.Packet

aliastypes
fields_desc
HCI_PHDR_Hdr fields

direction

IntField

0

payload_guess

Possible sublayers: HCI_Hdr

class scapy.layers.bluetooth.L2CAP_CmdHdr

Bases: scapy.packet.Packet

aliastypes
answers(other)
fields_desc
L2CAP_CmdHdr fields

code

ByteEnumField

8

id

ByteField

0

len

LEShortField

None

payload_guess

Possible sublayers: L2CAP_CmdRej, L2CAP_ConfReq, L2CAP_ConfResp, L2CAP_ConnReq, L2CAP_ConnResp, L2CAP_Connection_Parameter_Update_Request, L2CAP_Connection_Parameter_Update_Response, L2CAP_DisconnReq, L2CAP_DisconnResp, L2CAP_InfoReq, L2CAP_InfoResp

post_build(p, pay)
class scapy.layers.bluetooth.L2CAP_CmdRej

Bases: scapy.packet.Packet

aliastypes
fields_desc
L2CAP_CmdRej fields

reason

LEShortField

0

class scapy.layers.bluetooth.L2CAP_ConfReq

Bases: scapy.packet.Packet

aliastypes
fields_desc
L2CAP_ConfReq fields

dcid

LEShortField

0

flags

LEShortField

0

class scapy.layers.bluetooth.L2CAP_ConfResp

Bases: scapy.packet.Packet

aliastypes
answers(other)
fields_desc
L2CAP_ConfResp fields

scid

LEShortField

0

flags

LEShortField

0

result

LEShortEnumField

0

class scapy.layers.bluetooth.L2CAP_ConnReq

Bases: scapy.packet.Packet

aliastypes
fields_desc
L2CAP_ConnReq fields

psm

LEShortEnumField

0

scid

LEShortField

0

class scapy.layers.bluetooth.L2CAP_ConnResp

Bases: scapy.packet.Packet

aliastypes
answers(other)
fields_desc
L2CAP_ConnResp fields

dcid

LEShortField

0

scid

LEShortField

0

result

LEShortEnumField

0

status

LEShortEnumField

0

class scapy.layers.bluetooth.L2CAP_Connection_Parameter_Update_Request

Bases: scapy.packet.Packet

aliastypes
fields_desc
L2CAP_Connection_Parameter_Update_Request fields

min_interval

LEShortField

0

max_interval

LEShortField

0

slave_latency

LEShortField

0

timeout_mult

LEShortField

0

class scapy.layers.bluetooth.L2CAP_Connection_Parameter_Update_Response

Bases: scapy.packet.Packet

aliastypes
fields_desc
L2CAP_Connection_Parameter_Update_Response fields

move_result

LEShortField

0

class scapy.layers.bluetooth.L2CAP_DisconnReq

Bases: scapy.packet.Packet

aliastypes
fields_desc
L2CAP_DisconnReq fields

dcid

LEShortField

0

scid

LEShortField

0

class scapy.layers.bluetooth.L2CAP_DisconnResp

Bases: scapy.packet.Packet

aliastypes
answers(other)
fields_desc
L2CAP_DisconnResp fields

dcid

LEShortField

0

scid

LEShortField

0

class scapy.layers.bluetooth.L2CAP_Hdr

Bases: scapy.packet.Packet

aliastypes
fields_desc
L2CAP_Hdr fields

len

LEShortField

None

cid

LEShortEnumField

0

payload_guess

Possible sublayers: ATT_Hdr, L2CAP_CmdHdr, SM_Hdr

post_build(p, pay)
class scapy.layers.bluetooth.L2CAP_InfoReq

Bases: scapy.packet.Packet

aliastypes
fields_desc
L2CAP_InfoReq fields

type

LEShortEnumField

0

data

StrField

b''

class scapy.layers.bluetooth.L2CAP_InfoResp

Bases: scapy.packet.Packet

aliastypes
answers(other)
fields_desc
L2CAP_InfoResp fields

type

LEShortField

0

result

LEShortEnumField

0

data

StrField

b''

class scapy.layers.bluetooth.LEMACField(name, default)

Bases: scapy.fields.Field

any2i(pkt, x)
i2m(pkt, x)
i2repr(pkt, x)
m2i(pkt, x)
randval()
class scapy.layers.bluetooth.LowEnergyBeaconHelper

Bases: object

Helpers for building packets for Bluetooth Low Energy Beacons.

Implementors provide a build_eir() implementation.

This is designed to be used as a mix-in – see scapy.contrib.eddystone and scapy.contrib.ibeacon for examples.

base_eir = [<EIR_Hdr type=flags |<EIR_Flags flags=general_disc_mode+br_edr_not_supported |>>]
build_advertising_report()

Builds a HCI_LE_Meta_Advertising_Report containing this frame.

Return type

scapy.bluetooth.HCI_LE_Meta_Advertising_Report

build_eir()

Builds a list of EIR messages to wrap this frame.

Users of this helper must implement this method.

Returns

List of HCI_Hdr with payloads that describe this beacon type

Return type

list[scapy.bluetooth.HCI_Hdr]

build_set_advertising_data()

Builds a HCI_Cmd_LE_Set_Advertising_Data containing this frame.

This includes the HCI_Hdr and HCI_Command_Hdr layers.

Return type

scapy.bluetooth.HCI_Hdr

class scapy.layers.bluetooth.SM_Confirm

Bases: scapy.packet.Packet

aliastypes
fields_desc
SM_Confirm fields

confirm

StrFixedLenField

b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'

class scapy.layers.bluetooth.SM_DHKey_Check

Bases: scapy.packet.Packet

aliastypes
fields_desc
SM_DHKey_Check fields

dhkey_check

StrFixedLenField

b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'

class scapy.layers.bluetooth.SM_Encryption_Information

Bases: scapy.packet.Packet

aliastypes
fields_desc
SM_Encryption_Information fields

ltk

StrFixedLenField

b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'

class scapy.layers.bluetooth.SM_Failed

Bases: scapy.packet.Packet

aliastypes
fields_desc
SM_Failed fields

reason

XByteField

0

class scapy.layers.bluetooth.SM_Hdr

Bases: scapy.packet.Packet

aliastypes
fields_desc
SM_Hdr fields

sm_command

ByteField

None

payload_guess

Possible sublayers: SM_Confirm, SM_DHKey_Check, SM_Encryption_Information, SM_Failed, SM_Identity_Address_Information, SM_Identity_Information, SM_Master_Identification, SM_Pairing_Request, SM_Pairing_Response, SM_Public_Key, SM_Random, SM_Signing_Information

class scapy.layers.bluetooth.SM_Identity_Address_Information

Bases: scapy.packet.Packet

aliastypes
fields_desc
SM_Identity_Address_Information fields

atype

ByteEnumField

0

address

LEMACField

None

class scapy.layers.bluetooth.SM_Identity_Information

Bases: scapy.packet.Packet

aliastypes
fields_desc
SM_Identity_Information fields

irk

StrFixedLenField

b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'

class scapy.layers.bluetooth.SM_Master_Identification

Bases: scapy.packet.Packet

aliastypes
fields_desc
SM_Master_Identification fields

ediv

XLEShortField

0

rand

StrFixedLenField

b'\x00\x00\x00\x00\x00\x00\x00\x00'

class scapy.layers.bluetooth.SM_Pairing_Request

Bases: scapy.packet.Packet

aliastypes
fields_desc
SM_Pairing_Request fields

iocap

ByteEnumField

3

oob

ByteEnumField

0

authentication

BitField (8 bits)

0

max_key_size

ByteField

16

initiator_key_distribution

ByteField

0

responder_key_distribution

ByteField

0

class scapy.layers.bluetooth.SM_Pairing_Response

Bases: scapy.packet.Packet

aliastypes
fields_desc
SM_Pairing_Response fields

iocap

ByteEnumField

3

oob

ByteEnumField

0

authentication

BitField (8 bits)

0

max_key_size

ByteField

16

initiator_key_distribution

ByteField

0

responder_key_distribution

ByteField

0

class scapy.layers.bluetooth.SM_Public_Key

Bases: scapy.packet.Packet

aliastypes
fields_desc
SM_Public_Key fields

key_x

StrFixedLenField

b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'

key_y

StrFixedLenField

b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'

class scapy.layers.bluetooth.SM_Random

Bases: scapy.packet.Packet

aliastypes
fields_desc
SM_Random fields

random

StrFixedLenField

b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'

class scapy.layers.bluetooth.SM_Signing_Information

Bases: scapy.packet.Packet

aliastypes
fields_desc
SM_Signing_Information fields

csrk

StrFixedLenField

b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'

class scapy.layers.bluetooth.XLEShortField(name, default)

Bases: scapy.fields.LEShortField

i2repr(pkt, x)
class scapy.layers.bluetooth.sockaddr_hci

Bases: _ctypes.Structure

hci_channel

Structure/Union member

hci_dev

Structure/Union member

sin_family

Structure/Union member

scapy.layers.bluetooth.srbt(bt_address, pkts, inter=0.1, *args, **kargs)

send and receive using a bluetooth socket

scapy.layers.bluetooth.srbt1(bt_address, pkts, *args, **kargs)

send and receive 1 packet using a bluetooth socket