Automobile can bus message hybrid attack simulation method based on large model

Through a large-model-based automotive CAN bus message hybrid attack simulator, the DistilBERT model and data enhancement technology are used to generate high-quality and diverse intrusion messages, which solves the problem that existing testing tools are unable to comprehensively evaluate the security of the automotive CAN bus network, and achieves more effective security testing and vulnerability repair.

CN118677686BActive Publication Date: 2025-10-17CHONGQING UNIV OF POSTS & TELECOMM
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410927847.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-11
Publication Date
2025-10-17
Estimated Expiration
2044-07-11

AI Technical Summary

Technical Problem

Existing automotive CAN bus network security testing methods cannot fully simulate potential attack scenarios in the real world. The number of intrusion messages generated is limited and lacks diversity, making it impossible to fully evaluate the network's security and anti-attack capabilities.

Method used

A large-scale model-based automotive CAN bus message hybrid attack simulator is used. The DistilBERT model is combined with data enhancement and fuzzy feature extraction technology to generate high-quality and diverse intrusion messages. Various attack scenarios, including DoS attacks, deception attacks, and tampering attacks, are simulated, and the attack messages are output through the knowledge distillation training model.

Benefits of technology

The generated message test dataset can more comprehensively evaluate the security of the automotive CAN bus network, provide an effective reference for vulnerability repair and security protection, improve the diversity and complexity of testing tools, and meet testing needs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118677686B_ABST
    Figure CN118677686B_ABST
Patent Text Reader

Abstract

The application relates to a large model-based automobile CAN bus message hybrid attack simulation method, and belongs to the field of automobile information security testing, which comprises the following steps: according to the characteristics of a CAN network protocol, combining a plurality of attack means at present and error types defined by the CAN network protocol to generate an initial attack message sample library; optimizing the initial sample library through a data enhancement Borderline-SMOTE method; identifying the vulnerability features of CAN network features through a fuzzy feature extraction method, converting the vulnerability features of the CAN network into feature vectors, assigning labels to each feature vector, and forming a labeled data set; establishing a DistilBERT model based on knowledge distillation, training the DistilBERT model by using the optimized sample library and the CAN network feature vectors, and finally outputting attack messages from the DistilBERT model. The message test data generated by the application can not only meet the conventional tasks, but also understand complex contexts, generate fluent and context-related messages, and generate a high-quality message test data set meeting the test requirements.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application belongs to the field of automobile information security testing, and relates to a large model-based automobile CAN bus message hybrid attack simulation method. BACKGROUND

[0002] In the rapid development of vehicle-mounted networks, the importance of automobile CAN bus is increasingly highlighted. However, with the continuous enhancement of intelligence and connectivity of automobiles, the demand for automobile CAN bus network security is becoming increasingly urgent. In particular, in the aspects of safety testing and vulnerability repair, the demand for high-quality intrusion messages becomes increasingly important.

[0003] Currently, the security testing of automobile CAN bus network often faces a challenge: the traditional testing method may not be able to fully simulate the potential attack scenarios in the real world. This is mainly because the intrusion messages generated by existing testing tools and methods are limited in quantity, and lack sufficient diversity and complexity, which cannot comprehensively evaluate the security and attack resistance of automobile CAN bus network. The method currently used is to use the vehicle bus test tool Vehicle Spy to build a real vehicle attack experiment platform, and to generate corresponding data sets by injecting various attack messages through programs. Once the data sets are generated, it is difficult to adjust and change them, and they cannot dynamically generate corresponding attack messages according to the testing requirements. SUMMARY

[0004] Therefore, the purpose of the present application is to provide a large model-based automobile CAN bus message hybrid attack simulation method. A large model-based automobile CAN bus message hybrid attack simulator. The simulator uses advanced large model technology to generate high-quality, diversified intrusion messages according to real-world automobile network communication data. By simulating various possible attack scenarios, including DoS attacks, deception attacks and tampering attacks, the present application can more comprehensively evaluate the security of automobile CAN bus network, and provide more effective reference for vulnerability repair and security protection.

[0005] To achieve the above purpose, the present application provides the following technical solutions:

[0006] A large model-based automobile CAN bus message hybrid attack simulation method, the method comprising the following steps:

[0007] S1, according to the characteristics of CAN network protocol, combining several attack means and error types defined by CAN network protocol to generate an initial attack message sample library;

[0008] S2, optimizing the initial sample library through the data enhancement Borderline-SMOTE method;

[0009] S3, identify the vulnerability features of the CAN network features by the fuzzy feature extraction method, convert the vulnerability features of the CAN network into feature vectors, and assign a label to each feature vector to form a labeled data set;

[0010] S4, establish a DistilBERT model based on knowledge distillation, train the DistilBERT model using the optimized sample library and CAN network feature vectors, and finally output the attack message from the DistilBERT model.

[0011] Further, in step S1, the several attack means include at least: DoS attack, tampering attack, message injection attack, deception attack, discard attack and fuzzing attack;

[0012] The bit error mechanism defined by the CAN network is used to generate attack messages that trigger the bus shutdown mechanism, wherein the bit error refers to comparing the bit sent by each sender with the output bit on the CAN bus, and if the bit sent by the sender is different from the output bit on the CAN bus during non-arbitration, it indicates that a bit error occurs.

[0013] Further, in step S1, the process of generating an initial attack message sample library according to the CAR-HACKING DATASET data set includes:

[0014] S21, load the data set; read the CAR-HACKING DATASET data set, which contains normal message data, DoS attack, fuzzing attack and deception attack information; view the basic structure and content of the data set to ensure correct data reading and understand the characteristics and distribution of the data;

[0015] S22, add tampering attack; randomly select a certain proportion of normal messages in the data set, randomly modify the data fields of the selected messages, and mark the modified messages as tampering attacks;

[0016] S23, add message injection attack; based on the existing data, generate a certain proportion of false messages, set reasonable time stamps for the newly generated messages, and mark the newly generated false messages as message injection attacks;

[0017] S24, add discard attack; randomly select a certain proportion of messages in the data set, delete the selected messages from the data set to simulate the situation of message being discarded;

[0018] S25, combine the generated multiple attack message data with the original data to form a comprehensive data set containing multiple attack types.

[0019] Further, in step S2, the Borderline-SMOTE data enhancement is adopted to optimize the sample imbalance problem existing in the initial attack message sample library, and the specific steps include the following steps:

[0020] S21, identify the minority class samples located in the expected range of the class boundary, and include them in the boundary sample set;

[0021] S22, generate new synthetic minority class samples for the boundary samples, and add the generated synthetic samples to the original data set. Specifically, in step S21, assuming that the entire data set is T, the minority class is P, and the majority class is N, then:

[0022] P={p1, p2,..., p pnum}, N={n1, n2,..., n nnum}

[0023] Where p num and n num are the number of minority examples and majority examples;

[0024] For each P i (i=1, 2,..., p num ) in the minority class P, calculate its m nearest neighbors from the entire data set T, and the number of majority samples in the m nearest neighbors is denoted as m'(0≤m'≤m);

[0025] If m'=m, that is, the m nearest neighbors of P i are all majority class samples, then P i is considered as a noise point and is not processed subsequently;

[0026] If m / 2≤m'<m, that is, the number of majority class nearest neighbors of P i is greater than the number of minority class nearest neighbors, then P i is highly likely to be misclassified, and is placed in the DANGER set;

[0027] If 0≤m'<m / 2, that is, the number of minority class nearest neighbors of P i is greater than the number of majority class nearest neighbors, then P i is safe and is not processed subsequently;

[0028] Thus, the boundary sample set D is set For each example in DANGER, calculate its K nearest neighbors from P.

[0029] In step S22, for each p i ', randomly select s samples from its k nearest neighbors: first, calculate p ithe difference between p' and its s nearest neighbors, then multiply p' by a random number λ between 0 and 1 i the difference between p' and its s nearest neighbors, then multiply p' by a random number λ between 0 and 1 i the difference between p' and its s nearest neighbors, then multiply p' by a random number λ between 0 and 1

[0030] x new = x + λ × (x nn - x)

[0031] where x new represents the generated new message, x i represents the i-th sample in the minority class sample, x nn represents a randomly selected minority class sample from the K nearest neighbors of x n , (x nn - x) represents the difference between p' and its s nearest neighbors, and λ is a random number between 0 and 1.

[0032] Repeat the above steps for each p i ' in the DANGER set to generate s × d num synthetic positive samples.

[0033] Further, in step S3, the vulnerability features of the target CAN network are obtained by using the fuzzy feature extraction method, and the specific process is as follows:

[0034] Send the random or pseudo-random fuzzing test messages containing deformities or abnormalities in the fuzzing test tool to the target CAN network;

[0035] Monitor the corresponding behavior of each node in the target CAN network and record the response of the target CAN network system to the fuzzing test messages;

[0036] Collect and store the response data of the target CAN network system to the fuzzing test messages, wherein the response data at least includes: error code, crash log, response time;

[0037] Extract features from the response data of the target CAN network system, wherein the extracted features at least include: message type, response time and error code;

[0038] Convert the extracted features into structured feature vectors, and assign labels to each feature vector according to the message type and features to form a labeled dataset; wherein the labels are divided into normal and abnormal.

[0039] Further, in step S4, during the training process by knowledge distillation, first, the defined teacher model is a complete BERT model, and the defined student model is a DistilBERT model with fewer parameters than the teacher model, wherein:

[0040] The teacher model comprises a plurality of Transformer encoding layers for generating an output of the teacher model; the student model also comprises a plurality of Transformer encoding layers, which are trained by learning the output of the teacher, wherein the number of Transformer encoding layers in the student model is less than that in the teacher model;

[0041] The parameters of the student model are optimized by back propagation; for input x, the output T of the teacher model and the output S of the student model are as follows:

[0042]

[0043] wherein (t1,..., t n ) represents the output of the teacher model, represents the input of the teacher model through the softmax() function; (s1,..., s n ) represents the output of the student model, represents the input of the student model through the softmax() function; softmax() is an activation function.

[0044] Further, in step S4, the loss function in the model training process comprises:

[0045] The cross-entropy loss is applied to S with T as the target:

[0046]

[0047] The cosine loss is used to help the student model imitate the teacher model and ensure that the hidden vectors in the teacher model and the student model are aligned:

[0048] L cosine = 1 - cos(T(x), S(x))

[0049]

[0050] wherein L cosine is the student-teacher cosine loss, and L problem is the loss function when processing the message generation task with the sample library;

[0051] The total loss in the whole distillation process is represented as:

[0052]

[0053] The loss function part combines a supervised learning loss and a distillation loss to guide the training of the student model, the supervised learning loss is calculated based on the label and the output of the student model to calculate the cross entropy loss, the distillation loss is based on the KL divergence loss between the output of the teacher model and the output of the student model, and the final total loss is a weighted sum, which is used for back propagation to optimize the student model.

[0054] The beneficial effects of the present application are:

[0055] The method of the present application generates a limited number of intrusion packets generated by existing test tools and methods, and lacks sufficient diversity and complexity, which cannot comprehensively evaluate the security and attack resistance of the automobile CAN bus network. The method of the present application uses a DistilBERT model, and the emergent ability of the model makes the generated packet test data not only meet the regular tasks, but also understand complex contexts, generate fluent and context-related reports, and generate high-quality packet test data sets that meet the test requirements.

[0056] Other advantages, objects, and features of the present application will be in part apparent and in part pointed out hereinafter in the specification, and will be observed in the practice of the application. The objects and other advantages of the present application can be realized and attained by the structure particularly pointed out in the specification. BRIEF DESCRIPTION OF DRAWINGS

[0057] In order to make the purposes, technical solutions and advantages of the present application clearer, the preferred detailed description of the present application will be combined with the drawings, in which:

[0058] Figure 1 In, Figure 1 (a) of the CAN packet frame format schematic diagram and Figure 1 (b) of the packet transmission ID arbitration schematic diagram;

[0059] Figure 2 (a) to (f) of the schematic diagram of the six mainstream attack means, wherein, Figure 2 (a) to (f) of the schematic diagram of the six mainstream attack means, wherein,

[0060] Figure 3 (a) of the CAN bus closing attack schematic diagram, wherein, Figure 3 (a) shows the state change of the node when the TEC and REC change, Figure 3 (b) shows the schematic diagram of the bit error triggering the bus closing mechanism;

[0061] Figure 4 (a) to (f) of the schematic diagram of the six mainstream attack means, wherein,

[0062] Figure 5 A flowchart of a fuzzy feature extraction method is shown in Figure 1.

[0063] Figure 6 A schematic diagram of the internal structure of the DistilBERT large model is shown in Figure 2.

[0064] Figure 7 A schematic diagram of the overall framework of the large model is shown in Figure 3. DETAILED DESCRIPTION

[0065] The embodiments of the present application will be described in detail with specific reference to certain specific examples. Those skilled in the art can easily understand other advantages and effects of the present application from the content disclosed in the specification. The present application can also be implemented or applied in other different specific embodiments, and various modifications or changes can be made to the details in the specification based on different views and applications without departing from the spirit of the present application. It should be noted that the drawings provided in the following examples only illustrate the basic concept of the present application in a schematic manner, and the features in the following examples and embodiments can be combined with each other without conflict.

[0066] The drawings are only used for illustrative purposes, and the representation is only a schematic diagram, not a physical diagram, and should not be understood as a limitation on the present application. In order to better illustrate the embodiments of the present application, some components in the drawings may be omitted, enlarged or reduced, and do not represent the actual size of the product. It is understandable to those skilled in the art that some well-known structures and their descriptions in the drawings may be omitted.

[0067] The same or similar reference numerals in the drawings of the embodiments of the present application correspond to the same or similar components; in the description of the present application, it should be understood that if the terms "upper", "lower", "left", "right", "front", "back" and the like indicate the orientation or positional relationship based on the orientation or positional relationship shown in the drawings, only for the convenience of describing the present application and simplifying the description, and do not indicate or imply that the devices or elements referred to must have a particular orientation, be constructed and operated in a particular orientation, therefore the terms describing the positional relationship in the drawings are only used for illustrative purposes, and should not be understood as a limitation on the present application. For those skilled in the art, the specific meaning of the above terms can be understood according to the specific circumstances.

[0068] Please refer to Figures 1-7 A large model-based automobile CAN bus message hybrid attack simulation method is provided. The method optimizes the sample library by combining the data enhancement Borderline-SMOTE method, and mainly uses the fuzzy feature extraction method to analyze the vulnerability of the network to be tested. The feature vector generated by the network extraction feature is input to the large model training, and a large model framework for automobile CAN bus message hybrid attack is designed to generate high-quality messages that meet the test requirements. The steps are as follows:

[0069] S1. Based on the characteristics of the CAN network protocol, an initial attack message sample library is generated by combining several attack methods and error types defined by the CAN network protocol;

[0070] S2, optimize the initial sample library through the data enhancement Borderline-SMOTE method;

[0071] S3. Identify the vulnerability characteristics of the CAN network features through the fuzzy feature extraction method, convert the vulnerability characteristics of the CAN network into feature vectors, and assign a label to each feature vector to form a labeled data set;

[0072] S4. Establish a DistilBERT model based on knowledge distillation, use the optimized sample library and CAN network feature vector to train the DistilBERT model, and finally have the DistilBERT model output attack messages.

[0073] Example

[0074] In this embodiment, Figure 1 The format of standard CAN message and extended CAN message and their arbitration mechanism are shown, where: Figure 1 (a) shows the format of a standard CAN message and an extended CAN message, where the CAN ID is an 11-bit identification code. The CAN protocol resolves access contention through arbitration. Figure 1 (b) shows the arbitration mechanism. Because frame IDs are unique and the CAN bus is logically represented as a line gate, some competing nodes will see a dominant (0) bit, even though they have already transmitted a recessive (1) bit. At this point, they lose arbitration, exit bus contention, and switch to receiver mode. By analyzing the vulnerability characteristics of in-vehicle network protocols, several vulnerability characteristics of CAN networks are identified.

[0075] This embodiment provides the following features based on the CAN network protocol:

[0076] 1) Broadcast transmission: A malicious node can easily steal CAN bus messages sent by all other nodes.

[0077] 2) No encryption: By counting a large number of CAN bus messages, the communication behavior between electronic control units can be reverse analyzed and the encoding method of the messages can be deduced.

[0078] 3) No authentication: After understanding the message encoding method, the attacker can control the vehicle by sending specific forged messages to the CAN bus through a malicious node.

[0079] In step S1 , this embodiment simulates the attack methods that the CAN bus is susceptible to and its error detection mechanism to generate an initial attack message sample library.

[0080] As Figure 2 shown, it is a method schematic diagram of several existing network attack means. CAN bus is vulnerable to 6 attack scenarios, which can cause serious damage to the vehicle on-board network. Figure 2 (a) to (f) in the figure are respectively the schematic diagrams of DoS attack, tampering attack, message injection attack, spoofing attack, discard attack and fuzzing attack.

[0081] As Figure 3 shown, it is a schematic diagram of the principle of bus shutdown mechanism, which is used to generate bus shutdown attack messages. Bus shutdown uses the mechanism of CAN bus error conflict to generate attack messages, so that the target attack node is attacked in a short time and is forced to enter the sleep state. CAN protocol defines not less than 5 different error detection methods, including bit error, padding error, CRC error, format error and ACK error. The application uses the first bit error mechanism to generate attack messages to trigger bus shutdown. Specifically, bit error is to compare the bits sent by each sender with the output bits on the CAN bus, and if the two are different, a bit error has occurred, except during arbitration. CAN device maintains a transmission error counter (TEC) and a reception error counter (REC). Among them Figure 3 (a) shows the state change of the node when TEC and REC change, Figure 3 (b) can be seen that the first bit error (the attack node uses the same ID as the victim, but sets DLC to 0 to trigger conflict) makes the TEC count of the victim node increase by 8 to start the retransmission mechanism, which makes the TEC of the victim node increase rapidly in a short time, and finally reaches the bus shutdown.

[0082] The CAR-HACKING DATASET dataset disclosed by HCEL is used, which includes normal message data, DoS attack, fuzzing attack and spoofing attack information. The attack messages not included in the dataset need to be added.

[0083] The following is the process of generating the sample library of the application according to the CAR-HACKING DATASET dataset:

[0084] 1. Load the dataset: read the dataset from the file, make sure that the dataset contains normal message data, DoS attack, fuzzing attack and spoofing attack information; view the basic structure and content of the dataset to ensure correct data reading, and understand the characteristics and distribution of the data.

[0085] 2. Add tampering attack: randomly select a certain proportion of normal messages in the dataset, randomly modify the data field (such as the data field in the CAN message) of the selected message, and mark these modified messages as tampering attacks.

[0086] 3. Add message injection attack: based on existing data, generate a certain proportion of false messages. New messages can be randomly generated or modified based on existing messages; set reasonable timestamps for newly generated messages, and mark newly generated false messages as message injection attacks.

[0087] 4. Add discard attack: randomly select a certain proportion of messages in the dataset, delete the selected messages from the dataset to simulate the situation where messages are discarded.

[0088] 5. Merge the generated multiple attack message data with the original data to form a comprehensive data set containing multiple attack types.

[0089] In step S2, in order to train the DistilBERT model, there is a serious imbalance between the number of positive and negative samples when using public datasets to train this model, which may affect the learning effect of the classifier on the smaller number of classes, resulting in lower prediction accuracy of the classifier on the minority class and false positives. In order to solve the problem of sample imbalance, the Borderline-SMOTE data enhancement is used in the process of CAN message data processing in this embodiment. Borderline-SMOTE can more specifically generate synthetic samples to improve the diversity of the sample library, especially for those boundary samples.

[0090] Figure 4 is the process of Borderline-SMOTE classification and data enhancement, and the following is the specific process of using Borderline-SMOTE data enhancement in CAN message data:

[0091] S21, identify the minority class samples located near the class boundary;

[0092] Assume that the entire dataset is T, the minority class is P, and the majority class is N, where p num and n num are the number of minority and majority examples.

[0093] P={p1,p2,...,p pnum}, N={n1,n2,...,n nnum}

[0094] For each P i (i=1,2,......,p numIn the minority class P, the embodiment calculates its m nearest neighbors from the whole dataset T, and the number of majority samples in the m nearest neighbors is denoted as m' (0≤m'≤m).

[0095] If m'=m, i.e. P i is a majority class sample, then P i is considered as a noise point and does not participate in the following steps of generating messages. If m / 2≤m'<m, i.e. P i has more majority class nearest neighbors than minority class nearest neighbors, then P i is considered to be easily misclassified and is put into the DANGER set. If 0≤m'<m / 2, i.e. P i has more minority class nearest neighbors than majority class nearest neighbors, then P i is considered to be safe and does not participate in the following steps of generating messages. The examples in DANGER are the boundary data of the minority class P, which can be seen from the following table.

[0096] The embodiment sets and for each example in DANGER, the embodiment calculates its K nearest neighbors from P.

[0097] S22, generating synthetic samples for boundary samples;

[0098] In this step, the embodiment generates sxd num synthetic positive samples from the DANGER set. For each p i ', s samples are randomly selected from its k nearest neighbors. First, the differences between p i ' and its s nearest neighbors are calculated, and then a random number λ between 0 and 1 is multiplied by the differences to finally generate s new synthetic minority class samples between p i ' and its nearest neighbors, i.e.

[0099] x new = x+λ×(x nn -x)

[0100] where x new represents the generated new message, x i represents the i-th sample in the minority class sample, x nn represents a randomly selected minority class sample from the K nearest neighbors of x n , (x nn -x) represents the difference between p i ' and its s nearest neighbors, and λ is a random number in [0,1].

[0101] For each p iThe above steps are repeated to generate s x d num synthetic positive samples. This step is similar to the SMOTE algorithm. Finally, the generated synthetic samples are added to the original dataset.

[0102] In step S3, the embodiment also needs to analyze the CAN network features before starting to train the large model. Through a fuzzy feature extraction method, by sending random or pseudo-random data frames, the system response is observed, potential vulnerabilities are identified, and the corresponding feature vector is generated. As shown in the fuzzy feature extraction method flowchart, it specifically includes the following steps: Figure 5

[0103] First, use a fuzzy testing tool to generate random or pseudo-random CAN messages, which may contain malformed or abnormal data fields. Send these generated fuzzy test messages to the target CAN network to simulate the communication process in the actual environment. Then, monitor the response behavior of each node in the CAN network, and record the system's response to these fuzzy test messages. Collect and store system response data, including error codes, crash logs, response times, and other information. The purpose of these steps is to generate messages with potential vulnerabilities through fuzzy testing and observe the actual response of the system to extract valuable raw data.

[0104] In the data processing and model training phase, meaningful features such as message type, response time, and error code are extracted from the collected system response data, and these features are converted into structured feature vectors as analysis codes. Next, according to the type and characteristics of the system response, each feature vector is assigned a label (such as normal or abnormal), forming a labeled dataset. Input these combined feature vectors and corresponding labeled training dataset into the DistilBERT model for training. Through training, DistilBERT can learn and identify abnormal behavior and potential vulnerabilities in the CAN network.

[0105] In step S4, Figure 6 is a schematic diagram of the internal structure of the DistilBERT model. A lightweight DistilBERT model is used, which uses the method of knowledge distillation to distill the teacher BERT. A larger model can be distilled into a smaller model. Using this idea, the large model is used as the teacher of the small model, and the small model is used as the student to learn as many actions as possible from the teacher. As shown in Figure 7 DistilBERT is the student model, with about 40% of the teacher BERT's parameters, but 60% faster, and retains the performance of the teacher. The following is a detailed introduction to DistilBERT.

[0106] ​The distillation process of DistilBERT model, including the training architecture of teacher model (TEACHER) and student model (STUDENT). First, the input message sequence passes through the input embedding layer to convert the text of the message into a vector representation. Then, these embedding representations are sent into the teacher model and the student model at the same time. The teacher model is a complete BERT model, including 12 Transformer encoding layers, which is used to generate the teacher output. The student model is a smaller model, usually with only 6 Transformer encoding layers, which is trained by learning the output of the teacher model. The parameters of the student model are optimized by backpropagation to make its output as close as possible to the output of the teacher model. For input X, the teacher model output T and the student model output S are as follows:

[0107]

[0108]

[0109] where (t1,...,t n ) represents the output of the teacher model, represents the input of the teacher model through the softmax() function; (s1 , ...,s n ) represents the output of the student model, represents the input of the student model through the softmax() function; softmax() is an activation function.

[0110] The embodiment hopes that T and S are close, and the cross-entropy loss can be applied to S with T as the target. This is the student-teacher cross-entropy loss in the model:

[0111]

[0112] The second loss that helps the student to imitate the teacher is the cosine loss. The cosine loss is interesting because it does not try to make the vector x equal to the target y, but tries to align x with y, and does not consider their respective norms or spatial origins. The embodiment uses this loss to align the hidden vectors in the teacher and student models. The formula is as follows:

[0113] L cosine = 1 - cos(T(x), S(x))

[0114]

[0115] where L cosine is the student-teacher cosine loss, L problem is the loss function when processing the message generation task with the sample library; the total distillation loss is the integration of the above three losses:

[0116]

[0117] The loss function part combines the supervised learning loss and the distillation loss to guide the training of the student model. The supervised learning loss calculates the cross-entropy loss based on the label and the student model output, and the distillation loss is based on the KL divergence loss between the teacher model output and the student model output. The final total loss is a weighted sum, which is used for backpropagation to optimize the student model. Through this architecture and training process, DistilBERT retains most of the performance of the BERT model while reducing the number of parameters and computational cost. Figure 6 The flow structure of the present application is shown, from the generation of the sample library through data enhancement, to the generation of the CAN network feature vector and input into the DistilBERT model to produce the final attack message.

[0118] Finally, it is pointed out that the above embodiments are only used to illustrate the technical solutions of the present application and are not limiting. Although the present application has been described in detail with reference to the preferred embodiments, it should be understood by those skilled in the art that the technical solutions of the present application can be modified or replaced equivalently without departing from the purpose and scope of the technical solutions, which should be covered in the scope of the claims of the present application.

Claims

1. A large-scale model-based hybrid attack simulation method for automobile CAN bus messages, characterized by: The method comprises the following steps: S1. Based on the characteristics of the CAN network protocol, an initial attack message sample library is constructed based on the basic database by combining several attack methods and error types defined by the CAN network protocol. S2, optimize the initial sample library through the data enhancement Borderline-SMOTE method; S3. Identify the vulnerability characteristics of the CAN network features through the fuzzy feature extraction method, convert the vulnerability characteristics of the CAN network into feature vectors, and assign a label to each feature vector to form a labeled data set; S4. Establish a DistilBERT model based on knowledge distillation. Use the optimized sample library and CAN network feature vectors to train the DistilBERT model. Finally, the DistilBERT model outputs the attack message. In step S3, the fuzzy feature extraction method is used to obtain the vulnerability characteristics of the target CAN network. The specific process is as follows: Sending random or pseudo-random fuzz test messages containing deformities or anomalies in the fuzz test tool to the target CAN network; Monitor the corresponding behavior of each node in the target CAN network and record the response of the target CAN network system to the fuzzy test message; Collect and store the response data of the target CAN network system to the fuzz test message, wherein the response data at least includes: error code, crash log, and response time; Extracting features from the response data of the target CAN network system, wherein the extracted features include at least: message type, response time, and error code; The extracted features are converted into structured feature vectors, and labels are assigned to each feature vector based on the message type and characteristics to form a labeled dataset; the labels are divided into normal and abnormal.

2. The large-model-based automobile CAN bus message hybrid attack simulation method according to claim 1 is characterized in that: In step S1, the simulated attack methods include at least: DoS attack, tampering attack, message injection attack, deception attack, discard attack and fuzzy attack; The bit error mechanism defined by the CAN network is used to generate attack messages that trigger the bus shutdown mechanism. A bit error means that each transmitter compares the bit it sends with the bit generated by the output on the CAN bus. During the non-arbitration period, if the bit sent by the transmitter is different from the bit generated by the output on the CAN bus, it indicates a bit error.

3. The large-model-based automobile CAN bus message hybrid attack simulation method according to claim 2 is characterized in that: In step S1, the process of generating an initial attack message sample library based on the CAR-HACKING DATASET dataset includes: S11. Load the data set; read the CAR-HACKING DATASET data set, which contains normal message data, DoS attack, fuzzy attack, and spoofing attack information; check the basic structure and content of the data set to ensure that the data is read correctly, and understand the characteristics and distribution of the data; S12, adding a tampering attack; randomly selecting a certain proportion of normal messages in the data set, randomly modifying the data fields of the selected messages, and marking the modified messages as tampering attacks; S13. Add a message injection attack: Based on the existing data, generate a certain proportion of false messages, set a reasonable timestamp for the newly generated messages, and mark the newly generated false messages as message injection attacks; S14, adding a discard attack; randomly selecting a certain proportion of messages in the data set and deleting the selected messages from the data set to simulate the situation where messages are discarded; S15. Merge the generated multiple attack message data with the original data to form a comprehensive data set containing multiple attack types.

4. The large-model-based automobile CAN bus message hybrid attack simulation method according to claim 1 is characterized in that: In step S2, Borderline-SMOTE data enhancement is used to optimize the sample imbalance problem in the initial attack message sample library, which specifically includes the following steps: S21, identify minority class samples that are within the expected range of the class boundary and include them in the boundary sample set; S22. Generate new synthetic minority class samples for boundary samples and add the generated synthetic samples to the original dataset.

5. The large-model-based automobile CAN bus message hybrid attack simulation method according to claim 4 is characterized in that: In step S21, assuming that the entire data set is T, the minority class is P, and the majority class is N, then: P={p1,p2,...,p pnum },N={n1,n2,...,n nnum } where p num and n num is the number of minority and majority examples; For each P i (i=1,2,......,p num ) In the minority class P, calculate its m nearest neighbors from the entire data set T, and the majority number of samples among the m nearest neighbors is recorded as m' (0≤m'≤m); If m'=m, that is, P i The m nearest neighbors of are all majority class samples, then P i It is considered as a noise point and no subsequent processing is performed; If m / 2≤m'<m, that is, P i The number of the majority class nearest neighbors is greater than the number of the minority class nearest neighbors, which means P i The probability of being misclassified is high and it is placed in the DANGER set; If 0≤m'<m / 2, that is, P i The number of the nearest neighbors of the minority category is greater than the number of the nearest neighbors of the majority category, then P i Safe, no subsequent processing; Therefore, set the boundary sample set 0≤d num ≤p num , for each example in DANGER, compute its K nearest neighbors from P.

6. The large-model-based automobile CAN bus message hybrid attack simulation method according to claim 5 is characterized in that: In step S22, for each p i ', randomly select s samples from its k nearest neighbors: First, calculate p i 'The difference between it and its s nearest neighbors, and then take a random number λ between 0 and 1 and multiply it by p i 'The difference between the difference and its s nearest neighbors, and finally generate s new synthetic minority class samples, which are located at p i ' and its nearest neighbors, that is: x new =x+λ×(x nn -x) Among them, x new Indicates the new message generated, x i represents the i-th sample in the minority class sample, x nn Indicates x n A minority class sample is randomly selected from the K nearest neighbors, (x nn -x) means p i 'The difference between it and its s nearest neighbors, a random number λ∈[0,1]; For each p in the DANGER set i 'Repeat the above steps to generate s×d num synthetic positive examples.

7. The large-model-based automobile CAN bus message hybrid attack simulation method according to claim 1 is characterized in that: In step S4, during the knowledge distillation training process, first, the teacher model is defined as the complete BERT model, and the student model is defined as the DistilBERT model with fewer parameters than the teacher model, where: The teacher model contains several Transformer encoding layers, which are used to generate the output of the teacher model; the student model also contains several Transformer encoding layers, which are trained by learning the output of the teacher. The number of Transformer encoding layers in the student model is less than that in the teacher model. The parameters of the student model are optimized through backpropagation; for input X, the teacher model output T and the student model output S are as follows: Among them, (t1,…,t n ) represents the output of the teacher model, Represents the input of the teacher model through the softmax() function; (s1,…,s n ) represents the output of the student model, Represents the input of the student model through the softmax() function; softmax() is the activation function.

8. The large-model-based automobile CAN bus message hybrid attack simulation method according to claim 7 is characterized in that: In step S4, the loss function during model training includes: Apply cross entropy loss to S with T as target: Cosine loss is used to help the student model imitate the teacher model and ensure that the hidden vectors in the teacher model and the student model are aligned: L cosine =1-cos(T(x),S(x)) Among them, L cosine is the student-teacher cosine loss, L problem The loss function for the sample library when processing message generation tasks; The total loss during the entire distillation process is expressed as: The loss function combines supervised learning loss and distillation loss to guide the training of the student model. The supervised learning loss calculates the cross entropy loss based on the label and the student model output. The distillation loss is based on the KL divergence loss between the teacher model output and the student model output. The final total loss is a weighted sum, which is used for backpropagation to optimize the student model.

Citation Information

Patent Citations

  • Automobile CAN bus information safety simulation device

    CN111966083A

  • Vehicle-mounted terminal intrusion detection method based on vehicle-mounted network abnormal behavior characteristic driving

    CN112671701A