scapy.contrib.automotive.gm.gmlanutils

scapy.contrib.automotive.gm.gmlanutils.GMLAN_BroadcastSocket(interface: str) ISOTPSoftSocket[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: ISOTPSoftSocket, key_function: Callable[[int], int], level: int = 1, timeout: Optional[int] = None, verbose: Optional[bool] = None, retry: int = 0) 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.

  • verbose – set verbosity level

  • retry – number of retries in case of failure.

Returns:

True on success.

scapy.contrib.automotive.gm.gmlanutils.GMLAN_InitDiagnostics(sock: ISOTPSoftSocket, broadcast_socket: Optional[ISOTPSoftSocket] = None, timeout: Optional[int] = None, verbose: Optional[bool] = None, retry: int = 0) 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.

  • verbose – set verbosity level

  • retry – number of retries in case of failure.

Returns:

True on success else False

scapy.contrib.automotive.gm.gmlanutils.GMLAN_ReadMemoryByAddress(sock: ISOTPSoftSocket, addr: int, length: int, timeout: Optional[int] = None, verbose: Optional[bool] = None, retry: int = 0) Optional[bytes][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.

  • verbose – set verbosity level.

  • retry – number of retries in case of failure.

Returns:

bytes red or None

scapy.contrib.automotive.gm.gmlanutils.GMLAN_RequestDownload(sock: ISOTPSoftSocket, length: int, timeout: Optional[int] = None, verbose: Optional[bool] = 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.

  • verbose – set verbosity level.

  • retry – number of retries in case of failure.

Returns:

True on success

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

Bases: PeriodicSenderThread

run() None[source]
scapy.contrib.automotive.gm.gmlanutils.GMLAN_TransferData(sock: ISOTPSoftSocket, addr: int, payload: bytes, maxmsglen: Optional[int] = None, timeout: Optional[int] = None, verbose: Optional[bool] = 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.

  • verbose – set verbosity level.

  • retry – number of retries in case of failure.

Returns:

True on success.

scapy.contrib.automotive.gm.gmlanutils.GMLAN_TransferPayload(sock: ISOTPSoftSocket, addr: int, payload: bytes, maxmsglen: Optional[int] = None, timeout: Optional[int] = None, verbose: Optional[bool] = 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.

  • verbose – set verbosity level.

  • retry – number of retries in case of failure.

Returns:

True on success.