Training method and device of traffic analysis model, equipment and storage medium

By combining the thinking derivation chain and network security data sets, network model parameters are adjusted to form a highly accurate traffic analysis model, which solves the problem of reduced accuracy in identifying abnormal traffic in the existing technology and enhances network security analysis capabilities.

CN118740499APending Publication Date: 2024-10-01BEIJING HENGAN JIAXIN SAFETY TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411006258.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-25
Publication Date
2024-10-01

AI Technical Summary

Technical Problem

When existing technologies identify abnormal traffic, with the development of attack methods and tools, the identification effect based on rules and deep learning models gradually decreases, making it difficult to accurately analyze network traffic, making it difficult to effectively defend against network security threats.

Method used

By determining the first training data set containing the thinking derivation chain and the second training data set related to network security, using unsupervised pre-training and supervised fine-tuning methods, the network model parameters are adjusted until the set conditions are met to form high accuracy. Traffic analysis model to identify abnormal traffic.

Benefits of technology

It improves the accuracy of network traffic analysis, enhances network security defense capabilities, and can more effectively identify complex and covert attack traffic.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118740499A_ABST
    Figure CN118740499A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of data processing, and particularly provides a traffic analysis model training method and device, equipment and a storage medium, and the method comprises the steps: determining a first training data set and a second training data set; performing unsupervised pre-training on the first network model by using the second training data set to obtain a second network model; inputting the thinking derivation chain into a second network model to obtain first output data; inputting the first output data into a third network model to obtain a reward score; under the condition that the reward score does not meet the set condition, network parameters of the second network model are adjusted to obtain a new second network model, and next cycle training is carried out; and taking the second network model and the third network model as a flow analysis model under the condition that the reward score meets a set condition, and using the flow analysis model to analyze the network flow. According to the embodiment of the invention, the accuracy of analyzing network traffic by a large model can be improved, and the network security is ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to a training method, apparatus, device and storage medium for a traffic analysis model. Background Art

[0002] Abnormal traffic refers to traffic behavior that is different from normal traffic during network transmission. The abnormal traffic may include obvious attack behaviors, such as port scanning and attack attempts, and may also involve potential detection activities and unknown behaviors.

[0003] In the related technology, there are two main ways to identify abnormal traffic: rule-based identification and neural network-based identification. The rule-based identification method analyzes the behavioral characteristics of Trojan viruses to determine whether they have been attacked. The neural network-based identification method uses machine learning technology to train unlabeled network data flows and apply the model to unknown data flows. It can predict intermediate output results and then detect abnormal traffic.

[0004] With the continuous development of attack methods and identification methods, the difference between abnormal traffic and normal traffic is getting smaller and smaller, resulting in the inability of identification methods in related technologies to accurately analyze network traffic. Summary of the invention

[0005] In order to solve the above technical problems, the present application provides a training method, device, equipment and storage medium for a traffic analysis model to improve the accuracy of large models in analyzing network traffic and ensure network security.

[0006] In a first aspect, the present application provides a method for training a traffic analysis model, the method comprising: determining a first training data set and a second training data set, wherein the first training data set comprises a plurality of thought deduction chains, and the thought deduction chains are determined by abnormal traffic data; the second training data set comprises data related to network security; using the second training data set to perform unsupervised pre-training on the first network model to obtain a second network model; inputting the thought deduction chain into the second network model to obtain output data; inputting the output data into a third network model to obtain a reward score, and the reward score is used to indicate a quantitative indicator of the quality of the output data; when the reward score does not meet the set conditions, adjusting the network parameters of the second network model to obtain a new second network model, and returning to execute the step of inputting the thought deduction chain into the second network model to obtain the output data; until the reward score meets the set conditions, the second network model and the third network model are used as traffic analysis models, and the traffic analysis model is used to analyze network traffic.

[0007] In a second aspect, the present application provides a training device for a traffic analysis model, the device comprising: a data set determination module, used to determine a first training data set and a second training data set, wherein the first training data set includes multiple thought deduction chains, and the thought deduction chains are determined by abnormal traffic data; the second training data set includes data related to network security; a first training module, used to use the second training data set to perform unsupervised pre-training on the first network model to obtain a second network model; a second training module, used to input the thought deduction chain into the second network model to obtain output data; a third training module, used to input the output data into the third network model to obtain a reward score, and the reward score is used to indicate a quantitative indicator of the quality of the output data; a model parameter adjustment module, used to adjust the network parameters of the second network model to obtain a new second network model when the reward score does not meet the set conditions, and return to execute the step of inputting the thought deduction chain into the second network model to obtain the output data; a traffic analysis model determination module, used to use the second network model and the third network model as traffic analysis models until the reward score meets the set conditions, and the traffic analysis model is used to analyze network traffic.

[0008] In a third aspect, the present application provides a training device for a traffic analysis model, the device comprising: one or more processors; a storage device for storing one or more programs; when the one or more programs are executed by one or more processors, the one or more processors implement the training method for the traffic analysis model as described in the first aspect above.

[0009] In a fourth aspect, the present application provides a storage medium, which may be a computer-readable storage medium, storing a computer program thereon, which, when executed by a processor, implements the training method of the traffic analysis model in the first aspect described above.

[0010] In a fifth aspect, an embodiment of the present application provides a computer program product, which includes a computer program or instructions, and when the computer program or instructions are executed by a processor, the training method of the traffic analysis model as described in any one of the first aspects above is implemented.

[0011] Compared with the prior art, the technical solution provided by the embodiments of the present application has the following advantages:

[0012] The embodiment of the present application provides a training method, device, equipment and storage medium for a traffic analysis model, the method comprising: determining a first training data set and a second training data set, wherein the first training data set includes multiple thought deduction chains, and the thought deduction chains are determined by abnormal traffic data; the second training data set includes data related to network security; using the second training data set to perform unsupervised pre-training on the first network model to obtain a second network model; inputting the thought deduction chain into the second network model to obtain output data; inputting the output data into the third network model to obtain a reward score, and the reward score is used to indicate a quantitative indicator of the quality of the output data; when the reward score does not meet the set conditions, adjusting the network parameters of the second network model to obtain a new second network model, and returning to execute the step of inputting the thought deduction chain into the second network model to obtain the output data; until the reward score meets the set conditions, the second network model and the third network model are used as traffic analysis models, and the traffic analysis model is used to analyze network traffic. The embodiment of the present application can improve the accuracy of large models in analyzing network traffic and ensure network security. BRIEF DESCRIPTION OF THE DRAWINGS

[0013] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0014] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0015] Figure 1 A flow chart of a method for training a traffic analysis model provided in an embodiment of the present application;

[0016] Figure 2 A schematic diagram of the structure of a method for determining a first training data set provided in an embodiment of the present application;

[0017] Figure 3 A schematic diagram of a decision tree structure provided in an embodiment of the present application;

[0018] Figure 4 A schematic diagram of the structure of a training device for a traffic analysis model provided in an embodiment of the present application;

[0019] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0020] In order to more clearly understand the above-mentioned purposes, features and advantages of the present application, the scheme of the present application will be further described below. It should be noted that the embodiments of the present application and the features in the embodiments can be combined with each other without conflict.

[0021] In the following description, many specific details are set forth to facilitate a full understanding of the present application, but the present application may also be implemented in other ways different from those described herein; obviously, the embodiments in the specification are only part of the embodiments of the present application, rather than all of the embodiments.

[0022] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.

[0023] It should be noted that the concepts such as "first" and "second" mentioned in this application are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.

[0024] It should be noted that the modifications of "one" and "plurality" mentioned in the present application are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".

[0025] Abnormal traffic refers to the behavior that is different from normal traffic during network transmission. This abnormal traffic includes relatively obvious attack behaviors, such as port scanning and attack attempts, and may also involve potential detection activities and unknown behaviors. Identifying abnormal traffic during network transmission and intercepting it is an important means to ensure network security.

[0026] With the development of Internet technology, network attacks are increasing day by day, and network attack methods are emerging in an endless stream, making abnormal traffic analysis more difficult. Among them, Trojan virus attacks and command and control (C2) attacks are two common and more harmful network attack methods, and have become a security threat that needs special attention in daily network security management.

[0027] Trojan virus is a malicious software that sneaks into the computer system through impersonation, deception, tracking, etc. It is usually hidden in other useful software without being discovered. It can collect users' private information and control users' computers without their knowledge. Trojan virus is highly destructive and spreads quickly.

[0028] C2 attack architecture is often used in team-based intranet penetration. C2 allows multiple attackers to connect to the team server at the same time and share attack resources. Take the mainstream attack tool Cobalt Strike as an example. As a collaborative APT tool, Cobalt Strike's penetration test for intranets and its terminal control function as an APT make it the tool of choice for many APT organizations. Cobalt Strike can effectively identify heartbeats and channel traffic by capturing sufficient attack traffic and building AI models based on the extracted network traffic features. It can also quickly extract traffic features from the existing network, thereby efficiently identifying attack traffic in the existing network and helping enterprises identify attacks more accurately and timely.

[0029] In the related art, there are two main ways to identify abnormal traffic: a rule-based identification method and a neural network-based identification method.

[0030] Among them, rule-based identification methods mainly include behavior-based detection methods. Behavior-based detection methods mainly determine whether there is infection by analyzing the behavioral characteristics of Trojan viruses. This method focuses on the behavior patterns of Trojan viruses on the system, such as network upload and download operations, key records, etc. There are two types of detection methods. One is the abnormal behavior detection method: this method analyzes and identifies abnormal processes in the system by monitoring the system. The other is the static feature detection method: this method analyzes the complete file or program, analyzes the source code and data flow of the program, and looks for the behavioral characteristics of Trojan viruses.

[0031] However, both abnormal behavior detection and static feature detection mainly occur after the Trojan file has fallen to the disk, and the attack behavior is judged, which has a certain lag, and the attack has often caused damage to the computer system.

[0032] Rule-based identification methods also include rule-based traffic detection methods. Traffic-based detection methods determine whether there are Trojan viruses by analyzing the signal flow. This method focuses on combing, processing and analyzing signal flows to monitor potential Trojan behaviors. Rule-based traffic detection methods, also known as traffic characteristic detection methods, identify data packets with obvious fluctuations in traffic characteristics to identify potential Trojan behaviors, such as IP address changes.

[0033] The flaw of the rule-based traffic detection method is that the current use of attack covert tunnel encryption technology makes network security visibility increasingly difficult. Traditional rule matching and simple algorithm protection to intercept covert tunnel encrypted traffic are difficult. For example, mainstream attack methods such as Godzilla, Ice Scorpion and other attack tools have as many as a dozen encryption methods.

[0034] Neural network-based identification methods mainly include: machine learning detection and neural network detection. Machine learning detection uses machine learning technology to train unlabeled network data streams, and applies the model to unknown data streams, which can predict intermediate output results and detect malicious traffic. For example: real-time collection of malicious encrypted traffic and regular storage; use of DNS traffic identification model and TLS traffic identification model to characterize and classify malicious encrypted traffic; integrated training based on the learning mechanism of naive Bayes method and convolutional neural network; use of accuracy, precision, recall rate, and F1 in supervised classification to compare the classification performance of different algorithms and evaluate the classification performance of different feature sets.

[0035] However, with the continuous iteration of hacker attack tools, attack tools and encryption methods are also constantly evolving. For example, attacks based on the C2 framework are becoming more and more secretive, with hundreds of attack tools. Faced with more and more attack tools and emerging attack encryption methods, it is becoming increasingly necessary to identify encrypted attack traffic in secret tunnels.

[0036] The drawback of the traditional deep learning model for identifying encrypted attack traffic is that the model's learning ability is limited and can only target certain attack channels. When the attack tool is iterated, the identification effect will be greatly reduced. Therefore, in actual use, due to the limited ability of a single model, it is often necessary to constantly update and train new models. As the number of models increases, it will become more complicated to determine the authenticity of attack traffic.

[0037] The combination of traditional deep learning methods and machine learning has the same defects as traditional deep learning methods. Limited by the learning ability of deep learning models, only some traffic channels can be identified. Once updated, the feature fields used by machine learning will also become invalid.

[0038] When samples are limited, models with a small number of parameters are very prone to underfitting or overfitting, causing the model's capabilities to vary with the number of samples, showing very obvious instability.

[0039] To solve the above technical problems, an embodiment of the present application provides a training method for a traffic analysis model, the method comprising: determining a first training data set and a second training data set, wherein the first training data set includes multiple thought deduction chains, and the thought deduction chains are determined by abnormal traffic data; the second training data set includes data related to network security; using the second training data set to perform unsupervised pre-training on the first network model to obtain a second network model; inputting the thought deduction chain into the second network model to obtain output data; inputting the output data into a third network model to obtain a reward score, and the reward score is used to indicate a quantitative indicator of the quality of the output data; when the reward score does not meet the set conditions, adjusting the network parameters of the second network model to obtain a new second network model, and returning to execute the step of inputting the thought deduction chain into the second network model to obtain the output data; until the reward score meets the set conditions, the second network model and the third network model are used as traffic analysis models, and the traffic analysis model is used to analyze network traffic.

[0040] The following is a detailed description of the training method of the traffic analysis model provided by the present application in conjunction with the accompanying drawings and specific implementation methods.

[0041] Figure 1 This is a flow chart of a method for training a traffic analysis model in an embodiment of the present application. This embodiment is applicable to the case of training a model for analyzing network traffic. The method can be executed by a training device for a traffic analysis model. The training device for the traffic analysis model can be implemented in software and / or hardware. The training device for the traffic analysis model can be configured in an electronic device.

[0042] like Figure 1 As shown, the training method of the traffic analysis model provided in the embodiment of the present application mainly includes steps S101-S105.

[0043] S101. Determine a first training data set and a second training data set, wherein the first training data set includes multiple thought deduction chains, and the thought deduction chains are determined by abnormal traffic data; and the second training data set includes data related to network security.

[0044] The first training data set refers to a training data set for supervised training. The first training data set includes multiple chains of thought. Chain of Thought (CoT) refers to a series of thinking steps that are gradually unfolded in a logical order when solving a problem or making inferences. In the embodiment of the present application, the chain of thought can be understood as a series of thinking steps that are gradually unfolded in a logical order to analyze the cause of abnormal traffic in a connection.

[0045] Furthermore, the abnormal traffic between each connection during the network transmission process is collected, and a random forest decision tree is used to generate a corresponding thought deduction chain for the abnormal traffic between each connection.

[0046] The second training data set refers to a training data set used for unsupervised pre-training and model fine-tuning, wherein the second training data set includes basic knowledge data related to network security.

[0047] Determining the second training data set includes collecting a large number of security pre-training data sets such as network security books, network security knowledge bases, network security papers, security community articles, vulnerability libraries, etc. as the second training data set.

[0048] The following is an introduction to the method of determining the first training data set. Figure 2 As shown, the method for determining the first training data set provided in the embodiment of the present application mainly includes step S

[0049] S201. Obtain abnormal traffic data of each connection.

[0050] Among them, abnormal traffic data refers to traffic data that appears in a network environment and is inconsistent with normal network activity patterns. Abnormal traffic data may suddenly increase or show unusual behavior patterns. The abnormal traffic data obtained in the embodiment of the present application refers to abnormal traffic data caused by network attacks.

[0051] By building mainstream network attack tools, when using mainstream network attack tools to attack target machines, various channel traffic and heartbeat traffic of mainstream network attack tools are captured, and through network monitoring, the characteristics of the traffic are analyzed in real time to obtain abnormal traffic data.

[0052] Specifically, by building a mainstream network attack tool, when using the mainstream network attack tool to attack the target machine, the traffic packets between the server, client and target machine are obtained, and the traffic packets are replayed to obtain the full features. Then, through feature screening and feature weight calculation, as well as word segmentation and vector mapping of text features, the collection data set is obtained. Among them, the collection data set includes channel feature vectors and heartbeat feature vectors, and the quantitative features and text features in the channel feature vectors and heartbeat feature vectors are extracted as abnormal traffic data.

[0053] Among them, the communication channels include: HTTP, HTTPS, DNS, SMB, TCP and other listening channels. By building a server and client in an isolated system, different Beacons are used to communicate with the attacked machine. By capturing the gateway traffic, the complete traffic between the server-client-attacked machine can be obtained, and different Beacon communication channels are set on the server to achieve communication with the attacked machine.

[0054] S202: Preprocess the abnormal traffic data of each connection to obtain traffic data and text data corresponding to the connection.

[0055] The abnormal traffic data of each connection includes the feature vectors of each channel and the heartbeat feature vector. The above preprocessing includes cleaning, dimension reduction, desensitization and other processing of the abnormal traffic.

[0056] Cleaning abnormal traffic data can ensure the accuracy and consistency of abnormal traffic data, thereby improving data quality. Specifically, cleaning abnormal traffic data includes: checking whether the abnormal traffic data is complete; checking whether there are duplicate records, missing data, abnormal values ​​or erroneous data in the abnormal traffic data; using deletion, filling (such as using mean, median, mode or other prediction models), interpolation and other methods to process missing values, delete irrelevant fields, ensure that only variables required for analysis are retained, verify whether the data fields are complete, standardized and consistent, such as checking field names, data formats, units, etc.; discovering and deleting duplicate data entries to ensure the uniqueness of each record in the data set.

[0057] After cleaning the abnormal traffic data, it can also be desensitized. Desensitization is a data security measure that protects personal identity information, health information, financial data, and other sensitive data from unauthorized access or disclosure. By using different desensitization techniques, the original data is modified or replaced to reduce its sensitivity while maintaining the structure and functionality of the data.

[0058] The above-mentioned desensitization processing includes at least one of the following: replacing some or all characters of sensitive data with mask characters, such as replacing the middle part of a credit card number with an asterisk (*) or X. Using randomly generated fake data to replace real sensitive data, but keeping the data type unchanged. Disrupting the order of records in a data set to destroy the correlation between data. Using an encryption algorithm to convert sensitive data into ciphertext, only authorized users with a decryption key can restore the original data. Using a hash function to convert data into a string of fixed length, the same input always produces the same output, but the input and output cannot be reversed. Adding small random errors to numerical data to protect the exact value. Allowing data to have a certain range of variation, but still matching similar records. Removing part of the data, such as retaining only the first three digits of a phone number without displaying the specific personal number. Aggregating the data to display averages, totals, etc., to avoid displaying individual data. Using statistical models to generate synthetic data with a distribution similar to the original data.

[0059] In the embodiment of the present application, the specific data desensitization method is not limited, and any one or more of the above methods can be used to desensitize the abnormal traffic data.

[0060] After desensitizing the abnormal traffic data, the abnormal traffic data can also be subjected to dimensionality reduction processing to remove some useless features. Dimensionality reduction processing reduces the number of feature vectors in the abnormal traffic data, while retaining the useful information and structure of the data as much as possible, reducing the risk of overfitting, improving the efficiency of the algorithm, and improving the performance of the model. In the embodiments of the present application, the specific dimensionality reduction processing method is not limited.

[0061] Extract the text data related to the payload from the abnormal traffic data of each connection in the call list, as well as traffic data such as traffic characteristics that can be used for traffic analysis.

[0062] S203: Process the traffic data and text data to obtain a thought deduction chain corresponding to the connection.

[0063] The above traffic data mainly includes traffic features, and the text data mainly includes text features. After filtering the traffic features, the target traffic features are obtained; the target training traffic features and text features are input into the obtained decision tree, so that the decision tree generates the thought deduction chain corresponding to the connection.

[0064] Specifically, full traffic features are constructed based on traffic data; the full traffic features are processed to obtain target traffic features; the target traffic features and text data are input into a decision tree so that the decision tree generates a thought deduction chain corresponding to the connection.

[0065] Specifically, all traffic features are processed to obtain target traffic features, including: for each traffic feature in the all traffic features, calculating the variance of the traffic feature; retaining the traffic features whose variance is greater than or equal to the set variance threshold as preliminary traffic features; calculating the similarity between the preliminary traffic features; when a similarity threshold is set for the similarity between any two of the preliminary traffic features, retaining one of the preliminary traffic features and deleting the other preliminary traffic feature; and using all retained preliminary traffic features as training traffic features.

[0066] Since a flow data includes all abnormal flow features corresponding to a connection, all abnormal flow features included in a connection are called full flow features. Each full flow feature includes multiple flow features, and low variance filtering and deduplication processing are performed on each flow feature in the full flow feature.

[0067] For each traffic vector feature in the full traffic features, the variance of each traffic feature is calculated, and the traffic features with variance greater than or equal to the set variance threshold are retained as preliminary traffic features, and the traffic features with variance less than the set variance threshold are deleted.

[0068] Traffic features with variances less than the set variance threshold are almost the same or vary very little between different samples. Deleting such features can reduce data redundancy and improve the generalization ability of the model.

[0069] After low-variance filtering is performed on each traffic feature in the full traffic feature, the preliminary traffic features are obtained, and then the preliminary traffic features are deduplicated.

[0070] Set a sequence number for each value in the preliminary selected traffic feature, and then construct the sequence number arrangement of the preliminary selected traffic features according to the sequence number corresponding to each value. i . If the value of the number of transmitted bytes is: [1000, 1500, 2000, 2500, 3000], the sequence numbers are: [1, 2, 3, 4, 5]. If the initial traffic characteristics are [1000, 2000, 1500, 3000, 2500]. Then, the corresponding sequence number arrangement is d i = 13254. For each primary selected traffic feature, determine its corresponding sequence number arrangement according to the above method.

[0071] After determining the sequence number arrangement, the information complexity of the primary selected traffic feature is calculated based on the sequence number arrangement and formula (1).

[0072]

[0073] Among them, RankIC represents the information complexity of the i-th primary traffic feature, d i It represents the serial number arrangement of the i-th preliminary selected traffic feature, and n represents the dimension of the full traffic feature.

[0074] According to the above method, the information complexity corresponding to each preliminary traffic feature is calculated. The information complexity corresponding to each preliminary traffic feature is compared. If the information complexity corresponding to any two preliminary traffic features is not much different, that is, the difference in the information complexity corresponding to the preliminary traffic features is less than the set threshold, it means that the two preliminary traffic features are close in ranking. It can be understood that the information contained in the two preliminary traffic features is the same. One of the preliminary traffic features can be deleted, and only one is retained as the target traffic feature for subsequent model training to further improve the generalization ability of the model.

[0075] The full traffic characteristics of each link can be represented as D n The vector set of captured traffic can be expressed as A D×n Through principal component analysis, the vector features are reduced in dimension, as shown in formula (2).

[0076] I d = PCA(A D×n ) (2)

[0077] Among them, I d Represents the traffic characteristics after dimensionality reduction.

[0078] The target traffic features used in training the machine learning model are obtained by reducing the feature dimensionality.

[0079] The following is an introduction to the chain of reasoning corresponding to the use of random forest decision trees to generate target traffic features.

[0080] Among them, the decision tree is a machine learning model that is easy to understand and explain. It makes decisions through a series of conditional judgments. The target traffic features are input into the decision tree, and the decision tree will classify or predict the traffic based on the target traffic features. For example, a decision tree is used to identify malicious traffic and normal traffic.

[0081] The decision tree establishes a chain of reasoning based on the target traffic characteristics. For example, if the length of the response header is greater than a certain threshold, go to rule 2; otherwise, the traffic is considered normal. If the number of packets sent within a duration exceeds another threshold, it is considered malicious traffic; otherwise, continue to check other characteristics.

[0082] The above decision path can be visualized as a tree, where each internal node represents a feature test, each branch represents a test result, and each leaf node represents a classification decision.

[0083] The reasoning chain of the decision tree can be converted into a natural language description, for example: "If the length of the response header is greater than 500 bytes and more than 100 packets are sent within 1 second, the traffic is considered malicious". The language description can be used as part of the first training data set for supervised learning tasks. This can implement the decision logic of the model learning decision tree and enhance the interpretability of the model so that people with non-technical backgrounds can understand how the model makes decisions.

[0084] Further, such as Figure 3As shown in the figure, a simple decision tree is shown for classifying samples of two categories. The target variable of the decision tree has two categories: 0 and 1. The decision tree performs classification through a series of feature tests. First, the condition of the root node 301 is X[1]<=1.5, gini=0.5, samples=16, value=[8,8], and gini=0.5 indicates that the sample categories under this branch are unevenly distributed. There are 16 samples, 8 of which belong to one category and the other 8 belong to another category. The root node 301 divides the data according to whether the value of feature 1 is less than or equal to 1.5. If feature 1 is less than or equal to 1.5, enter the left child node 302; otherwise, enter the right child node 303. The condition of the left child node 302 is gini=0.0, samples=4, value=[0,4], indicating that the Gini index of this part of the data is 0, indicating that 4 samples belong to the same category (category 1). Therefore, no further segmentation is required here, and this part of the data is directly classified as category 1. For the right child node 303, the condition is X[0]<=2.5, gini=0.444, samples=12, value=[8,4], gini=0.444 means that the sample categories under this branch are unevenly distributed. There are 12 samples, 8 of which belong to one category and the other 4 belong to another category. The right child node 303 divides the data according to whether the value of feature 0 is less than or equal to 2.5. If feature 0 is less than or equal to 2.5, enter the first child node 304 of the left child node; otherwise, enter the second child node 305. The condition of the first child node 304 is gini=0.0, samples=6, value=[6,0], indicating that the Gini index of this part of the data is 0, indicating that 6 samples belong to the same category (category 0). Therefore, no further segmentation is required here, and this part of the data is directly classified as category 0. The condition of the second child node 305 is X[1]<=2.5, gini=0.444, samples, 6, value=[2, 4], gini=0.444 indicates that the sample categories under this branch are unevenly distributed. There are 6 samples, 2 of which belong to one category and the other 4 belong to another category. The second child node 305 divides the data according to whether the value of feature 1 is less than or equal to 2.5. If feature 1 is less than or equal to 2.5, enter the left child node 306 of the second child node 305; otherwise, enter the right child node 307 of the second child node 305. The condition of the left child node 306 of the second child node 305 is gini=0.0, samples=2, value=[2, 0], indicating that the Gini index of this part of the data is 0, indicating that there are 2 samples belonging to the same category (category 0).The conditions of the right child node 307 of the second child node 305 are gini=0.0, samples=4, value=[0,4], indicating that the Gini index of this part of the data is 0, indicating that 4 samples belong to the same category (category 1). In summary, this decision tree successfully divides the data into four areas with higher category purity through two feature tests, corresponding to category 0 and category 1 respectively.

[0085] The above processing is performed on the traffic data of each connection to obtain the corresponding thought deduction chain of each traffic data, forming the first training data set.

[0086] S102: Perform unsupervised pre-training on the first network model using the second training data set to obtain a second network model.

[0087] The first network model may include a foundation model, which refers to a type of machine learning model pre-trained on a second data training set, which can learn a wide range of general knowledge representations. The model is usually learned in an unsupervised or weakly supervised manner, and by absorbing a large amount of text, image, audio or other types of data, they can capture complex patterns and structures in the data.

[0088] Among them, unsupervised pre-training is a machine learning technique that refers to a training method in which the model learns useful3 from data without labels or guidance signals. Unsupervised pre-training can be regarded as a method of feature learning or representation learning so that the model can encode data efficiently.

[0089] The following is an introduction to the unsupervised pre-training method.

[0090] The unsupervised pre-training method of the first network model is as follows: the data in the second training set is used as the input sequence of the first network model. For a given input sequence U = [u1, u2, ...un], the maximum likelihood function of the sentence is trained as shown in formula (3).

[0091] score U =∑ i log P(u i |u i-k , ..., u i-1 ,θ) (3)

[0092] Among them, u i is the i-th word in the input sequence. The goal of maximum likelihood estimation is to maximize the probability of the sentence under the parameter θ. θ is the parameter of the model, such as the weight of the neural network. The training goal of the model is to find a set of numbers θ such that score U (θ) is maximized.

[0093] Among them, P(u i |u i-k , ..., u i-1 , θ) means that given the first k words, word u i Probability of occurrence.

[0094] Specifically, for the input sequence U = [u1, u2, ..., u n ], first map each word ui to a vector W of fixed dimension e At the same time, in order to retain the information between each word in the input sequence, add position encoding W p to the word embedding. In this way, each input sequence in the first layer of the model can be finally represented by formula (4).

[0095] h0=UW e +W p (4)

[0096] h0 represents the identification form of the input sequence in the first layer of the model, Wp is the position encoding of the sentence, and We is the encoding of the sentence itself.

[0097] In each decoder block, the state of the input sequence is updated to capture more contextual information. This process is repeated for l layers, where l is the number of layers in the model. The output of each layer is used as the input to the next layer. Specifically, the output of the last layer h t The output h of the previous layer can be t-1 The calculation is shown in formula (5).

[0098] h t = decoder_block(h t-1 ), t∈[1,1] (5)

[0099] Among them, decoder_block refers to the network block that contains self-attention mechanism and feed-forward neural network, as well as residual connection and layer normalization components.

[0100] The output ht of the last layer is used to predict the probability distribution of the next word. Specifically, the probability distribution of the next word is predicted through a fully connected layer and a softmax function. The probability distribution of the next word is predicted through formula (6).

[0101]

[0102] Among them, p(u) is a probability vector, which indicates the probability that the next word is any word in the sequence. Represents the transposed matrix of the word embedding matrix, which also refers to the weight matrix of the linear transformation.

[0103] The network model is unsupervisedly pre-trained using the second training data set to obtain a second network model.

[0104] S103, input the thought deduction chain into the second network model to obtain output data.

[0105] By chaining thoughts and building prompts for supervised training, a fine-tuning (SFT) model specifically for a specific task is obtained.

[0106] In the embodiments of the present application, the powerful representation learning ability of the pre-trained model and the precise task orientation of supervised learning are combined, so that the final trained model performs well on specific tasks.

[0107] In a possible implementation, the thought deduction chain is input into the second network model to obtain output data, including: constructing training prompt words; inputting the training prompt words and the thought deduction chain into the second network model; using the second network model to analyze the training prompt words based on the thought deduction chain to obtain output data, and the output data is answer data for the training prompt words.

[0108] The construction of training prompts is mainly based on the training objectives of the model. For example, training prompts can include: Analyze whether this section of traffic data contains abnormal traffic data, and analyze it according to the thinking process of the thought chain. The thought chain refers to a series of logical steps that can help the model understand how to get from the input to the expected output.

[0109] After the training prompt words and the thought deduction chain are input into the second network model, the second network model understands and analyzes the training prompt words and the thought deduction chain, and outputs the answer data corresponding to the training prompt words.

[0110] S104: Input the output data into the third network model to obtain a reward score, where the reward score is used to indicate a quantitative indicator of the quality of the output data.

[0111] The output data is the answer data for the training prompt words output by the second network model. Verify whether the model's answer is correct, and adjust the training data or model parameters as needed to improve its performance.

[0112] Among them, the third network model may include an evaluation model or a scoring model, and the third network model can evaluate the correctness of multiple answer data output by the second network model to obtain a reward score corresponding to each answer data.

[0113] The higher the reward score, the closer the corresponding answer data is to the correct answer, and the lower the reward score, the farther the corresponding answer data deviates from the correct answer.

[0114] The training process of the third network model is described below, which mainly includes: obtaining the arrangement order of multiple answer data, the arrangement order is used to indicate the rationality of the answer data; and training the third network model using the sorted answer data and the second training data set.

[0115] The order of the multiple answer data can be sorted according to the correctness of the answers. The higher the order, the higher the probability that the answer is the correct answer, and the lower the order, the lower the probability that the answer is the correct answer. The above order can be determined by manual annotation or output by other models.

[0116] The objective function of defining the third network model is to quantify the gap between the model output and the true answer. In the embodiment of the present application, a loss function is used as the objective function, which can measure the difference between the answer data output by the second network model and the distribution of the correct answer.

[0117] The above loss function can be expressed by formula (7).

[0118]

[0119] Among them, θ is the parameter of the third network model, K refers to the number of sample pairs used in the calculation. x is the input feature, y w is the "good" output, y l is the "bad" output. θ (x,y w ) is the scoring function of model r for a given input x and output y. σ is usually a sigmoid function, which is used to map any real value to the interval [0, 1]. The overall expectation E refers to the average loss for all sample pairs.

[0120] Through algorithms such as back propagation and gradient descent, the parameters of the third network model are adjusted to minimize the objective function so that the model assigns higher scores to correct answers and lower scores to incorrect answers.

[0121] S105, determine whether the reward score meets the set conditions, if not, execute S106, if not, execute S107.

[0122] S106. When the reward score does not meet the set conditions, adjust the network parameters of the second network model to obtain a new second network model, and return to execute S103.

[0123] The fact that the bonus score does not meet the set conditions can be understood as the bonus score not reaching the set threshold. This indicates that the correct answer output by the second network model is quite different from the correct answer, that is, the performance of the second network model is poor and needs to be further trained.

[0124] In a possible implementation, adjusting the network parameters of the second network model to obtain a new second network model includes: using a proximal policy optimization algorithm to adjust the network parameters of the second network model to obtain the new second network model.

[0125] Proximal Policy Optimization (PPO) is a parameter update algorithm in the field of reinforcement learning, used for policy gradient methods in continuous action space. The PPO algorithm combines the advantage function and truncated importance sampling to stabilize the training process while allowing a larger policy update step size, thereby improving learning efficiency.

[0126] The steps of adjusting the network parameters of the second network model using the PPO algorithm include: using the current second network model to generate a series of output data and the corresponding reward scores output by the third network model. The advantage function is an indicator of how well an action performs relative to the average behavior. PPO uses a value function to estimate the state value to calculate the advantage. PPO updates the strategy by minimizing an objective function, which is designed to maintain the similarity between the new and old strategies and avoid performance degradation caused by large-scale strategy updates. The above steps require multiple iterations until a satisfactory performance level is reached or the stopping condition is met.

[0127] S107. Until the reward score meets the set conditions, the second network model and the third network model are used as traffic analysis models, and the traffic analysis models are used to analyze network traffic.

[0128] The bonus score meeting the set conditions can be understood as the bonus score reaching the set threshold. This indicates that the correct answer output by the second network model is consistent. This indicates that the second network model and the third network model are mature and accurate enough to be put into use as traffic analysis models. The traffic analysis model is mainly used to identify abnormal traffic patterns, etc.

[0129] The embodiment of the present application builds a complete pre-training and supervised training network security data set, and uses the pre-training-supervised training-reinforcement learning training method to train a traffic analysis model, so as to use the traffic analysis model to analyze and identify network security traffic, which should be protected.

[0130] The embodiment of the present application provides a training method for a traffic analysis model, the method comprising: determining a first training data set and a second training data set, wherein the first training data set includes a plurality of thought deduction chains, and the thought deduction chains are determined by abnormal traffic data; the second training data set includes data related to network security; using the second training data set to perform unsupervised pre-training on the first network model to obtain a second network model; inputting the thought deduction chain into the second network model to obtain output data; inputting the output data into the third network model to obtain a reward score, and the reward score is used to indicate a quantitative indicator of the quality of the output data; when the reward score does not meet the set conditions, adjusting the network parameters of the second network model to obtain a new second network model, and returning to execute the step of inputting the thought deduction chain into the second network model to obtain the output data; until the reward score meets the set conditions, the second network model and the third network model are used as traffic analysis models, and the traffic analysis model is used to analyze network traffic. The embodiment of the present application can improve the accuracy of large models in analyzing network traffic and ensure network security.

[0131] Figure 4 Schematic diagram of the structure of a training device for a traffic analysis model in an embodiment of the present application. Figure 4 As shown, the training device 40 for the traffic analysis model provided in the embodiment of the present application mainly includes: a data set determination module 41, a first training module 42, a second training module 43, a third training module 44, a model parameter adjustment module 45 and a traffic analysis model determination module 46.

[0132] The data set determination module 41 is used to determine the first training data set and the second training data set, wherein the first training data set includes multiple thought deduction chains, and the thought deduction chains are determined by abnormal traffic data; the second training data set includes data related to network security; the first training module 42 is used to use the second training data set to perform unsupervised pre-training on the first network model to obtain the second network model; the second training module 43 is used to input the thought deduction chain into the second network model to obtain output data; the third training module 44 is used to input the output data into the third network model to obtain a reward score, and the reward score is used to indicate a quantitative indicator of the quality of the output data; the model parameter adjustment module 45 is used to adjust the network parameters of the second network model to obtain a new second network model when the reward score does not meet the set conditions, and return to execute the step of inputting the thought deduction chain into the second network model to obtain the output data; the traffic analysis model determination module 46 is used to use the second network model and the third network model as traffic analysis models until the reward score meets the set conditions, and the traffic analysis model is used to analyze network traffic.

[0133] In a possible implementation, the data set determination module 41 is specifically used to obtain abnormal traffic data of each connection; for the abnormal traffic data of each connection, the abnormal traffic data is pre-processed to obtain traffic data and text data corresponding to the connection; the traffic data and the text data are processed to obtain a thought deduction chain corresponding to the connection.

[0134] In one possible implementation, the traffic data includes full traffic features, and the data set determination module 41 is specifically used to process the full traffic features to obtain target traffic features; the target traffic features and the text data are input into a decision tree so that the decision tree generates a thought deduction chain corresponding to the connection.

[0135] In one possible implementation, the data set determination module 41 is specifically used to calculate the variance of each traffic feature in the total traffic features; retain the traffic features whose variance is greater than or equal to the set variance threshold as preliminary traffic features; calculate the similarity between the preliminary traffic features; when a similarity threshold is set for the similarity between any two of the preliminary traffic features, retain one of the preliminary traffic features and delete the other preliminary traffic feature; and use all retained preliminary traffic features as training traffic features.

[0136] In a possible implementation, the second training module 43 is specifically used to pre-build a prompt word library; select any prompt word from the prompt word library as a training prompt word; input the training prompt word and the thought deduction chain into the second network model; use the second network model to analyze the training prompt word based on the thought deduction chain to obtain output data, and the output data is the answer data for the training prompt word.

[0137] In one possible implementation, the output data includes multiple answer data, and the device also includes a fourth training module, which is specifically used to obtain an arrangement order of the multiple answer data, and the arrangement order is used to indicate the rationality of the answer data; the third network model is trained using the sorted answer data and the second training data set.

[0138] In a possible implementation, the model parameter adjustment module 45 is specifically configured to use a proximal strategy optimization algorithm to adjust the network parameters of the second network model to obtain a new second network model.

[0139] The training device for the traffic analysis model provided in the embodiment of the present application can execute the training method for the traffic analysis model provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.

[0140] Figure 5is a schematic diagram of the structure of an electronic device provided in this embodiment. The electronic device may include a training device for a traffic analysis model, such as Figure 5 As shown, the electronic device 500 includes a processor 510, a memory 520, an input device 530, and an output device 540; the number of the processor 510 in the electronic device can be one or more. Figure 5 A processor 510 is taken as an example; the processor 510, the memory 520, the input device 530 and the output device 540 in the electronic device can be connected via a bus or other means. Figure 5 The example of connecting through bus is taken in the following.

[0141] The memory 520, as a computer-readable storage medium, can be used to store software programs, computer executable programs and modules, such as program instructions / modules corresponding to the method for training a traffic analysis model in an embodiment of the present invention. The processor 510 executes various functional applications and data processing of the electronic device by running the software programs, instructions and modules stored in the memory 520, that is, implements the method for training a traffic analysis model provided in an embodiment of the present invention.

[0142] The memory 520 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system and at least one application required for a function; the data storage area may store data created according to the use of the terminal, etc. In addition, the memory 520 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some instances, the memory 520 may further include a memory remotely arranged relative to the processor 510, and these remote memories may be connected to the electronic device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0143] The input device 530 may be used to receive input digital or character information and generate key signal input related to user settings and function control of the electronic device, and may include a keyboard, a mouse, etc. The output device 540 may include a display device such as a display screen.

[0144] This embodiment also provides a storage medium containing computer executable instructions, which, when executed by a computer processor, are used to implement the training method of the traffic analysis model provided in the embodiment of the present invention.

[0145] Of course, the storage medium containing computer executable instructions provided by an embodiment of the present invention is not limited to the method operations described above, and can also execute related operations in the training method of the traffic analysis model provided by any embodiment of the present invention.

[0146] Through the above description of the implementation methods, the technicians in the relevant field can clearly understand that the present invention can be implemented by means of software and necessary general hardware, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as a computer floppy disk, read-only memory (ROM), random access memory (RAM), flash memory (FLASH), hard disk or optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, server, or network device, etc.) to execute the methods described in each embodiment of the present invention.

[0147] It is worth noting that in the embodiment of the training device for the above-mentioned traffic analysis model, the various units and modules included are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of the present invention.

[0148] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0149] The above description is only a specific implementation of the present application, so that those skilled in the art can understand or implement the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments described herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A method for training a traffic analysis model, characterized in that: The method comprises: Determine a first training data set and a second training data set, wherein the first training data set includes a plurality of thought deduction chains, and the thought deduction chains are determined by abnormal traffic data; and the second training data set includes data related to network security; Using the second training data set to perform unsupervised pre-training on the first network model to obtain a second network model; Inputting the thought deduction chain into the second network model to obtain output data; Inputting the first output data into a third network model to obtain a reward score, wherein the reward score is used to indicate a quantitative indicator of the quality of the output data; If the reward score does not meet the set condition, adjust the network parameters of the second network model to obtain a new second network model, and return to the step of inputting the thought deduction chain into the second network model to obtain output data; Until the reward score meets the set conditions, the second network model and the third network model are used as traffic analysis models, and the traffic analysis models are used to analyze network traffic.

2. The method according to claim 1, characterized in that Determine a first training data set, including: Get abnormal traffic data for each connection; For each connection's abnormal traffic data, preprocess the abnormal traffic data to obtain traffic data and text data corresponding to the connection; The flow data and the text data are processed to obtain a thought deduction chain corresponding to the connection.

3. The method according to claim 2, characterized in that The traffic data includes full traffic features. The traffic data and the text data are processed to obtain a thought deduction chain corresponding to the connection, including: Processing the full flow characteristics to obtain target flow characteristics; The target traffic feature and the text data are input into a decision tree so that the decision tree generates a thought deduction chain corresponding to the connection.

4. The method according to claim 3, characterized in that The full traffic features are processed to obtain training traffic features, including: For each flow feature in the full flow features, calculating the variance of the flow feature; The flow features whose variance is greater than or equal to the set variance threshold are retained as the primary flow features; Calculate the similarity between each primary traffic feature; When a similarity threshold is set based on the similarity between any two of the preliminarily selected traffic features, one of the preliminarily selected traffic features is retained and the other preliminarily selected traffic feature is deleted; All retained preliminary traffic features are used as training traffic features.

5. The method according to claim 1, characterized in that Inputting the thought deduction chain into the second network model to obtain output data includes: Pre-build a library of prompt words; Selecting any prompt word from the prompt word library as a training prompt word; Inputting the training prompt words and the thought deduction chain into the second network model; The training prompt word is analyzed by using the second network model based on the thought deduction chain to obtain output data, where the output data is answer data for the training prompt word.

6. The method according to claim 1, characterized in that The output data includes a plurality of answer data, and further includes: Acquire an arrangement order of the plurality of answer data, wherein the arrangement order is used to indicate a reasonable degree of the answer data; The third network model is trained using the sorted answer data and the second training data set.

7. The method according to claim 1, characterized in that Adjusting the network parameters of the second network model to obtain a new second network model includes: The network parameters of the second network model are adjusted using a proximal policy optimization algorithm to obtain a new second network model.

8. A training device for a traffic analysis model, characterized in that: The device comprises: A data set determination module, used to determine a first training data set and a second training data set, wherein the first training data set includes a plurality of thought deduction chains, and the thought deduction chains are determined by abnormal traffic data; and the second training data set includes data related to network security; A first training module, configured to perform unsupervised pre-training on the first network model using the second training data set to obtain a second network model; A second training module, used for inputting the thought deduction chain into the second network model to obtain output data; A third training module, used for inputting the output data into a third network model to obtain a reward score, wherein the reward score is used to indicate a quantitative index of the quality of the output data; A model parameter adjustment module, configured to adjust the network parameters of the second network model to obtain a new second network model when the reward score does not meet the set conditions, and return to execute the step of inputting the thought deduction chain into the second network model to obtain output data; The traffic analysis model determination module is used to use the second network model and the third network model as traffic analysis models until the reward score meets the set conditions, and the traffic analysis model is used to analyze the network traffic.

9. An electronic device, characterized in that: The device comprises: one or more processors; A storage device for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the training method of the traffic analysis model as described in any one of claims 1-7.

10. A storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the training method of the traffic analysis model as described in any one of claims 1 to 7 is implemented.