scapy.contrib.automotive.uds_scan

class scapy.contrib.automotive.uds_scan.UDS_CCEnumerator[source]

Bases: UDS_Enumerator

class scapy.contrib.automotive.uds_scan.UDS_DSCEnumerator[source]

Bases: UDS_Enumerator, StateGeneratingServiceEnumerator

static enter_state(socket: SuperSocket | SingleConversationSocket, configuration: AutomotiveTestCaseExecutorConfiguration, request: Packet) bool[source]
static enter_state_with_tp(sock: SuperSocket | SingleConversationSocket, conf: AutomotiveTestCaseExecutorConfiguration, kwargs: Dict[str, Any]) bool[source]
execute(socket: SuperSocket | SingleConversationSocket, state: EcuState, **kwargs: Any) None[source]
Parameters:
  • timeout (integer or float) – Timeout until a response will arrive after a request

  • count (integer) – Number of request to be sent in one execution

  • execution_time (int) – Time in seconds until the execution of this enumerator is stopped.

  • state_allow_list (EcuState or list) – List of EcuState objects or EcuState object in which the the execution of this enumerator is allowed. If provided, other states will not be executed.

  • state_block_list (EcuState or list) – List of EcuState objects or EcuState object in which the the execution of this enumerator is blocked.

  • retry_if_none_received (bool) – Specifies if a request will be send again, if None was received (usually because of a timeout).

  • exit_if_no_answer_received (bool) – Specifies to finish the execution of this enumerator once None is received.

  • exit_if_service_not_supported (bool) – Specifies to finish the execution of this enumerator, once the negative return code ‘serviceNotSupported’ is received.

  • exit_scan_on_first_negative_response (bool) – Specifies to finish the execution once a negative response is received.

  • retry_if_busy_returncode (bool) – Specifies to retry a request, if the ‘busyRepeatRequest’ negative response code is received.

  • debug (bool) – Enables debug functions during execute.

  • stop_event (Event) – Signals immediate stop of the execution.

  • scan_range (list or tuple or range or iterable) – Specifies the identifiers to be scanned.

  • delay_state_change (int) – Specifies an additional delay after after a session is modified from the transition function. In unit-test scenarios, this delay should be set to zero.

  • overwrite_timeout (bool) – True by default. This enumerator overwrites the timeout argument, since most ECUs take some time until a session is changed. This ensures that more results are gathered by default. In unit-test scenarios, this value should be set to False, in order to use the timeout specified by the ‘timeout’ argument.

get_new_edge(socket: SuperSocket | SingleConversationSocket, config: AutomotiveTestCaseExecutorConfiguration) Tuple[EcuState, EcuState] | None[source]
get_transition_function(socket: SuperSocket | SingleConversationSocket, edge: Tuple[EcuState, EcuState]) Tuple[Callable[[SuperSocket | SingleConversationSocket, AutomotiveTestCaseExecutorConfiguration, Dict[str, Any]], bool], Dict[str, Any], Callable[[SuperSocket | SingleConversationSocket, AutomotiveTestCaseExecutorConfiguration], bool] | None] | None[source]
class scapy.contrib.automotive.uds_scan.UDS_EREnumerator[source]

Bases: UDS_Enumerator

class scapy.contrib.automotive.uds_scan.UDS_Enumerator[source]

Bases: ServiceEnumerator, ABC

class scapy.contrib.automotive.uds_scan.UDS_IOCBIEnumerator[source]

Bases: UDS_Enumerator

class scapy.contrib.automotive.uds_scan.UDS_RCEnumerator[source]

Bases: UDS_Enumerator

class scapy.contrib.automotive.uds_scan.UDS_RCSelectiveEnumerator[source]

Bases: StagedAutomotiveTestCase

expansion_width = 253
static points_to_ranges(pois: Iterable[int]) Iterable[int][source]
class scapy.contrib.automotive.uds_scan.UDS_RCStartEnumerator[source]

Bases: UDS_RCEnumerator

class scapy.contrib.automotive.uds_scan.UDS_RDBIEnumerator[source]

Bases: UDS_Enumerator

static print_information(resp: Packet) str[source]
class scapy.contrib.automotive.uds_scan.UDS_RDBIRandomEnumerator[source]

Bases: UDS_RDBIEnumerator

block_size = 64
execute(socket: SuperSocket | SingleConversationSocket, state: EcuState, **kwargs: Any) None[source]
Parameters:
  • timeout (integer or float) – Timeout until a response will arrive after a request

  • count (integer) – Number of request to be sent in one execution

  • execution_time (int) – Time in seconds until the execution of this enumerator is stopped.

  • state_allow_list (EcuState or list) – List of EcuState objects or EcuState object in which the the execution of this enumerator is allowed. If provided, other states will not be executed.

  • state_block_list (EcuState or list) – List of EcuState objects or EcuState object in which the the execution of this enumerator is blocked.

  • retry_if_none_received (bool) – Specifies if a request will be send again, if None was received (usually because of a timeout).

  • exit_if_no_answer_received (bool) – Specifies to finish the execution of this enumerator once None is received.

  • exit_if_service_not_supported (bool) – Specifies to finish the execution of this enumerator, once the negative return code ‘serviceNotSupported’ is received.

  • exit_scan_on_first_negative_response (bool) – Specifies to finish the execution once a negative response is received.

  • retry_if_busy_returncode (bool) – Specifies to retry a request, if the ‘busyRepeatRequest’ negative response code is received.

  • debug (bool) – Enables debug functions during execute.

  • stop_event (Event) – Signals immediate stop of the execution.

  • scan_range (list or tuple or range or iterable) – Specifies the identifiers to be scanned.

  • probe_start (int) – Specifies the start identifier for probing.

  • probe_end (int) – Specifies the end identifier for probing.

class scapy.contrib.automotive.uds_scan.UDS_RDBISelectiveEnumerator[source]

Bases: StagedAutomotiveTestCase

static points_to_blocks(pois: Sequence[int]) Iterable[int][source]
class scapy.contrib.automotive.uds_scan.UDS_RDBPIEnumerator[source]

Bases: UDS_Enumerator

class scapy.contrib.automotive.uds_scan.UDS_RDEnumerator[source]

Bases: UDS_Enumerator

execute(socket: SuperSocket | SingleConversationSocket, state: EcuState, **kwargs: Any) None[source]
Parameters:
  • timeout (integer or float) – Timeout until a response will arrive after a request

  • count (integer) – Number of request to be sent in one execution

  • execution_time (int) – Time in seconds until the execution of this enumerator is stopped.

  • state_allow_list (EcuState or list) – List of EcuState objects or EcuState object in which the the execution of this enumerator is allowed. If provided, other states will not be executed.

  • state_block_list (EcuState or list) – List of EcuState objects or EcuState object in which the the execution of this enumerator is blocked.

  • retry_if_none_received (bool) – Specifies if a request will be send again, if None was received (usually because of a timeout).

  • exit_if_no_answer_received (bool) – Specifies to finish the execution of this enumerator once None is received.

  • exit_if_service_not_supported (bool) – Specifies to finish the execution of this enumerator, once the negative return code ‘serviceNotSupported’ is received.

  • exit_scan_on_first_negative_response (bool) – Specifies to finish the execution once a negative response is received.

  • retry_if_busy_returncode (bool) – Specifies to retry a request, if the ‘busyRepeatRequest’ negative response code is received.

  • debug (bool) – Enables debug functions during execute.

  • stop_event (Event) – Signals immediate stop of the execution.

  • scan_range (list or tuple or range or iterable) – Specifies the identifiers to be scanned.

  • unittest (bool) – Enables smaller search space for unit-test scenarios. This safes execution time.

class scapy.contrib.automotive.uds_scan.UDS_RMBAEnumerator[source]

Bases: StagedAutomotiveTestCase

class scapy.contrib.automotive.uds_scan.UDS_RMBAEnumeratorABC[source]

Bases: UDS_Enumerator

static get_addr(pkt: UDS_RMBA) int[source]

Helper function to get the memoryAddress from a UDS_RMBA packet :param pkt: UDS_RMBA request :return: memory address of the request

static get_size(pkt: UDS_RMBA) int[source]

Helper function to gets the memorySize of a UDS_RMBA packet :param pkt: UDS_RMBA request

static set_addr(pkt: UDS_RMBA, addr: int) None[source]

Helper function to set the memoryAddress of a UDS_RMBA packet :param pkt: UDS_RMBA request :param addr: memory address to be set

static set_size(pkt: UDS_RMBA, size: int) None[source]

Helper function to set the memorySize of a UDS_RMBA packet :param pkt: UDS_RMBA request :param size: memory size to be set

class scapy.contrib.automotive.uds_scan.UDS_RMBARandomEnumerator[source]

Bases: UDS_RMBAEnumeratorABC

execute(socket: SuperSocket | SingleConversationSocket, state: EcuState, **kwargs: Any) None[source]
Parameters:
  • timeout (integer or float) – Timeout until a response will arrive after a request

  • count (integer) – Number of request to be sent in one execution

  • execution_time (int) – Time in seconds until the execution of this enumerator is stopped.

  • state_allow_list (EcuState or list) – List of EcuState objects or EcuState object in which the the execution of this enumerator is allowed. If provided, other states will not be executed.

  • state_block_list (EcuState or list) – List of EcuState objects or EcuState object in which the the execution of this enumerator is blocked.

  • retry_if_none_received (bool) – Specifies if a request will be send again, if None was received (usually because of a timeout).

  • exit_if_no_answer_received (bool) – Specifies to finish the execution of this enumerator once None is received.

  • exit_if_service_not_supported (bool) – Specifies to finish the execution of this enumerator, once the negative return code ‘serviceNotSupported’ is received.

  • exit_scan_on_first_negative_response (bool) – Specifies to finish the execution once a negative response is received.

  • retry_if_busy_returncode (bool) – Specifies to retry a request, if the ‘busyRepeatRequest’ negative response code is received.

  • debug (bool) – Enables debug functions during execute.

  • stop_event (Event) – Signals immediate stop of the execution.

  • scan_range (list or tuple or range or iterable) – Specifies the identifiers to be scanned.

  • unittest (bool) – Enables smaller search space for unit-test scenarios. This saves execution time.

class scapy.contrib.automotive.uds_scan.UDS_RMBASequentialEnumerator[source]

Bases: UDS_RMBAEnumeratorABC

execute(socket: SuperSocket | SingleConversationSocket, state: EcuState, **kwargs: Any) None[source]
Parameters:
  • timeout (integer or float) – Timeout until a response will arrive after a request

  • count (integer) – Number of request to be sent in one execution

  • execution_time (int) – Time in seconds until the execution of this enumerator is stopped.

  • state_allow_list (EcuState or list) – List of EcuState objects or EcuState object in which the the execution of this enumerator is allowed. If provided, other states will not be executed.

  • state_block_list (EcuState or list) – List of EcuState objects or EcuState object in which the the execution of this enumerator is blocked.

  • retry_if_none_received (bool) – Specifies if a request will be send again, if None was received (usually because of a timeout).

  • exit_if_no_answer_received (bool) – Specifies to finish the execution of this enumerator once None is received.

  • exit_if_service_not_supported (bool) – Specifies to finish the execution of this enumerator, once the negative return code ‘serviceNotSupported’ is received.

  • exit_scan_on_first_negative_response (bool) – Specifies to finish the execution once a negative response is received.

  • retry_if_busy_returncode (bool) – Specifies to retry a request, if the ‘busyRepeatRequest’ negative response code is received.

  • debug (bool) – Enables debug functions during execute.

  • stop_event (Event) – Signals immediate stop of the execution.

  • scan_range (list or tuple or range or iterable) – Specifies the identifiers to be scanned.

  • points_of_interest (list) – A list of _PointOfInterest objects as starting points for sequential search.

pre_execute(socket: SuperSocket | SingleConversationSocket, state: EcuState, global_configuration: AutomotiveTestCaseExecutorConfiguration) None[source]
show(dump: bool = False, filtered: bool = True, verbose: bool = False) str | None[source]
class scapy.contrib.automotive.uds_scan.UDS_SAEnumerator[source]

Bases: UDS_Enumerator

static evaluate_security_access_response(res: Packet | None, seed: Packet, key: Packet | None) bool[source]
static get_seed_pkt(sock: SuperSocket | SingleConversationSocket, level: int = 1, record: bytes = b'') Packet | None[source]
pre_execute(socket: SuperSocket | SingleConversationSocket, state: EcuState, global_configuration: AutomotiveTestCaseExecutorConfiguration) None[source]
class scapy.contrib.automotive.uds_scan.UDS_SA_XOR_Enumerator[source]

Bases: UDS_SAEnumerator, StateGenerator

static get_key_pkt(seed: Packet, level: int = 1) Packet | None[source]
get_new_edge(socket: SuperSocket | SingleConversationSocket, config: AutomotiveTestCaseExecutorConfiguration) Tuple[EcuState, EcuState] | None[source]
get_security_access(sock: SuperSocket | SingleConversationSocket, level: int = 1, seed_pkt: Packet | None = None) bool[source]
get_transition_function(socket: SuperSocket | SingleConversationSocket, edge: Tuple[EcuState, EcuState]) Tuple[Callable[[SuperSocket | SingleConversationSocket, AutomotiveTestCaseExecutorConfiguration, Dict[str, Any]], bool], Dict[str, Any], Callable[[SuperSocket | SingleConversationSocket, AutomotiveTestCaseExecutorConfiguration], bool] | None] | None[source]
transition_function(sock: SuperSocket | SingleConversationSocket, _: AutomotiveTestCaseExecutorConfiguration, kwargs: Dict[str, Any]) bool[source]
class scapy.contrib.automotive.uds_scan.UDS_Scanner(socket: SuperSocket | SingleConversationSocket, reset_handler: Callable[[], None] | None = None, reconnect_handler: Callable[[], SuperSocket | SingleConversationSocket] | None = None, test_cases: List[AutomotiveTestCaseABC | Type[AutomotiveTestCaseABC]] | None = None, **kwargs: Dict[str, Any] | None)[source]

Bases: AutomotiveTestCaseExecutor

Example

>>> def reconnect():
>>>     return UDS_DoIPSocket("169.254.186.237")
>>>
>>> es = [UDS_ServiceEnumerator, UDS_DSCEnumerator]
>>>
>>> def reset():
>>>     reconnect().sr1(UDS()/UDS_ER(resetType="hardReset"),
>>>                     verbose=False, timeout=1)
>>>
>>> s = UDS_Scanner(reconnect(), reconnect_handler=reconnect,
>>>                 reset_handler=reset, test_cases=es,
>>>                 UDS_DSCEnumerator_kwargs={
>>>                     "timeout": 20,
>>>                     "overwrite_timeout": False,
>>>                     "scan_range": [1, 3]})
>>>
>>> try:
>>>     s.scan()
>>> except KeyboardInterrupt:
>>>     pass
>>>
>>> s.show_testcases_status()
>>> s.show_testcases()
property default_test_case_clss: List[Type[AutomotiveTestCaseABC]]
class scapy.contrib.automotive.uds_scan.UDS_ServiceEnumerator[source]

Bases: UDS_Enumerator

execute(socket: SuperSocket | SingleConversationSocket, state: EcuState, **kwargs: Any) None[source]
Parameters:
  • timeout (integer or float) – Timeout until a response will arrive after a request

  • count (integer) – Number of request to be sent in one execution

  • execution_time (int) – Time in seconds until the execution of this enumerator is stopped.

  • state_allow_list (EcuState or list) – List of EcuState objects or EcuState object in which the the execution of this enumerator is allowed. If provided, other states will not be executed.

  • state_block_list (EcuState or list) – List of EcuState objects or EcuState object in which the the execution of this enumerator is blocked.

  • retry_if_none_received (bool) – Specifies if a request will be send again, if None was received (usually because of a timeout).

  • exit_if_no_answer_received (bool) – Specifies to finish the execution of this enumerator once None is received.

  • exit_if_service_not_supported (bool) – Specifies to finish the execution of this enumerator, once the negative return code ‘serviceNotSupported’ is received.

  • exit_scan_on_first_negative_response (bool) – Specifies to finish the execution once a negative response is received.

  • retry_if_busy_returncode (bool) – Specifies to retry a request, if the ‘busyRepeatRequest’ negative response code is received.

  • debug (bool) – Enables debug functions during execute.

  • stop_event (Event) – Signals immediate stop of the execution.

  • scan_range (list or tuple or range or iterable) – Specifies the identifiers to be scanned.

  • request_length (int) – Specifies the maximum length of arequest packet. The enumerator will generate all packets from a length of 1 (UDS Service ID only) up to the specified request_length.

class scapy.contrib.automotive.uds_scan.UDS_TDEnumerator[source]

Bases: UDS_Enumerator

class scapy.contrib.automotive.uds_scan.UDS_TPEnumerator[source]

Bases: UDS_Enumerator, StateGeneratingServiceEnumerator

static cleanup(_: SuperSocket | SingleConversationSocket, configuration: AutomotiveTestCaseExecutorConfiguration) bool[source]
static enter(socket: SuperSocket | SingleConversationSocket, configuration: AutomotiveTestCaseExecutorConfiguration, _: Dict[str, Any]) bool[source]
get_transition_function(socket: SuperSocket | SingleConversationSocket, edge: Tuple[EcuState, EcuState]) Tuple[Callable[[SuperSocket | SingleConversationSocket, AutomotiveTestCaseExecutorConfiguration, Dict[str, Any]], bool], Dict[str, Any], Callable[[SuperSocket | SingleConversationSocket, AutomotiveTestCaseExecutorConfiguration], bool] | None] | None[source]
class scapy.contrib.automotive.uds_scan.UDS_WDBIEnumerator[source]

Bases: UDS_Enumerator

execute(socket: SuperSocket | SingleConversationSocket, state: EcuState, **kwargs: Any) None[source]
Parameters:
  • timeout (integer or float) – Timeout until a response will arrive after a request

  • count (integer) – Number of request to be sent in one execution

  • execution_time (int) – Time in seconds until the execution of this enumerator is stopped.

  • state_allow_list (EcuState or list) – List of EcuState objects or EcuState object in which the the execution of this enumerator is allowed. If provided, other states will not be executed.

  • state_block_list (EcuState or list) – List of EcuState objects or EcuState object in which the the execution of this enumerator is blocked.

  • retry_if_none_received (bool) – Specifies if a request will be send again, if None was received (usually because of a timeout).

  • exit_if_no_answer_received (bool) – Specifies to finish the execution of this enumerator once None is received.

  • exit_if_service_not_supported (bool) – Specifies to finish the execution of this enumerator, once the negative return code ‘serviceNotSupported’ is received.

  • exit_scan_on_first_negative_response (bool) – Specifies to finish the execution once a negative response is received.

  • retry_if_busy_returncode (bool) – Specifies to retry a request, if the ‘busyRepeatRequest’ negative response code is received.

  • debug (bool) – Enables debug functions during execute.

  • stop_event (Event) – Signals immediate stop of the execution.

  • scan_range (list or tuple or range or iterable) – Specifies the identifiers to be scanned.

  • rdbi_enumerator (UDS_RDBIEnumerator) – Specifies an instance of an UDS_RDBIEnumerator which is used to extract possible data identifiers.

class scapy.contrib.automotive.uds_scan.UDS_WDBISelectiveEnumerator[source]

Bases: StagedAutomotiveTestCase