scapy.contrib.isotp.isotp_scanner
- scapy.contrib.isotp.isotp_scanner.filter_periodic_packets(packet_dict: Dict[int, Tuple[Packet, int]]) None [source]
Filter to remove periodic packets from packet_dict
ISOTP-Filter for periodic packets (same ID, always same time-gaps) Deletes periodic packets in packet_dict
- Parameters
packet_dict – Dictionary, where the filter is applied
- scapy.contrib.isotp.isotp_scanner.generate_code_output(found_packets: Dict[int, Tuple[Packet, int]], can_interface: Optional[str] = 'iface', extended_addressing: bool = False) str [source]
Generate a copy&past-able output from the result of the scan or the scan_extended function.
- Parameters
found_packets – result of the scan or scan_extended function
can_interface – description string for a CAN interface to be used for the creation of the output.
extended_addressing – print results from a scan with ISOTP extended addressing
- Returns
Python-code as string to generate all found sockets
- scapy.contrib.isotp.isotp_scanner.generate_isotp_list(found_packets: Dict[int, Tuple[Packet, int]], can_interface: Union[SuperSocket, str], extended_addressing: bool = False) List[SuperSocket] [source]
Generate a list of ISOTPSocket objects from the result of the scan or the scan_extended function.
- Parameters
found_packets – result of the scan or scan_extended function
can_interface – description string for a CAN interface to be used for the creation of the output.
extended_addressing – print results from a scan with ISOTP extended addressing
- Returns
A list of all found ISOTPSockets
- scapy.contrib.isotp.isotp_scanner.generate_text_output(found_packets: Dict[int, Tuple[Packet, int]], extended_addressing: bool = False) str [source]
Generate a human readable output from the result of the scan or the scan_extended function.
- Parameters
found_packets – result of the scan or scan_extended function
extended_addressing – print results from a scan with ISOTP extended addressing
- Returns
human readable scan results
- scapy.contrib.isotp.isotp_scanner.get_isotp_fc(id_value: int, id_list: Union[List[int], Dict[int, Tuple[Packet, int]]], noise_ids: Optional[List[int]], extended: bool, packet: Packet) None [source]
Callback for sniff function when packet received
If received packet is a FlowControl and not in noise_ids append it to id_list.
- Parameters
id_value – packet id of send packet
id_list – list of received IDs
noise_ids – list of packet IDs which will not be considered when received during scan
extended – boolean if extended scan
packet – received packet
- scapy.contrib.isotp.isotp_scanner.get_isotp_packet(identifier: int = 0, extended: bool = False, extended_can_id: bool = False) Packet [source]
Craft ISO-TP packet
- Parameters
identifier – identifier of crafted packet
extended – boolean if packet uses extended address
extended_can_id – boolean if CAN should use extended Ids
- Returns
Crafted Packet
- scapy.contrib.isotp.isotp_scanner.isotp_scan(sock: SuperSocket, scan_range: Iterable[int] = range(0, 2048), extended_addressing: bool = False, extended_scan_range: Iterable[int] = range(0, 256), noise_listen_time: int = 2, sniff_time: float = 0.1, output_format: Optional[str] = None, can_interface: Optional[str] = None, extended_can_id: bool = False, verify_results: bool = True, verbose: bool = False, stop_event: Optional[Event] = None) Union[str, List[SuperSocket]] [source]
Scan for ISOTP Sockets on a bus and return findings
Scan for ISOTP Sockets in the defined range and returns found sockets in a specified format. The format can be:
text: human readable output
code: python code for copy&paste
sockets: if output format is not specified, ISOTPSockets will be created and returned in a list
- Parameters
sock – CANSocket object to communicate with the bus under scan
scan_range – range of CAN-Identifiers to scan. Default is 0x0 - 0x7ff
extended_addressing – scan with ISOTP extended addressing
extended_scan_range – range for ISOTP extended addressing values
noise_listen_time – seconds to listen for default communication on the bus
sniff_time – time the scan waits for isotp flow control responses after sending a first frame
output_format – defines the format of the returned results (text, code or sockets). Provide a string e.g. “text”. Default is “socket”.
can_interface – interface used to create the returned code/sockets
extended_can_id – Use Extended CAN-Frames
verify_results – Verify scan results. This will cause a second scan of all possible candidates for ISOTP Sockets
verbose – displays information during scan
stop_event – Event object to asynchronously stop the scan
- Returns
- scapy.contrib.isotp.isotp_scanner.scan(sock: SuperSocket, scan_range: Iterable[int] = range(0, 2048), noise_ids: Optional[List[int]] = None, sniff_time: float = 0.1, extended_can_id: bool = False, verify_results: bool = True, stop_event: Optional[Event] = None) Dict[int, Tuple[Packet, int]] [source]
Scan and return dictionary of detections
ISOTP-Scan - NO extended IDs found_packets = Dictionary with Send-to-ID as key and a tuple (received packet, Recv_ID)
- Parameters
sock – socket for can interface
scan_range – hexadecimal range of IDs to scan. Default is 0x0 - 0x7ff
noise_ids – list of packet IDs which will not be tested during scan
sniff_time – time the scan waits for isotp flow control responses after sending a first frame
extended_can_id – Send extended can frames
verify_results – Verify scan results. This will cause a second scan of all possible candidates for ISOTP Sockets
stop_event – Event object to asynchronously stop the scan
- Returns
Dictionary with all found packets
- scapy.contrib.isotp.isotp_scanner.scan_extended(sock: SuperSocket, scan_range: Iterable[int] = range(0, 2048), scan_block_size: int = 32, extended_scan_range: Iterable[int] = range(0, 256), noise_ids: Optional[List[int]] = None, sniff_time: float = 0.1, extended_can_id: bool = False, stop_event: Optional[Event] = None) Dict[int, Tuple[Packet, int]] [source]
Scan with ISOTP extended addresses and return dictionary of detections
If an answer-packet found -> slow scan with single packages with extended ID 0 - 255 found_packets = Dictionary with Send-to-ID as key and a tuple (received packet, Recv_ID)
- Parameters
sock – socket for can interface
scan_range – hexadecimal range of IDs to scan. Default is 0x0 - 0x7ff
scan_block_size – count of packets send at once
extended_scan_range – range to search for extended ISOTP addresses
noise_ids – list of packet IDs which will not be tested during scan
sniff_time – time the scan waits for isotp flow control responses after sending a first frame
extended_can_id – Send extended can frames
stop_event – Event object to asynchronously stop the scan
- Returns
Dictionary with all found packets
- scapy.contrib.isotp.isotp_scanner.send_multiple_ext(sock: SuperSocket, ext_id: int, packet: Packet, number_of_packets: int) None [source]
Send multiple packets with extended addresses at once.
This function is used for scanning with extended addresses. It sends multiple packets at once. The number of packets is defined in the number_of_packets variable. It only iterates the extended ID, NOT the actual CAN ID of the packet. This method is used in extended scan function.
- Parameters
sock – CAN interface to send packets
ext_id – Extended ISOTP-Address
packet – Template Packet
number_of_packets – number of packets to send in one batch