scapy.contrib.isotp.isotp_scanner

scapy.contrib.isotp.isotp_scanner.filter_periodic_packets(packet_dict, verbose=False)[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

  • verbose – Displays further information

scapy.contrib.isotp.isotp_scanner.generate_code_output(found_packets, can_interface='iface', extended_addressing=False)[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, can_interface, extended_addressing=False)[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, extended_addressing=False)[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, id_list, noise_ids, extended, packet, verbose=False)[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

  • verbose – displays information during scan

scapy.contrib.isotp.isotp_scanner.get_isotp_packet(identifier=0, extended=False, extended_can_id=False)[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, scan_range=range(0, 2048), extended_addressing=False, extended_scan_range=range(0, 256), noise_listen_time=2, sniff_time=0.1, output_format=None, can_interface=None, extended_can_id=False, verbose=False)[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

  • verbose – displays information during scan

Returns

scapy.contrib.isotp.isotp_scanner.scan(sock, scan_range=range(0, 2048), noise_ids=None, sniff_time=0.1, extended_can_id=False, verbose=False)[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

  • verbose – displays information during scan

Returns

Dictionary with all found packets

scapy.contrib.isotp.isotp_scanner.scan_extended(sock, scan_range=range(0, 2048), scan_block_size=32, extended_scan_range=range(0, 256), noise_ids=None, sniff_time=0.1, extended_can_id=False, verbose=False)[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

  • verbose – displays information during scan

Returns

Dictionary with all found packets

scapy.contrib.isotp.isotp_scanner.send_multiple_ext(sock, ext_id, packet, number_of_packets)[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