scapy.contrib.automotive.uds_scan

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

Bases: scapy.contrib.automotive.uds_scan.UDS_Enumerator

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

Bases: scapy.contrib.automotive.uds_scan.UDS_Enumerator, scapy.contrib.automotive.scanner.enumerator.StateGeneratingServiceEnumerator

static enter_state(socket: Union[scapy.supersocket.SuperSocket, scapy.utils.SingleConversationSocket], configuration: scapy.contrib.automotive.scanner.configuration.AutomotiveTestCaseExecutorConfiguration, request: scapy.packet.Packet) bool[source]
static enter_state_with_tp(sock: Union[scapy.supersocket.SuperSocket, scapy.utils.SingleConversationSocket], conf: scapy.contrib.automotive.scanner.configuration.AutomotiveTestCaseExecutorConfiguration, kwargs: Dict[str, Any]) bool[source]
execute(socket: Union[scapy.supersocket.SuperSocket, scapy.utils.SingleConversationSocket], state: scapy.contrib.automotive.ecu.EcuState, **kwargs: Any) None[source]
Parameters
  • timeout (integer or float) – Timeout until a response will arrive after a request

  • 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.

  • 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: Union[scapy.supersocket.SuperSocket, scapy.utils.SingleConversationSocket], config: scapy.contrib.automotive.scanner.configuration.AutomotiveTestCaseExecutorConfiguration) Optional[Tuple[scapy.contrib.automotive.ecu.EcuState, scapy.contrib.automotive.ecu.EcuState]][source]
get_transition_function(socket: Union[scapy.supersocket.SuperSocket, scapy.utils.SingleConversationSocket], edge: Tuple[scapy.contrib.automotive.ecu.EcuState, scapy.contrib.automotive.ecu.EcuState]) Optional[Tuple[Callable[[Union[scapy.supersocket.SuperSocket, scapy.utils.SingleConversationSocket], scapy.contrib.automotive.scanner.configuration.AutomotiveTestCaseExecutorConfiguration, Dict[str, Any]], bool], Dict[str, Any], Optional[Callable[[Union[scapy.supersocket.SuperSocket, scapy.utils.SingleConversationSocket], scapy.contrib.automotive.scanner.configuration.AutomotiveTestCaseExecutorConfiguration], bool]]]][source]
class scapy.contrib.automotive.uds_scan.UDS_EREnumerator[source]

Bases: scapy.contrib.automotive.uds_scan.UDS_Enumerator

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

Bases: scapy.contrib.automotive.scanner.enumerator.ServiceEnumerator, abc.ABC

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

Bases: scapy.contrib.automotive.uds_scan.UDS_Enumerator

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

Bases: scapy.contrib.automotive.uds_scan.UDS_Enumerator

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

Bases: scapy.contrib.automotive.scanner.staged_test_case.StagedAutomotiveTestCase

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

Bases: scapy.contrib.automotive.uds_scan.UDS_RCEnumerator

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

Bases: scapy.contrib.automotive.uds_scan.UDS_Enumerator

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

Bases: scapy.contrib.automotive.uds_scan.UDS_RDBIEnumerator

block_size = 64
execute(socket: Union[scapy.supersocket.SuperSocket, scapy.utils.SingleConversationSocket], state: scapy.contrib.automotive.ecu.EcuState, **kwargs: Any) None[source]
Parameters
  • timeout (integer or float) – Timeout until a response will arrive after a request

  • 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.

  • 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: scapy.contrib.automotive.scanner.staged_test_case.StagedAutomotiveTestCase

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

Bases: scapy.contrib.automotive.uds_scan.UDS_Enumerator

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

Bases: scapy.contrib.automotive.uds_scan.UDS_Enumerator

execute(socket: Union[scapy.supersocket.SuperSocket, scapy.utils.SingleConversationSocket], state: scapy.contrib.automotive.ecu.EcuState, **kwargs: Any) None[source]
Parameters
  • timeout (integer or float) – Timeout until a response will arrive after a request

  • 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.

  • 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: scapy.contrib.automotive.scanner.staged_test_case.StagedAutomotiveTestCase

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

Bases: scapy.contrib.automotive.uds_scan.UDS_Enumerator

static get_addr(pkt: scapy.contrib.automotive.uds.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: scapy.contrib.automotive.uds.UDS_RMBA) int[source]

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

static set_addr(pkt: scapy.contrib.automotive.uds.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: scapy.contrib.automotive.uds.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: scapy.contrib.automotive.uds_scan.UDS_RMBAEnumeratorABC

execute(socket: Union[scapy.supersocket.SuperSocket, scapy.utils.SingleConversationSocket], state: scapy.contrib.automotive.ecu.EcuState, **kwargs: Any) None[source]
Parameters
  • timeout (integer or float) – Timeout until a response will arrive after a request

  • 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.

  • 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: scapy.contrib.automotive.uds_scan.UDS_RMBAEnumeratorABC

execute(socket: Union[scapy.supersocket.SuperSocket, scapy.utils.SingleConversationSocket], state: scapy.contrib.automotive.ecu.EcuState, **kwargs: Any) None[source]
Parameters
  • timeout (integer or float) – Timeout until a response will arrive after a request

  • 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.

  • 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: Union[scapy.supersocket.SuperSocket, scapy.utils.SingleConversationSocket], state: scapy.contrib.automotive.ecu.EcuState, global_configuration: scapy.contrib.automotive.scanner.configuration.AutomotiveTestCaseExecutorConfiguration) None[source]
show(dump: bool = False, filtered: bool = True, verbose: bool = False) Optional[str][source]
class scapy.contrib.automotive.uds_scan.UDS_SAEnumerator[source]

Bases: scapy.contrib.automotive.uds_scan.UDS_Enumerator

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

Bases: scapy.contrib.automotive.uds_scan.UDS_SAEnumerator, scapy.contrib.automotive.scanner.test_case.StateGenerator

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

Bases: scapy.contrib.automotive.scanner.executor.AutomotiveTestCaseExecutor

Example

>>> def reconnect():
>>>     return UDS_DoIPSocket("169.254.186.237")
>>>
>>> es = [UDS_ServiceEnumerator, UDS_WDBISelectiveEnumerator]
>>>
>>> s = UDS_Scanner(reconnect(), reconnect_handler=reconnect,
>>>                 reset_handler=reset_ecu, 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
class scapy.contrib.automotive.uds_scan.UDS_ServiceEnumerator[source]

Bases: scapy.contrib.automotive.uds_scan.UDS_Enumerator

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

Bases: scapy.contrib.automotive.uds_scan.UDS_Enumerator

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

Bases: scapy.contrib.automotive.uds_scan.UDS_Enumerator, scapy.contrib.automotive.scanner.enumerator.StateGeneratingServiceEnumerator

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

Bases: scapy.contrib.automotive.uds_scan.UDS_Enumerator

execute(socket: Union[scapy.supersocket.SuperSocket, scapy.utils.SingleConversationSocket], state: scapy.contrib.automotive.ecu.EcuState, **kwargs: Any) None[source]
Parameters
  • timeout (integer or float) – Timeout until a response will arrive after a request

  • 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.

  • 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: scapy.contrib.automotive.scanner.staged_test_case.StagedAutomotiveTestCase