scapy.contrib.automotive.bmw.hsfz

class scapy.contrib.automotive.bmw.hsfz.HSFZ(_pkt, /, *, length=None, control=1, source=0, target=0, identification_string=None)[source]

Bases: Packet

aliastypes
control_words = {1: 'diagnostic_req_res', 2: 'acknowledge_transfer', 16: 'terminal15', 17: 'vehicle_ident_data', 18: 'alive_check', 19: 'status_data_inquiry', 64: 'incorrect_tester_address', 65: 'incorrect_control_word', 66: 'incorrect_format', 67: 'incorrect_dest_address', 68: 'message_too_large', 69: 'diag_app_not_ready', 255: 'out_of_memory'}
extract_padding(s: bytes) Tuple[bytes, bytes][source]
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                             LENGTH                            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|            CONTROL            |     SOURCE    |     TARGET    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|     IDENTIFICATION STRING     |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                            Fig. HSFZ                             
HSFZ fields

length

IntField

None

control

ShortEnumField

1

source

XByteField (Cond)

0

target

XByteField (Cond)

0

identification_string

StrFixedLenField (Cond)

None

hashret() bytes[source]
payload_guess

Possible sublayers: UDS

post_build(pkt: bytes, pay: bytes) bytes[source]

This will set the LenField ‘length’ to the correct value.

class scapy.contrib.automotive.bmw.hsfz.HSFZSocket(ip: str = '127.0.0.1', port: int = 6801)[source]

Bases: StreamSocket

recv(x: int | None = 65535, **kwargs: Any) Packet | None[source]
class scapy.contrib.automotive.bmw.hsfz.UDS_HSFZSocket(source: int, target: int, ip: str = '127.0.0.1', port: int = 6801, basecls: ~typing.Type[~scapy.packet.Packet] = <class 'scapy.contrib.automotive.uds.UDS'>)[source]

Bases: HSFZSocket

recv(x: int | None = 65535, **kwargs: Any) Packet | None[source]
send(x: Packet) int[source]
scapy.contrib.automotive.bmw.hsfz.hsfz_scan(ip: str, scan_range: Iterable[int] = range(0, 256), source: int = 244, timeout: int | float = 0.1, verbose: bool = True) List[UDS_HSFZSocket][source]

Helper function to scan for HSFZ endpoints.

Example

>>> sockets = hsfz_scan("192.168.0.42")
Parameters:
  • ip – IPv4 address of target to scan

  • scan_range – Range for HSFZ destination address

  • source – HSFZ source address, used during the scan

  • timeout – Timeout for each request

  • verbose – Show information during scan, if True

Returns:

A list of open UDS_HSFZSockets