scapy.contrib.automotive.ecu

class scapy.contrib.automotive.ecu.ECU(init_session=None, init_security_level=None, init_communication_control=None, logging=True, verbose=True, store_supported_responses=True)

Bases: object

A ECU object can be used to
  • 跟踪ECU的状态.

  • 将所有修改记录到ECU

  • 提取实际ECU支持的响应

用法:>>> print("此ecu记录,跟踪并创建支持的响应")>>> my_virtual_ecu = ECU()>>> my_virtual_ecu.update(PacketList([…]))>>> my_virtual_ecu.supported_responses >>> print("另一个ecu只是跟踪")>>> my_tracking_ecu = ECU(logging = False,store_supported_responses = False)#noqa:E501 >>> my_tracking_ecu.update(PacketList([…]))>>> print("另一个ecu只需记录对它的所有修改")>>> my_logging_ecu = ECU(详细= False,store_supported_responses = False)#noqa:E501 >>> my_logging_ecu.update(PacketList([…]))>>> my_logging_ecu.log >>> print("另一个ecu只是创建受支持的响应")>>> my_response_ecu = ECU(详细= False,logging = False)>>> my_response_ecu.update(PacketList([…]))>>> my_response_ecu.supported_responses

property communication_control
property current_security_level
property current_session
reset()
property supported_responses
property unanswered_packets
update(p)
class scapy.contrib.automotive.ecu.ECUResponse(session=1, security_level=0, responses=<Raw load='\x7f\x10' |>, answers=None)

Bases: object

封装响应和相应的ECU状态. 这些对象的列表可用于配置ECU答录机. 如果要克隆总线上实际ECU的行为,这很有用.

用法:>>> print("如果ECU在会话2中并且具有安全级别2,则生成UDRes()/ UDS_RDBI(identifiers = [2])上回答的ECUResponse")#noqa:E501 >>> ECUResponse(session = 2 ,security_level = 2,response = UDS()/ UDS_RDBIPR(dataIdentifier = 2)/ Raw(b" deadbeef1"))#noqa:E501 >>> print("其他示例")>>> ECUResponse(session = range(3 ,5),security_level = [3,4],响应= UDS()/ UDS_RDBIPR(dataIdentifier = 3)/ Raw(b" deadbeef2"))#noqa:E501 >>> ECUResponse(session = [5,6,7 ],security_level = range(5,7),响应= UDS()/ UDS_RDBIPR(dataIdentifier = 5)/ Raw(b" deadbeef3"))#noqa:E501 >>> ECUResponse(session = lambda x:8 <x < = 10,security_level = lambda x:x> 10,响应= UDS()/ UDS_RDBIPR(dataIdentifier = 9)/ Raw(b" deadbeef4"))#noqa:E501

answers(other)
has_security_access(current_security_level)
in_correct_session(current_session)
class scapy.contrib.automotive.ecu.ECUSession(*args, **kwargs)

Bases: scapy.sessions.DefaultSession

跟踪对"流中" ECU的修改.

用法:>>>嗅探(session = ECUSession)

on_packet_received(pkt)
class scapy.contrib.automotive.ecu.ECU_State(session=1, tester_present=False, security_level=0, communication_control=0, **kwargs)

Bases: object

reset()
property tp
class scapy.contrib.automotive.ecu.ECU_am(**kargs)

Bases: scapy.ansmachine.AnsweringMachine

模拟真实ECU的基本行为的AnsweringMachine. 提供ECUResponse对象的列表以配置此AnsweringMachine的行为.

param supported_responses

定义行为的ECUResponse对象的列表. 默认响应是generalReject .

param main_socket

定义套接字的对象以发送和接收数据包.

param broadcast_socket

定义广播套接字的对象. 仅侦听,以main_socket响应. 禁用广播功能.

param basecls

提供所用协议的基本规则

用法:>>> resp = ECUResponse(会话=范围(0,255),security_level = 0,响应= UDS()/ UDS_NR(negativeResponseCode = 0x7f,requestServiceId = 0x10))#noqa:E501 >>>袜子= ISOTPSocket(can_iface, sid = 0x700,did = 0x600,basecls = UDS)#noqa:E501 >>> answering_machine = ECU_am(supported_responses = [resp],main_socket = sock,basecls = UDS)#noqa:E501 >>> sim = threading.Thread( target = answering_machine,kwargs = {'count':4,'timeout':5})#noqa:E501 >>> sim.start()

function_name = 'ECU_am'
is_request(req)
make_reply(req)
parse_options(supported_responses=None, main_socket=None, broadcast_socket=None, basecls=<class 'scapy.packet.Raw'>, timeout=None)
print_reply(req, reply)
send_reply(reply)
sniff_options_list = ['store', 'opened_socket', 'count', 'filter', 'prn', 'stop_filter', 'timeout']