Training method of encrypted traffic detection model and encrypted traffic detection method

By extracting feature vectors from unencrypted traffic data and generating a training dataset using noise vector offset processing, and then training a classifier using an adversarial model, the problem of requiring a large amount of manpower and time to detect VPN encrypted traffic in existing technologies is solved, achieving efficient and accurate encrypted traffic detection.

CN117076925BActive Publication Date: 2026-11-24BEIJING TOPSEC NETWORK SECURITY TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311035448.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-08-17
Publication Date
2026-11-24
Estimated Expiration
2043-08-17

AI Technical Summary

Technical Problem

Existing technologies require collecting and labeling a large amount of encrypted traffic when detecting VPN encrypted traffic, which consumes a lot of human and time resources.

Method used

Feature vectors are extracted from unencrypted traffic data using a pre-trained feature extractor, and a training dataset is generated using noise vector offset processing. This dataset is then combined with an adversarial model to train a classifier, thus avoiding the direct collection and labeling of encrypted traffic.

Benefits of technology

It reduces the need for human and time resources, improves the efficiency and accuracy of encrypted traffic detection, and reduces the demand for human and time resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117076925B_ABST
    Figure CN117076925B_ABST
Patent Text Reader

Abstract

This application provides a training method for an encrypted traffic detection model and an encrypted traffic detection method, relating to the technical field of network security. The training method for the encrypted traffic detection model includes: extracting a first training dataset from multiple unencrypted traffic data using a feature extractor, the first training dataset including a first feature vector corresponding to each of the multiple unencrypted traffic data; shifting at least a portion of the first feature vectors in the first training dataset based on a preset noise vector to obtain a second training dataset, the second training dataset including multiple second feature vectors; wherein each digit in the noise vector has a greater probability in a first preset interval than in other intervals; training the classifier based on the first training dataset and the second training dataset to obtain the trained classifier.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of network security, and more specifically, to a training method for an encrypted traffic detection model and an encrypted traffic detection method. Background Technology

[0002] In recent years, the traffic involved in frequent telecom fraud cases is often encrypted using a VPN (Virtual Private Network). Furthermore, VPNs are not permitted in certain network scenarios.

[0003] Currently, machine learning is commonly used to detect VPN encrypted traffic. However, this method requires collecting a large amount of encrypted traffic in advance and labeling the collected encrypted traffic as objects for machine learning. Collecting and labeling encrypted traffic requires a lot of human and time resources. Summary of the Invention

[0004] This application provides a training method for an encrypted traffic detection model and an encrypted traffic detection method to solve the problem that existing technologies require a large amount of human and time resources to collect and label encrypted traffic.

[0005] In a first aspect, this application proposes a training method for an encrypted traffic detection model. The encrypted traffic detection model includes a pre-trained feature extractor and a classifier to be trained. The output of the feature extractor is connected to the input of the classifier. The method includes: extracting a first training dataset from multiple unencrypted traffic data using the feature extractor, the first training dataset including a first feature vector corresponding to each of the multiple unencrypted traffic data; shifting at least a portion of the first feature vectors in the first training dataset based on a preset noise vector to obtain a second training dataset, the second training dataset including multiple second feature vectors; wherein each digit in the noise vector has a greater probability in a first preset interval than in other intervals; and training the classifier based on the first training dataset and the second training dataset to obtain a trained classifier.

[0006] In this embodiment, the first feature vector is obtained by extracting unencrypted traffic data using a pre-trained feature extractor, enabling the first feature vector to characterize the features of the unencrypted traffic data. The second feature vector is obtained by shifting the first feature vector using a noise vector, resulting in a different distribution position of the second feature vector in the vector space compared to the first feature vector. This allows the classifier to be trained using both the first and second training datasets. Furthermore, obtaining both the first and second training datasets does not require collecting and labeling encrypted traffic, thus reducing the expenditure of significant human and time resources on collecting and labeling encrypted traffic data.

[0007] In conjunction with the technical solution provided in the first aspect above, in some possible implementations, the preset noise vector is obtained by: obtaining the noise vector based on multiple sampled values ​​randomly sampled from a preset offset function, wherein the independent variable of the offset function is the sampled value, and the dependent variable of the offset function is the probability that the independent variable corresponding to the dependent variable is sampled.

[0008] In this embodiment, since the noise vector is obtained from multiple sampled values ​​randomly sampled from the offset function, the specific value of the noise vector cannot be predicted, thus preventing the fixed noise vector from affecting the learning effect of the classifier. Furthermore, the dependent variable of the offset function is set to the probability of the corresponding independent variable being sampled, making the probability of each number in the noise vector falling within a first preset interval greater than its probability falling within other intervals. This allows the second feature vector obtained after noise vector offset processing to more accurately simulate the feature vector of encrypted traffic data, improving the training effect of the classifier.

[0009] In conjunction with the technical solution provided in the first aspect above, in some possible implementations, the preset offset function is a normal distribution function, wherein the mean of the normal distribution function is greater than or equal to -100 and less than or equal to 100; and the variance of the normal distribution function is greater than or equal to 0.1 and less than or equal to 5.

[0010] In this embodiment, since the normal distribution function is simpler than other distribution functions, it is easier to quickly obtain the sampled values, thereby making it more efficient to determine the noise vector using the normal distribution function and improving training efficiency.

[0011] In conjunction with the technical solution provided in the first aspect above, in some possible implementations, the feature extractor is trained in the following manner: acquiring a third training dataset, the third training dataset including multiple unencrypted traffic data; training a preset adversarial model based on the third training dataset to obtain a trained adversarial model; the trained adversarial model includes the feature extractor, a data decoder, and a discriminator, the input end of the feature extractor is used to receive unencrypted traffic data, the output end of the feature extractor is connected to the input end of the data decoder, the output end of the data decoder is connected to the input end of the discriminator, and the input end of the discriminator is also used to receive the unencrypted traffic data.

[0012] In this embodiment, the feature extractor can be trained using a third training dataset that includes multiple unencrypted traffic data. In other words, the training process of the feature extractor and classifier of the encrypted traffic detection model does not require the participation of labeled encrypted traffic data. This reduces the need to spend a lot of human and time resources to collect and label encrypted traffic data, thus reducing the occupation of human and time resources.

[0013] In conjunction with the technical solution provided in the first aspect above, in some possible implementations, training a preset adversarial model based on the third training dataset to obtain a trained adversarial model includes: inputting an unencrypted traffic data from the third training dataset into the feature extractor of the adversarial model to obtain a third feature vector; reconstructing the third feature vector using the data decoder to obtain reconstructed traffic data; outputting a first score corresponding to the unencrypted traffic data and a second score corresponding to the reconstructed traffic data using the discriminator; calculating a first loss value based on the first score and a preset first loss function, and calculating a second loss value based on the second score and a preset second loss function, and modifying the parameters of the discriminator using the first loss value and the second loss value; calculating a third loss value based on the similarity between the unencrypted traffic data and the reconstructed traffic data, as well as the first score and the second score, and modifying the parameters of the feature extractor and the data decoder using the third loss value; ending training if a preset training termination condition is met; and repeating the above training process if the preset training termination condition is not met.

[0014] In this embodiment, the parameters of the discriminator, feature extractor, and data decoder are adjusted in each training process, so that the discriminator, feature extractor, and data decoder compete with each other, which is beneficial to improving the training effect of the feature extractor and making the feature vector extracted by the feature extractor more accurately represent the input unencrypted traffic data.

[0015] In conjunction with the technical solution provided in the first aspect above, in some possible implementations, when the preset training termination condition is met, the method further includes: determining a target similarity and / or a target third loss value that meets the preset usage conditions from the similarity and / or the third loss value obtained in each round of training; updating the feature extractor using the parameters of the feature extractor corresponding to the target similarity and / or the target third loss value to obtain the trained feature extractor.

[0016] In conjunction with the technical solution provided in the first aspect above, in some possible implementations, if there is no target similarity and / or target third loss value that meets the preset usage conditions among the similarity and / or the third loss value obtained in each round of training, the feature extractor continues to be trained.

[0017] In this embodiment, if there is no target similarity and / or target third loss value that meets the preset usage conditions, the feature extractor continues to be trained, thereby ensuring that the accuracy of the feature vector extracted by the final feature extractor meets the actual usage requirements and improving the accuracy of the output results of the final encrypted traffic detection model.

[0018] In conjunction with the technical solution provided in the first aspect above, in some possible implementations, the preset training termination condition includes any one of the following: the similarity and the preset similarity threshold satisfy the preset similarity condition, the third loss value converges, and the number of training iterations reaches the preset training number threshold.

[0019] In conjunction with the technical solution provided in the first aspect above, in some possible implementations, obtaining a third training dataset includes: obtaining multiple unencrypted traffic data packets; for each unencrypted traffic data packet, supplementing the length of each header and the length of the payload of the traffic data packet, such that the length of each header of the supplemented traffic data packet meets a corresponding preset header length, and the length of the payload of the supplemented traffic data packet meets a preset payload length, thereby obtaining the unencrypted traffic data; wherein, the preset header length is equal to the header length of each unencrypted traffic data in the third training dataset, and the preset payload length is equal to the payload length of each unencrypted traffic data in the third training dataset.

[0020] In conjunction with the technical solution provided in the first aspect above, in some possible implementations, after acquiring multiple unencrypted traffic data packets, the method further includes: for each unencrypted traffic data packet, removing the protocol header corresponding to the data link layer from the traffic data packet.

[0021] In this embodiment of the application, since the protocol header corresponding to the data link layer in the traffic data packet has few features related to whether the traffic is encrypted, removing the protocol header corresponding to the data link layer can reduce the length and data dimension of the obtained unencrypted traffic data, thereby improving the efficiency of the feature extractor in extracting the corresponding feature vector.

[0022] In conjunction with the technical solution provided in the first aspect above, in some possible implementations, after acquiring multiple unencrypted traffic data packets, the method further includes: removing traffic data packets from the acquired unencrypted traffic data packets that are unrelated to the specific activity.

[0023] In this embodiment, since traffic data packets unrelated to specific activities are irrelevant to the specific activities in the session, such traffic data packets do not help in training the encrypted traffic detection model. Therefore, removing these traffic data packets unrelated to specific activities is beneficial to improving training efficiency in the future.

[0024] Secondly, this application provides an encrypted traffic detection method, comprising: acquiring traffic data to be detected; detecting whether the traffic data to be detected is encrypted traffic data based on an encrypted traffic detection model; wherein the encrypted traffic detection model is trained using the first aspect described above and / or in combination with any possible implementation of the first aspect described above.

[0025] Thirdly, this application provides a training device for an encrypted traffic detection model. The encrypted traffic detection model includes a pre-trained feature extractor and a classifier to be trained. The output of the feature extractor is connected to the input of the classifier. The encrypted traffic detection model training device includes: an acquisition module, a processing module, and a training module. The acquisition module is used to extract a first training dataset from multiple unencrypted traffic data using the feature extractor. The first training dataset includes a first feature vector corresponding to each of the multiple unencrypted traffic data. The processing module is used to perform offset processing on at least some of the first feature vectors in the first training dataset based on a preset noise vector to obtain a second training dataset. The second training dataset includes multiple second feature vectors. Each digit in the noise vector has a greater probability in a first preset interval than in other intervals. The training module is used to train the classifier based on the first training dataset and the second training dataset to obtain the trained classifier.

[0026] Fourthly, this application provides an encrypted traffic detection device, comprising: an acquisition module and a processing module, wherein the acquisition module is used to acquire preprocessed traffic data to be detected; the processing module is used to detect whether the traffic data to be detected is encrypted traffic data based on an encrypted traffic detection model; the encrypted traffic detection model is trained using the first aspect described above and / or in combination with any possible implementation of the first aspect described above.

[0027] Fifthly, this application provides an electronic device, comprising: a memory and a processor, the memory and the processor being connected; the memory being used to store a program; and the processor being used to invoke the program stored in the memory to perform the method as described in the first aspect above and / or in combination with any possible implementation of the first aspect above.

[0028] In a sixth aspect, this application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a computer, performs the method as described in the first aspect above and / or in combination with any possible implementation of the first aspect above. Attached Figure Description

[0029] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0030] Figure 1 This is a flowchart illustrating the training method of the first encrypted traffic detection model in an embodiment of this application;

[0031] Figure 2 This is a schematic diagram of the structure of an adversarial model shown in an embodiment of this application;

[0032] Figure 3 This is a flowchart illustrating the training method of the second encrypted traffic detection model in an embodiment of this application;

[0033] Figure 4 This is a flowchart illustrating an encrypted traffic detection method according to an embodiment of this application;

[0034] Figure 5 This is a structural block diagram of a training device for an encrypted traffic detection model, as shown in an embodiment of this application.

[0035] Figure 6 This is a structural block diagram of an encrypted traffic detection device shown in an embodiment of this application;

[0036] Figure 7This is a structural block diagram of an electronic device shown in an embodiment of this application. Detailed Implementation

[0037] The technical solutions in the embodiments of this application will now be described with reference to the accompanying drawings.

[0038] It should be noted that similar reference numerals and letters in the following figures denote similar items; therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. Furthermore, relational terms such as "first," "second," etc., in the description of this application are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one…" does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0039] The technical solution of this application will now be described in detail with reference to the accompanying drawings.

[0040] Please see Figure 1 , Figure 1 This is a flowchart illustrating a training method for an encrypted traffic detection model according to an embodiment of this application. The following will be combined with... Figure 1 The steps involved are explained.

[0041] The encrypted traffic detection model includes a pre-trained feature extractor and a classifier to be trained, with the output of the feature extractor connected to the input of the classifier. The feature extractor extracts feature vectors from the input traffic data, and the classifier classifies the data based on these feature vectors to obtain an output indicating whether the input traffic data is encrypted.

[0042] Optionally, the output here can be a score, which determines whether the input traffic data is encrypted. The correspondence between the output score and whether the input traffic data is encrypted may vary depending on the classifier parameters.

[0043] S100: Extract the first training dataset from multiple unencrypted traffic data using a feature extractor.

[0044] The first training dataset includes the first feature vector corresponding to each of multiple unencrypted traffic data.

[0045] The first training dataset can be pre-acquired and stored in a storage medium, and can be directly called when needed. Alternatively, the first training dataset can be obtained in real time when needed.

[0046] In one implementation, the specific process of obtaining the aforementioned multiple unencrypted traffic data may be as follows: First, multiple unencrypted traffic data packets are obtained. Then, for each unencrypted traffic data packet, the length of each header and the length of the payload of the traffic data packet are supplemented, such that the length of each header of the supplemented traffic data packet meets the corresponding preset header length, and the length of the payload of the supplemented traffic data packet meets the preset payload length, thereby obtaining the unencrypted traffic data.

[0047] The preset header length is equal to the header length of each unencrypted traffic data in the third training dataset, and the preset payload length is equal to the payload length of each unencrypted traffic data in the third training dataset.

[0048] When data is transmitted, a header is added for each layer of protocol (such as transport layer, network layer, data link layer, etc.).

[0049] For example, when user data (payload) is sent through an application, the data packet includes an APPL header and user data; when the data sent by the application passes through TCP (Transmission Control Protocol), the data packet includes a TCP header, an APPL header, and user data; when data is sent from the transport layer to the network layer (e.g., IP (Internet Protocol)), the data packet includes an IP header, a TCP header, an APPL header, and user data; when the data packet is sent from the network layer to the data link layer (e.g., Ethernet), the data packet includes an Ethernet header, an IP header, a TCP header, an APPL header, and user data. These examples are only for illustrative purposes and should not be construed as limiting the scope of this application.

[0050] Since the header length of each layer of a traffic data packet is related to the protocol type—for example, the transport layer can include protocols such as TCP and UDP (User Datagram Protocol)—and the lengths of the TCP and UDP headers may differ, a preset transport layer header length can be pre-set to ensure that the final unencrypted traffic data has the same length. This preset transport layer header length is then padded to match the length of the transport layer header in each traffic data packet. The preset transport layer header length is greater than or equal to the length of the transport layer header in any given traffic data packet.

[0051] Similarly, preset network layer header length and preset data link layer header length can also be set, with the preset network layer header length being greater than or equal to the length of the network layer header in any traffic data packet; and the preset data link layer header length being greater than or equal to the length of the data link layer header in any traffic data packet.

[0052] It can also set a preset payload length or a preset traffic data length. The preset payload length can be the theoretical length of the traffic data packet payload, and the preset traffic data length can be the theoretical total length of the traffic data packet.

[0053] Therefore, the aforementioned preset header length may include at least one of the preset network layer header length, preset data link layer header length, and preset application header length.

[0054] Optionally, after acquiring multiple unencrypted traffic data packets, the protocol header corresponding to the data link layer can be removed from each unencrypted traffic data packet. Since the protocol header corresponding to the data link layer in the traffic data packet has few features related to whether the traffic is encrypted, removing the protocol header corresponding to the data link layer can reduce the length and data dimensionality of the obtained unencrypted traffic data, thereby improving the efficiency of the feature extractor in extracting the corresponding feature vector.

[0055] To prevent the model from directly identifying fields in unencrypted traffic data instead of learning sample features for detection, optionally, the network addresses (such as source IP address, destination IP address, etc.) in the header corresponding to the network layer can be anonymized.

[0056] Anonymization involves replacing the network address with a specified string, such as replacing each character of the network address with "0". This example is only for illustrative purposes and should not be construed as a limitation of this application.

[0057] Optionally, after acquiring multiple unencrypted traffic data packets, the training method for the encrypted traffic detection model may further include: removing traffic data packets from the acquired unencrypted traffic data packets that are irrelevant to the specific activity.

[0058] The specific activity refers to data transmission, while data packets unrelated to the specific activity include traffic data packets used to establish communication connections that do not carry the data to be transmitted.

[0059] Optionally, for each traffic data packet, normalization can be performed, and the normalized data can be used as unencrypted traffic data.

[0060] The normalization process can be any existing method that can normalize traffic data packets, such as the maximum-minimum normalization method. There are no restrictions on the specific normalization method here. The specific implementation and principle of normalization are well known to those skilled in the art, and will not be elaborated here for the sake of brevity.

[0061] S200: Based on a preset noise vector, at least some of the first feature vectors in the first training dataset are offset to obtain the second training dataset.

[0062] The second training dataset includes multiple second feature vectors, where each digit in the noise vector has a higher probability of falling within a first preset interval than in other intervals. The dimension of the noise vector is the same as that of the first feature vector.

[0063] Within the first preset interval, the probability that each digit is sampled as a digit in the noise vector can be the same or different. Similarly, the probability that each digit is sampled as a digit in the noise vector within other intervals can be the same or different.

[0064] Optionally, the offset processing can be done by adding the first feature vector to the noise vector, or by calculating the average of the noise vector and the first feature vector.

[0065] For different first feature vectors, the corresponding noise vectors can be different or the same.

[0066] For example, each time a first feature vector is obtained, a new noise vector is acquired; or, N adjacent first feature vectors may correspond to the same noise vector, where N is a positive integer greater than or equal to 1.

[0067] The noise vector can be obtained from a pre-set set of vectors that includes at least one vector, or it can be obtained in real time when needed.

[0068] One way to obtain the noise vector is to obtain the noise vector based on multiple sample values ​​randomly sampled from a preset offset function.

[0069] For example, when the noise vector consists of N numbers (see below), N sample values ​​can be randomly sampled from the preset offset function, and the N sample values ​​are used to construct the N-dimensional noise vector. This example is for illustrative purposes only and should not be construed as a limitation of this application.

[0070] In this function, the independent variable is the sampled value, and the dependent variable is the probability that the corresponding independent variable will be sampled. The dependent variable is greater than or equal to 0 and less than or equal to 1.

[0071] For example, if the set of independent and dependent variables in the offset function is (X1, Y1), then the probability that the sampled value is X1 is Y1.

[0072] Optionally, the aforementioned offset function can be a normal distribution function, a Poisson distribution, or the like.

[0073] When the offset function is a normal distribution function, the mean of the normal distribution function can be greater than or equal to -100 and less than or equal to 100; the variance of the normal distribution function can be greater than or equal to 0.1 and less than or equal to 5.

[0074] S300: The classifier is trained based on the first training dataset and the second training dataset to obtain a trained classifier.

[0075] The specific method for training the classifier using the first training dataset can be as follows: input the first feature vector from the first training dataset into the classifier to obtain the output of the classifier. Since the first feature vector in the first training dataset is known to be the feature vector of unencrypted traffic data, the loss value is calculated based on the output of the classifier and the preset loss function, and the parameters of the classifier are adjusted using the calculated loss value.

[0076] The specific method for training the classifier using the second training dataset can be as follows: input the second feature vector from the second training dataset into the classifier to obtain the classifier's output. Since the second feature vector in the second training dataset is known to be the feature vector of the unencrypted traffic data after offset processing, the loss value is calculated based on the classifier's output and a preset loss function, and the calculated loss value is used to adjust the classifier's parameters.

[0077] This can be achieved by first training the classifier using the first training dataset and then training it using the second training dataset; or by alternately training the classifier using the first feature vector from the first training dataset and the second feature vector from the second training dataset.

[0078] The cutoff condition for training the classifier is that the calculated loss value converges, or the number of training iterations reaches a preset training threshold.

[0079] The specific methods for calculating the loss value and adjusting the classifier are well known to those skilled in the art, and will not be elaborated here for the sake of brevity.

[0080] Optionally, the classifier mentioned above can be a neural network model with classification function, such as a binary classification model.

[0081] In one implementation, the specific training process of the feature extractor may be as follows: first, a third training dataset is obtained, which includes multiple unencrypted traffic data; then, a preset adversarial model is trained based on the third training dataset to obtain the trained adversarial model.

[0082] like Figure 2 As shown, the adversarial model includes a feature extractor, a data decoder, and a discriminator. The input of the feature extractor is used to receive unencrypted traffic data, the output of the feature extractor is connected to the input of the data decoder, the output of the data decoder is connected to the input of the discriminator, and the input of the discriminator is also used to receive unencrypted traffic data.

[0083] The method for obtaining the third training dataset is the same as the method for obtaining multiple unencrypted traffic data described above, and will not be repeated here for the sake of brevity.

[0084] Optionally, the third training dataset and the multiple unencrypted traffic data used to obtain the first training dataset can be the same batch of unencrypted traffic data, or they can be different unencrypted traffic data, or the third training dataset and the multiple unencrypted traffic data used to obtain the first training dataset can have overlap.

[0085] In one implementation, the specific process of training a pre-defined adversarial model based on a third training dataset to obtain the trained adversarial model can be as follows: First, an unencrypted traffic data point from the third training dataset is input into the feature extractor of the adversarial model to obtain a third feature vector. Then, the third feature vector is reconstructed using a data decoder to obtain reconstructed traffic data. Next, a discriminator outputs a first score corresponding to the unencrypted traffic data and a second score corresponding to the reconstructed traffic data. Then, a first loss value is calculated based on the first score and a pre-defined first loss function, and a second loss value is calculated based on the second score and a pre-defined second loss function. The parameters of the discriminator are modified using the first and second loss values. Next, a third loss value is calculated based on the similarity between the unencrypted traffic data and the reconstructed traffic data, as well as the first and second scores. The parameters of the feature extractor and the data decoder are modified using the third loss value. Finally, training ends when a pre-defined training termination condition is met; otherwise, the above training process is repeated.

[0086] The score output by the discriminator represents the probability that the data input to the discriminator is of a specified type, where the specified type of data can be unencrypted traffic data or reconstructed traffic data.

[0087] The type of input data (unencrypted traffic data or reconstructed traffic data, i.e., standard output) can be determined by the source of the input data to the discriminator (external input or data decoder input). Therefore, based on the type of input data and the discriminator's output, the loss value can be calculated. The specific implementation of calculating the loss value is well-known to those skilled in the art and will not be elaborated upon here for brevity.

[0088] Optionally, the loss value can be obtained by calculating the type of input data and the mean squared error of the discriminator's output. The type of input data can be represented numerically. For example, if the discriminator's output shows 1 as 1% unencrypted traffic data and 0 as 10% reconstructed traffic data, then the input data type is 1 if the input data is unencrypted traffic data, and 0 if the input data is reconstructed traffic data. This allows the loss value to be calculated based on the type of input data and the discriminator's output.

[0089] Optionally, the specific way to modify the discriminator parameters using the first loss value and the second loss value can be to first calculate the weighted sum (or average) of the first loss value and the second loss value to obtain the actual loss value, and then modify the discriminator parameters based on the actual loss value.

[0090] The method involves pre-setting a first weight for the first loss value and a second weight for the second loss value, and then performing a weighted summation calculation on the first loss value and the second loss value based on the first weight and the second weight.

[0091] The specific values ​​of the first weight of the first loss value and the second weight of the second loss value can be set according to actual needs. For example, the first weight of the first loss value can be set to 0.5 and the second weight of the second loss value can be set to 0.5. This example is only for ease of understanding. The specific values ​​of the first weight of the first loss value and the second weight of the second loss value include, but are not limited to, the examples mentioned above.

[0092] Optionally, the specific method for calculating the third loss value based on the similarity between the unencrypted traffic data and the reconstructed traffic data, as well as the first score and the second score, can be as follows: First, calculate the similarity between the unencrypted traffic data and the reconstructed traffic data, and perform a weighted summation (or average calculation) on the first score and the second score to obtain a weighted summation value. Then, perform a weighted summation (or average calculation) on the similarity and the weighted summation value to obtain the third loss value.

[0093] The similarity between unencrypted traffic data and reconstructed traffic data can be calculated using methods such as cosine similarity. In this case, the higher the similarity, the more similar the unencrypted traffic data and the reconstructed traffic data are. The specific method for calculating cosine similarity is well known to those skilled in the art and will not be elaborated here for the sake of brevity.

[0094] Alternatively, the squared error loss between the unencrypted traffic data and the reconstructed traffic data can be calculated, and this squared error loss can be used as the similarity between the unencrypted traffic data and the reconstructed traffic data. In this case, the smaller the similarity, the more similar the unencrypted traffic data and the reconstructed traffic data are. The specific method for calculating the squared error loss (using the squared error function) is well known to those skilled in the art and will not be elaborated here for the sake of brevity.

[0095] The calculation includes a pre-set third weight for the first score and a fourth weight for the second score, and a weighted sum of the first and second scores based on these third and fourth weights. It also includes a pre-set fifth weight for similarity and a sixth weight for the weighted sum, and a weighted sum of the similarity and the weighted sum based on these fifth and sixth weights.

[0096] The specific values ​​of the third weight of the first rating and the fourth weight of the second rating can be set according to actual needs. For example, the third weight of the first rating can be set to 0.5 and the fourth weight of the second rating can be set to 0.5. This example is only for ease of understanding. The specific values ​​of the third weight of the first rating and the fourth weight of the second rating include, but are not limited to, the examples mentioned above.

[0097] Similarly, the specific values ​​of the fifth weight of similarity and the sixth weight of the weighted sum can be set according to actual needs. For example, the fifth weight of similarity can be set to 0.5 and the sixth weight of the weighted sum can be set to 0.5. This example is only for ease of understanding. The specific values ​​of the fifth weight of similarity and the sixth weight of the weighted sum are not limited to the examples mentioned above.

[0098] Optionally, the preset training termination conditions include any one of the following: the similarity and the preset similarity threshold satisfy the preset similarity condition, the third loss value converges, or the number of training iterations reaches the preset training number threshold.

[0099] The preset similarity threshold can be set according to actual needs; no specific value is restricted here.

[0100] When the similarity is higher (e.g., cosine similarity), indicating a greater similarity between unencrypted and reconstructed traffic data, the preset similarity condition is that the similarity is greater than a preset similarity threshold. When the similarity is lower (e.g., squared error loss), indicating a greater similarity between unencrypted and reconstructed traffic data, the preset similarity condition is that the similarity is less than a preset similarity threshold.

[0101] Optionally, after each calculation of the similarity and / or third loss value between unencrypted traffic data and reconstructed traffic data, the similarity and / or third loss value is recorded, along with the parameters of the corresponding feature extractor.

[0102] In this case, if the preset training termination condition is met, the training method of the encrypted traffic detection model further includes: determining the target similarity and / or target third loss value that meets the preset usage conditions from the similarity and / or third loss value obtained in each round of training; updating the feature extractor using the parameters of the feature extractor corresponding to the target similarity and / or target third loss value to obtain the trained feature extractor.

[0103] The preset usage conditions may include similarity greater than a preset similarity threshold and / or convergence of the third loss value.

[0104] For example, if the preset training termination condition is that the number of training iterations reaches a preset training number threshold, and the preset training number threshold is 50, and the preset usage condition is that the similarity is greater than the preset similarity threshold and the third loss value converges.

[0105] Since each training round records the similarity and / or third loss value, as well as the corresponding feature extractor parameters, after meeting the preset training termination condition, 50 sets of data are recorded. Each set includes the similarity, third loss value, and corresponding feature extractor parameters. From these 50 sets, data sets with similarity greater than a preset similarity threshold and converged third loss values ​​are selected. The feature extractor parameters recorded in these sets are then used to update the feature extractor, resulting in a trained feature extractor. This example is for illustrative purposes only and should not be construed as a limitation of this application.

[0106] For easier understanding, please refer to Figure 3 , Figure 3 This is a flowchart illustrating a training method for an encrypted traffic detection model, as shown in an embodiment of this application. It should be noted that... Figure 3 The training method for the encrypted traffic detection model shown is only one of many embodiments of the training method for the encrypted traffic detection model provided in this application, and should not be regarded as a limitation of this application.

[0107] like Figure 3 As shown, firstly, multiple unencrypted traffic data packets are acquired, and then traffic data packets irrelevant to the specific activity are removed from the acquired unencrypted traffic data packets. For each unencrypted traffic data packet, preprocessing is performed to obtain the third training set. The specific preprocessing process is as follows: the protocol header corresponding to the data link layer is removed from the traffic data packet, the network address in the header is anonymized, the lengths of each header and the payload of the traffic data packet are added, and finally, the supplemented data is normalized to obtain unencrypted traffic data. The third training dataset includes the obtained multiple unencrypted traffic data packets.

[0108] The pre-defined adversarial model is trained using the obtained third training dataset to obtain a trained adversarial model. A first training dataset is extracted from multiple unencrypted traffic datasets using the feature extractor in the trained adversarial model. At least a portion of the first feature vectors in the first training dataset are shifted based on pre-defined noise vectors to obtain a second training dataset. Finally, a classifier is trained using the first and second training datasets to obtain a trained classifier.

[0109] Finally, a trained encrypted traffic detection model is obtained based on the trained classifier and the trained feature extractor. The output of the feature extractor is connected to the input of the classifier.

[0110] Based on the same inventive concept, this application also provides a method for detecting encrypted traffic, such as... Figure 4 As shown, the following will be combined with Figure 4 The steps involved are explained.

[0111] S500: Acquire traffic data to be detected.

[0112] The traffic data to be detected can be pre-acquired and stored in a storage medium, and then directly retrieved when needed. Alternatively, the traffic data to be detected can be obtained in real time when needed.

[0113] The traffic data to be detected can be obtained based on the traffic data packet to be detected. After obtaining the traffic data packet to be detected, the traffic data packet to be detected is processed to obtain the traffic data to be detected.

[0114] The specific methods and principles for processing the traffic data packets to be detected are the same as those for obtaining unencrypted traffic data based on unencrypted traffic data packets, and will not be repeated here for the sake of brevity.

[0115] S600: Detects whether the traffic data to be detected is encrypted based on the encrypted traffic detection model.

[0116] The encrypted traffic detection model is trained using the aforementioned training method for the encrypted traffic detection model.

[0117] By inputting the traffic data to be detected into the encrypted traffic detection model, the encrypted traffic detection model outputs the corresponding detection result, which represents whether the input traffic data to be detected is encrypted.

[0118] Based on the same inventive concept, this application also provides a training device for an encrypted traffic detection model, such as... Figure 5 As shown, the encrypted traffic detection model includes a pre-trained feature extractor and a classifier to be trained. The output of the feature extractor is connected to the input of the classifier. The encrypted traffic detection model training device 100 includes an acquisition module 110, a processing module 120, and a training module 130.

[0119] The acquisition module 110 is used to extract a first training dataset from multiple unencrypted traffic data through the feature extractor. The first training dataset includes a first feature vector corresponding to each of the multiple unencrypted traffic data.

[0120] The processing module 120 is used to perform offset processing on at least a portion of the first feature vectors in the first training dataset based on a preset noise vector to obtain a second training dataset, wherein the second training dataset includes a plurality of second feature vectors; wherein, the probability of each digit in the noise vector being in a first preset interval is greater than the probability being in other intervals.

[0121] The training module 130 is used to train the classifier based on the first training dataset and the second training dataset to obtain the trained classifier.

[0122] The processing module 120 is further configured to obtain the noise vector based on multiple sampled values ​​randomly sampled from a preset offset function, wherein the independent variable of the offset function is the sampled value, and the dependent variable of the offset function is the probability that the independent variable corresponding to the dependent variable is sampled.

[0123] In one implementation, the preset offset function is a normal distribution function, wherein the mean of the normal distribution function is greater than or equal to -100 and less than or equal to 100; and the variance of the normal distribution function is greater than or equal to 0.1 and less than or equal to 5.

[0124] The acquisition module 110 is further configured to acquire a third training dataset, which includes multiple unencrypted traffic data. The training module 130 is further configured to train a preset adversarial model based on the third training dataset to obtain a trained adversarial model; the trained adversarial model includes the feature extractor, the data decoder, and the discriminator, wherein the input of the feature extractor is used to receive unencrypted traffic data, the output of the feature extractor is connected to the input of the data decoder, the output of the data decoder is connected to the input of the discriminator, and the input of the discriminator is also used to receive the unencrypted traffic data.

[0125] The training module 130 is specifically used to input an unencrypted traffic data from the third training dataset into the feature extractor of the adversarial model to obtain a third feature vector; to reconstruct the third feature vector using the data decoder to obtain reconstructed traffic data; to output a first score corresponding to the unencrypted traffic data and a second score corresponding to the reconstructed traffic data using the discriminator; to calculate a first loss value based on the first score and a preset first loss function, and to calculate a second loss value based on the second score and a preset second loss function, and to modify the parameters of the discriminator using the first loss value and the second loss value; to calculate a third loss value based on the similarity between the unencrypted traffic data and the reconstructed traffic data, as well as the first score and the second score, and to modify the parameters of the feature extractor and the data decoder using the third loss value; to end training if a preset training termination condition is met; and to repeat the above training process if the preset training termination condition is not met.

[0126] The training module 130 is further configured to determine, from the similarity and / or the third loss value obtained in each round of training, a target similarity and / or a target third loss value that meets preset usage conditions; and update the feature extractor using the parameters of the feature extractor corresponding to the target similarity and / or the target third loss value to obtain the trained feature extractor.

[0127] In one implementation, if none of the similarity and / or the third loss value obtained in each round of training satisfies the preset usage conditions, the feature extractor continues to be trained.

[0128] In one implementation, the preset training termination condition includes any one of the following: the similarity is greater than a preset similarity threshold, the third loss value converges, and the number of training iterations reaches a preset training number threshold.

[0129] The acquisition module 110 is specifically used for: acquiring multiple unencrypted traffic data packets; for each unencrypted traffic data packet, supplementing the length of each header and the length of the payload of the traffic data packet, such that the length of each header of the supplemented traffic data packet meets the corresponding preset header length, and the length of the payload of the supplemented traffic data packet meets the preset payload length; wherein, the preset header length is equal to the header length of each unencrypted traffic data in the third training dataset, and the preset payload length is equal to the payload length of each unencrypted traffic data in the third training dataset.

[0130] The acquisition module 110 is also used to, after acquiring multiple unencrypted traffic data packets, remove the protocol header corresponding to the data link layer from each unencrypted traffic data packet.

[0131] The acquisition module 110 is also used to remove traffic data packets that are irrelevant to the specific activity from the acquired unencrypted traffic data packets after acquiring multiple unencrypted traffic data packets.

[0132] The encrypted traffic detection model training device 100 provided in this application embodiment has the same implementation principle and technical effect as the aforementioned encrypted traffic detection model training method embodiment. For the sake of brevity, any parts not mentioned in the device embodiment can be referred to the corresponding content in the aforementioned encrypted traffic detection model training method embodiment.

[0133] Based on the same inventive concept, this application also provides an encrypted traffic detection device, such as... Figure 6 As shown, the encrypted traffic detection device 200 includes an acquisition module 210 and a processing module 220.

[0134] The acquisition module 210 is used to acquire the preprocessed traffic data to be detected.

[0135] The processing module 220 is used to detect whether the traffic data to be detected is encrypted traffic data based on the encrypted traffic detection model.

[0136] The encrypted traffic detection model is trained using the aforementioned training method for the encrypted traffic detection model.

[0137] The encrypted traffic detection device 200 provided in this application embodiment has the same implementation principle and technical effect as the aforementioned encrypted traffic detection method embodiment. For the sake of brevity, any parts not mentioned in the device embodiment can be referred to the corresponding content in the aforementioned encrypted traffic detection method embodiment.

[0138] Please see Figure 7 This is an electronic device 300 provided in an embodiment of this application. The electronic device 300 includes: a processor 310 and a memory 320 communicatively connected to the processor 310.

[0139] The processor 310 and memory 320 can be connected via a communication bus, or via communication modules such as wireless communication modules, Bluetooth communication modules, and 4G / 5G communication modules. The memory 320 is used to store computer programs, such as... Figure 5 or Figure 6The software functional modules shown are the encrypted traffic detection model training device 100 or the encrypted traffic detection device 200. The encrypted traffic detection model training device 100 or the encrypted traffic detection device 200 includes at least one software functional module that can be stored in the memory 320 in the form of software or firmware, or embedded in the operating system (OS) of the electronic device 300.

[0140] The processor 310 is configured to execute executable modules stored in the memory 320, such as software function modules or computer programs included in the encrypted traffic detection model training device 100. At this time, the processor 310 is configured to extract a first training dataset from multiple unencrypted traffic data using the feature extractor. The first training dataset includes a first feature vector corresponding to each of the multiple unencrypted traffic data. Based on a preset noise vector, at least a portion of the first feature vectors in the first training dataset are offset to obtain a second training dataset, which includes multiple second feature vectors. Each digit in the noise vector has a greater probability of falling within a first preset interval than within other intervals. The classifier is then trained based on the first training dataset and the second training dataset to obtain the trained classifier.

[0141] The processor 310 is used to execute executable modules stored in the memory 320, such as software function modules or computer programs included in the encrypted traffic detection device 200. In this case, the processor 310 is used to acquire traffic data to be detected; and to detect whether the traffic data to be detected is encrypted traffic data based on an encrypted traffic detection model; the encrypted traffic detection model is trained using the aforementioned encrypted traffic detection model training method.

[0142] The memory 320 may be, but is not limited to, random access memory (RAM), read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), etc.

[0143] Processor 310 may be an integrated circuit chip with signal processing capabilities. The aforementioned processor can be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it can also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor, or processor 310 can be any conventional processor.

[0144] It is understood that the electronic device 300 may also include more general modules required by itself, which will not be described one by one in the embodiments of this application.

[0145] Among them, the aforementioned electronic devices 300 include, but are not limited to, personal computers, servers, etc.

[0146] This application embodiment also provides a computer-readable storage medium (hereinafter referred to as the storage medium) storing a computer program. When the computer program is executed by a computer, such as the electronic device 300 described above, it performs the policy matching method shown above. The computer-readable storage medium includes various media capable of storing program code, such as a USB flash drive, a portable hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.

[0147] The above description is merely a preferred embodiment of this application and is not intended to limit this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.

Claims

1. A method for training an encrypted traffic detection model, the method comprising: The encrypted traffic detection model comprises a pre-trained feature extractor and a classifier to be trained, an output end of the feature extractor is connected with an input end of the classifier, and the method comprises: extracting a first training data set from a plurality of unencrypted traffic data through the feature extractor, the first training data set comprising a first feature vector corresponding to each of the plurality of unencrypted traffic data; performing offset processing on at least part of the first feature vectors in the first training data set based on a preset noise vector, to obtain a second training data set, the second training data set comprising a plurality of second feature vectors; wherein the probability of each digit in the noise vector in a first preset interval is greater than that in other intervals; training the classifier based on the first training data set and the second training data set to obtain the trained classifier; wherein the preset noise vector is obtained by the following method: obtaining the noise vector based on a plurality of sampling values randomly sampled from a preset offset function, wherein the independent variable of the offset function is the sampled value, and the dependent variable of the offset function is the probability of the corresponding independent variable being sampled.

2. The method of claim 1, wherein, The preset offset function is a normal distribution function, and the mean of the normal distribution function is greater than or equal to -100 and less than or equal to 100; the variance of the normal distribution function is greater than or equal to 0.1 and less than or equal to 5.

3. The method of claim 1, wherein, The feature extractor is trained by the following method: obtaining a third training data set, the third training data set comprising a plurality of unencrypted traffic data; training a preset adversarial model based on the third training data set to obtain a trained adversarial model; the trained adversarial model comprises the feature extractor, a data decoder and a discriminator, an input end of the feature extractor is used to receive unencrypted traffic data, an output end of the feature extractor is connected with an input end of the data decoder, an output end of the data decoder is connected with an input end of the discriminator, and the input end of the discriminator is also used to receive the unencrypted traffic data.

4. The method of claim 3, wherein, Training a preset adversarial model based on the third training data set to obtain a trained adversarial model comprises: inputting an unencrypted traffic data in the third training data set into the feature extractor of the adversarial model to obtain a third feature vector; reconstructing the third feature vector through the data decoder to obtain reconstructed traffic data; outputting a first score corresponding to the unencrypted traffic data and a second score corresponding to the reconstructed traffic data through the discriminator respectively; calculating a first loss value based on the first score and a preset first loss function, and calculating a second loss value based on the second score and a preset second loss function, and modifying the parameters of the discriminator using the first loss value and the second loss value; calculating a third loss value based on the similarity of the unencrypted traffic data and the reconstructed traffic data, and the first score and the second score, and modifying the parameters of the feature extractor and the data decoder using the third loss value; In a case where the preset training end condition is met, the training is ended; in a case where the preset training end condition is not met, the training process is repeated.

5. The method of claim 4, wherein, In a case where the preset training end condition is met, the method further comprises: From the similarity and / or the third loss value obtained in each training process, a target similarity and / or a target third loss value meeting a preset use condition are determined; The feature extractor is updated using the parameters of the feature extractor corresponding to the target similarity and / or the target third loss value, to obtain a trained feature extractor.

6. The method of claim 5, wherein, If there is no target similarity and / or target third loss value meeting the preset use condition in the similarity and / or the third loss value obtained in each training process, the feature extractor is continuously trained.

7. The method of claim 4, wherein, The preset training end condition includes any one of the similarity and a preset similarity threshold value meeting a preset similarity condition, the third loss value converging, and a training iteration number reaching a preset training number threshold value.

8. The method of claim 3, wherein, The third training data set is obtained, including: A plurality of unencrypted traffic data packets are obtained; For each unencrypted traffic data packet, the length of each header and the length of the payload of the traffic data packet are supplemented, so that the length of each header of the supplemented traffic data packet meets the corresponding preset header length, and the length of the payload of the supplemented traffic data packet meets the preset payload length; The preset header length is equal to the header length of the unencrypted traffic data of each traffic data in the third training data set, and the preset payload length is equal to the length of the payload of the unencrypted traffic data of each traffic data in the third training data set.

9. The method of claim 8, wherein, After obtaining a plurality of unencrypted traffic data packets, the method further comprises: For each unencrypted traffic data packet, the protocol header corresponding to the data link layer in the traffic data packet is removed.

10. The method of claim 8, wherein, After obtaining a plurality of unencrypted traffic data packets, the method further comprises: The unencrypted traffic data packets unrelated to specific activities in the obtained unencrypted traffic data packets are removed.

11. A method of encrypted traffic detection, the method comprising: It comprises: Obtain the to-be-detected traffic data; Detect whether the to-be-detected traffic data is encrypted traffic data based on an encrypted traffic detection model; The encrypted traffic detection model is trained by the training method of the encrypted traffic detection model of any one of claims 1-10.

12. An encrypted traffic detection model training apparatus, comprising: The encrypted traffic detection model comprises a pre-trained feature extractor and a to-be-trained classifier, an output end of the feature extractor is connected to an input end of the classifier, and the encrypted traffic detection model training device comprises: An acquisition module is configured to extract a first training data set from a plurality of unencrypted traffic data by the feature extractor, and the first training data set comprises a first feature vector corresponding to each of the plurality of unencrypted traffic data; The encrypted traffic detection model training device further comprises: The processing module is configured to perform offset processing on at least part of the first feature vectors in the first training data set respectively based on a preset noise vector, to obtain a second training data set, the second training data set comprising a plurality of second feature vectors; wherein each digit in the noise vector has a probability of being in a first preset interval that is greater than a probability of being in other intervals. The training module is configured to train a classifier based on the first training data set and the second training data set, to obtain the trained classifier. The processing module is further configured to obtain the noise vector based on a plurality of sampling values randomly sampled from a preset offset function, wherein an independent variable of the offset function is a sampled value, and a dependent variable of the offset function is a probability of the dependent variable corresponding to the independent variable being sampled.

13. An encrypted traffic detection apparatus, characterized by, Comprising: The acquisition module is configured to acquire preprocessed to-be-detected traffic data. The processing module is configured to detect whether the to-be-detected traffic data is encrypted traffic data based on an encrypted traffic detection model. The encrypted traffic detection model is trained by the training method of the encrypted traffic detection model of any one of claims 1-10.

14. An electronic device, comprising: Comprising: A memory and a processor, the memory and the processor being connected; The memory is configured to store a program; The processor is configured to call the program stored in the memory to execute the method of any one of claims 1-11.

15. A computer-readable storage medium, characterized in that, A computer program is stored thereon, and the computer program is run by a computer to execute the method of any one of claims 1-11.