scapy.contrib.automotive.gm.gmlanutils

scapy.contrib.automotive.gm.gmlanutils.GMLAN_BroadcastSocket(interface: str) SuperSocket[source]

Returns a GMLAN broadcast socket using interface.

Parameters:

interface – interface name

Returns:

ISOTPSocket configured as GMLAN Broadcast Socket

scapy.contrib.automotive.gm.gmlanutils.GMLAN_GetSecurityAccess(sock: SuperSocket, key_function: Callable[[int], int], level: int = 1, timeout: int | None = None, retry: int = 0, unittest: bool = False) bool[source]

Authenticate on ECU. Implements Seey-Key procedure.

Parameters:
  • sock – socket to send the message on.

  • key_function – function implementing the key algorithm.

  • level – level of access

  • timeout – timeout for sending, receiving or sniffing packages.

  • retry – number of retries in case of failure.

  • unittest – disable internal delays

Returns:

True on success.

scapy.contrib.automotive.gm.gmlanutils.GMLAN_InitDiagnostics(sock: SuperSocket, broadcast_socket: SuperSocket | None = None, timeout: int = 1, retry: int = 0, unittest: bool = False) bool[source]

Send messages to put an ECU into diagnostic/programming state.

Parameters:
  • sock – socket for communication.

  • broadcast_socket – socket for broadcasting. If provided some message will be sent as broadcast. Recommended when used on a network with several ECUs.

  • timeout – timeout for sending, receiving or sniffing packages.

  • retry – number of retries in case of failure.

  • unittest – disable delays

Returns:

True on success else False

scapy.contrib.automotive.gm.gmlanutils.GMLAN_ReadMemoryByAddress(sock: SuperSocket, addr: int, length: int, timeout: int | None = None, retry: int = 0) bytes | None[source]

Read data from ECU memory.

Parameters:
  • sock – socket to send the data on.

  • addr – source memory address on the ECU.

  • length – bytes to read.

  • timeout – timeout for sending, receiving or sniffing packages.

  • retry – number of retries in case of failure.

Returns:

bytes red or None

scapy.contrib.automotive.gm.gmlanutils.GMLAN_RequestDownload(sock: SuperSocket, length: int, timeout: int | None = None, retry: int = 0) bool[source]

Send RequestDownload message.

Usually used before calling TransferData.

Parameters:
  • sock – socket to send the message on.

  • length – value for the message’s parameter ‘unCompressedMemorySize’.

  • timeout – timeout for sending, receiving or sniffing packages.

  • retry – number of retries in case of failure.

Returns:

True on success

class scapy.contrib.automotive.gm.gmlanutils.GMLAN_TesterPresentSender(sock: ~scapy.supersocket.SuperSocket, pkt: ~scapy.packet.Packet = <GMLAN  service=TesterPresent |>, interval: int = 2)[source]

Bases: PeriodicSenderThread

run() None[source]
scapy.contrib.automotive.gm.gmlanutils.GMLAN_TransferData(sock: SuperSocket, addr: int, payload: bytes, maxmsglen: int | None = None, timeout: int | None = None, retry: int = 0) bool[source]

Send TransferData message.

Usually used after calling RequestDownload.

Parameters:
  • sock – socket to send the message on.

  • addr – destination memory address on the ECU.

  • payload – data to be sent.

  • maxmsglen – maximum length of a single iso-tp message. default: maximum length

  • timeout – timeout for sending, receiving or sniffing packages.

  • retry – number of retries in case of failure.

Returns:

True on success.

scapy.contrib.automotive.gm.gmlanutils.GMLAN_TransferPayload(sock: SuperSocket, addr: int, payload: bytes, maxmsglen: int | None = None, timeout: int | None = None, retry: int = 0) bool[source]

Send data by using GMLAN services.

Parameters:
  • sock – socket to send the data on.

  • addr – destination memory address on the ECU.

  • payload – data to be sent.

  • maxmsglen – maximum length of a single iso-tp message. default: maximum length

  • timeout – timeout for sending, receiving or sniffing packages.

  • retry – number of retries in case of failure.

Returns:

True on success.