CAN bus intrusion detection method and device based on counterfeit message
By sending counterfeit messages and undetected messages on the CAN bus to determine their matching status, it solves the problems in the existing technology that CAN bus intrusion detection requires human intervention and consumes a large amount of computing resources, and achieves efficient intrusion identification and cracking difficulty. promote.
Patent Information
- Application Number
- CN202410928061.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-11
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2044-07-11
AI Technical Summary
In the existing technology, CAN bus intrusion detection requires human intervention, the intrusion recognition rate is low, the labor cost is high, the computing resources are occupied, and the reserved bits send the same content by default, which reduces the difficulty of intrusion cracking.
By obtaining the vehicle signal to be sent from the controller, determine its signal data type, build preset signal counterfeiting rules, generate counterfeit signals, and send counterfeit messages and undetected messages on the CAN bus to determine the counterfeit signals and undetected messages. The matching status between them determines the intrusion status of the CAN bus.
It achieves efficient CAN bus intrusion detection without manual intervention, improves the intrusion recognition rate, reduces computing resource usage, and increases the difficulty of intrusion cracking by forging signal changes in reserved bits.
Smart Images

Figure CN118677689A
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of vehicle technology, and more particularly to a method and device for detecting CAN bus intrusion based on counterfeit messages. Background Art
[0002] CAN (Controller Area Network) is an ISO internationally standardized serial communication protocol and a multi-master serial communication bus widely used in the automotive industry. The CAN bus has excellent real-time performance and is suitable for applications that require timely data transmission, such as automotive control systems, industrial automation, etc.
[0003] In the related art, for the intrusion detection of the CAN bus, a support vector machine model or a neural network model can be used to identify whether the features between the associated data are correct, thereby identifying whether the CAN bus has been invaded. The forms of CAN bus invasion include but are not limited to at least one of CAN message tampering, CAN message forgery, and CAN message replay. However, based on the support vector machine model or the neural network model, it is necessary to manually identify which data is associated data, and there is not much strongly associated data. The recognition rate of tampering with weakly associated data is very low, the labor cost is high, and the overall detection occupies a lot of computing resources of the controller. On the other hand, the vehicle CAN protocol has many reserved bits, and these reserved bits are always sent with the same content (such as 0) by default, so the intruder can easily identify it, reducing the difficulty of intrusion cracking. Summary of the invention
[0004] The embodiment of the present application provides a CAN bus intrusion detection method and device based on counterfeit messages to solve the technical problems in the related art that the intrusion detection of the CAN bus requires human intervention, has a low intrusion recognition rate, high labor costs, and occupies a large amount of computing resources of the controller, and the reserved bits send the same content by default, which is easy to identify and reduces the difficulty of intrusion cracking.
[0005] The embodiment of the present application provides a CAN bus intrusion detection method based on counterfeit messages, the method comprising: obtaining a vehicle signal to be sent from a controller; determining a signal data type of the vehicle signal to be sent, and determining a preset signal counterfeiting rule corresponding to the vehicle signal to be sent according to the signal data type, the preset signal counterfeiting rule comprising a filling content generation rule, and a preset correlation between the vehicle signal to be sent and the counterfeit signal generated based on the filling content generation rule; filling the reserved position in the preset associated message based on the preset signal counterfeiting rule with the counterfeit signal according to the filling content generation rule, to obtain the counterfeit message of the vehicle signal to be sent, and The controller sends the simulated message and the message to be detected to the CAN bus, wherein the message to be detected includes the vehicle signal to be sent; the simulated message and the message to be detected sent by one or more controllers are obtained through the CAN bus, and a preset signal imitation rule corresponding to the simulated signal in each simulated message is determined; based on the preset signal imitation rule, the current correlation between the simulated signal and the corresponding vehicle signal to be sent in the message to be detected and the matching state between the preset correlation are judged to obtain the matching state result of each simulated signal; based on the matching state results of all simulated signals, the current intrusion state of the CAN bus is determined to perform CAN bus intrusion detection.
[0006] In one embodiment of the present application, the method for constructing the preset signal imitation rule includes: obtaining all vehicle signals that require CAN bus intrusion detection, and counting the signal data types of all vehicle signals; configuring a corresponding initial filling content rule for each signal data type, the initial filling content rule at least including a preset number of reserved bits and a filling content generation rule; determining a preset correlation between a vehicle signal and an imitation signal according to the filling content generation rule, and generating an imitation signal according to the vehicle signal and the filling content generation rule; associating the filling content generation rule, the preset correlation and the vehicle signal to obtain a preset signal imitation rule corresponding to the vehicle signal.
[0007] In one embodiment of the present application, based on the preset signal imitation rule, the reserved bits in the preset associated message are filled with imitated signals according to the filling content generation rule, and before the imitation message of the vehicle signal to be sent is obtained, the method includes: pre-configuring a corresponding preset associated message for each vehicle signal, the preset associated message including the message to be detected where the vehicle signal is located, the message in the same network segment as the message to be detected, or the message in the same period as the message to be detected; determining the blank position of the preset reserved bit number in the preset associated message as the reserved bit, and the preset reserved bit number is determined based on the initial filling content rule corresponding to the vehicle signal.
[0008] In one embodiment of the present application, configuring a corresponding filling content generation rule for each signal data type includes at least one of the following: if the signal data type is an enumeration type and the data length of the vehicle signal is less than a preset data length, the filling content generation rule is to copy the vehicle signal as a simulated signal; if the signal data type is an enumeration type and the data length of the vehicle signal is greater than or equal to the preset data length, the filling content generation rule is to change the vehicle signal into associated data and use the associated data as a simulated signal, wherein the associated data and the vehicle signal are signal data corresponding to different signal states of the same vehicle state data; if the signal data type is a continuous numerical type, the filling content generation rule is to determine a simulated bus value of the simulated signal data in the simulated signal according to the original bus value of the vehicle signal, the original signal accuracy of the vehicle signal, the original signal offset of the vehicle signal, a preset distortion coefficient, a preset simulated signal data accuracy and a preset simulated signal data offset, round the simulated bus value, and determine the simulated signal based on the rounded simulated bus value.
[0009] In one embodiment of the present application, the vehicle signal is changed into associated data, including: obtaining a vehicle state signal data set corresponding to the vehicle state defined by the vehicle signal; if the vehicle signal is vehicle state signal data representing an initial state or an invalid state in the vehicle state signal data set, determining the associated data as the vehicle signal itself; if the vehicle signal is variable-order vehicle state signal data, sorting all variable-order vehicle state signal data to obtain an initial signal sequence, taking the inverse sequence of the initial signal sequence as an associated signal sequence, obtaining the initial sorting of the vehicle signal in the initial signal sequence, and determining the variable-order vehicle state signal data at the initial sequence position of the associated signal sequence as the associated data, wherein the variable-order vehicle state signal data is vehicle state signal data representing other than the initial state and the invalid state in the vehicle state signal data set.
[0010] In one embodiment of the present application, determining the simulated bus value of the simulated signal data in the simulated signal according to the original bus value of the vehicle signal, the original signal accuracy of the vehicle signal, the original signal offset of the vehicle signal, a preset distortion coefficient, a preset simulated signal data accuracy and a preset simulated signal data offset includes:
[0011] S 仿 =(g*(S 原 *R 原 +Offset 原 )-Offset 仿 ) / R 仿 ,
[0012] Among them, S仿 is the simulated bus value, g is the preset distortion coefficient, S 原 is the original bus value of the vehicle signal, R 原 is the original signal accuracy of the vehicle signal, Offset 原 Offset is the original signal offset of the vehicle signal. 仿 R is the preset pseudo signal data offset. 仿 The simulated signal data accuracy is preset; wherein the deviation between the simulated bus value and the original bus value is less than a preset deviation threshold.
[0013] In one embodiment of the present application, the current intrusion state of the CAN bus is determined based on the matching state results of all the imitated signals, including: if the matching state results of the imitated signals exceeding a preset number are matching failures, the current intrusion state of the CAN bus is intrusion, the preset intrusion flag position is set to a preset mark, and the attacked message is reported to the cloud platform; if the matching state results of the imitated signals less than or equal to the preset number are matching failures, the current intrusion state of the CAN bus is non-intrusion.
[0014] In one embodiment of the present application, if the current intrusion state of the CAN bus is intrusion, after a preset time when the current intrusion state is detected as intrusion, the controller is controlled to send the newly generated message to be detected to the CAN bus inverted until the vehicle is powered on again.
[0015] In one embodiment of the present application, after detecting that the current intrusion state is a preset time of intrusion, the method further includes: obtaining a new imitation message corresponding to the newly generated message to be detected sent by the controller through the CAN bus, and determining a new preset signal imitation rule corresponding to the new imitation signal in the new imitation message; judging the matching state between the new current correlation relationship and the preset correlation relationship between the new imitation signal and the new vehicle signal to be sent in the corresponding new message to be detected based on the new preset signal imitation rule; if the matching state result is a matching failure, inverting the new message to be detected, and judging the matching state between the new current correlation relationship and the preset correlation relationship between the new vehicle signal to be sent in the inverted new message to be detected and the corresponding new imitation signal based on the new preset signal imitation rule; if the matching state result is a matching success, inverting all the messages to be detected obtained through the CAN bus thereafter, and judging the matching state between the current correlation relationship and the preset correlation relationship between the vehicle signal to be sent in the inverted message to be detected and the corresponding imitation signal based on the preset signal imitation rule corresponding to the imitation signal, until the vehicle is powered on again.
[0016] The embodiment of the present application also provides a CAN bus intrusion detection device based on counterfeit messages, the device comprising: an acquisition module, used to acquire a vehicle signal to be sent from a controller; a rule matching module, used to determine the signal data type of the vehicle signal to be sent, and determine a preset signal counterfeiting rule corresponding to the vehicle signal to be sent according to the signal data type, wherein the preset signal counterfeiting rule comprises a filling content generation rule, and a preset correlation between the vehicle signal to be sent and the counterfeit signal generated based on the filling content generation rule; a message counterfeiting module, used to fill the reserved position in the preset associated message according to the filling content generation rule based on the preset signal counterfeiting rule, to obtain the counterfeit message of the vehicle signal to be sent, and through the The controller sends the simulated message and the message to be detected to the CAN bus, wherein the message to be detected includes the vehicle signal to be sent; the simulated signal acquisition module is used to obtain the simulated message and the message to be detected sent by one or more controllers through the CAN bus, and determine the preset signal simulation rule corresponding to the simulated signal in each simulated message; the matching module is used to judge the matching state between the current correlation between the simulated signal and the corresponding vehicle signal to be sent in the message to be detected and the preset correlation based on the preset signal simulation rule, and obtain the matching state result of each simulated signal; the intrusion detection module is used to determine the current intrusion state of the CAN bus based on the matching state results of all simulated signals, so as to perform CAN bus intrusion detection.
[0017] An embodiment of the present application further provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method described in any one of the above embodiments when executing the computer program.
[0018] An embodiment of the present application further provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the method described in any one of the above embodiments is implemented.
[0019] The above-mentioned CAN bus intrusion detection method and device based on counterfeit messages, the method obtains the controlled vehicle signal to be sent and the signal data type of the signal, and then determines the corresponding preset signal counterfeiting rule according to the signal data type, fills the reserved position in the preset associated message with the counterfeit signal according to the preset signal counterfeiting rule, obtains the counterfeit signal and sends it to the CAN bus, collects the counterfeit signal of the CAN bus and the message to be detected generated based on the vehicle signal to be sent, determines the preset signal counterfeiting rule corresponding to the counterfeit signal in each counterfeit message, judges the current correlation between the counterfeit signal and the vehicle signal to be sent in the corresponding message to be detected, and further determines the current correlation The matching state between the relationship and the preset correlation relationship is determined, and then the current intrusion state of the CAN bus is determined by the matching state results of all the imitation signals, so as to realize the intrusion detection of the CAN bus. By constructing the imitation signal, and based on whether the current correlation between the imitation signal and the vehicle message to be sent in the message to be detected matches the preset correlation relationship, the abnormal intrusion can be accurately detected, which can effectively interfere with the intruder's cracking of the communication protocol, and improve the difficulty of being cracked. It does not require excessive human participation, saves manpower, and improves the recognition rate of intrusion. Compared with the method of identifying whether the features between the associated data are correct through the support vector machine model or the neural network model, the computing resources of the controller are also less. By constructing the imitation signal in the reserved position, the content of the reserved position has certain changes, which is not easy to be identified, and the difficulty of cracking is increased. In addition, after a certain degree of intrusion occurs, the newly generated message to be detected is converted and sent again. Since the intruder may regard the imitation message including the imitation signal as the message to be detected, the difficulty of cracking by the intruder can be further increased. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments of the present application will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0021] Figure 1 A flow chart of a method for detecting CAN bus intrusion based on counterfeit messages provided in an embodiment of the present application;
[0022] Figure 2 A schematic diagram of a structure of a CAN bus intrusion detection device based on counterfeit messages provided in an embodiment of the present application;
[0023] Figure 3 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0024] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0025] See also Figure 1 As shown, Figure 1 A flow chart of a method for CAN bus intrusion detection based on counterfeit messages provided in an embodiment of the present application, the method comprising the following steps:
[0026] Step S110, obtaining the vehicle signal to be sent from the controller.
[0027] The method can determine which controllers are to be used for constructing the imitation signals based on which vehicle signals to be sent according to the number of target controllers pre-set by a person skilled in the art. In other words, the number of the controllers can be one or more, which is not limited here. In the above embodiment, the implementation of one controller is used as an example. When the number of controllers is multiple, the method of constructing the imitation signal provided can be referred to. The number of vehicle signals to be sent corresponding to each controller can be one or more, which is not limited here.
[0028] The generation of the imitation signal based on the vehicle signal to be sent can be achieved by the controller itself, or by other devices preset by those skilled in the art.
[0029] In the related art, since the CAN bus can generally receive messages sent by multiple ECUs (Electronic Control Units), technical personnel in this field can pre-specify which one or which part of the ECUs among all the ECUs connected to the CAN bus can serve as the controller in this method.
[0030] Step S120, determining the signal data type of the vehicle signal to be sent, and determining a preset signal imitation rule corresponding to the vehicle signal to be sent according to the signal data type.
[0031] The preset signal imitation rule includes a filling content generation rule and a preset correlation between the vehicle signal to be sent and the imitation signal generated based on the filling content generation rule.
[0032] It can be understood that each signal data type has a corresponding preset signal imitation rule pre-set, and the preset signal imitation rule will be stored in a controller or other device for generating imitation signals, and the preset signal imitation rule will be stored in an intrusion detection device, which can facilitate the execution of the solution.
[0033] Signal data types include but are not limited to enumeration types and continuous numeric types, among which enumeration types are further divided into two types according to the length of signal data: enumeration types less than a preset data length and enumeration types greater than or equal to a preset data length. For example, a bit length less than 3 (or other values set by technicians in this field), such as brake pedal status (0x0: Not pressed 0x1: Pressed), main positive relay status (0x0: Open 0x1: Close 0x2: Fault), high-pressure tank pressure relief request (0x0: No Request 0x1: Request 0x2: Reserved 0x3: Invalid), waiting to send vehicle signals can be used as enumerated vehicle signals to be sent with a data length less than the preset data length; the bit length can be greater than or equal to 3, such as target gear (0x1: P 0x2: R 0x3: N 0x4: D 0x5: invalid value), actual gear (0x0: Undefined initial value 0x1: P gear 0x2: R gear 0x3: N gear 0x4: D gear), vehicle driving mode (0x0: Initial 0x1: ECO 0x2: Comfort 0x3: Sport 0x4: Individual 0x5: Wet 0x6: Snow 0x7: Escape 0x8: Race 0x9: Reserved) etc. can be used as enumerated vehicle signals to be sent that are greater than or equal to the preset data length; the charging target SOC (precision is 1, offset is 0, occupies 7 bits, physical value = decimal value converted from bus value * precision + offset, 0x7F: Invalid), accelerator pedal opening (precision is 0.1, offset is 0, occupies 10 bits, 0x3FF: Invalid) etc. can be used as continuous numerical vehicle signals to be sent.
[0034] In one embodiment, the method for constructing the preset signal imitation rule includes: obtaining all vehicle signals that need to be subjected to CAN bus intrusion detection, and counting the signal data types of all vehicle signals; configuring a corresponding initial filling content rule for each signal data type, the initial filling content rule at least including a preset reserved bit number of reserved bits and a filling content generation rule; determining a preset correlation between the vehicle signal and the imitation signal according to the filling content generation rule, and generating the imitation signal according to the vehicle signal and the filling content generation rule; associating the filling content generation rule, the preset correlation and the vehicle signal to obtain the preset signal imitation rule corresponding to the vehicle signal.
[0035] Continuing from the above-mentioned embodiment, based on the preset signal imitation rule, the reserved positions in the preset associated message are filled with imitation signals according to the filling content generation rule, and before the imitation message of the vehicle signal to be sent is obtained, the method includes: pre-configuring a corresponding preset associated message for each vehicle signal, the preset associated message includes the message to be detected where the vehicle signal is located, the message in the same network segment as the message to be detected, or the message in the same period as the message to be detected; determining the blank position of the preset reserved bit number in the preset associated message as the reserved position, and the preset reserved bit number is determined based on the initial filling content rule corresponding to the vehicle signal.
[0036] The preset associated message is a message pre-set by a person skilled in the art to have an associated relationship with the message to be detected. Generally speaking, the message to be detected and / or messages in the same network segment and period as the message to be detected can be used as the preset associated message.
[0037] Since there are often blank positions in a message without any filling content, a certain number of blank positions can be selected in advance in the preset associated message as reserved positions.
[0038] The aforementioned initial message counterfeiting rule, as a general rule, often represents the initial filling content rule of the reserved position, and the initial filling content rule at least includes the preset reserved bit number of the reserved position and the filling content generation rule of the blank content in the reserved position.
[0039] Since the filling content generation rule represents a rule for converting the vehicle signal to be sent into the imitation signal through a preset conversion relationship, the preset correlation relationship between the vehicle signal to be sent of the message to be detected and the imitation signal of the imitation signal can be determined based on the filling content generation rule. For example, the filling content generation rule can be copying, then the preset correlation relationship between the vehicle signal to be sent of the message to be detected and the imitation signal of the imitation signal should be the same, and for another example, the filling content generation rule can be converting the vehicle signal to be sent into a corresponding associated signal, then the preset correlation relationship should be the association relationship between the conversion of the vehicle signal to be sent and the associated signal.
[0040] It can be understood that the correlation relationship can be that the vehicle signal to be sent and the imitation signal are extracted from the message to be detected and the imitation signal respectively, and the correlation relationship between the vehicle signal to be sent and the imitation signal is used as the preset correlation relationship between the message to be detected and the imitation signal generated based on the filling content generation rule.
[0041] The controller to be detected is also the target controller mentioned in the above embodiment that needs to perform CAN bus intrusion detection. By pre-acquiring the message identifiers and signal data types of the messages to be detected of all the controllers to be detected, the initial filling content rules are determined based on the signal data type. An initial filling content rule is constructed in advance for each signal data type, and the association relationship between the signal data type and the initial filling content rule is obtained. Based on the association relationship, the initial filling content rule is matched by the signal data type. The initial filling content rule at least stipulates the number of reserved bits of the reserved bits, so as to find a suitable number of blank positions from the preset associated message. The initial filling content rule should also include a filling content generation rule, which characterizes what kind of conversion of the vehicle signal to be detected can obtain the filling content, or in other words, based on the filling content generation rule, the conversion relationship between the vehicle signal to be detected and the filling content can be obtained, that is, the preset correlation relationship. The conversion relationship can be a copy, a mapping relationship, or a calculation formula, etc.
[0042] The preset associated message can be the message to be detected itself, or it can be other messages with the same period and / or the same network segment as the message to be detected, or it can be said that the preset associated message is at least one of the message to be detected, the message with the same period as the message to be detected, and the message with the same network segment as the message to be detected.
[0043] The above-mentioned pre-configured process can be completed in advance before the method is executed, so that the signal data type can be directly used for searching during the subsequent method execution to obtain the preset signal imitation rule corresponding to the signal data type. Those skilled in the art can modify the preset signal imitation rule when the method is executed a certain number of times or when necessary.
[0044] As an example, after the preset signal imitation rules are generated, they can be stored locally in the corresponding controller, so that when the controller collects the vehicle signal to be sent, it can obtain the preset signal imitation rules locally and then construct the imitation signal.
[0045] Following the above embodiment, configuring a corresponding filling content generation rule for each signal data type includes at least one of the following:
[0046] If the signal data type is an enumeration type, and the data length of the vehicle signal is less than the preset data length, the filling content generation rule is to copy the vehicle signal as a counterfeit signal;
[0047] If the signal data type is an enumeration type, and the data length of the vehicle signal is greater than or equal to the preset data length, the filling content generation rule is to change the vehicle signal into associated data, use the associated data as the simulated signal, and the associated data and the vehicle signal are signal data corresponding to different signal states of the same vehicle state data;
[0048] If the signal data type is a continuous numeric type, the filling content generation rule is to determine the simulated bus value of the simulated signal data in the simulated signal according to the original bus value of the vehicle signal, the original signal accuracy of the vehicle signal, the original signal offset of the vehicle signal, the preset distortion coefficient, the preset simulated signal data accuracy and the preset simulated signal data offset, round the simulated bus value, and determine the simulated signal based on the rounded simulated bus value.
[0049] In this way, after obtaining the vehicle signal to be sent, the corresponding filling content generation rule can be known based on the signal data type to which the vehicle signal to be sent belongs.
[0050] In accordance with the above embodiment, if the signal data type is an enumeration type, and the data length of the vehicle signal to be sent is greater than or equal to the preset data length, at this time, the vehicle signal is changed into associated data, including: obtaining a vehicle state signal data set corresponding to the vehicle state defined by the vehicle signal; if the vehicle signal is a vehicle state signal data representing an initial state or an invalid state in the vehicle state signal data set, determining the associated data as the vehicle signal itself; if the vehicle signal is a variable-order vehicle state signal data, sorting all the variable-order vehicle state signal data to obtain an initial signal sequence, taking the reverse sequence of the initial signal sequence as the associated signal sequence, obtaining the initial sorting of the vehicle signal in the initial signal sequence, and determining the variable-order vehicle state signal data at the initial sequence position of the associated signal sequence as the associated data, and the variable-order vehicle state signal data is the vehicle state signal data representing the vehicle state other than the initial state and the invalid state in the vehicle state signal data set. For this type of signal data, the number of signals corresponding to it is often limited. At this time, another vehicle signal different from the real signal can be selected from the vehicle state signal data set as a counterfeit signal, which can not only confuse the intruder and make him unclear about the real vehicle signal, but also increase the difficulty of signal cracking and improve the security of the data.
[0051] As an example, the simulated bus value can be determined by determining a first product between the original bus value and the original signal precision, summing the product with the original signal offset to obtain a current sum value, subtracting the current sum value from a preset simulated signal data offset to obtain a current difference value, determining a second product of a preset distortion coefficient and the current difference value, and then using the quotient of the second product and the preset simulated signal data precision as the simulated bus value.
[0052] In accordance with the above embodiment, if the signal data type is a continuous numerical type, determining the simulated bus value of the simulated signal data in the simulated signal according to the original bus value of the vehicle signal, the original signal accuracy of the vehicle signal, the original signal offset of the vehicle signal, the preset distortion coefficient, the preset simulated signal data accuracy and the preset simulated signal data offset includes:
[0053] S 仿 =(g*(S 原 *R 原 +Offset 原 )-Offset 仿 ) / R 仿 ,
[0054] Among them, S 仿 is the simulated bus value, g is the preset distortion coefficient, S 原 is the original bus value of the vehicle signal, R 原 is the original signal accuracy of the vehicle signal, Offset 原 Offset is the original signal offset of the vehicle signal. 仿 R is the preset pseudo signal data offset. 仿 Preset simulation signal data accuracy.
[0055] The deviation between the simulated bus value and the original bus value is less than a preset deviation threshold. The preset deviation threshold can be determined by determining the difference between the simulated bus value and the original bus value, and taking the quotient between the difference and the original bus value as the preset deviation threshold. The preset deviation threshold is greater than 0 and less than 1. As an example, it can be 10%.
[0056] Through the above method, continuous numerical signal data can be simulated so that the simulated value is very similar to the real value, and the real value can also be protected.
[0057] Step S130, based on the preset signal imitation rule, the reserved position in the preset associated message is filled with imitation signal according to the filling content generation rule to obtain the imitation message of the vehicle signal to be sent, and the imitation message and the message to be detected are sent to the CAN bus through the controller.
[0058] The message to be detected includes a vehicle signal to be sent.
[0059] The vehicle signal to be sent can be modified or copied by filling content generation rules, and then a counterfeit signal is obtained, and the counterfeit signal is filled in the reserved position according to a preset filling order to obtain a counterfeit signal. The counterfeit signal is then sent to the CAN bus.
[0060] The above provides a method for generating and sending a simulated signal. A controller may correspond to one or more vehicle signals to be detected, that is, there are one or more messages to be detected, each of which can use the above method to achieve the generation and sending of simulated signals. In the case where there are multiple controllers to be detected, each controller can refer to the above method to achieve the generation and sending of simulated signals.
[0061] Step S140, acquiring the simulated signals and the to-be-detected messages sent by one or more controllers through the CAN bus, and determining the preset signal simulated rule corresponding to the simulated signal of each simulated message.
[0062] The steps S140 to S160 may be executed by a gateway, or by a designated controller, or by a gateway and a controller working together.
[0063] In one embodiment, the preset signal emulation rule corresponding to each emulated signal can be determined by the signal data type of the emulated signal to obtain the preset signal emulation rule corresponding to each emulated signal. The preset signal emulation rule is pre-stored in the gateway and / or designated controller that executes steps S140 to S160.
[0064] Step S150, based on the preset signal imitation rule, the matching status between the current correlation relationship between the imitation signal and the corresponding vehicle signal to be sent in the message to be detected and the preset correlation relationship is determined to obtain the matching status result of each imitation signal.
[0065] In one embodiment, judging the matching status between the current correlation relationship and the preset correlation relationship between the imitated signal and the corresponding message to be detected based on the preset signal imitation rule includes: extracting the imitated signal from the imitated signal according to the preset signal imitation rule, then extracting the signal to be sent from the message to be detected, and then obtaining the current correlation relationship based on the imitated signal and the signal to be sent, and then obtaining the matching status result by matching the preset correlation relationship in the preset signal imitation rule with the current correlation relationship.
[0066] As mentioned in the above embodiment, the preset signal imitation rule includes information of reserved bits, based on which the filling contents on the reserved bits can be extracted and reorganized according to the preset filling sequence to obtain an imitation signal.
[0067] Step S160, determining the current intrusion state of the CAN bus based on the matching state results of all the simulated signals to perform CAN bus intrusion detection.
[0068] In one embodiment, the current intrusion state of the CAN bus is determined based on the matching state results of all the imitated signals, including: if the matching state results of the imitated signals exceeding a preset number are matching failures, the current intrusion state of the CAN bus is intrusion, the preset intrusion flag position is set to a preset mark, and the attacked message is reported to the cloud platform; if the matching state results of the imitated signals less than or equal to a preset number are matching failures, the current intrusion state of the CAN bus is non-intrusion.
[0069] The preset number can be set by those skilled in the art as needed. The time of each detection cycle can also be set by those skilled in the art as needed, and re-detection is performed when the detection cycle is exceeded.
[0070] Following the above embodiment, if the current intrusion state of the CAN bus is intrusion, after the preset time when the current intrusion state is detected as intrusion, the controller is controlled to invert the newly generated message to be detected and send it to the CAN bus until the vehicle is powered on again. Due to the intrusion, the counterfeit message or the message to be detected is unreliable. At this time, the message can be inverted, such as reversing the filling order of the vehicle data to be sent in the message to be detected, thereby increasing the difficulty of cracking by the intruder to a certain extent.
[0071] Following the above embodiment, after the current intrusion state is detected as a preset intrusion time, in other words, when the intrusion occurs for a period of time, such as 3 seconds, the method further includes: obtaining a new imitation message corresponding to the newly generated message to be detected sent by the controller through the CAN bus, and determining a new preset signal imitation rule corresponding to the new imitation signal in the new imitation message; judging a matching state between a new current correlation relationship and a preset correlation relationship (a preset correlation relationship corresponding to the new preset signal imitation rule) between the new imitation signal and the new vehicle signal to be sent in the corresponding new message to be detected based on the new preset signal imitation rule; If the matching status result is a matching failure, the new message to be detected is inverted, and the matching status between the new current correlation relationship and the preset correlation relationship between the new vehicle signal to be sent of the inverted new message to be detected and the corresponding new imitation signal is judged based on the new preset signal imitation rule; if the matching status result is a matching success, all the messages to be detected obtained through the CAN bus afterwards are inverted first, and the matching status between the current correlation relationship and the preset correlation relationship between the vehicle signal to be sent of the inverted message to be detected and the corresponding imitation signal is judged based on the preset signal imitation rule corresponding to the imitation signal until the vehicle is powered on again.
[0072] The preset time can be set by technicians in this field as needed, such as 3 seconds. The reason for waiting for a certain time is to prepare and send the message inversion by the front controller to avoid the confusion of parsing caused by the one-size-fits-all time difference. First, detect according to the original intrusion detection method. If it has not been inverted, continue to perform intrusion detection in the original way. If it has been inverted, the current result is a match failure. At this time, the message to be detected is inverted, and then the intrusion detection is performed again.
[0073] The CAN bus intrusion detection method based on the counterfeit message provided in the above embodiment obtains the controlled vehicle signal to be sent and the signal data type of the signal, and then determines the corresponding preset signal counterfeiting rule according to the signal data type, fills the reserved position in the preset associated message with the counterfeit signal according to the preset signal counterfeiting rule, obtains the counterfeit signal and sends it to the CAN bus, collects the counterfeit signal of the CAN bus and the message to be detected generated based on the vehicle signal to be sent, determines the preset signal counterfeiting rule corresponding to the counterfeit signal in each counterfeit message, judges the current correlation between the counterfeit signal and the vehicle signal to be sent in the corresponding message to be detected, and further determines the current correlation The matching state between the preset correlation relationship and the current intrusion state of the CAN bus is determined by the matching state results of all the imitation signals, and the intrusion detection of the CAN bus is realized. By constructing the imitation signal, and based on whether the current correlation between the imitation signal and the vehicle message to be sent in the message to be detected matches the preset correlation relationship, the abnormal intrusion can be accurately detected, which can effectively interfere with the intruder's cracking of the communication protocol, and improve the difficulty of being cracked. It does not require excessive human participation, saves manpower, and improves the recognition rate of intrusion. Compared with the method of identifying whether the features between the associated data are correct through the support vector machine model or the neural network model, the computing resources of the controller are also less. By constructing the imitation signal in the reserved position, the content of the reserved position has certain changes, which is not easy to be identified, and the difficulty of cracking is increased. In addition, after a certain degree of intrusion occurs, the newly generated message to be detected is converted and sent again. Since the intruder may regard the imitation message including the imitation signal as the message to be detected, the difficulty of cracking by the intruder can be further increased.
[0074] By using a large number of reserved bits to imitate important signals to obtain imitated signals, the intruder's cracking of the communication protocol can be effectively interfered with; establishing a correlation between the imitated signal and the original important signal (the vehicle signal to be sent), and detecting the correlation, the intrusion can be detected to a certain extent; after a certain degree of intrusion occurs, the original important signal is transformed and sent, which further increases the difficulty of cracking, because at this time the intruder will think that the imitated signal is the original important message.
[0075] The following is an exemplary description of the CAN bus intrusion detection method based on counterfeit messages provided in the above embodiment through a specific embodiment. In order to accurately detect the intrusion, the data characteristics of the reserved bits (unused bits) in each message should be obvious, and if the reserved bits of any message are not set according to the rules, the counterfeit signal will be destroyed.
[0076] There are many important signals in vehicles, but different important signals require different imitation methods. This is because different signals have different changing rules, bit lengths and data types. According to whether the data is enumerated (continuous values) and the bit length, the signals to be imitated are divided into three types, and different types require different imitation methods.
[0077] The first type is enumerated data with a bit length of <3; for example, brake pedal status (0x0: Not pressed 0x1: Pressed), main positive relay status (0x0: Open 0x1: Close 0x2: Fault), high-pressure tank pressure relief request (0x0: NoRequest 0x1: Request 0x2: Reserved 0x3: Invalid), etc.
[0078] This type of signal has limited states and can be easily matched to the vehicle state, so when imitating this type of signal, it is necessary to fill the same signal into the reserved position of the same message (or the reserved position of the message with the same network segment and the same period).
[0079] The reason for not changing the counterfeit signal is that there are too few states, and it is easy to be discovered that the counterfeit signal is fake. If they are the same, it is difficult for an intruder to distinguish which one is the counterfeit message.
[0080] The second type is enumeration type, with a bit length ≥ 3; for example, target gear (0x1: P 0x2: R 0x3: N 0x4: D 0x5: invalid value), actual gear (0x0: Undefined initial value 0x1: P gear 0x2: R gear 0x3: N gear 0x4: D gear), vehicle driving mode (0x0: Initial 0x1: ECO 0x2: Comfort 0x3: Sport 0x4: Individual 0x5: Wet 0x6: Snow 0x7: Escape 0x8: Race 0x9: Reserved), etc.
[0081] This type of signal has many states, and the states defined by the signal can be exchanged in a certain order, which further increases the difficulty of cracking. Because of some default rules designed by the CAN communication protocol, generally 0x0 and 0xn represent the initial value (default value) and invalid value respectively. Therefore, for a signal with n+1 states (including invalid and initial states), keep the values 0x0 and 0xn unchanged, and for the remaining n-1 states, that is, the i-th state (0xi) from 1 to n-1, at this time,
[0082] i 仿 =(0.5*(n-1)-i 原 )*2+i 原 ,
[0083] Among them, i 仿 is the serial number of the state signal of the imitation signal, i 原 is the sequence number of the status signal of the vehicle message (real message) to be sent, and n is the number of other status signals except the invalid state.
[0084] It can be understood as swapping the states of the two sides along the center.
[0085] According to the above rules, this type of counterfeit signal can be obtained. Similarly, it is best to fill the counterfeit signal into the reserved position of the same message (or the reserved position of the message with the same network segment and the same period).
[0086] The third type is continuous numerical data, such as charging target SOC (precision is 1, offset is 0, occupies 7 bits, physical value = decimal value converted from bus value * precision + offset, 0x7F: Invalid), accelerator pedal opening (precision is 0.1, offset is 0, occupies 10 bits, 0x3FF: Invalid).
[0087] Also, due to some default rules designed by the CAN communication protocol, generally 0xn, that is, the maximum value of the bus of the signal, represents an invalid value of the signal, so when counterfeiting a continuous numerical signal, this feature should remain unchanged. In addition, continuous numerical signals often represent a specific physical value meaning, which cannot be changed at will, otherwise it is easy to be identified as a wrong counterfeit signal. In order to ensure that the counterfeit signal is sufficiently real and the real content represented by the real signal must be kept confidential, this purpose can be achieved by changing the precision and offset. Although the physical values represented are similar, the physical values parsed from the bus value have been distorted.
[0088] For example, P 原 Represents the physical value represented by the original signal, R 原 Indicates the accuracy of the original signal, Offset 原 Indicates the offset of the original signal, S原 Indicates the bus value of the original signal (decimal). 仿 Represents the physical value represented by the original signal, R 仿 Indicates the accuracy of the original signal, Offset 仿 Indicates the offset of the original signal, S 仿 Indicates the bus value of the original signal (decimal).
[0089] In order to make P 仿 There is a certain degree of distortion, so let P 仿 =gP 原 .
[0090] S 仿 *R 仿 +Offset 仿 =g*(S 原 *R 原 +Offset 原 ).
[0091] Then according to S 原 Get S 仿 , the specific formula is as follows:
[0092] S 仿 =(g*(S 原 *R 原 +Offset 原 )-Offset 仿 ) / R 仿 ,
[0093] Among them, S 仿 is the simulated bus value, g is the preset distortion coefficient, S 原 is the original bus value of the vehicle signal, R 原 is the original signal accuracy of the vehicle signal, Offset 原 Offset is the original signal offset of the vehicle signal. 仿 R is the preset pseudo signal data offset. 仿 Preset simulation signal data accuracy.
[0094] Because the simulated signal will eventually be sent to the bus, it must be an integer, so the S simulated signal obtained above must be rounded [S 仿] This is the counterfeit signal. Among them, g is the distortion coefficient, which is to make the physical value of the counterfeit signal have a certain distortion. Even if the counterfeit signal is cracked, the real physical value will not be completely exposed to the intruder. g can take an empirical value, such as g = 0.99, or it can be adjusted appropriately according to the bit length occupied by the counterfeit signal. The larger the bit, the smaller the difference between g and 1 should be. For continuous numerical signals, the longer the BIT, the larger the range or the higher the accuracy, and the distortion can be not so large (the difference between g and 1), because a little distortion has a relatively large impact on the signal.
[0095] As for S 仿 With S 原 The difference shall not exceed 10%S 原 Because the accuracy range required for the physical signal of the vehicle is well known by professionals, if the difference is large, it is easy to be detected, and the larger the difference in accuracy, the greater the difference in length between the counterfeit signal and the original message, and the lower the counterfeit effect.
[0096] Offset 仿 You can select it according to experience, as long as it does not violate the requirement that the simulated signal covers the physical maximum and minimum values. If the offset of the simulated signal is too outrageous, the S 仿 It may not be sent at all, or it may take up a very long BIT, which not only occupies reserved bit resources but also has a poor imitation effect.
[0097] According to the three types, the counterfeit signal is constructed, and the correlation between the counterfeit signal and the vehicle signal to be sent in the original message (preset correlation) is also constructed. The detection can be carried out based on this correlation. If the correlation is destroyed, it means that the important message has been tampered with. At this time, the intrusion flag position can be set to 1, and the cloud platform can be reported to have been attacked.
[0098] After the controller detects that the correlation of its own important signal is destroyed (immediately sends an intrusion flag) for 3S or receives an intrusion flag sent by another controller for 3S, it sends the original important message in reverse order. That is, it originally sent 000101, but now sends 101000. The original sending mode is restored after power on and off.
[0099] The reason for the 3S delay before inverted transmission is to give the controller receiving the important message a certain amount of time to synchronize the protocol analysis changes. In addition, inverted transmission can further protect the original message from being discovered. The controller receiving the important message determines whether it has been inverted based on the correlation between the original signal and the counterfeit signal, that is, it determines that the original signal and the counterfeit signal are irrelevant, and further inverts the original signal to determine the correlation; if they are irrelevant, the controller receives and processes according to the original protocol until it automatically parses according to the inverted protocol after 4S of intrusion; if the first one is relevant, it is received and processed according to the original protocol; if the first one is irrelevant (matching failed), the second one is relevant (matching successful), and it is parsed according to the inverted protocol until the original parsing method is restored after power on and off.
[0100] In one embodiment, a CAN bus intrusion detection device based on a forged message is provided, and the CAN bus intrusion detection device based on a forged message is used to perform the steps in the CAN bus intrusion detection method provided in any of the above embodiments. Figure 2 , Figure 2 A schematic diagram of a CAN bus intrusion detection device based on counterfeit messages provided in an embodiment of the present application is shown in FIG. Figure 2 As shown, the CAN bus intrusion detection device 200 based on counterfeit message includes: an acquisition module 201, used to acquire the vehicle signal to be sent of the controller; a rule matching module 202, used to determine the signal data type of the vehicle signal to be sent, and determine the preset signal counterfeiting rule corresponding to the vehicle signal to be sent according to the signal data type, the preset signal counterfeiting rule includes a filling content generation rule, and a preset correlation between the vehicle signal to be sent and the counterfeit signal generated based on the filling content generation rule; a message counterfeiting module 203, used to fill the reserved position in the preset associated message with the counterfeit signal according to the filling content generation rule based on the preset signal counterfeiting rule, to obtain the counterfeit message of the vehicle signal to be sent, and to send the counterfeit message to the controller through the controller. The message and the message to be detected are sent to the CAN bus, and the message to be detected includes the vehicle signal to be sent; the imitation signal acquisition module 204 is used to obtain the imitation message and the message to be detected sent by one or more controllers through the CAN bus, and determine the preset signal imitation rule corresponding to the imitation signal in each imitation message; the matching module 205 is used to judge the matching state between the current correlation relationship and the preset correlation relationship between the imitation signal and the corresponding vehicle signal to be sent in the message to be detected based on the preset signal imitation rule, and obtain the matching state result of each imitation signal; the intrusion detection module 206 is used to determine the current intrusion state of the CAN bus based on the matching state results of all imitation signals, so as to perform CAN bus intrusion detection.
[0101] In one embodiment, the device also includes a preset signal imitation rule construction module, which is used to obtain all vehicle signals that require CAN bus intrusion detection and count the signal data types of all vehicle signals; configure a corresponding initial filling content rule for each signal data type, the initial filling content rule at least includes a preset reserved bit number of reserved bits and a filling content generation rule; determine a preset correlation between the vehicle signal and the imitation signal according to the filling content generation rule, and the imitation signal is generated according to the vehicle signal and the filling content generation rule; associate the filling content generation rule, the preset correlation and the vehicle signal to obtain the preset signal imitation rule corresponding to the vehicle signal.
[0102] In one embodiment, the preset signal imitation rule construction module is further configured to: fill the reserved positions in the preset associated message with imitation signals according to the filling content generation rule based on the preset signal imitation rule, and before obtaining the imitation message of the vehicle signal to be sent, pre-configure the corresponding preset associated message for each vehicle signal, the preset associated message includes the message to be detected where the vehicle signal is located, the message in the same network segment as the message to be detected, or the message in the same period as the message to be detected; determine the blank positions of the preset reserved bit number in the preset associated message as reserved positions, and the preset reserved bit number is determined based on the initial filling content rule corresponding to the vehicle signal.
[0103] In one embodiment, the preset signal imitation rule construction module is also configured as at least one of the following: if the signal data type is an enumeration type and the data length of the vehicle signal is less than the preset data length, the filling content generation rule is to copy the vehicle signal as the imitation signal; if the signal data type is an enumeration type and the data length of the vehicle signal is greater than or equal to the preset data length, the filling content generation rule is to change the vehicle signal into associated data, and use the associated data as the imitation signal, and the associated data and the vehicle signal are signal data corresponding to different signal states of the same vehicle state data; if the signal data type is a continuous numerical type, the filling content generation rule is to determine the imitation bus value of the imitation signal data in the imitation signal according to the original bus value of the vehicle signal, the original signal accuracy of the vehicle signal, the original signal offset of the vehicle signal, the preset distortion coefficient, the preset imitation signal data accuracy and the preset imitation signal data offset, round the imitation bus value, and determine the imitation signal based on the rounded imitation bus value.
[0104] In one embodiment, the preset signal imitation rule construction module is further configured to: obtain a vehicle state signal data set corresponding to the vehicle state defined by the vehicle signal; if the vehicle signal is vehicle state signal data representing an initial state or an invalid state in the vehicle state signal data set, determine the associated data as the vehicle signal itself; if the vehicle signal is variable-order vehicle state signal data, sort all variable-order vehicle state signal data to obtain an initial signal sequence, use the inverse sequence of the initial signal sequence as the associated signal sequence, obtain the initial sorting of the vehicle signal in the initial signal sequence, and determine the variable-order vehicle state signal data at the initial sequence position of the associated signal sequence as the associated data, where the variable-order vehicle state signal data is vehicle state signal data representing other than the initial state and the invalid state in the vehicle state signal data set.
[0105] In one embodiment, the preset signal imitation rule building module is further configured to: determine the imitation bus value of the imitation signal data in the imitation signal according to the original bus value of the vehicle signal, the original signal accuracy of the vehicle signal, the original signal offset of the vehicle signal, the preset distortion coefficient, the preset imitation signal data accuracy and the preset imitation signal data offset, including:
[0106] S 仿 =(g*(S 原 *R 原 +Offset 原 )-Offset 仿 ) / R 仿 ,
[0107] Among them, S 仿 is the simulated bus value, g is the preset distortion coefficient, S 原 is the original bus value of the vehicle signal, R 原 is the original signal accuracy of the vehicle signal, Offset 原 Offset is the original signal offset of the vehicle signal. 仿 R is the preset pseudo signal data offset. 仿 The simulated signal data accuracy is preset; wherein the deviation between the simulated bus value and the original bus value is less than the preset deviation threshold.
[0108] In one embodiment, the intrusion detection module is configured as follows: if the matching status result of the counterfeit signals exceeding a preset number is a matching failure, the current intrusion status of the CAN bus is an intrusion, the preset intrusion flag position is set to a preset mark, and the attacked message is reported to the cloud platform; if the matching status result of the counterfeit signals less than or equal to a preset number is a matching failure, the current intrusion status of the CAN bus is no intrusion.
[0109] In one embodiment, the device also includes an inversion module, which is used to control the controller to invert and send the newly generated message to be detected to the CAN bus after a preset time when the current intrusion state of the CAN bus is intrusion, until the vehicle is powered on again.
[0110] In one embodiment, the inversion module is further used to detect that the current intrusion state is a preset time of intrusion, obtain a new imitation message corresponding to the newly generated message to be detected sent by the controller through the CAN bus, and determine a new preset signal imitation rule corresponding to the new imitation signal in the new imitation message; judge the matching state between the new current correlation relationship and the preset correlation relationship between the new imitation signal and the new vehicle signal to be sent in the corresponding new message to be detected based on the new preset signal imitation rule; if the matching state result is a matching failure, invert the new message to be detected, and judge the matching state between the new current correlation relationship and the preset correlation relationship between the new vehicle signal to be sent in the inverted new message to be detected and the corresponding new imitation signal based on the new preset signal imitation rule; if the matching state result is a matching success, invert all the messages to be detected obtained through the CAN bus thereafter, and judge the matching state between the current correlation relationship and the preset correlation relationship between the vehicle signal to be sent in the inverted message to be detected and the corresponding imitation signal based on the preset signal imitation rule corresponding to the imitation signal, until the vehicle is powered on again.
[0111] For the specific definition of the CAN bus intrusion detection device based on the counterfeit message, please refer to the definition of the CAN bus intrusion detection method based on the counterfeit message above, which will not be repeated here. Each module in the above-mentioned CAN bus intrusion detection device based on the counterfeit message can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the electronic device in the form of hardware, or can be stored in the memory of the electronic device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0112] In this embodiment, the CAN bus intrusion detection device based on counterfeit messages is essentially equipped with multiple modules to execute the CAN bus intrusion detection method based on counterfeit messages in any of the above embodiments. The specific functions and technical effects can be referred to the above embodiments and will not be repeated here.
[0113] In one embodiment, a vehicle is provided, the vehicle comprising the CAN bus intrusion detection device based on counterfeit messages provided in any of the above embodiments. The specific functions and technical effects of the vehicle can refer to the above embodiments, and will not be repeated here.
[0114] See also Figure 3An embodiment of the present invention further provides an electronic device 300, including a processor 301, a memory 302 and a communication bus 303; the communication bus 303 is used to connect the processor 301 and the memory 302; the processor 301 is used to execute a computer program stored in the memory 302 to implement a method provided in any one of the above embodiments.
[0115] An embodiment of the present invention further provides a computer-readable storage medium on which a computer program is stored. The computer program is used to enable a computer to execute a method provided in any one of the above embodiments.
[0116] The embodiment of the present application also provides a non-volatile readable storage medium, which stores one or more modules (programs). When the one or more modules are applied to a device, the device can execute instructions (instructions) of the steps included in the embodiment 1 of the embodiment of the present application.
[0117] The embodiment of the present application also provides a computer program product, including a computer program, which can implement the steps and corresponding contents of the aforementioned method embodiment when executed by a processor.
[0118] It should be noted that the computer-readable medium mentioned above in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0119] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0120] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages, or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0121] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of the code contains one or more executable instructions for implementing the specified logical functions. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in an order different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart, can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0122] It should be understood that the terms "first", "second", etc. mentioned in this application are used to distinguish similar objects, and do not necessarily represent that they refer to a specific order or sequence. The technical features in which these terms are located can be interchanged under appropriate circumstances, so that the embodiments of the application described here can be implemented in an order other than the illustrated or written description.
[0123] It should be understood that although the flowcharts provided in the embodiments of the present application indicate the steps by arrows, the order indicated by the arrows does not necessarily limit the order in which the steps are implemented. Those skilled in the art can perform the steps in other orders according to the requirements for different implementation scenarios.
[0124] The above embodiments are merely illustrative of the principles and effects of the present invention, and are not intended to limit the present invention. Anyone familiar with the art may modify or alter the above embodiments without departing from the spirit and scope of the present invention. Therefore, all equivalent modifications or alterations made by a person of ordinary skill in the art without departing from the spirit and technical concept disclosed by the present invention shall still be covered by the claims of the present invention.
Claims
1. A CAN bus intrusion detection method based on counterfeit messages, characterized in that: The method comprises: Obtain the vehicle signal to be sent from the controller; Determine a signal data type of the vehicle signal to be sent, and determine a preset signal imitation rule corresponding to the vehicle signal to be sent according to the signal data type, wherein the preset signal imitation rule includes a filling content generation rule and a preset correlation relationship between the vehicle signal to be sent and the imitation signal generated based on the filling content generation rule; Based on the preset signal imitation rule, the reserved position in the preset associated message is filled with an imitation signal according to the filling content generation rule to obtain the imitation message of the vehicle signal to be sent, and the imitation message and the message to be detected are sent to the CAN bus through the controller, and the message to be detected includes the vehicle signal to be sent; Acquire the counterfeit messages and the to-be-detected messages sent by one or more controllers through the CAN bus, and determine the preset signal counterfeiting rule corresponding to the counterfeit signal in each counterfeit message; Based on the preset signal imitation rule, determine the matching status between the current correlation relationship between the imitation signal and the corresponding vehicle signal to be sent in the message to be detected and the preset correlation relationship, and obtain the matching status result of each imitation signal; The current intrusion state of the CAN bus is determined based on the matching state results of all the simulated signals to perform CAN bus intrusion detection.
2. The CAN bus intrusion detection method based on counterfeit messages as claimed in claim 1, characterized in that: The construction method of the preset signal imitation rule includes: Obtain all vehicle signals that require CAN bus intrusion detection, and count the signal data types of all vehicle signals; Configuring a corresponding initial filling content rule for each signal data type, wherein the initial filling content rule includes at least a preset number of reserved bits and a filling content generation rule; Determining a preset correlation between a vehicle signal and an imitation signal according to the filling content generation rule, wherein the imitation signal is generated according to the vehicle signal and the filling content generation rule; The filling content generation rule, the preset correlation relationship and the vehicle signal are associated to obtain a preset signal imitation rule corresponding to the vehicle signal.
3. The CAN bus intrusion detection method based on counterfeit messages as claimed in claim 2 is characterized in that: Based on the preset signal imitation rule, the reserved position in the preset associated message is filled with an imitation signal according to the filling content generation rule, and before obtaining the imitation message of the vehicle signal to be sent, the method includes: Pre-configure a corresponding preset associated message for each vehicle signal, wherein the preset associated message includes a message to be detected where the vehicle signal is located, a message in the same network segment as the message to be detected, or a message in the same period as the message to be detected; The blank position of the preset reserved bit number in the preset association message is determined as the reserved bit, and the preset reserved bit number is determined based on the initial filling content rule corresponding to the vehicle signal.
4. The CAN bus intrusion detection method based on counterfeit messages as claimed in claim 2, characterized in that: Configuring a corresponding filling content generation rule for each signal data type includes at least one of the following: If the signal data type is an enumeration type, and the data length of the vehicle signal is less than the preset data length, the filling content generation rule is to copy the vehicle signal as a counterfeit signal; If the signal data type is an enumeration type, and the data length of the vehicle signal is greater than or equal to the preset data length, the filling content generation rule is to change the vehicle signal into associated data, and use the associated data as a simulated signal, and the associated data and the vehicle signal are signal data corresponding to different signal states of the same vehicle state data; If the signal data type is a continuous numeric type, the filling content generation rule is to determine the simulated bus value of the simulated signal data in the simulated signal according to the original bus value of the vehicle signal, the original signal accuracy of the vehicle signal, the original signal offset of the vehicle signal, the preset distortion coefficient, the preset simulated signal data accuracy and the preset simulated signal data offset, round the simulated bus value, and determine the simulated signal based on the rounded simulated bus value.
5. The CAN bus intrusion detection method based on counterfeit messages as claimed in claim 4 is characterized in that: Changing the vehicle signal into associated data includes: Acquire a vehicle state signal data set corresponding to the vehicle state defined by the vehicle signal; If the vehicle signal is vehicle state signal data representing an initial state or an invalid state in the vehicle state signal data set, determining the associated data as the vehicle signal itself; If the vehicle signal is variable-sequence vehicle status signal data, all variable-sequence vehicle status signal data are sorted to obtain an initial signal sequence, the inverse sequence of the initial signal sequence is used as an associated signal sequence, the initial sorting of the vehicle signal in the initial signal sequence is obtained, and the variable-sequence vehicle status signal data at the initial sequence position of the associated signal sequence is determined as the associated data, and the variable-sequence vehicle status signal data is the vehicle status signal data in the vehicle status signal data set that represents the vehicle status other than the initial state and the invalid state.
6. The CAN bus intrusion detection method based on counterfeit messages as claimed in claim 4 is characterized in that: Determining the simulated bus value of the simulated signal data in the simulated signal according to the original bus value of the vehicle signal, the original signal accuracy of the vehicle signal, the original signal offset of the vehicle signal, a preset distortion coefficient, a preset simulated signal data accuracy and a preset simulated signal data offset comprises: S 仿 =(g*(S 原 *R 原 +Offset 原 )-Offset 仿 ) / R 仿 , Among them, S 仿 is the simulated bus value, g is the preset distortion coefficient, S 原 is the original bus value of the vehicle signal, R 原 is the original signal accuracy of the vehicle signal, Offset 原 Offset is the original signal offset of the vehicle signal. 仿 R is the preset pseudo signal data offset. 仿 To preset the simulation signal data accuracy; The deviation between the simulated bus value and the original bus value is less than a preset deviation threshold.
7. The method for detecting CAN bus intrusion based on counterfeit messages according to any one of claims 1 to 6, characterized in that: Determining the current intrusion state of the CAN bus based on the matching state results of all the imitation signals includes: If the matching status result of the counterfeit signals exceeding the preset number is a matching failure, the current intrusion status of the CAN bus is an intrusion, the preset intrusion flag position is set to a preset flag, and the attacked message is reported to the cloud platform; If the matching status result of the counterfeit signals less than or equal to the preset number is a matching failure, the current intrusion status of the CAN bus is no intrusion.
8. The method for detecting CAN bus intrusion based on counterfeit messages as claimed in claim 7, characterized in that: If the current intrusion state of the CAN bus is intrusion, after a preset time when the current intrusion state is detected as intrusion, the controller is controlled to send the newly generated message to be detected to the CAN bus in an inverted manner until the vehicle is powered on again.
9. The method for detecting CAN bus intrusion based on counterfeit messages as claimed in claim 8, characterized in that: After detecting that the current intrusion state is a preset intrusion time, the method further includes: Acquire a new counterfeit message corresponding to the newly generated message to be detected sent by the controller through the CAN bus, and determine a new preset signal counterfeit rule corresponding to a new counterfeit signal in the new counterfeit message; Determining the matching state between the new current correlation relationship and the preset correlation relationship between the new imitation signal and the new vehicle signal to be sent in the corresponding new message to be detected based on the new preset signal imitation rule; If the matching status result is a matching failure, the new message to be detected is inverted, and the matching status between the new current correlation relationship and the preset correlation relationship between the new vehicle signal to be sent in the inverted new message to be detected and the corresponding new imitation signal is determined based on the new preset signal imitation rule; If the matching status result is a successful match, all the messages to be detected obtained through the CAN bus are inverted first, and the matching status between the current correlation relationship and the preset correlation relationship between the vehicle signal to be sent and the corresponding imitation signal in the inverted message to be detected is determined based on the preset signal imitation rule corresponding to the imitation signal until the vehicle is powered on again.
10. A CAN bus intrusion detection device based on counterfeit messages, characterized in that: The device comprises: An acquisition module, used for acquiring a vehicle signal to be sent from a controller; A rule matching module, used to determine the signal data type of the vehicle signal to be sent, and determine a preset signal imitation rule corresponding to the vehicle signal to be sent according to the signal data type, wherein the preset signal imitation rule includes a filling content generation rule and a preset correlation relationship between the vehicle signal to be sent and the imitation signal generated based on the filling content generation rule; A message imitation module, used for filling the reserved position in the preset associated message with an imitation signal according to the filling content generation rule based on the preset signal imitation rule, obtaining the imitation message of the vehicle signal to be sent, and sending the imitation message and the message to be detected to the CAN bus through the controller, wherein the message to be detected includes the vehicle signal to be sent; A simulated signal acquisition module, used for acquiring simulated messages and to-be-detected messages sent by one or more controllers through the CAN bus, and determining a preset signal simulated rule corresponding to the simulated signal in each simulated message; A matching module, for determining the matching status between the current correlation between the imitation signal and the vehicle signal to be sent in the corresponding message to be detected and the preset correlation based on the preset signal imitation rule, and obtaining the matching status result of each imitation signal; The intrusion detection module is used to determine the current intrusion state of the CAN bus based on the matching state results of all the imitation signals to perform CAN bus intrusion detection.
Citation Information
Patent Citations
Vehicle bus intrusion detection system and method
CN113612786A
Vehicle CAN network intrusion detection method and device, electronic equipment and medium
CN114374565A
Intrusion detection system and method
CN115664737A
Vehicle-mounted CAN bus intrusion detection chip
CN116599723A
Intrusion detection apparatus, system and methods
US10410002B1
