scapy.contrib.isotp.isotp_scanner
- scapy.contrib.isotp.isotp_scanner.filter_periodic_packets(packet_dict: Dict[int, Tuple[Packet, int]]) None [源代码]
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
- 参数:
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: str | None = 'iface', extended_addressing: bool = False) str [源代码]
Generate a copy&past-able output from the result of the scan or the scan_extended function.
- 参数:
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
- 返回:
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: SuperSocket | str, extended_addressing: bool = False) List[SuperSocket] [源代码]
Generate a list of ISOTPSocket objects from the result of the scan or the scan_extended function.
- 参数:
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
- 返回:
A list of all found ISOTPSockets
- scapy.contrib.isotp.isotp_scanner.generate_json_output(found_packets: Dict[int, Tuple[Packet, int]], can_interface: str | None = 'iface', extended_addressing: bool = False) str [源代码]
Generate a list of ISOTPSocket objects from the result of the scan or the scan_extended function.
- 参数:
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
- 返回:
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 [源代码]
Generate a human readable output from the result of the scan or the scan_extended function.
- 参数:
found_packets -- result of the scan or scan_extended function
extended_addressing -- print results from a scan with ISOTP extended addressing
- 返回:
human readable scan results
- scapy.contrib.isotp.isotp_scanner.get_isotp_fc(id_value: int, id_list: List[int] | Dict[int, Tuple[Packet, int]], noise_ids: List[int] | None, extended: bool, packet: Packet) None [源代码]
Callback for sniff function when packet received
If received packet is a FlowControl and not in noise_ids append it to id_list.
- 参数:
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 [源代码]
Craft ISO-TP packet
- 参数:
identifier -- identifier of crafted packet
extended -- boolean if packet uses extended address
extended_can_id -- boolean if CAN should use extended Ids
- 返回:
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: str | None = None, can_interface: str | None = None, extended_can_id: bool = False, verify_results: bool = True, verbose: bool = False, stop_event: Event | None = None) str | List[SuperSocket] [源代码]
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
json: json string
sockets: if output format is not specified, ISOTPSockets will be created and returned in a list
- 参数:
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
- 返回:
- scapy.contrib.isotp.isotp_scanner.scan(sock: SuperSocket, scan_range: Iterable[int] = range(0, 2048), noise_ids: List[int] | None = None, sniff_time: float = 0.1, extended_can_id: bool = False, verify_results: bool = True, stop_event: Event | None = None) Dict[int, Tuple[Packet, int]] [源代码]
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)
- 参数:
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
- 返回:
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: List[int] | None = None, sniff_time: float = 0.1, extended_can_id: bool = False, stop_event: Event | None = None) Dict[int, Tuple[Packet, int]] [源代码]
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)
- 参数:
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
- 返回:
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 [源代码]
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.
- 参数:
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