CAN bus intrusion detection method and device

By using the reserved bits of the CAN protocol to construct data features in CAN bus intrusion detection and automatically comparing the data feature arrays, it solves the problems of intrusion detection in the existing technology requiring human intervention, low recognition rate, and large computing resource usage, and achieves Efficient intrusion detection.

CN118677690APending Publication Date: 2024-09-20CHONGQING SELIS PHOENIX INTELLIGENT INNOVATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410928064.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-11
Publication Date
2024-09-20

AI Technical Summary

Technical Problem

In the existing technology, CAN bus intrusion detection requires human intervention, the recognition rate is low, the labor cost is high, and the computing resources are occupied.

Method used

By obtaining the message group sent by the controller to be detected to the CAN bus, reading the content of the filling bits reserved by the CAN protocol, constructing a data feature array, and comparing it with the preset array, the intrusion status of the CAN bus is determined. Using the CAN protocol Bits are reserved to build data features to accurately detect abnormal intrusions.

Benefits of technology

It improves the intrusion recognition rate, reduces manual participation, saves manpower, and reduces the occupation of controller computing resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118677690A
    Figure CN118677690A
Patent Text Reader

Abstract

The invention relates to the technical field of vehicles, and provides a CAN bus intrusion detection method and device, and the method comprises the steps: obtaining one or more current to-be-detected messages sent by a to-be-detected controller to a CAN bus, reading the current filling content in the messages, obtaining a current to-be-detected data feature array, and carrying out the detection of the current to-be-detected data feature array; the method comprises the following steps of: acquiring a current preset data feature array, comparing the current preset data feature array with the current preset data feature array, determining the current intrusion state of the CAN bus based on a comparison result so as to realize CAN bus intrusion detection, constructing data features by using reserved bits of a CAN protocol, and accurately detecting abnormal intrusion. And the data features provided by the current to-be-detected data feature array are features of data change in the message, so that the cracking difficulty is improved, excessive manual participation is not needed, the manpower is saved, the intrusion recognition rate is improved, and the detection efficiency is improved. And compared with a mode of identifying whether the characteristics between the associated data are correct or not through a support vector machine model or a neural network model, the occupied computing resources of the controller are relatively small.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of vehicle technology, and in particular to a CAN bus intrusion detection method and device. 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 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 intrusion of the CAN bus 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 data with strong association. 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. Summary of the invention

[0004] The embodiments of the present application provide a CAN bus intrusion detection method and device 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.

[0005] An embodiment of the present application provides a CAN bus intrusion detection method, the method comprising: obtaining a current message group to be detected sent by a controller to be detected to a CAN bus, the current message group to be detected comprising one or more current messages to be detected; reading the current filling content of a CAN protocol reserved filling bit of each current message to be detected to obtain a current data feature array to be detected; comparing the current data feature array to be detected with a current preset data feature array; determining the current intrusion state of the CAN bus according to the comparison result to perform CAN bus intrusion detection.

[0006] In one embodiment of the present application, before obtaining the current message group to be detected sent by the controller to be detected to the CAN bus, the method includes: the controller to be detected receives the intrusion detection result message group sent by the gateway, and the intrusion detection result message group includes an intrusion data feature array pair representing the number of intrusions; if the intrusion data feature array pair has not changed, the controller to be detected determines the current data feature array to be detected based on the previous data feature array to be detected used in the previous message group to be detected, the current data feature array set to be detected, the preset loop sequence and the cycle period of the data feature array to be detected, and the previous data feature array to be detected and the current data feature array to be detected belong to the current data feature array set to be detected. In combination, each set of data feature arrays to be detected includes multiple data feature arrays to be detected, and the multiple data feature arrays to be detected have a preset cyclic order. The current set of data feature arrays to be detected is determined based on the intrusion data feature array pairs in the intrusion detection result message group, and different intrusion data feature array pairs are pre-set with different sets of data feature arrays to be detected; the controller to be detected determines the current filling content of the CAN protocol reserved filling bit of each current message to be detected in the current message group to be detected that needs to be sent according to the current data feature array to be detected, and fills the CAN protocol reserved filling bit of each current message to be detected based on the current filling content to obtain the current message group to be detected.

[0007] In one embodiment of the present application, the method also includes: if the intrusion data feature array pair changes, the controller to be detected determines the changed data feature array set to be detected based on the intrusion data feature array pair in the intrusion detection result message; the data feature array to be detected with a preset loop order as the first in the changed data feature array set to be detected is determined as the current data feature array to be detected; the controller to be detected determines the current filling content of the CAN protocol reserved filling bit of each current message to be detected in the current message group to be detected that needs to be sent based on the current data feature array to be detected, and fills the CAN protocol reserved filling bit of each current message to be detected based on the current filling content to obtain the current message group to be detected.

[0008] In one embodiment of the present application, the method for determining the cycle period of the characteristic array of data to be detected includes: if there are at least two messages to be detected in the message group to be detected of the controller to be detected with different sending frequencies, determining the cycle period of the characteristic array of data to be detected of the controller to be detected based on all sending frequencies.

[0009] In an embodiment of the present application, if there are multiple controllers to be detected, the characteristic arrays of data to be detected corresponding to the controllers to be detected are different.

[0010] In one embodiment of the present application, a method for determining the CAN protocol reserved fill bits of a controller to be detected includes: obtaining all types of controller messages sent by a controller to be detected to the CAN bus; determining at least a part of all types of controller messages as messages to be detected; selecting at least one bit of reserved fill bits in each of the messages to be detected, and the reserved fill bits are used to fill the corresponding fill content that constitutes the feature array of data to be detected, so as to complete the determination of the CAN protocol reserved fill bits of each message to be detected.

[0011] In one embodiment of the present application, before comparing the current data feature array to be detected with the current preset data feature array, the method further includes: determining a current set of data feature arrays to be detected according to an intrusion detection result message group currently sent by the gateway, the intrusion detection result message group including an intrusion data feature array pair representing the number of intrusions, different intrusion data feature array pairs are pre-set with different sets of data feature arrays to be detected, each set of data feature arrays to be detected including multiple data feature arrays to be detected, and the multiple data feature arrays to be detected have a preset cyclic order; if the intrusion detection result message group currently sent by the gateway is the same as the intrusion detection result message group sent by the gateway last time, determining the current preset data feature array according to the previous data feature array to be detected determined by the previous acquired group of messages to be detected, the current set of data feature arrays to be detected, and the preset cyclic order; if the intrusion detection result message group currently sent by the gateway is different from the intrusion detection result message group sent by the gateway last time, determining the data feature array to be detected with the first preset cyclic order in the current set of data feature arrays to be detected as the current preset data feature array.

[0012] In one embodiment of the present application, the current intrusion state of the CAN bus is determined according to the comparison result, including: if the comparison result is a comparison failure, obtaining a new current message group to be detected sent by the controller to be detected to the CAN bus within a preset time period; comparing the new current data feature array to be detected obtained for each new current message group to be detected with the new current preset data feature array; if there are comparison failure results greater than a preset failure threshold number in the comparison results obtained within the preset time period, the current intrusion state of the CAN bus is determined to be intrusion; if there are comparison failure results less than or equal to the preset failure threshold number in the comparison results obtained within the preset time period, the current intrusion state of the CAN bus is determined to be safe.

[0013] In one embodiment of the present application, the method also includes: if the current intrusion state of the CAN bus is determined to be an intrusion, triggering the gateway to determine a new intrusion detection result message group as the intrusion detection result message group currently sent, the new intrusion detection result message group includes a new intrusion data feature array pair, the new intrusion data feature array pair is determined based on the number of intrusions that the current intrusion state of the CAN bus is determined to be an intrusion, and each number of intrusions is pre-set with a corresponding intrusion data feature array pair; if the current intrusion state of the CAN bus has not yet been determined to be an intrusion, triggering the gateway to use the intrusion detection result message group sent last time as the intrusion detection result message group currently sent.

[0014] An embodiment of the present application also provides a CAN bus intrusion detection device, which includes: an acquisition module, used to acquire a current message group to be detected sent by a controller to be detected to the CAN bus, wherein the current message group to be detected includes one or more current messages to be detected; a reading module, used to read the current filling content of the CAN protocol reserved filling bit of each current message to be detected, and obtain a current data feature array to be detected; a comparison module, used to compare the current data feature array to be detected with the current preset data feature array; and a detection module, used to determine the current intrusion state of the CAN bus according to the comparison result, so as to perform CAN bus intrusion detection on the controller to be detected.

[0015] 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.

[0016] 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.

[0017] The CAN bus intrusion detection method and device provided above obtain one or more current messages to be detected sent by the controller to be detected to the CAN bus, read the current filled content therein, obtain the current data feature array to be detected, and compare the current data feature array to be detected with the current preset data feature array, and determine the current intrusion state of the CAN bus based on the comparison result to realize CAN bus intrusion detection. By using the reserved bits of the CAN protocol to construct data features, abnormal intrusions can be accurately detected, and the data features provided by the current data feature array to be detected are the features of data changes within the message, which increases the difficulty of cracking, does not require excessive human participation, saves manpower, and improves the recognition rate of intrusion. Compared with the method of using a support vector machine model or a neural network model to identify whether the features between related data are correct, the computing resources of the controller are also less occupied. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] 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 labor.

[0019] Figure 1 A flow chart of a CAN bus intrusion detection method provided in an embodiment of the present application;

[0020] Figure 2 A square matrix D R Example diagram of

[0021] Figure 3 This is an example diagram of a 2*2 square matrix D;

[0022] Figure 4 A schematic diagram of the structure of a CAN bus intrusion detection device provided in an embodiment of the present application;

[0023] Figure 5 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 1As shown, Figure 1 A flow chart of a CAN bus intrusion detection method provided in an embodiment of the present application, the method comprises the following steps:

[0026] Step S110, obtaining the current message group to be detected sent by the controller to be detected to the CAN bus.

[0027] The current message group to be detected includes one or more current messages to be detected.

[0028] The method may be executed by a gateway, or other implementations set by those skilled in the art may be provided.

[0029] The controller to be detected may be one or more. 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 ECUs among all the ECUs connected to the CAN bus can be used as the controller to be detected in this method.

[0030] One ECU can send multiple types of messages. It is understood that if a certain ECU is selected as the controller to be detected, all or part of the messages of the ECU can be selected as the messages to be detected by the ECU. Each type of message of each ECU has a unique message identifier according to the CAN protocol. The message identifier can be used to query which ECU sent the message and which type of message it is.

[0031] In some embodiments, before obtaining the current message group to be detected sent by the controller to be detected to the CAN bus, the method includes: the controller to be detected receives the intrusion detection result message group sent by the gateway, the intrusion detection result message group includes an intrusion data feature array pair representing the number of intrusions; if the intrusion data feature array pair has not changed, the controller to be detected determines the current data feature array to be detected based on the previous data feature array to be detected used in the previous message group to be detected, the current data feature array set to be detected, the preset loop sequence and the cycle period of the data feature array to be detected, and the previous data feature array to be detected and the current data feature array to be detected belong to the current data feature array set to be detected. , each set of data feature arrays to be detected includes multiple data feature arrays to be detected, and the multiple data feature arrays to be detected have a preset cyclic order. The current set of data feature arrays to be detected is determined based on the intrusion data feature array pair in the intrusion detection result message group, and different intrusion data feature array pairs are pre-set with different sets of data feature arrays to be detected; the controller to be detected determines the current filling content of the CAN protocol reserved filling bit of each current message to be detected in the current message group to be detected that needs to be sent according to the current data feature array to be detected, and fills the CAN protocol reserved filling bit of each current message to be detected based on the current filling content to obtain the current message group to be detected.

[0032] As an example, the method for determining the intrusion detection result message group and the intrusion data feature array pair is as follows: the gateway periodically sends an intrusion detection result message to each ECU, the intrusion detection result message will include an intrusion data feature array that represents the number of intrusions, and the ECU receives two consecutive intrusion detection result messages sent by the gateway to obtain an intrusion detection result message group, and the two intrusion data feature arrays in the two intrusion detection result messages are used as an intrusion data feature array pair.

[0033] A counter for recording the number of intrusions can be set in the gateway. The counter is reset according to a certain counting threshold, such as starting from 0, counting to 10, then returning to zero and counting from 0 again. Each count corresponds to a detection of the current intrusion state as an intrusion. Two intrusion data feature arrays, that is, an intrusion data feature array pair, are pre-configured for each count. The gateway generates an intrusion detection result message based on an intrusion data feature array, obtains two intrusion detection result messages, and sends the two intrusion detection result messages alternately, so that the ECU receives two intrusion detection result messages and obtains an intrusion detection result message group. For example, for count 0, intrusion detection result message A and intrusion detection result message B are pre-configured, and for count 1, intrusion detection result message C and intrusion detection result message D are pre-configured. When the first current intrusion state is not detected as an intrusion, the gateway periodically sends intrusion detection result message A and intrusion detection result message B alternately. When the first current intrusion state is detected as an intrusion, the gateway periodically sends intrusion detection result message C and intrusion detection result message D alternately.

[0034] As an example, a method for generating an intrusion detection result message based on an intrusion data feature array can be: pre-configuring a reserved position of the intrusion detection result message according to each data position in the intrusion data feature array, and then filling the data in the intrusion data feature array into the intrusion detection result message according to the correspondence between the data position in the intrusion data feature array and the reserved position of the intrusion detection result message, so as to obtain an intrusion detection result message that can be sent by the gateway.

[0035] The method for determining whether the intrusion data feature array pair has changed can be obtained by comparing the intrusion data feature array pair obtained from the intrusion detection result message group received last time with the intrusion data feature array pair obtained from the intrusion detection result message group currently received. The mapping relationship between the intrusion data feature array pair in the intrusion detection result message group and the corresponding count times can also be pre-stored in the ECU, and the ECU determines whether the intrusion data feature array pair has changed by determining whether the count times corresponding to each intrusion data feature array pair have changed.

[0036] If the intrusion data feature array pair has not changed, the set of data feature arrays to be detected used by the current data feature array to be detected does not need to be changed. Otherwise, if the intrusion data feature array pair has changed, the set of data feature arrays to be detected used by the current data feature array to be detected needs to be changed. This can effectively improve the security of data transmission and effectively resist intrusion risks.

[0037] For a message to be detected sent by an ECU, only a fixed data feature array to be detected may be used, but the risk resistance of this method is poor. Therefore, a set of data feature arrays to be detected can be set for cyclic use to increase the difficulty of intrusion. This set of data feature arrays to be detected is used as a set of data feature arrays to be detected. The preset cyclic order of different data feature arrays to be detected in the set of data feature arrays to be detected is pre-set, and the data feature arrays to be detected are cyclically used according to certain data feature arrays to be detected. Furthermore, a set of data feature arrays to be detected can be set for each intrusion data feature array, so that once an intrusion event occurs, the set of data feature arrays to be detected is replaced to resist the risk of intrusion.

[0038] Continuing with the above embodiment, if the intrusion data feature array pair changes, the controller to be detected determines the changed data feature array set to be detected based on the intrusion data feature array pair in the intrusion detection result message; the data feature array to be detected with the first preset loop order in the changed data feature array set to be detected is determined as the current data feature array to be detected; the controller to be detected determines the current filling content of the CAN protocol reserved filling bit of each current message to be detected in the current message group to be detected that needs to be sent based on the current data feature array to be detected, and fills the CAN protocol reserved filling bit of each current message to be detected based on the current filling content to obtain the current message group to be detected.

[0039] If the used data feature array set to be detected is changed, for the newly enabled data feature array set to be detected, that is, the changed data feature array set to be detected, the first data feature array to be detected can be directly used as the current data feature array to be detected.

[0040] Continuing from the above embodiment, the method for determining the cycle period of the characteristic array of data to be detected includes: if there are at least two to-be-detected messages with different sending frequencies in the to-be-detected message group of the to-be-detected controller, determining the cycle period of the characteristic array of data to be detected of the to-be-detected controller according to all sending frequencies.

[0041] As mentioned in the above embodiment, in the case of receiving the same intrusion data feature array, the data feature array to be detected filled in the message to be detected will also be updated according to the preset cycle order of the set of data feature arrays to be detected. At this time, if the update frequencies of different messages of an ECU are inconsistent, it may cause the update of each part of the final current data feature array to be detected, which is composed of the data feature array to be detected obtained based on all the messages to be detected of the ECU, to be very chaotic, resulting in a relatively complex final comparison. At this time, a cycle period of a data feature array to be detected can be determined according to the sending frequency of all the messages to be detected, and the longest sending period of all the messages to be detected can be used as the cycle period of the data feature array to be detected of the ECU. Then, the data feature array to be detected filled in the message to be detected will also be updated according to the preset cycle order of the set of data feature arrays to be detected and the cycle period of the data feature array to be detected.

[0042] Continuing from the above embodiment, if there are multiple controllers to be detected, the characteristic arrays of data to be detected corresponding to the controllers to be detected are all different.

[0043] Of course, all the controllers to be detected can also use the same data feature array to be detected, which will reduce the difficulty of intrusion. If each data feature array to be detected in the set of data feature arrays to be detected used by each ECU is different, it will greatly increase the difficulty of attack and will not cause large-scale attacks.

[0044] Alternatively, the above effect can be achieved by controlling the sets of characteristic arrays of data to be detected corresponding to different controllers to be detected. The security level is slightly lower than that of the above solution, but the configuration difficulty of the characteristic arrays of data to be detected is also reduced.

[0045] Step S120, reading the current filling content of the CAN protocol reserved filling bit of each current message to be detected, and obtaining the current data feature array to be detected.

[0046] In one embodiment, a method for determining a CAN protocol reserved fill bit of a controller to be detected includes: obtaining all types of controller messages sent by a controller to be detected to a CAN bus; determining at least a portion of all types of controller messages as messages to be detected; selecting at least one bit of reserved fill bits in each message to be detected, and the reserved fill bits are used to fill corresponding fill contents constituting a feature array of data to be detected, so as to complete the determination of the CAN protocol reserved fill bits of each message to be detected.

[0047] That is, for each data position of the data feature array to be detected, a bit of reserved filling position is configured in a message to be detected, and subsequently the data content of the data feature array to be detected at the data position is used as the filling content of the reserved filling position in the corresponding message to be detected.

[0048] Since each type of message to be detected of an ECU has a unique message identifier, and the sending frequencies of different types of messages to be detected may be different, it is possible that not all messages to be detected of a certain ECU are received at a time, but only part of the messages to be detected. Therefore, if the CAN protocol reserved fill bits of a current message to be detected are sufficient, and the number of its CAN protocol reserved fill bits is greater than the preset fill bit threshold, which is sufficient to generate at least one minimum unit of the data feature array to be detected, then the subsequent comparison can find the current preset data feature array corresponding to the message identifier according to the message identifier to perform a comparison of at least one minimum unit of the data feature array to be detected. However, if the number of reserved fill bits of the CAN protocol of a current message to be detected is less than the preset fill bit threshold, it is not enough to generate at least one minimum unit of the data feature array to be detected. At this time, according to the preset association relationship between the messages to be detected, the search can be realized through the associated message identifier, and then at least one minimum unit of the data feature array to be detected is generated through two or more current messages to be detected, and then the corresponding current preset data feature array is matched through the associated message identifier to perform a comparison of at least one minimum unit of the data feature array to be detected. During the configuration process, the sending frequency of the two associated messages to be detected is consistent, ensuring that at least one minimum unit of the data feature array to be detected can be determined through one reception each time.

[0049] The current data feature array to be detected may be an integrated data feature array (a large array) composed of one or more minimum unit data feature arrays to be detected obtained based on the current filling content corresponding to each current message to be detected, and / or an array set of one or more minimum unit data feature arrays to be detected obtained separately based on the current filling content corresponding to each current message to be detected. Alternatively, it may be one or more minimum unit data feature arrays to be detected obtained separately from the current filling content corresponding to a part of the current messages to be detected, one or more minimum unit data feature arrays to be detected obtained separately from the current filling content corresponding to at least two current messages to be detected that have an associated relationship in another part, a set of two parts of minimum unit data feature arrays to be detected (a plurality of small arrays), etc.

[0050] What those skilled in the art should know is, no matter adopt a large array, or a plurality of small arrays, or adopt two ways simultaneously, consider that each array is associated with the message identification of the message to be detected itself, so just can find preset data characteristic array, can be to compare the current data characteristic array to be detected with the current preset data characteristic array by a message identification, can also be to organize the current preset data characteristic array by the message identification with the association relationship, and then realize the comparison of the current data characteristic array to be detected corresponding to the message identification with the association relationship and the current preset data characteristic array. It is also possible to construct a large array as the current preset data characteristic array in the current message group to be detected by the message identification of all the current messages to be detected according to the same array construction rule, and then compare with the large array (current data characteristic array to be detected) constituted by the data characteristics in all the current messages to be detected. Specific implementation can be selected by those skilled in the art as needed.

[0051] The minimum unit of the data feature array to be detected can be understood as the minimum unit in the array structure set by those skilled in the art. For example, the data feature array to be detected of all the messages to be detected of a controller to be detected (the so-called large array) is set to 64 bits, which is an 8*8 square matrix, and then the 4 adjacent elements in the 8*8 square matrix are combined into a 2*2 square matrix, then the array represented by this 2*2 square matrix is ​​the aforementioned minimum unit. That is, an 8*8 square matrix can be split into 16 2*2 square matrices. The current data feature array to be detected obtained at one time can be an 8*8 square matrix obtained from the filling content in all the messages to be detected. Considering that a message of a controller to be detected has multiple sending cycles, a more specific scenario is that several messages to be detected form multiple 2*2 square matrices, and multiple current data feature arrays to be detected are obtained, that is, the current data feature array to be detected includes multiple arrays, and then these arrays are formed into a temporary data feature array (square matrix) according to preset rules, and then compared with the preset data feature array, and / or each array (2*2 square matrix) is compared with the corresponding preset data feature array.

[0052] Step S130, comparing the current data feature array to be detected with the current preset data feature array.

[0053] Each CAN protocol reserved fill bit corresponds to at least one data position of the data feature array to be detected. In this way, after determining the current data feature array to be detected, the data content at each position is obtained, which can be filled into the corresponding CAN protocol reserved fill bit of the corresponding message to be detected as fill content. The correspondence between each CAN protocol reserved fill bit and the data position of the data feature array to be detected can be pre-constructed, and the gateway and ECU can store the correspondence in advance to facilitate subsequent processing.

[0054] In one embodiment, before comparing the current data feature array to be detected with the current preset data feature array, the method further includes: determining a current set of data feature arrays to be detected according to the intrusion detection result message group currently sent by the gateway, the intrusion detection result message group including an intrusion data feature array pair representing the number of intrusions, different intrusion data feature array pairs are pre-set with different sets of data feature arrays to be detected, each set of data feature arrays to be detected including multiple data feature arrays to be detected, and the multiple data feature arrays to be detected have a preset cyclic order; if the intrusion detection result message group currently sent by the gateway is the same as the intrusion detection result message group sent by the gateway last time, determining the current preset data feature array according to the previous data feature array to be detected determined by the previous acquired group of messages to be detected, the current set of data feature arrays to be detected, and the preset cyclic order; if the intrusion detection result message group currently sent by the gateway is different from the intrusion detection result message group sent by the gateway last time, determining the data feature array to be detected with the first preset cyclic order in the current set of data feature arrays to be detected as the current preset data feature array.

[0055] Similar to the aforementioned method of filling the data feature array to be detected in the message group to be detected, as another example, for the method of filling the content of the intrusion data feature array in the intrusion detection result message, the position of the number of digits in the intrusion data feature array can be selected in advance in the reserved position of the intrusion detection result message as the reserved position, and each reserved position is pre-configured with a corresponding array position in the intrusion data feature array. Then, when the intrusion data feature array that needs to be filled is known, the numbers in the intrusion data feature array are filled in the corresponding reserved positions according to the above-mentioned position mapping relationship. Every time a recognized intrusion event is detected, the intrusion detection result message needs to be changed, and an intrusion event is characterized by a set of different intrusion data feature array pairs. For example, the intrusion data feature array pair a and b are used to represent the number of intrusions as 0, the intrusion data feature array pair c and d are used to represent the number of intrusions as 1, the intrusion data feature array pair e and f are used to represent the number of intrusions as 2, the intrusion data feature array pair g and h are used to represent the number of intrusions as 3... The intrusion data feature array pair q and r are used to represent the number of intrusions as 8. When the number of intrusions is 0, the intrusion data feature array a is first filled once to obtain the intrusion detection result message A, and the intrusion data feature array b is first filled once to obtain the intrusion detection result message B. Before the next intrusion event is detected, the intrusion detection result message A and the intrusion detection result message B are repeatedly sent as the intrusion detection result message group currently sent by the gateway. Once the next intrusion event is detected, when the number of intrusions is 1, the intrusion data feature array c is first filled once to obtain the intrusion detection result message C, and the intrusion data feature array d is first filled once to obtain the intrusion detection result message D. Before the next intrusion event is detected, the intrusion detection result message C and the intrusion detection result message D are repeatedly sent as the intrusion detection result message group currently sent by the gateway... When the number of intrusions is 8, the intrusion data feature array q is first filled once to obtain the intrusion detection result message Q, and the intrusion data feature array r is first filled once to obtain the intrusion detection result message R. Before the next intrusion event is detected, the intrusion detection result message Q and the intrusion detection result message R are repeatedly sent as the intrusion detection result message group currently sent by the gateway. If the next intrusion event is detected again within the same detection cycle, then from the time when the intrusion number is 1, the intrusion data feature array c is first filled once to obtain the intrusion detection result message C, and the intrusion data feature array d is first filled once to obtain the intrusion detection result message D, the step is still a cycle. If the next intrusion event is not detected within the same detection cycle, the cyclic sending of the intrusion detection result message Q and the intrusion detection result message R is maintained.When the next detection cycle is reached, when the number of intrusions is 0, the intrusion data feature array a is first filled to obtain the intrusion detection result message A, and the intrusion data feature array b is first filled to obtain the intrusion detection result message B. Before the next intrusion event is detected, the intrusion detection result message A and the intrusion detection result message B are repeatedly sent as the intrusion detection result message group currently sent by the gateway to start the cycle.

[0056] If the intrusion detection result message group is a switch between intrusion detection result message A and intrusion detection result message B within a certain period of time, it means that the current number of intrusions has not changed. As mentioned in the above embodiment, each ECU is pre-configured with a specific set of data feature arrays to be detected J1 for each number of intrusions (i.e., intrusion data feature arrays). Then, under the premise that the intrusion detection result message group sent by the gateway remains unchanged, at this time, the cyclic switching of the data feature arrays to be detected in the set of data feature arrays to be detected J1 can be performed under the preset requirements of the cycle period of the data feature arrays to be detected. If the intrusion detection result message group was a switch between intrusion detection result message A and intrusion detection result message B last time, and is currently a switch between intrusion detection result message C and intrusion detection result message D, it means that the number of intrusions has changed. At this time, it is necessary to find the intrusion number, or the intrusion data feature arrays corresponding to the intrusion detection result message C and the intrusion detection result message D in the specific set of data feature arrays to be detected J2 corresponding to a certain ECU, and then the data feature array to be detected with the preset cycle order as the first in the set of data feature arrays to be detected J2 is used as the current preset data feature array. And if the intrusion detection result message groups are all switches between intrusion detection result messages C and intrusion detection result messages D within a certain period of time, the cyclic switching of the feature arrays to be detected in the feature array set J2 is performed according to the preset requirement of the cyclic period of the feature arrays to be detected.

[0057] Step S140, determining the current intrusion state of the CAN bus according to the comparison result to perform CAN bus intrusion detection.

[0058] In one embodiment, the current intrusion state of the CAN bus is determined according to the comparison result, including: if the comparison result is a comparison failure, obtaining a new current message group to be detected sent by the controller to be detected to the CAN bus within a preset time length; comparing a new current data feature array to be detected obtained for each new current message group to be detected with a new current preset data feature array; if there are comparison failure results greater than a preset failure threshold number in the comparison results obtained within the preset time length, the current intrusion state of the CAN bus is determined to be intrusion; if there are comparison failure results less than or equal to the preset failure threshold number in the comparison results obtained within the preset time length, the current intrusion state of the CAN bus is determined to be safe.

[0059] In other words, when the comparison result obtained for the first time is a failure, new comparison results can be determined continuously within a certain preset time, and the number of comparison results that fail can be counted. If the number of comparison results that fail within the preset time is greater than or equal to the preset failure threshold number, then the current intrusion state of the CAN bus is determined to be an intrusion, that is, the aforementioned intrusion event, and the number of intrusions is recorded. Otherwise, the number of intrusions is not counted. Due to certain errors in the system, if an intrusion is determined to be an intrusion based on only one comparison result that fails, there may be a greater risk of misjudgment.

[0060] The above-mentioned one comparison can be considered as the process of judging by the message of the ECU received by the gateway at one time. When there are multiple controllers to be detected, the gateway receives the current message group to be detected of all controllers in a batch, and then compares them. If the comparison result of the current data feature array to be detected of at least one current message to be detected of at least one controller fails, the result of this comparison is considered to be a failure.

[0061] Continuing with the above embodiment, the method further includes: if the current intrusion state of the CAN bus is determined to be an intrusion, triggering the gateway to determine a new intrusion detection result message group as the intrusion detection result message group currently sent, the new intrusion detection result message group includes a new intrusion data feature array pair, the new intrusion data feature array pair is determined based on the number of intrusions that the current intrusion state of the CAN bus is determined to be an intrusion, and each number of intrusions is pre-set with a corresponding intrusion data feature array pair; if the current intrusion state of the CAN bus has not yet been determined to be an intrusion, triggering the gateway to use the intrusion detection result message group sent last time as the intrusion detection result message group currently sent.

[0062] As mentioned in the above-mentioned embodiment, each time an intrusion event is detected, the intrusion data feature array pair is updated, and then the intrusion detection result message group is updated to trigger all the controllers to be detected to update the currently used data feature array set to be detected according to the mapping relationship between the pre-agreed number of intrusions (intrusion data feature array pairs) and the data feature array set to be detected.

[0063] If each ECU uses a different set of data feature arrays to be detected, once an intrusion event occurs, the number of affected controllers can be effectively reduced.

[0064] In one embodiment, if the detection frequency of intrusion events is greater than a preset frequency threshold, that is, the frequency of determining that the current intrusion state is intrusion is greater than the preset frequency threshold, the gateway randomly selects an intrusion data feature array pair from all intrusion data feature array pairs as the currently used intrusion data feature array pair.

[0065] In one embodiment, if the intrusion data feature array pair changes, and the change pattern of the intrusion data feature array pair is different from the preset change pattern, different durations are counted. If the duration is greater than the preset duration threshold, the ECU randomly selects a data feature array set to be detected from all corresponding data feature array sets to be detected as the currently used data feature array set to be detected, and randomly selects a data feature array to be detected from the currently used data feature array set to be detected as the current data feature array to be detected.

[0066] The CAN bus intrusion detection method provided in the above embodiment obtains one or more current messages to be detected sent by the controller to be detected to the CAN bus, reads the current filled content therein, obtains the current data feature array to be detected, and compares the current data feature array to be detected with the current preset data feature array, and determines the current intrusion state of the CAN bus based on the comparison result to realize CAN bus intrusion detection. By constructing data features using the reserved bits of the CAN protocol, abnormal intrusions can be accurately detected, and the data features provided by the current data feature array to be detected are the features of data changes within the message, which increases the difficulty of cracking, does not require excessive human participation, saves manpower, and improves the recognition rate of intrusion. Compared with the method of using a support vector machine model or a neural network model to identify whether the features between related data are correct, the computing resources of the controller are also less occupied.

[0067] The CAN bus intrusion detection method provided in the above embodiment uses the unused data bits in the CAN protocol to establish the data features of the vehicle CAN. When an intrusion occurs, the data features will be destroyed, and the CAN bus can be detected to be intruded and destroyed. Because the data features are designed in advance, the data features are strong, the detection rate is high, and the calculation amount is small, which can reduce the occupation of computing resources.

[0068] The CAN bus intrusion detection method provided by the above embodiment is exemplarily described below through a specific embodiment. In order to accurately detect intrusion, the data characteristics of the reserved bits (unused bits) in the message of each ECU should be obvious, and if the reserved bits of any message are not set according to the rules, the data characteristics will be destroyed.

[0069] To this end, we select 64 bits of reserved bits from ID1, ID2, ..., IDn in all messages (messages to be detected) sent by a certain ECU (controller to be detected) to form an 8*8 square matrix D R , from the square matrix D R Take four adjacent elements to form a 2*2 square matrix D, such as Figure 2 As shown, Figure 2 A square matrix D R An example diagram of the matrix D R Take out 4 X or 4 Y to form a square matrix D, so that 16 2*2 square matrices can be taken out, and then use 16 square matrices D to form a 4*4 square matrix D 组 A 2*2 square matrix D can be found in Figure 3 , Figure 3 This is an example diagram of a 2*2 square matrix D. Then the 16 states are divided into four groups, and the four groups are numbered 0, 1, 2, and 3, thus obtaining four feature array sets of data to be detected. 组 The 16 matrix elements in the matrix are selected from 0, 1, 2, and 3 (the selection method is determined by the communication matrix designer himself), thus forming a 4*4 matrix D with specific values. 组 , this matrix is ​​the data feature of each ECU (similar to a fingerprint). The matrix D of each ECU 组 It is better to be inconsistent to increase the difficulty of cracking. When ECU sends a message, it follows its own data characteristics D 组To fill the reserved bits, for example, if the square matrix D composed of 4 Xs takes the value of 2, then the four reserved bits are filled according to the second group of the grouping state of the square matrix D. The filled four reserved bits are cycled according to the four states of the second group, which can be cycled sequentially or sent several times in a row and then cycled. The purpose of each square matrix cycle is to increase the difficulty of cracking and prevent replay attacks. It is best for each message to contain a square matrix D (the smallest unit of the data feature array to be detected), so that it can be confirmed in time that a certain message does not meet the data characteristics, and a certain message can be detected in time if it is tampered with or forged. The square matrix D of a message is cycled according to the same cycle, and the square matrix D of different messages is cycled according to the message with a longer cycle. Similarly, each ECU can have a set of data features (that is, different sets of data feature arrays to be detected are pre-set according to the intrusion data feature array pair (number of intrusions)). When an intrusion occurs, the ECU can switch the data features according to certain rules.

[0070] In one embodiment, a set of data features (n, more than 3, less than 8) is selected for each ECU. The set of data features D 组 The last digit of the determinant of the 4*4 matrix should satisfy the distribution of 1, 2, 3, ..., n. Calculate the determinant of this set of data feature matrices, and the last digit of their determinants should be 1, 2, 3, ..., n, respectively, without duplication or omission.

[0071] The switching steps after an intrusion is detected (each time an intrusion event occurs) are as follows:

[0072] S1: The gateway module monitors in real time whether the messages sent by each ECU on each network segment (the current message group to be detected sent by the controller to be detected) are filled in the reserved positions according to their data characteristics. If ten intrusions are detected (the data characteristics of the ECU are destroyed for 10 frames, and the comparison results have accumulated 10 failures), it is considered to have been attacked and reported to the cloud platform that an attack has occurred, that is, an intrusion event has occurred, and the current intrusion status is recorded as an intrusion.

[0073] Note: The reason why it takes ten intrusions to be considered an attack is that when the bus is disturbed or wrong, the data characteristics may be destroyed.

[0074] S2: The gateway module sends an updated matrix D representing the number of intrusions 侵 (Fill in the reserved position of a message, intrusion data feature array pair), each time it is attacked, the number of intrusions increases. (If it is added to 8, it will be cycled again. Here, 8 is taken as an example, and technicians in this field can adjust it as needed)

[0075] Among them, D 侵It is a 2*2 matrix with the following 16 states, where every two states (intrusion data feature array pairs) correspond to one intrusion frequency (intrusion frequency 0, 1, 2, ..., 8). 侵 The two states of each group are exchanged. The total 16 intrusion data feature arrays D 侵 An implementation example can also be found in Figure 3 The arrays shown in the examples may be implemented in other ways as determined by those skilled in the art.

[0076] S3: Each ECU receives a square matrix D indicating the number of intrusions 侵 ,First, the authenticity of the matrix is ​​determined (i.e., whether it changes in two states and ,whether it changes alternately according to a set of intrusion data feature array pairs set in advance), ,if it is true, the data features are updated according to the ,number of intrusions.

[0077] The data features corresponding to the number of intrusions (the data feature array to be detected in the set of data feature arrays to be detected), such as the above example, the number of intrusions can be the data feature D of each group of ECU 组 The last digits of the determinants of the 4*4 matrices are equal.

[0078] S4: The gateway continues to detect whether the message sent by each ECU fills the reserved position according to its data characteristics (the current preset data characteristic array). If the frequency of data characteristics being changed is greater than 10 times per second, the gateway sends D 侵 No more swapping changes according to the rules.

[0079] This means that there may be large-scale errors in the messages sent by the ECU, which means that the scope of the possible invasion is large. In order to further solve the current intrusion problem as much as possible, the change pattern of the original array can be broken to make the intruder doubt the data sending pattern.

[0080] S5: Each ECU detects the D sent by the gateway 侵 If it is not true for 10 seconds, the data feature filled in the reserved position will be randomly selected from a group of data features. 侵 to set it up.

[0081] The unreality here is the D sent by the gateway. 侵 The exchange and changes are no longer carried out according to the rules. At this time, the ECU's current data feature array to be detected does not change according to the pre-set rules. This increases the difficulty of malicious cracking and ensures that intrusion detection can still be accurately detected.

[0082] The above setting of numerical values, such as 10 seconds, 10 times per second, etc., is only an example, and those skilled in the art can set the numerical values ​​as needed.

[0083] By using the reserved bits of the CAN protocol to construct data features, abnormal intrusions can be accurately detected; and the data features are the features of internal data changes, which increases the difficulty of being cracked. By using the square matrix of the number of intrusions, other controllers can adjust the data features through this matrix to increase the difficulty of cracking. By using the reserved bits of the CAN protocol to construct data features (data feature array to be detected), abnormal intrusions can be accurately detected; and the data features are the features of internal data changes, which increases the difficulty of being cracked. By using the square matrix of the number of intrusions (intrusion data feature array pair), other controllers can adjust the data features through this matrix to increase the difficulty of cracking.

[0084] In one embodiment, a CAN bus intrusion detection device is provided, and the CAN bus intrusion detection device is used to perform the steps in the CAN bus intrusion detection method provided in any of the above embodiments. Figure 4 , Figure 4 A schematic diagram of the structure of a CAN bus intrusion detection device provided in an embodiment of the present application is shown in FIG. Figure 4 As shown, the CAN bus intrusion detection device 400 includes: an acquisition module 401, which is used to acquire the current message group to be detected sent by the controller to be detected to the CAN bus, and the current message group to be detected includes one or more current messages to be detected; a reading module 402, which is used to read the current filling content of the CAN protocol reserved filling bit of each current message to be detected, and obtain the current data feature array to be detected; a comparison module 403, which is used to compare the current data feature array to be detected with the current preset data feature array; a detection module 404, which is used to determine the current intrusion state of the CAN bus according to the comparison result, so as to perform CAN bus intrusion detection on the controller to be detected.

[0085] In one embodiment, the device further includes a current to-be-detected message group determination module, which is used for obtaining the current to-be-detected message group sent by the to-be-detected controller to the CAN bus before the to-be-detected controller receives the intrusion detection result message group sent by the gateway, the intrusion detection result message group including an intrusion data feature array pair representing the number of intrusions; if the intrusion data feature array pair has not changed, the to-be-detected controller determines the current to-be-detected data feature array based on the previous to-be-detected data feature array used in the previous to-be-detected message group, the current to-be-detected data feature array set, the preset loop sequence and the to-be-detected data feature array loop period, and the previous to-be-detected data feature array and the current to-be-detected data feature array belong to the same A current set of data feature arrays to be detected, each set of data feature arrays to be detected includes multiple data feature arrays to be detected, the multiple data feature arrays to be detected have a preset cyclic order, the current set of data feature arrays to be detected is determined based on an intrusion data feature array pair in an intrusion detection result message group, and different intrusion data feature array pairs are pre-set with different sets of data feature arrays to be detected; the controller to be detected determines the current filling content of the CAN protocol reserved filling bit of each current message to be detected in the current message group to be detected that needs to be sent according to the current data feature array, and fills the CAN protocol reserved filling bit of each current message to be detected based on the current filling content to obtain the current message group to be detected.

[0086] In one embodiment, the current message group to be detected determination module is also used for, if the intrusion data feature array pair changes, the to-be-detected controller determines the changed data feature array set to be detected according to the intrusion data feature array pair in the intrusion detection result message; the to-be-detected data feature array with the first preset loop order in the changed data feature array set to be detected is determined as the current data feature array to be detected; the to-be-detected controller determines the current filling content of the CAN protocol reserved filling bit of each current message to be detected in the current message group to be detected that needs to be sent according to the current data feature array to be detected, and fills the CAN protocol reserved filling bit of each current message to be detected based on the current filling content to obtain the current message group to be detected.

[0087] In one embodiment, the device further comprises a period determination module for determining the cycle period of the characteristic array of data to be detected of the controller to be detected according to all the transmission frequencies if at least two messages to be detected in the message group to be detected of the controller to be detected have different transmission frequencies.

[0088] In one embodiment, the device also includes a CAN protocol reserved fill bit determination module, which is used to obtain all types of controller messages sent by a controller to be detected to the CAN bus; determine at least a part of all types of controller messages as messages to be detected; select at least one bit of reserved fill bits in each message to be detected, and the reserved fill bits are used to fill the corresponding fill content that constitutes the feature array of data to be detected, so as to complete the determination of the CAN protocol reserved fill bits of each message to be detected.

[0089] In one embodiment, the device further includes a current preset data feature array determination module, which is used to determine a current set of data feature arrays to be detected according to an intrusion detection result message group currently sent by the gateway before comparing the current data feature array to be detected with the current preset data feature array, the intrusion detection result message group including an intrusion data feature array pair representing the number of intrusions, different intrusion data feature array pairs are pre-set with different sets of data feature arrays to be detected, each set of data feature arrays to be detected includes multiple data feature arrays to be detected, and the multiple data feature arrays to be detected have a preset cyclic order; if the intrusion detection result message group currently sent by the gateway is the same as the intrusion detection result message group sent by the gateway last time, the current preset data feature array is determined according to the previous data feature array to be detected determined by the previous acquired message group to be detected, the current set of data feature arrays to be detected, and the preset cyclic order; if the intrusion detection result message group currently sent by the gateway is different from the intrusion detection result message group sent by the gateway last time, the data feature array to be detected with the first preset cyclic order in the current set of data feature arrays to be detected is determined as the current preset data feature array.

[0090] In one embodiment, the detection module is configured as follows: if the comparison result is a comparison failure, a new current message group to be detected sent by the controller to be detected to the CAN bus is obtained within a preset time length; a new current data feature array to be detected obtained for each new current message group to be detected is compared with a new current preset data feature array; if there are comparison failure results greater than a preset failure threshold number in the comparison results obtained within the preset time length, the current intrusion state of the CAN bus is determined to be intrusion; if there are comparison failure results less than or equal to the preset failure threshold number in the comparison results obtained within the preset time length, the current intrusion state of the CAN bus is determined to be safe.

[0091] In one embodiment, the detection module is further configured as follows: if the current intrusion state of the CAN bus is determined to be an intrusion, the gateway is triggered to determine a new intrusion detection result message group as the intrusion detection result message group currently being sent, the new intrusion detection result message group includes a new intrusion data feature array pair, the new intrusion data feature array pair is determined based on the number of intrusions that determine the current intrusion state of the CAN bus as an intrusion, and each number of intrusions is pre-set with a corresponding intrusion data feature array pair; if the current intrusion state of the CAN bus has not yet been determined to be an intrusion, the gateway is triggered to use the intrusion detection result message group sent last time as the intrusion detection result message group currently being sent.

[0092] For the specific definition of the CAN bus intrusion detection device, please refer to the definition of the CAN bus intrusion detection method above, which will not be repeated here. Each module in the above-mentioned CAN bus intrusion detection device 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.

[0093] In this embodiment, the CAN bus intrusion detection device is essentially provided with multiple modules for executing the CAN bus intrusion detection method 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.

[0094] In one embodiment, a vehicle is provided, the vehicle comprising the CAN bus intrusion detection device provided by any of the above embodiments. The specific functions and technical effects of the vehicle can refer to the above embodiments, and will not be described in detail here.

[0095] See also Figure 5 An embodiment of the present invention further provides an electronic device 500, including a processor 501, a memory 502 and a communication bus 503; the communication bus 503 is used to connect the processor 501 and the memory 802; the processor 501 is used to execute the computer program stored in the memory 502 to implement a method provided in any one of the above embodiments.

[0096] 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.

[0097] 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.

[0098] 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.

[0099] 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.

[0100] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.

[0101] 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).

[0102] 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.

[0103] 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.

[0104] 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.

[0105] 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, characterized in that: The method comprises: Acquire a current message group to be detected sent by the controller to be detected to the CAN bus, wherein the current message group to be detected includes one or more current messages to be detected; Read the current filling content of the CAN protocol reserved filling bit of each message to be detected, and obtain the current data feature array to be detected; Comparing the current to-be-detected data feature array with the current preset data feature array; The current intrusion state of the CAN bus is determined according to the comparison result to perform CAN bus intrusion detection.

2. The CAN bus intrusion detection method according to claim 1, characterized in that: Before obtaining the current message group to be detected sent by the controller to be detected to the CAN bus, the method includes: The controller to be detected receives an intrusion detection result message group sent by the gateway, wherein the intrusion detection result message group includes an intrusion data feature array pair representing the number of intrusions; If the intrusion data feature array pair has not changed, the controller to be detected determines the current data feature array to be detected according to the previous data feature array to be detected used in the previous message group to be detected, the current data feature array set to be detected, the preset loop order and the cycle period of the data feature array to be detected, the previous data feature array to be detected and the current data feature array to be detected belong to the current data feature array set to be detected, each data feature array set to be detected includes a plurality of data feature arrays to be detected, the plurality of data feature arrays to be detected have a preset loop order, the current data feature array set to be detected is determined based on the intrusion data feature array pair in the intrusion detection result message group, and different intrusion data feature array pairs are pre-set with different data feature array sets to be detected; The controller to be detected determines the current filling content of the CAN protocol reserved filling bit of each current message to be detected in the current message group to be detected that needs to be sent according to the current data feature array to be detected, and fills the CAN protocol reserved filling bit of each current message to be detected based on the current filling content to obtain the current message group to be detected.

3. The CAN bus intrusion detection method according to claim 2, characterized in that: The method further comprises: If the intrusion data feature array pair changes, the to-be-detected controller determines a changed to-be-detected data feature array set according to the intrusion data feature array pair in the intrusion detection result message; Determine the first data feature array to be detected in the preset cycle order in the changed set of data feature arrays to be detected as the current data feature array to be detected; The controller to be detected determines the current filling content of the CAN protocol reserved filling bit of each current message to be detected in the current message group to be detected that needs to be sent according to the current data feature array to be detected, and fills the CAN protocol reserved filling bit of each current message to be detected based on the current filling content to obtain the current message group to be detected.

4. The CAN bus intrusion detection method according to claim 2, characterized in that: The method for determining the cycle period of the characteristic array of data to be detected includes: if there are at least two to-be-detected messages in the to-be-detected message group of the to-be-detected controller with different sending frequencies, determining the cycle period of the characteristic array of data to be detected of the to-be-detected controller according to all sending frequencies.

5. The CAN bus intrusion detection method according to claim 2, characterized in that: If there are multiple controllers to be detected, the characteristic arrays of data to be detected corresponding to the controllers to be detected are different.

6. The CAN bus intrusion detection method according to any one of claims 1 to 5, characterized in that: Methods for determining the CAN protocol reserved fill bits of a controller to be detected include: Obtain all types of controller messages sent by a controller to be detected to the CAN bus; determining at least a portion of all types of controller messages as messages to be detected; At least one bit of reserved filling bit is selected in each of the messages to be detected, and the reserved filling bit is used to fill the corresponding filling content constituting the data feature array to be detected, so as to complete the determination of the CAN protocol reserved filling bit of each message to be detected.

7. The CAN bus intrusion detection method according to any one of claims 1 to 5, characterized in that: Before comparing the current to-be-detected data feature array with the current preset data feature array, the method further includes: Determine a current set of data feature arrays to be detected according to an intrusion detection result message group currently sent by the gateway, wherein the intrusion detection result message group includes an intrusion data feature array pair representing the number of intrusions, and different intrusion data feature array pairs are pre-set with different sets of data feature arrays to be detected, and each set of data feature arrays to be detected includes multiple data feature arrays to be detected, and the multiple data feature arrays to be detected have a preset cyclic order; If the intrusion detection result message group currently sent by the gateway is the same as the intrusion detection result message group sent by the gateway last time, determine the current preset data feature array according to the previous data feature array to be detected determined by the previous message group to be detected, the current set of data feature arrays to be detected, and the preset loop sequence; If the intrusion detection result message group currently sent by the gateway is different from the intrusion detection result message group sent by the gateway last time, the data feature array to be detected with the first preset cycle order in the current set of data feature arrays to be detected is determined as the current preset data feature array.

8. The CAN bus intrusion detection method according to any one of claims 1 to 5, characterized in that: Determining the current intrusion state of the CAN bus according to the comparison result includes: If the comparison result is a comparison failure, obtaining a new current message group to be detected sent by the controller to be detected to the CAN bus within a preset time period; Compare the new current to-be-detected data feature array obtained for each new current to-be-detected message group with the new current preset data feature array; If there are comparison failure results greater than a preset failure threshold number among the comparison results obtained within the preset time period, determining the current intrusion state of the CAN bus as intrusion; If there are comparison failure results less than or equal to a preset failure threshold number among the comparison results obtained within the preset time period, the current intrusion state of the CAN bus is determined to be safe.

9. The CAN bus intrusion detection method according to claim 8, characterized in that: The method further comprises: If the current intrusion state of the CAN bus is determined to be an intrusion, the gateway is triggered to determine a new intrusion detection result message group as the intrusion detection result message group currently being sent, wherein the new intrusion detection result message group includes a new intrusion data feature array pair, wherein the new intrusion data feature array pair is determined based on the number of intrusions for which the current intrusion state of the CAN bus is determined to be an intrusion, and each number of intrusions is pre-set with a corresponding intrusion data feature array pair; If the current intrusion state of the CAN bus has not been determined to be an intrusion, the gateway is triggered to use the intrusion detection result message group sent last time as the intrusion detection result message group sent currently.

10. A CAN bus intrusion detection device, characterized in that: The device comprises: An acquisition module, used for acquiring a current message group to be detected sent by the controller to be detected to the CAN bus, wherein the current message group to be detected includes one or more current messages to be detected; The reading module is used to read the current filling content of the CAN protocol reserved filling bit of each current message to be detected, and obtain the current data feature array to be detected; A comparison module, used for comparing the current data feature array to be detected with the current preset data feature array; The detection module is used to determine the current intrusion state of the CAN bus according to the comparison result, so as to perform CAN bus intrusion detection on the controller to be detected.