Double-engine encryption malicious traffic detection method based on deep learning

Through the dual-engine detection method based on deep learning, encrypted traffic is grouped and characterized, and statistical features and data packet features are integrated to solve the problem of poor accuracy in encrypted traffic detection in the existing technology and achieve more efficient malicious detection. Traffic detection.

CN118694585APending Publication Date: 2024-09-24NAT COMP NETWORK & INFORMATION SECURITY MANAGEMENT CENT GUANGDONG BRANCH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410788747.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-19
Publication Date
2024-09-24

AI Technical Summary

Technical Problem

Existing malicious traffic detection methods based on deep learning have the problem of poor detection accuracy when facing encrypted traffic. Especially when dealing with encrypted malicious traffic with unknown or disguised characteristics, it is difficult to achieve satisfactory detection results, and traditional methods The fine-grained characteristics of the encrypted data packet payload are ignored, resulting in unsatisfactory detection results.

Method used

Adopting a dual-engine encrypted malicious traffic detection method based on deep learning, by grouping and feature extraction of encrypted traffic data, two independent malicious traffic detection engines are used to process statistical features and packet features respectively, and the results are integrated and judged to ensure Accurate detection of encrypted traffic.

Benefits of technology

It improves the detection accuracy of encrypted malicious traffic, can handle complex situations more effectively, such as encrypted malicious traffic with unknown or disguised characteristics, and enhances the comprehensiveness and accuracy of detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118694585A
    Figure CN118694585A
Patent Text Reader

Abstract

The invention relates to a double-engine encrypted malicious traffic detection method based on deep learning. The method comprises the following steps: acquiring encrypted traffic data; grouping each data packet in the encrypted traffic data to obtain multiple groups of traffic data units; extracting basic information field content corresponding to each data packet, performing statistical operation processing on each basic information field of each data packet to obtain various statistical features and form a feature list; performing detection processing on the feature list and each data packet in each group of traffic data units to obtain two intermediate results; and integrating the two intermediate results corresponding to each group of traffic data units to obtain a candidate result of the traffic data unit, and judging whether the traffic data unit is malicious traffic or not based on the candidate result. According to the invention, based on the deep learning model, the statistical features and the data packet features can be utilized at the same time for comprehensive analysis, and more complex conditions can be processed, so that the detection accuracy of the network encryption malicious traffic is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of network security technology, and in particular to a dual-engine encrypted malicious traffic detection method based on deep learning. Background Art

[0002] With the development of Internet technology and cryptography, as well as people's increasing attention to the security and privacy of network communications, encrypted traffic technology has been rapidly developed and widely used. More and more individuals and enterprises choose to use encryption mechanisms to encrypt traffic transmission to improve the security of traffic transmission and protect privacy data. However, while enhancing data and privacy protection, encrypted traffic technology also provides convenience for concealing malicious network traffic. In the past, the malicious detection mechanism for non-encrypted traffic would, on the one hand, obtain the IP address from the packet header to check whether it hits the blacklist, and on the other hand, confirm whether it is malicious traffic based on whether the data in the payload hits the rules (such as whether a specific string or byte sequence appears). However, due to the improvement of software development tools' support for traffic encryption technology and the toolization and commercialization of various traffic encryption software, the threshold of encryption technology has been significantly lowered, which provides great convenience for attackers to use encrypted traffic to hide malicious behavior. At present, most network attacks use encrypted traffic. Attackers will encrypt malicious traffic to avoid traditional detection mechanisms for malicious traffic and launch malicious attacks on users. This encrypted malicious traffic can hide many known or unknown threats. It is highly concealed and very dangerous. The traditional malicious traffic detection method based on plaintext feature matching of data packets will be greatly reduced in effectiveness when facing encrypted malicious traffic. Therefore, providing new detection methods for encrypted malicious traffic is of great significance for preventing attackers from invading using encryption technology and improving network security protection capabilities.

[0003] Among the existing detection methods, malicious encrypted traffic detection based on traditional machine learning is a commonly used detection technology. However, this method relies on the manual selection of features by experts, which requires some expert knowledge or experience to manually extract features from network traffic, and it is difficult to perform feature learning on the encrypted payload part of the data packet, which will affect the detection efficiency and accuracy, and it is difficult to face the current complex and massive network applications. In recent years, deep learning methods have gradually become the mainstream method in the field of malicious traffic detection. Compared with traditional machine learning, deep learning has good feature extraction capabilities and has the advantage of low dependence on artificial feature engineering methods. It can avoid complex and cumbersome data processing processes and make the detection model more adaptable. At present, some related detection methods have applied malicious traffic detection engines based on deep learning models, which can detect and process the input network traffic data, output the detection results, and judge whether the network traffic data is malicious traffic based on the detection results. However, the current research on related detection methods based on deep learning models has a relatively single focus. When faced with data packets extracted from network traffic data, they usually only focus on a part of the features, such as relatively coarse-grained features such as session traffic statistical features, and detect based on the differences in some statistical features between normal encrypted traffic and malicious encrypted traffic, while ignoring other aspects such as relatively fine-grained features such as data packet encryption payload. Therefore, there are certain limitations. When faced with more complex situations, such as encrypted malicious traffic with unknown or disguised features, the detection accuracy of the above detection technology may be greatly reduced, resulting in poor detection accuracy of network encrypted malicious traffic and unsatisfactory detection results, which cannot meet existing needs.

[0004] In addition, since the characteristics of malicious behavior are mainly contained in the encrypted data packet payload data, and the packet header or header is non-encrypted plaintext information, mainly including protocol fields with specific meanings, control information used to tell network transmission equipment how to process payload data, etc., they play different roles in detection. Therefore, for each part of the neurons in the model, they will have different focuses when processing the header and payload. When processing data packets, existing methods often input the IP datagram header and payload of the data packet into the model together and use the same method to process them without distinguishing them. In this case, when the model faces different data packets, it will cause the data content received by each group of neurons to sometimes correspond to the header and sometimes to the payload, which lacks regularity and causes confusion in the detection and processing of neurons. This will cause the information difference between the header and the payload to be ignored by the model or the information to be insufficiently utilized during detection. In this case, it will be difficult to truly train an effective neural network, thereby affecting the detection accuracy of the detection model, which is not conducive to model training or model use. On the other hand, the promotion of IPv6 is the future development trend of the network. Currently, the number of active IPv6 users is also growing rapidly. Therefore, when detecting encrypted malicious traffic, it is necessary to consider using data of different IP protocols to meet current needs. Since the header of the IPv6 datagram cancels or changes some header fields of the original IPv4 datagram, and the length of some fields also changes, the two have great differences in structure. Although there are still some field information with the same or similar meanings in the two, the existing model does not distinguish these data packets when facing data packets using different IP protocols, but detects and processes the entire data packet content together. Therefore, the effect of using the header field information of the IP datagram will be different. For example, the method of processing data packets using the IPv4 protocol is used to process data packets using the IPv6 protocol, which lacks differentiation. This will also affect the detection accuracy of the model when detecting data packets using different IP protocols, and it is difficult to achieve a good detection effect. Summary of the invention

[0005] The purpose of the present invention is to provide a dual-engine encrypted malicious traffic detection method based on deep learning, which can improve the detection accuracy of network encrypted malicious traffic.

[0006] A dual-engine encrypted malicious traffic detection method based on deep learning, comprising the following steps: S1: Collect encrypted traffic data; S2: grouping the data packets in the encrypted traffic data in units of sessions to obtain multiple groups of traffic data units; S3: extract the content of the basic information field corresponding to each data packet in each group of traffic data units; the basic information field includes a header field, a timestamp, a data packet transmission direction, a packet byte number, and a flag bit; the header field is an IP version, an IP datagram byte number, a service type, a survival time, and a protocol taken from an IP datagram header; Performing statistical operations on the contents of each basic information field of each data packet in each group of traffic data units to obtain a plurality of statistical features corresponding to the basic information fields, and forming a feature list of the group of traffic data units based on the statistical features; S4: numerically process the non-numerical statistical features in the feature list of the traffic data unit, and then input the feature list into a first malicious traffic detection engine based on deep learning for detection processing, to obtain labels of various traffic types and their probability values ​​as a first intermediate result; Input each data packet of the traffic data unit into the second malicious traffic detection engine based on deep learning for detection and processing, and obtain the labels of various traffic types corresponding to each data packet and their probability values; then take the maximum value of the probability values ​​corresponding to each traffic type, normalize them, and obtain the labels of various traffic types corresponding to the traffic data unit and their processed probability values, which are used as the second intermediate result; S5: Integrate the first intermediate result and the second intermediate result corresponding to each group of traffic data units to obtain a candidate result of the traffic data unit, and determine whether the traffic data unit is malicious traffic based on the candidate result.

[0007] As a further implementation, in step S4, before each data packet of the traffic data unit is input into the second malicious traffic detection engine based on deep learning for detection processing, each data packet is processed as follows: The generalized payload in the data packet is adjusted in bytes by padding the end with zeros or truncating the end, and then the byte contents are arranged from beginning to end in a matrix with the same number of rows and columns to form a payload matrix; wherein the generalized payload includes the payload part of the IP datagram; Arrange each field in the header field corresponding to the data packet in the same order, and then fill the content of the arranged header field into the head of each row of the payload matrix according to its byte number to form an input matrix corresponding to the data packet.

[0008] As a further implementation, in step S4, before each data packet of the traffic data unit is input into the second malicious traffic detection engine based on deep learning for detection processing, each data packet is processed as follows: The generalized payload in the data packet is adjusted in bytes by padding the end with zeros or truncating the end, and then the byte contents are arranged from beginning to end in a matrix with the same number of rows and columns to form a payload matrix; wherein the generalized payload includes the payload part of the IP datagram; Arrange each field in the header field corresponding to the data packet in the same order, and then fill the content of the arranged header field at the end of each row of the payload matrix according to its byte number to form an input matrix corresponding to the data packet.

[0009] As a further implementation manner, in a data packet using the IPv4 protocol, the generalized payload also includes an optional field in its IP datagram header.

[0010] As a further implementation, in a data packet using the IPv4 protocol, the contents corresponding to the fields of the header field are as follows: The IP version field corresponds to the version field and header length field in the IPv4 datagram header; The IP datagram byte number field corresponds to the total length field in the IPv4 datagram header; The service type field corresponds to the service type field in the IPv4 datagram header; The survival time field corresponds to the lifetime field in the IPv4 datagram header; The protocol field corresponds to the protocol field in the IPv4 datagram header.

[0011] As a further implementation, in a data packet using the IPv6 protocol, the contents corresponding to the fields of the header field are as follows: The IP version field corresponds to the version field in the IPv6 datagram header; The IP datagram byte number field corresponds to the payload length field in the IPv6 datagram header; The service type field corresponds to the flow label field in the IPv6 datagram header; The survival time field corresponds to the hop limit field in the IPv6 datagram header; The protocol field corresponds to the next header field in the IPv6 datagram header.

[0012] As a further implementation, in step S2, the data packets in the encrypted traffic data are grouped in units of sessions, specifically: The five-tuple of the data packet is used as the session identification number for grouping, and the data packets with the same content in each part of the five-tuple are divided into the same group of traffic data units; wherein the five-tuple includes the source IP address, the destination IP address, the source port, the destination port, and the protocol number.

[0013] As a further implementation, the normalization process used in step S4 is specifically: The square of the probability value of each traffic type is divided by the sum of the squares of the probability values ​​of all traffic types, and the result obtained is used as the normalized probability value of each traffic type.

[0014] As a further implementation, in step S5, the first intermediate result and the second intermediate result corresponding to each group of traffic data units are integrated to obtain the candidate result of the traffic data unit, specifically: The probability values ​​of the same traffic type in the first intermediate result and the second intermediate result are weighted averaged, and then the probability values ​​of each traffic type are normalized to obtain labels of various traffic types and their processed probability values ​​as candidate results.

[0015] As a further implementation, in the step of normalizing the probability values ​​of each traffic type to obtain labels of various traffic types and their processed probability values ​​as candidate results, the normalization process used is specifically: The probability value of each traffic type is divided by the sum of the probability values ​​of all traffic types, and the result obtained is used as the normalized probability value of each traffic type.

[0016] The present invention collects encrypted traffic data and groups the data packets therein to obtain multiple groups of traffic data units containing data packets; then extracts the content of the basic information field of each data packet in each group of traffic data units; then performs statistical calculations on each basic information field to obtain a corresponding plurality of statistical features and form a feature list; the feature list of the traffic data unit is input into a first malicious traffic detection engine based on deep learning after preprocessing for detection processing, and obtains labels of various traffic types and probability values ​​thereof as a first intermediate result; each data packet of the traffic data unit is input into a second malicious traffic detection engine based on deep learning for detection processing, and after processing, obtains labels of various traffic types and probability values ​​thereof as a second intermediate result; finally, the two intermediate results are integrated to obtain a candidate result of the traffic data unit, and based on the candidate result, it is determined whether the traffic data unit is malicious traffic. The method provided by the present invention utilizes the advantage of low dependence of deep learning models on artificial feature engineering methods. Two malicious traffic detection engines based on deep learning models respectively perform parallel detection and processing on the statistical features of encrypted traffic data and the two different levels of features of data packets. Then, the two intermediate results detected and output by the two malicious traffic detection engines are integrated and processed. Based on the integrated results, it is determined whether the corresponding encrypted traffic data is malicious traffic to obtain the final detection result, so that the data packets belonging to fine-grained features and the statistical features belonging to coarse-grained features can be comprehensively analyzed, so as to achieve the purpose of simultaneously utilizing statistical features and data packet encryption load features. The detection result information of these two different levels of features complement each other, reducing the detection omissions when focusing on a single feature, so that it can detect and process more complex situations such as encrypted malicious traffic with unknown and disguised features, and the detection range is more comprehensive, so as to obtain detection results with higher accuracy, improve the detection accuracy of network encrypted malicious traffic, and achieve better detection effect. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] The present invention will be further described below in conjunction with the accompanying drawings: Figure 1 A schematic diagram of a flow chart of a dual-engine encrypted malicious traffic detection method based on deep learning of the present invention; Figure 2 This is a specific flow chart of step S2 of the present invention; Figure 3 It is a schematic diagram of the process of converting the data packet arrangement process into an input matrix in step S4 of the present invention; Figure 4 A schematic diagram of a process of processing the first intermediate result and the second intermediate result to obtain a final test result in step S5 of the present invention; Figure 5 A schematic diagram of the structure of a generalized payload of an IPv4 and TCP protocol data packet provided in an embodiment of the present invention; Figure 6 A schematic diagram of the structure of a load matrix provided in an embodiment of the present invention; Figure 7 A schematic diagram of the structure of an input matrix provided in an embodiment of the present invention; Figure 8 The present invention provides a schematic diagram of the structure of a generalized effective load of an IPv6 and UDP protocol data packet according to an embodiment of the present invention. DETAILED DESCRIPTION

[0018] The technical scheme in the embodiment of the present invention is further described in detail below in conjunction with the accompanying drawings. Obviously, the described embodiment is only a part of the embodiment of the present invention, rather than all the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in the field based on the present invention belong to the scope of protection of the present invention. In the absence of conflict, the embodiments in the present invention and the features in the embodiments can be combined with each other.

[0019] In addition, it should be noted that the terms used, such as "first", "second", etc., are intended to distinguish one element from another, and do not have order or importance, and "plurality" means two or more, unless otherwise clearly and specifically defined. The terms "include", "comprise", or any other variant 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. For those of ordinary skill in the art, all technical and scientific terms in this solution have the same meaning as those commonly understood by those of ordinary skill in the art to which the invention belongs.

[0020] For ease of understanding, the following explains the relevant content. Data packets are the basic unit of transmission in computer networks. They are a piece of data in network communication. During network transmission, a large amount of data is divided into smaller data packets. Each data packet carries a part of data (which can be different types of data such as text, images, audio, video, etc.) and necessary control information, and then is transmitted in the network according to certain rules. Data packets usually contain multiple layers of data, and each layer of data is composed of the data of the previous layer and the header information of this layer. Among them, the header (also called the packet header) contains control information, such as the destination address, source address, checksum, etc., which are used to indicate the sender and receiver of the data packet, the type and length of the data packet, etc. The data of each layer is called the protocol data unit of this layer. The data obtained by adding the header to the application layer data in the transport layer is called a data segment (such as a TCP segment); the data segment of the transport layer is passed to the network layer, and the data obtained by adding the header to the network layer is called a datagram (such as an IP datagram, referred to as an IP packet); the datagram of the network layer is passed to the data link layer, and the data obtained by encapsulating the header of the data link layer is called a data frame (such as an Ethernet frame); finally, the data frame is converted into bits and transmitted through the network medium.

[0021] In the TCP / IP protocol, packets that use the IP protocol to transmit data are called IP data packets, and each data packet contains the content specified by the IP protocol. These contents specified by the IP protocol are called IP datagrams or IP datagrams. IP datagrams consist of two parts: the header (also called the header) and the data. The header contains a lot of information, such as the source IP address, the destination IP address, the datagram length, the IP version number, etc. Each piece of information is called a field, namely the header field, while the data part is the main data content carried by the data packet, which is the actual transmitted data, and its corresponding content belongs to the data segment in the transport layer. In IPv4 datagrams, the first part of the header is a fixed length of 20 bytes, which is required for all IP datagrams, while the latter part of the fixed part of the header can include some optional fields (also called option fields, option parts), whose length is variable, which is used to provide additional functions, such as routing selection, recording the arrival time of data packets, special processing, etc., and the data part is its payload part. In IPv6 datagrams, the headers are all fixed length, and the structure is quite different from that of IPv4 headers. The optional fields are cancelled, and the functions of the optional fields are merged into the newly added extension headers. The extension headers and the data part together serve as the payload part. For ease of explanation, this scheme adopts the concept of "generalized payload" to distinguish it from the traditional payload part. For IPv4 datagrams, "generalized payload" includes the optional fields in its datagram header and the payload part; for IPv6 datagrams, "generalized payload" is the payload part including its extension header and the data part.

[0022] like Figure 1 As shown, an embodiment of the present invention provides a dual-engine encrypted malicious traffic detection method based on deep learning, comprising the following steps: S1: Collect encrypted traffic data; S2: grouping the data packets in the encrypted traffic data in units of sessions to obtain multiple groups of traffic data units; S3: extract the content of the basic information field corresponding to each data packet in each group of traffic data units; the basic information field includes a header field, a timestamp, a data packet transmission direction, a packet byte number, and a flag bit; the header field is an IP version, an IP datagram byte number, a service type, a survival time, and a protocol taken from an IP datagram header; Performing statistical operations on the contents of each basic information field of each data packet in each group of traffic data units to obtain a plurality of statistical features corresponding to the basic information fields, and forming a feature list of the group of traffic data units based on the statistical features; S4: numerically process the non-numerical statistical features in the feature list of the traffic data unit, and then input the feature list into a first malicious traffic detection engine based on deep learning for detection processing, to obtain labels of various traffic types and their probability values ​​as a first intermediate result; Input each data packet of the traffic data unit into the second malicious traffic detection engine based on deep learning for detection and processing, and obtain the labels of various traffic types corresponding to each data packet and their probability values; then take the maximum value of the probability values ​​corresponding to each traffic type, normalize them, and obtain the labels of various traffic types corresponding to the traffic data unit and their processed probability values, which are used as the second intermediate result; S5: Integrate the first intermediate result and the second intermediate result corresponding to each group of traffic data units to obtain a candidate result of the traffic data unit, and determine whether the traffic data unit is malicious traffic based on the candidate result.

[0023] The traffic types include normal traffic types and various malicious traffic types. The traffic type label is the name or identifier of the corresponding traffic type to indicate the detection result of the traffic. The probability value corresponding to each traffic type is used to indicate the probability of judging the corresponding traffic as a certain traffic type after detection and processing. The higher the probability value, the higher the possibility of judging the corresponding traffic as belonging to the traffic type.

[0024] The present invention collects encrypted traffic data and groups the data packets therein to obtain multiple groups of traffic data units containing data packets; then extracts the content of the basic information field of each data packet in each group of traffic data units; then performs statistical calculations on each basic information field to obtain a corresponding plurality of statistical features and form a feature list; the feature list of the traffic data unit is input into a first malicious traffic detection engine based on deep learning after preprocessing for detection processing, and obtains labels of various traffic types and probability values ​​thereof as a first intermediate result; each data packet of the traffic data unit is input into a second malicious traffic detection engine based on deep learning for detection processing, and after processing, obtains labels of various traffic types and probability values ​​thereof as a second intermediate result; finally, the two intermediate results are integrated to obtain a candidate result of the traffic data unit, and based on the candidate result, it is determined whether the traffic data unit is malicious traffic. In the above steps, the first malicious traffic detection engine and the second malicious traffic detection engine are both trained based on the deep learning model from the historical training sample set; the historical training sample set includes multiple historical feature lists or historical data packets, wherein the historical feature lists correspond to the input of the first malicious traffic detection engine, and the historical data packets correspond to the input of the second malicious traffic detection engine; the historical feature lists or historical data packets are obtained by processing multiple historical traffic data units with labeled traffic types according to steps S1 to S4, the traffic types include normal traffic types and various malicious traffic types, and the format of the traffic data units is consistent with the format of the historical traffic data units. In this embodiment, the deep learning models corresponding to the first malicious traffic detection engine and the second malicious traffic detection engine can be pre-trained in the above manner to obtain the corresponding optimal models, and the specific training process is not specifically limited here.

[0025] In this solution, both malicious traffic detection engines are based on deep learning models and have been pre-trained. The deep learning model performs a series of operations on the input data during detection to obtain the probability values ​​of each required label classification. The deep learning model refers to a machine learning model that includes a deep neural network structure, which can use a Transformer model or a BERT model, or other deep learning models, which are not specifically limited in this solution.

[0026] The method provided by the present invention utilizes the advantage of low dependence of deep learning models on artificial feature engineering methods. Two malicious traffic detection engines based on deep learning models respectively perform parallel detection and processing on the statistical features of encrypted traffic data and data packets, two different levels of features. The two intermediate results detected and output by the two malicious traffic detection engines are integrated and processed. Based on the integrated results, it is determined whether the corresponding encrypted traffic data is malicious traffic to obtain the final detection result, so that the data packets belonging to fine-grained features and the statistical features belonging to coarse-grained features can be comprehensively analyzed, so as to achieve the purpose of simultaneously utilizing statistical features and data packet encryption load features. The detection result information of these two different levels of features complement each other, reducing the detection omissions when focusing on a single feature, so that it can detect and process more complex situations such as encrypted malicious traffic with unknown and disguised features, and the detection range is more comprehensive, so as to obtain detection results with higher accuracy, improve the detection accuracy of network encrypted malicious traffic, and achieve better detection effect.

[0027] The implementation of steps S1 to S5 is described in detail below.

[0028] In step S1, encrypted traffic data is collected, specifically including: In a specified time period, a packet capture tool is used to capture all traffic of one or more ports in the network that may contain encrypted traffic data, and the collected encrypted traffic data is saved as a Pcap file, and then the process proceeds to step S2.

[0029] Among them, the main types of encrypted traffic data include malicious programs, tunnel traffic, SSL / TLS traffic, etc. Pcap (Packet Capture) files are commonly used data packet storage formats, which can be generated or opened by packet capture tools such as wireshark. The overall structure of a Pcap file is in the form of "file header-data packet header 1-data packet data 1-data packet header 2-data packet data 2...", that is, there is only one file header (Pcap header) in each Pcap file, and there can be multiple data packets, which include a data packet header (Packet Header) and data packet data (PacketData). Each data packet header corresponds to a data packet data, and the data packet data can be an Ethernet frame belonging to the data link layer.

[0030] Step S2 performs grouping processing on the encrypted traffic data in the Pcap file format obtained in step S1 to obtain multiple groups of traffic data units containing at least one data packet. As a further implementation, in step S2, the data packets in the encrypted traffic data are grouped in units of sessions, specifically: The five-tuple of the data packet is used as the session identification number for grouping, and the data packets with the same content in each part of the five-tuple are divided into the same group of traffic data units; wherein the five-tuple includes the source IP address, the destination IP address, the source port, the destination port, and the protocol number. In this way, each data packet in the encrypted traffic data can be accurately identified and confirmed, and each data packet can be effectively grouped and processed according to the session identification number, so as to facilitate the subsequent detection and processing of each group of traffic data units.

[0031] Specifically, Figure 2 As shown, this step can be performed as follows: S21: Reading a data packet using the IP protocol from the encrypted traffic data.

[0032] A session data packet dictionary is established, wherein each record in the session data packet dictionary corresponds to a set of traffic data units, and each record includes the following fields: Session identification number ID, whose format is "IP1-IP2-port1-port2-protocol number"; PacketList, which records data packets. The packet list contains one or more records, and each record corresponds to a data packet; The basic information table list PacketInfoList is used to store the basic information table obtained in step S3.

[0033] Then, read the next data packet from the Pcap file to determine whether the data packet is an IP data packet using the IP protocol. If it is not an IP data packet, reread the next data packet and repeat the identification process.

[0034] In this embodiment, each data packet corresponds to an Ethernet frame, and the network layer message encapsulated by an Ethernet frame includes types such as IP datagrams. Since the useful data of the encrypted flow data transmission are all in the IP data packet using the IP protocol, it is necessary to identify the read data packet during detection, and only select the data packet using the IP protocol to avoid other data affecting the subsequent detection and processing effect of the data packet. When identifying the data packet, two special bytes of the Ethernet frame header, i.e., the length (Length) / type (Type) field of the Ethernet frame header, can be used to identify whether it is an IP data packet. Of course, other identification methods can also be used, which will not be described in detail here. In addition, the identification content in the identification process can be adjusted according to actual needs. For example, it can also be further identified whether the protocol number in the data packet is a specific value (such as 6, corresponding to the TCP protocol, or 17, corresponding to the UDP protocol) to limit the protocol type adopted by the data packet in the transport layer.

[0035] S22: Construct a session identification number according to the quintuple of the current data packet.

[0036] Specifically, a forward ID and a reverse ID can be constructed based on the quintuple, where the quintuple includes the source IP address, the destination IP address, the source port, the destination port, and the protocol number. The format of the forward ID is "source IP address-destination IP address-source port-destination port-protocol number", and the format of the reverse ID is "destination IP address-source IP address-destination port-source port-protocol number". Each session identification number corresponds to a group of traffic data units, which can be referred to as a group of sessions.

[0037] S23: Determine the grouping of the current data packet according to the constructed session identification number. If there is a traffic data unit corresponding to the session identification number, the current data packet is grouped into the group of traffic data units; otherwise, a group of traffic data units corresponding to the session identification number is created and the current data packet is grouped into the group of traffic data units.

[0038] In this embodiment, according to the forward ID and reverse ID constructed by the current data packet, a search is performed in the ID field of the session data packet dictionary: If there is an ID field in the session data packet dictionary that is consistent with the forward ID or reverse ID, the current data packet is inserted at the end of the data packet list corresponding to the ID field; If the ID field that matches the forward ID or reverse ID cannot be found in the session data packet dictionary, a new record is added to the session data packet dictionary, with the forward ID as the value of the ID field of this record, and the current data packet is inserted as the first content in the data packet list of this record.

[0039] S24: Repeat the data packet grouping process of steps S21 to S23 above until the end of the encrypted traffic data has been reached, that is, the reading result of the Pcap file is empty, then all data packets in the encrypted traffic data have been read, and enter step S3.

[0040] By means of the above method, each data packet using the IP protocol in the encrypted traffic data is grouped, and a plurality of groups of traffic data units are obtained based on the session identification number, each group of traffic data units including at least one data packet.

[0041] In step S3, it specifically includes: extracting the content of the basic information field corresponding to each data packet in each group of traffic data units; performing statistical calculations on the content of each basic information field of each data packet in each group of traffic data units to obtain a variety of statistical features corresponding to the basic information fields, and forming a feature list of the group of traffic data units based on these statistical features.

[0042] The basic information fields include a header field, a timestamp, a data packet transmission direction, a packet byte count, and a flag bit; the header fields are the IP version (vertion), the IP datagram byte count (payload_len), the service type (tos), the survival time (ttl), and the protocol (pro) taken from the IP datagram header.

[0043] In the basic information field, the header field is a field with the same or similar meaning in the datagram header of a data packet using different IP protocols. The IP protocol includes the IPv4 protocol and the IPv6 protocol.

[0044] In a specific implementation, in a data packet using the IPv4 protocol, the contents corresponding to the fields of the header field are as follows: The IP version field corresponds to the version field and header length (IHL) field in the IPv4 datagram header. In IPv4, the value of the version field corresponds to 4. The IP datagram byte number field corresponds to the Total Len field in the IPv4 datagram header; The service type field corresponds to the service type (TOS) field in the IPv4 datagram header; The survival time field corresponds to the survival time (TTL) field in the IPv4 datagram header; The protocol field corresponds to the protocol field in the IPv4 datagram header; when its value is 6, it corresponds to TCP, and when it is 17, it corresponds to UDP.

[0045] In a specific implementation, in a data packet using the IPv6 protocol, the contents corresponding to the fields of the header field are as follows: The IP version field corresponds to the version field in the IPv6 datagram header. In IPv6, the value of the version field corresponds to 6, and its header length is a fixed value. The IP datagram byte number field corresponds to the Payload Length field in the IPv6 datagram header; The service type field corresponds to the flow label (Traffic Class) field in the IPv6 datagram header; The survival time field corresponds to the Hop Limit field in the IPv6 datagram header; The protocol field corresponds to the Next Header field in the IPv6 datagram header; when its value is 6, it corresponds to TCP, and when it is 17, it corresponds to UDP; if the current value of the "Next Header" field corresponds to one of the six extended headers defined in the IPv6 specification (i.e., hop-by-hop options, routing selection, fragmentation, authentication, encapsulating security payload, and destination options), then the "Next Header" field in the extended header is taken, and the above process is repeated until the "Next Header" field value corresponds to a field that does not belong to the above six extended headers, such as the TCP header or the UDP header, then the field value is used as the protocol field content in the above header field.

[0046] Since the length of each field in the above header field may be different in different IP protocols, in order to facilitate the use of different IP protocols in the data packets corresponding to each header field with a unified format, the length of each field in the header field can be set to a fixed length. When the content length corresponding to a header field in different IP protocol data packets does not match the required length of the header field, the corresponding content length can be matched with the required length by padding with zeros at the end or truncating the tail. In a specific embodiment, in the above header field, the field length of the number of bytes of the IP datagram is set to 2 bytes, and the field lengths of the IP version, service type, survival time, and protocol are all set to 1 byte. For the IP version field, it corresponds to the version field and the header length field of the IPv4 datagram header, which occupy a total of 1 byte, so there is no need to adjust its length additionally; in the IPv6 datagram header, since the header length is fixed, it only corresponds to the version field, and its length is less than 1 byte, so it is necessary to pad the last bit with zeros to make its length 1 byte.

[0047] The present invention utilizes the header fields with the same or similar meanings in the above-mentioned IPv4 datagram header and the IPv6 datagram header, and these header fields are input into the malicious traffic detection engine in step S4, so that the header fields of the IP datagrams corresponding to the data packets using different IP protocols can be processed as the same type of fields and detected and processed in the model, which can better eliminate the influence of the difference between the IP datagram header structures of the two protocols on the detection results, so as to process and detect the network encrypted traffic data using different IP protocols, and improve its detection accuracy and effect. The specific process is described in step S4.

[0048] In addition, the basic information fields also include but are not limited to the following fields: Timestamp time, which is taken from the Timestamp field in the packet header and is accurate to microseconds; The data packet transmission direction, whose value is 1 or 0, 1 means from source to destination, 0 means from destination to source; The number of bytes in the packet is taken from the Len field in the packet header; Flags. When the pro field is 6, the value is a string of 6, with the characters "U", "A", "P", "R", "S", and "F" representing the situation where the flags URG (urgent bit), ACK (acknowledgement bit), PSH (push bit), RST (reset bit), SYN (synchronization bit), and FIN (stop bit) in the TCP data segment header are 1. If the corresponding flag is 0, it is replaced by "-". For example, "-A--S-" means that the flags ACK and SYN in the TCP data segment header are 1, and the other four flags are 0. When the pro field is 17, the value is empty.

[0049] The contents of the above basic information fields are all taken from the data packet and are not listed here one by one.

[0050] The following is a specific process for extracting the content of the basic information field of each data packet in each group of traffic data units in the above step S3.

[0051] Using the session data packet dictionary established in step S21, each record thereof contains a basic information table list PacketInfoList field, the basic information table list includes at least one basic information table, and each basic information table corresponds to each data packet in the data packet list of the same record in sequence.

[0052] First, read the next record in the session data packet dictionary. If the end of the session data packet dictionary has not been reached, a basic information table list is established in the current record.

[0053] Then, read the next data packet in the data packet list of the current record. If the end of the data packet list has not been reached, construct a basic information table at the end of the basic information table list of the current record, extract the content of the basic information field from the read current data packet, and fill the information of each basic information field into the newly constructed basic information table as the basic information table corresponding to the current data packet. Repeat reading the next data packet and performing the above processing on it until the end of the data packet list of the current record has been reached, and the basic information table construction of all data packets in a traffic data unit is completed.

[0054] Repeatedly read the next record in the session data packet dictionary and perform the above processing on it until the end of the session data packet dictionary has been reached, and the processing of all traffic data units has been completed. In each group of traffic data units, the basic information field content in each basic information table is used to establish the feature list.

[0055] The following is a specific process for establishing a corresponding feature list for each group of traffic data units in the above step S3, performing statistical operations on each basic information field of each data packet in each group of traffic data units, obtaining multiple statistical features and storing them in the feature list.

[0056] First, a feature list is established for the current traffic data unit. Specifically, a session statistics feature dictionary can be established, where each record in the session statistics feature dictionary corresponds to a group of traffic data units, and each record includes the following fields: Session identification number ID, whose format is "IP1-IP2-port1-port2-protocol number"; The feature list Features records various statistical features.

[0057] Among them, the statistical features in the feature list include but are not limited to: source IP address, destination IP address, source port, destination port, protocol, source-to-destination TTL, destination-to-source TTL, number of SYN packets, number of ACK packets, earliest record time, latest record time, session duration, number of bytes transmitted from source to destination, number of bytes transmitted from destination to source, source-to-destination transmission bit rate, destination-to-source transmission bit rate, etc., and are all obtained by statistical calculation processing of the corresponding basic information fields, and their types can be adjusted according to actual conditions.

[0058] Then, read the next record in the session data packet dictionary. If the end of the session data packet dictionary has not been reached, insert a new record at the end of the session statistical feature dictionary. The value of the session identification number ID field of the record is equal to the value of the session identification number ID field in the current session data packet dictionary record, and construct a feature list as the value of the feature list Features field of the record.

[0059] Then, in the basic information table list currently recorded in the read session data packet dictionary, the basic information fields of all the basic information tables are subjected to corresponding statistical operation processing to obtain a variety of statistical features. The statistical operation processing includes different calculation methods such as counting, summing, taking the maximum value, taking the mean, taking the median, taking the standard deviation, taking the byte rate, etc. According to the definition of each statistical feature, a suitable method is selected to calculate and process the basic information field to obtain the corresponding value.

[0060] The statistical features obtained above are filled into the current feature list in the same order, that is, into the feature list constructed by the newly created record of the session statistical feature dictionary in the above step, so as to obtain the feature list corresponding to the current traffic data unit. The statistical features are arranged in the same order so that the subsequent malicious traffic detection engine can perform detection and processing.

[0061] Repeat reading the next record in the session data packet dictionary and performing the above processing on it until the end of the session data packet dictionary is reached, then the establishment of the feature list of all traffic data units has been completed, and the process proceeds to step S4.

[0062] In step S4, input detection processing of the feature list and input detection processing of each data packet are performed on each group of traffic data units.

[0063] Specifically, in step S4, the input detection process of the feature list specifically includes: The non-numeric statistical features in the feature list of the traffic data unit are digitized so that the data types of all statistical features in the feature list are converted to numeric types. For example, for non-numeric statistical features such as the protocol type "TCP" and "UDP" in the feature list, it can be stipulated that "TCP" is converted to 6 and "UDP" is converted to 17, etc., so that the input format meets the requirements of the malicious traffic detection engine; the specific digitization process can be carried out in the existing conventional way and will not be elaborated here.

[0064] Then, the processed feature list is input into the first malicious traffic detection engine based on deep learning for detection processing, and the labels of various traffic types and their probability values ​​are obtained as the first intermediate result, whose format is: {type 1: probability value 1, type 2: probability value 2, ..., type N: probability value N}, where N is the total number of all traffic types that can be output by the first malicious traffic detection engine, and the traffic types include normal traffic types and various malicious traffic types. The first malicious traffic detection engine based on deep learning has been pre-trained.

[0065] Specifically, in step S4, the input detection processing process of each data packet specifically includes: Each data packet of the traffic data unit is input into the second malicious traffic detection engine based on deep learning for detection and processing, and the labels of various traffic types corresponding to each data packet and their probability values ​​are obtained; then the maximum value of the probability values ​​corresponding to each traffic type is taken, and after normalization, the labels of various traffic types corresponding to the traffic data unit and their processed probability values ​​are obtained, which are used as the second intermediate result.

[0066] As a further embodiment, Figure 3 As shown, in step S4, before each data packet of the traffic data unit is input into the second malicious traffic detection engine based on deep learning for detection processing, each data packet is processed as follows: The generalized payload in the data packet is adjusted in bytes by padding the end with zeros or truncating the end, and then the byte contents are arranged from beginning to end in a matrix with the same number of rows and columns to form a payload matrix; wherein the generalized payload includes the payload part of the IP datagram; Arrange each field in the header field corresponding to the data packet in the same order, and then fill the content of the arranged header field into the head of each row of the payload matrix according to its byte number to form an input matrix corresponding to the data packet.

[0067] In another embodiment, the above steps are changed to process each data packet as follows: The generalized payload in the data packet is adjusted in bytes by padding the end with zeros or truncating the end, and then the byte contents are arranged from beginning to end in a matrix with the same number of rows and columns to form a payload matrix; wherein the generalized payload includes the payload part of the IP datagram; Arrange each field in the header field corresponding to the data packet in the same order, and then fill the content of the arranged header field at the end of each row of the payload matrix according to its byte number to form an input matrix corresponding to the data packet.

[0068] Furthermore, in a data packet using the IPv4 protocol, the generalized payload also includes an optional field in its IP datagram header.

[0069] By performing the above arrangement processing on the data packet, the data packet format input to the malicious traffic detection engine is converted into an input matrix formed by splicing the content of each header field and the payload matrix. Each header field is extracted from the header field information of the IP datagram of the data packet, and the corresponding content of the payload matrix is ​​a generalized payload including the payload part of the IP datagram of the data packet. The above arrangement method divides the header field and the payload of the IP datagram of the data packet in the input matrix, so that the content input to the detection engine has a certain degree of distinction. The neurons in the corresponding model of the malicious detection engine can form a clear correspondence with the received data content during the detection process, that is, each neuron can maintain the header field information or payload data of the corresponding IP datagram after receiving the data, so that the neuron detection processing process in the model maintains a unified rule, and improves the stability of the model during detection processing. When detecting network encrypted traffic data, the model can make full use of the information difference between the header and the payload in the IP datagram, so that its detection accuracy is better, thereby improving the model training and use effect, so that it can handle more complex situations and achieve better detection effect on encrypted malicious traffic.

[0070] In addition, the present invention extracts fields with the same or similar meanings from the IPv4 datagram header and the IPv6 datagram header, arranges these header fields in the same order, and fills them in the same preset position of each row of the input matrix (i.e., the head of each row or the tail of each row) and then inputs them into the malicious traffic detection engine, so that the header fields of the datagrams corresponding to the data packets using different IP protocols can be processed into the same structure and detected and processed in the model, which can better eliminate the influence of the difference between the header structures of the IP datagrams of the two protocols on the detection results, so that it can process and detect network encrypted traffic data using different IP protocols, improve its detection capability, and further improve its detection accuracy.

[0071] The following is a specific process for obtaining the input matrix according to the above steps.

[0072] First, a data packet is read from the data packet list of the current record of the session data packet dictionary, and the IP datagram part of the data packet at the network layer is obtained by removing the data packet header, Ethernet frame header and other parts of the data packet, and then the generalized payload in the IP datagram is extracted and recorded as data. Among them, the generalized payload includes the payload part of the IP datagram; in the data packet using the IPv4 protocol, the generalized payload also includes the optional field in its IP datagram header. In the IPv4 datagram, the payload part usually only includes its data part, and its optional field belongs to the header part of the datagram. The optional field is used to provide additional functions, such as routing selection, recording the arrival time of the data packet, special processing, etc.; in the IPv6 datagram, the optional field is cancelled and the extended header is used to implement the function of the optional field, and its payload part includes the extended header and the data part. In order to utilize the content of the optional fields of the IPv4 datagram in the malicious traffic detection process to improve the detection accuracy and achieve better detection results, in the above-mentioned IP datagram extraction process, if the IPv4 datagram header contains the optional fields, the optional fields can be extracted as part of the generalized payload, that is, data includes the data part of the IP datagram as the payload part and the optional fields in the IP datagram header, refer to Figure 5 In an IPv6 datagram, since the extension header is part of its payload, in the above extracted IP datagram, the generalized payload includes the payload part of the IP datagram, see Figure 8 As shown, the content of the extension header of the IPv6 datagram can be used.

[0073] Then, the data is truncated at the end or filled with zeros to make its length equal to N bytes; then the byte contents of the data are filled into a matrix with x bytes in columns and y bytes in rows in order from the beginning to the end, so as to form a load matrix; wherein, x*y=N; usually, the values ​​of x and y are both greater than 1, and the specific values ​​of N, x, and y can be pre-set according to actual conditions, and correspond to the deep learning model used by the malicious traffic detection engine, and remain unchanged after setting, so that each load matrix has the same number of rows and columns; in a specific embodiment, N is 1500, x is 50, and y is 30, which can be referred to Figure 6 shown.

[0074] Extract all header fields from the basic information table corresponding to the current data packet; arrange each field in the header field in the same order to form a row vector with a total length of m bytes; fill the row vector at the head of each row of the payload matrix according to its byte number, forming an input matrix with (x+m) bytes in columns and y bytes in rows corresponding to the data packet.

[0075] Specifically, each field of the header field includes IP version, number of IP datagram bytes, service type, survival time, and protocol, and the length of each of the above header fields when extracted in step S3 has been set to a fixed value, that is, the field length of the number of IP datagram bytes is 2 bytes, and the field lengths of the IP version, service type, survival time, and protocol are all 1 byte. Taking the above header field as an example, the order of arrangement of each field in the header field can be adjusted according to actual conditions to facilitate one-to-one detection processing in the subsequent detection engine. For example, they can be arranged in the order of IP version, service type, number of IP datagram bytes, survival time, and protocol to form a row vector with a total length of 6 bytes, that is, m corresponds to 6 at this time. The above row vector is filled in the head of each row of the payload matrix to form an input matrix. In a specific embodiment, the number of columns of the input matrix is ​​56 bytes and the number of rows is 30 bytes. Its structure can refer to Figure 7 shown.

[0076] Of course, in the above steps, the row vector can also be filled at the end of each row of the payload matrix according to its byte number. It can be pre-set to select the filling position at the head or tail, and ensure that the row vector is filled according to one of the aforementioned selected positions throughout the entire processing process of the malicious traffic detection engine to ensure that the input matrix format is fixed.

[0077] The sequence of the steps for obtaining the input matrix is ​​not limited to the sequence given in the embodiment, as long as it is ensured that there is no conflict between the steps, which will not be elaborated here.

[0078] Through the above embodiment, the data packet is converted into a corresponding input matrix, and then the obtained input matrix is ​​input into the second malicious traffic detection engine based on deep learning for detection processing, and the labels of various traffic types corresponding to each data packet and their probability values ​​are output, and the format is: {Type 1: probability value 1, Type 2: probability value 2, ..., Type N: probability value N}, where N is the total number of all traffic types that can be output by the second malicious traffic detection engine, and the traffic types include normal traffic types and various malicious traffic types. The second malicious traffic detection engine based on deep learning has been pre-trained. In addition, the total number and order of traffic types of the second malicious traffic detection engine are consistent with the traffic types that can be output by the first malicious traffic detection engine, so that its output result is consistent with the total number and order of traffic types in the format of the first intermediate result, so as to facilitate subsequent processing.

[0079] In order to facilitate storage of the output results of the second malicious traffic detection engine, a data packet detection result list may be established, wherein the format of each record in the data packet detection result list is consistent with the format of the output results of the second malicious traffic detection engine, namely: {Type 1: probability value 1, Type 2: probability value 2, ..., Type N: probability value N}. When the second malicious traffic detection engine outputs a result, it is added as a new record to the data packet detection result list.

[0080] Repeat the above steps. When all the data packets in the current record data packet list of the session data packet dictionary have been processed according to the above steps, take the maximum value of the probability value corresponding to each traffic type in all the records in the data packet detection result list, and calculate the result set S according to the following formula: S={Type 1: Probability value 1 MAX , Type 2: Probability value 2 MAX , ..., type N: probability value N MAX}; Among them, the probability value i MAX =MAX{Probability value i j |j=1, 2, ..., M}, (i=1, 2, ..., N), MAX{} is the maximum value operation, M is the total number of list records in the current data packet detection result list, N is the total number of all traffic types that can be output by the second malicious traffic detection engine, and the probability value i j It refers to the probability value i in the jth record in the current packet detection result list.

[0081] Then, each maximum value is normalized to make each type of probability value have better distinction.

[0082] Specifically, the normalization process used above is as follows: the squared value of the probability value of each traffic type is divided by the square sum of the probability values ​​of all traffic types, and the result is used as the normalized probability value of each traffic type. The second intermediate result can be calculated according to the following formula: The second intermediate result = {type 1: probability value 1, type 2: probability value 2, ..., type N: probability value N}, in, Probability value i = probability value i MAX 2 / Σ i (Probability value i MAX 2 ), (i=1, 2, …, N), The second intermediate result obtained includes probability values ​​corresponding to normal traffic and various malicious traffic types, and is consistent with the format of the first intermediate result, which are: {Type 1: probability value 1, Type 2: probability value 2, ..., Type N: probability value N}, and the total number and order of their traffic types are consistent. Through the above method, on the one hand, the normalization of the probability values ​​of each type is achieved, so that the sum of the probability values ​​corresponding to all traffic types in the second intermediate result is 1, and at the same time, the distinction of the probability values ​​of each type can be increased. Of course, the specific calculation formula of the normalization processing can also select other formulas according to actual needs, which will not be described in detail here.

[0083] In the above step S4, the detection processing corresponding to the two malicious traffic detection engines is parallel processing, that is, when each group of traffic data units is pre-processed to obtain the corresponding feature list and multiple input matrices corresponding to the data packets, the feature list is input to the first malicious traffic detection engine based on deep learning for processing, and the input matrix is ​​input to the second malicious traffic detection engine based on deep learning for processing, and the input of the first malicious traffic detection engine does not depend on the result of the second malicious traffic detection engine, and vice versa, so as to simultaneously use statistical features and data packet features to obtain corresponding detection results. In S4, after waiting for each group of traffic data units to obtain the corresponding first intermediate result and second intermediate result, that is, the two malicious traffic detection engines have output results, the detection processing of the next group of traffic data units can be carried out, and the order of the output results of the two detection engines is not limited here.

[0084] In steps S3 and S4, the order of the steps in the input detection processing of the feature list and the input detection processing of each data packet may not be limited to the operating order given in the embodiment, as long as there is no conflict between the steps. For example, the process of obtaining the feature list corresponding to each group of traffic data units can be combined with the process of obtaining the basic information fields corresponding to the data packet, that is, after obtaining all the basic information fields of a group of traffic data units, the subsequent steps are connected to obtain the feature list corresponding to the group of traffic data units.

[0085] For storage purposes, an intermediate result list can be created. Each record in the intermediate result list contains the following fields: Session identification number ID, whose format is "IP1-IP2-port1-port2-protocol number"; The first intermediate result Result1; The second intermediate result Result2.

[0086] According to the traffic data unit currently being processed, that is, from the current record of the session data packet dictionary, read the ID field value, then create a new record in the intermediate result list, use the ID field value as the ID field value of the newly created record, and fill the obtained first intermediate result and second intermediate result into the corresponding fields.

[0087] As a further implementation, in step S5, the first intermediate result and the second intermediate result corresponding to each group of traffic data units are integrated to obtain a candidate result of the traffic data unit, and whether the traffic data unit is malicious traffic is determined based on the candidate result, specifically: The probability values ​​of the same traffic type in the first intermediate result and the second intermediate result are weighted averaged, and then the probability values ​​of each traffic type are normalized to obtain the labels of various traffic types and their processed probability values ​​as candidate results. Through the above method, the processing process is convenient, and the two intermediate results obtained by detecting and processing the corresponding two different level features can be effectively complemented and integrated into one candidate result, so as to achieve better results in the subsequent judgment process.

[0088] Specifically, this step can be performed in the following manner: S51: Extract the first intermediate result and the second intermediate result in the current traffic data unit.

[0089] S52: Perform a weighted average on the probability values ​​of the same traffic type in the first intermediate result and the second intermediate result to obtain labels of various traffic types and their weighted averaged probability values ​​as temporary results.

[0090] S53: normalizing the probability values ​​of each traffic type in the temporary result to obtain labels of various traffic types and their normalized probability values ​​as candidate results.

[0091] The specific process of the above steps can be referred to Figure 4 As shown, the next record can be read from the intermediate result list established in step S4; if the read result is empty, the whole process ends; if the read result is not empty, the first intermediate result field and the second intermediate result field in the current record are extracted, which are: First intermediate result = {Type 1: Probability value 1 1 , Type 2: Probability value 2 1 , ..., type N: probability value N 1}, Second intermediate result = {Type 1: Probability value 1 2 , Type 2: Probability value 2 2 , ..., type N: probability value N 2}, Among them, N is the total number of all traffic types that can be output by the two detection engines, and the total number N is the same. The two intermediate results include probability values ​​corresponding to normal traffic types and various malicious traffic types, and the order of each type corresponds one to one, that is, type i in the first intermediate result is the same as type i in the second intermediate result, i=1, 2, ..., N. For the convenience of explanation, it is agreed here that the label corresponding to the traffic type of type 1 is "normal", and the other types correspond to the labels of specific types of various malicious traffic.

[0092] The probability values ​​of the corresponding types in the two are weighted averaged and the temporary result is calculated using the following formula: Probability value i T = probability value i 1 ×W i +Probability value i 2 ×(1-W i ), (i=1, 2,…,N and W i ∈[0,1]), where W i is for probability value i 1 The specific setting method of the pre-set weight value can be adjusted according to actual needs and is not specifically limited here; Get temporary result = {Type 1: Probability value 1 T , Type 2: Probability value 2 T , ..., type N: probability value N T}.

[0093] Then, the probability values ​​of each type in the temporary results are normalized to make the probability values ​​of each type more distinguishable.

[0094] Specifically, the normalization process used in the above steps is: divide the probability value of each traffic type by the sum of the probability values ​​of all traffic types, and the result is used as the normalized probability value of each traffic type. The following formula can be used to calculate the candidate result based on the temporary result: Probability value i C = probability value i C / Σ i Probability value i C , (i=1, 2, …, N); Get candidate result = {Type 1: Probability value 1 C , Type 2: Probability value 2 C , ..., type N: probability value N C}.

[0095] By the above method, the normalization of the probability values ​​of each type can be achieved, so that the sum of the probability values ​​corresponding to all traffic types in the second intermediate result is 1, and the distinction of the probability values ​​of each type can be increased. Of course, the specific calculation formula of the normalization processing can also select other formulas according to actual needs, which will not be described in detail here.

[0096] S54: Based on the candidate results, the current flow data unit is judged according to the following process, and a final detection result is output: If the candidate result is in the range, the probability value is 1 C ≥T Normal , that is, the probability value corresponding to the normal traffic type is not less than the normal threshold T Normal , then the current traffic data unit is marked as a normal traffic type, and the final detection result outputs "normal" and the probability value corresponding to the normal traffic type; If the probability value corresponding to the normal traffic type in the candidate results is less than the normal threshold, and there is at least one malicious traffic type whose probability value is not less than the malicious threshold, that is, at least one probability value i C ≥ Malicious threshold T Malicious In the case of (i=2, ..., N), the current traffic data unit is marked as the above malicious traffic type and arranged from high to low according to the corresponding probability value. The final detection result is output as all malicious traffic types that meet the above conditions and the probability values ​​corresponding to these malicious traffic types in turn, and the corresponding probability value i is used to identify the malicious traffic types. C Arrange from high to low; If, in the candidate results, the probability value corresponding to the normal traffic type is less than the normal threshold, and the probability values ​​corresponding to the malicious traffic type are all less than the malicious threshold, the current traffic data unit is marked as other malicious traffic types, and the final detection result is output as "other malicious traffic" and the candidate result; Among them, the normal threshold T Normal and malicious threshold T Malicious are preset fixed thresholds, with a value range of (0, 1). In one embodiment, T Normal The value of T is not less than 0.8. Malicious The value of is not less than 0.5.

[0097] The steps for obtaining the final detection result are explained in detail: if it can be clearly identified as a certain type of traffic including normal traffic, the corresponding type name will be marked in the final detection result, and the probability value of being judged as this type will be given; if it is determined that there are multiple types of malicious traffic behavior in the traffic at the same time, that is, the probability values ​​of these types all exceed the malicious threshold, then these types will be marked in the final detection result, arranged from high to low according to the corresponding probability values, and the corresponding probability values ​​will be given; if the traffic is judged to have malicious behavior, but the probability values ​​of each type do not reach the preset malicious threshold, then the final detection result will be marked as "other malicious traffic", and the content of the entire candidate result will be output as a reference.

[0098] The final detection result may be configured to include the following fields: Session identification number ID, which is the ID field value of the current read record, that is, corresponding to the current traffic data unit; Detection classification result Result, which can be "normal", "other malicious traffic", or one or more malicious traffic types; Result description Detail, corresponding to the probability value of the detection and classification result, or the entire candidate result.

[0099] In summary, the present invention can overcome some problems existing in the prior art in the detection of encrypted malicious traffic through the above-mentioned method. It adopts two malicious traffic detection engines based on deep learning. By performing statistical feature detection processing and data packet detection processing on each group of traffic data units, it can simultaneously use statistical features and data packet features at two different levels to detect encrypted malicious traffic, reduce detection omissions when focusing on a single feature, and improve detection accuracy, so that its detection effect on network encrypted malicious traffic can meet existing needs; in the detection processing of each data packet, the content of each data packet input to the malicious traffic detection engine can be transformed into an input matrix composed of a header field and a payload matrix through arrangement processing, which is different from the direct input data packet. Compared with the method of content, it can distinguish the header field information of the IP datagram and the generalized payload including the payload part, so that the content of the data packet input detection engine has a certain degree of distinction, which is conducive to model training and use, and further improves its detection ability; and, by extracting the header field from the header field of the IP datagram, since it is the field information with the same or similar meaning in the IP datagram header using different IP protocols, these field information are filled in the input matrix in the same order as the IP datagram header information, which can eliminate the difference between the utilization effects of the datagram header field information using different IP protocols, so that the model can process and detect data packets using different IP protocols, and further improve its detection ability. Through the above-mentioned method, the present invention can detect and process more complex situations such as encrypted malicious traffic using unknown and disguised features when detecting encrypted malicious traffic, thereby obtaining a detection result with higher accuracy, improving the detection accuracy of network encrypted malicious traffic, and achieving better detection effect.

[0100] An embodiment in a specific scenario is given below: First, by collecting encrypted traffic, a Pcap file named pcap.pcap is obtained, which contains traffic data of 50 data packets.

[0101] According to step S2, by reading the pcap.pcap file, a session data packet dictionary including two groups of traffic data units as shown in Table 1 is extracted.

[0102] Table 1:

[0103] Each record of the session data packet dictionary corresponds to a group of traffic data units, and each group of traffic data units can be referred to as a group of sessions. The session identification numbers of the two groups of traffic data units constructed according to the five-tuple are 10.1.0.1-10.1.0.2-5799-443-6 and 10.1.0.3-10.1.0.4-10001-53-17, respectively. The first group of traffic data units includes 20 data packets, and the second group of traffic data units includes 30 data packets, each of which includes a data packet header and data packet data.

[0104] According to step S3, the corresponding basic information tables, namely PacketInfo in Table 1, are processed in sequence according to the data packets in the PacketList field. Each basic information table contains basic information fields extracted from the corresponding data packets. Then, corresponding statistical operations are performed on each basic information field of all basic information tables in the current session data packet dictionary to obtain a variety of statistical features. Each statistical feature forms a feature list corresponding to the record of the current session data packet dictionary (i.e., a group of flow data units), i.e., a feature list corresponding to the two groups of flow data units. Each feature list includes 40 statistical features (only a part of which is shown in Table 2), which are stored in the session statistical feature dictionary shown in Table 2.

[0105] Table 2:

[0106] In step S4, the two groups of flow data units are detected and processed in sequence.

[0107] First, process the first group of traffic data units, extract the session identification number of the first group of traffic data units and the corresponding data packet list and feature list, that is, the PacketList field value and Features field value corresponding to the ID value 10.1.0.1-10.1.0.2-5799-443-6. Input the Features field value into the first malicious traffic detection engine, and input the PacketList field value into the second malicious traffic detection engine.

[0108] Among them, before the Features field value is input into the first malicious traffic detection engine, the non-numeric statistical features such as "TCP" and "UDP" must be digitized and converted according to the preset conversion rules. For example, it is stipulated that "TCP" is converted to 6 and "UDP" is converted to 17, so that the data types of all statistical features in the Features field value are converted to numerical values.

[0109] Then, the Features field value after the above processing is input into the first malicious traffic detection engine based on Transformer deep learning model 1. Specifically, the input of deep learning model 1 is 1 token, corresponding to the Features field value of the group of traffic data units, the embedding dimension is 40, corresponding to 40 statistical features; the output layer has 4 neurons, corresponding to the labels of 4 traffic types, namely "normal", "malicious 1", "malicious 2", and "malicious 3". Deep learning model 1 outputs the first intermediate result Result1, as shown below: Result1={Normal: 0.9, Malicious 1: 0.08, Malicious 2: 0.02, Malicious 3: 0}.

[0110] The second malicious traffic detection engine processes the 20 data packets in the first group of traffic data units in turn. For each data packet before entering the engine, first read the data packet content (corresponding to an Ethernet frame), then remove the Ethernet frame header and other components of the data packet, retain the generalized payload of its IP datagram, and make the data length of the current generalized payload equal to 1500 bytes by padding the end with zeros or truncating the tail. Because the first group of traffic data units uses IPv4 and TCP protocols, the generalized payload includes the optional fields in the IP datagram header (if any) and the data part as the payload part. The content of the data part is the TCP data segment, and its structure is as follows: Figure 5 shown.

[0111] The byte contents of the generalized payload of the above data packet (i.e., byte 0 to byte 1499) are converted from the beginning to the end in order into the following Figure 6 The 30×50 byte payload matrix is ​​shown.

[0112] Then, all the header fields are extracted from the basic information table corresponding to the current data packet. In this embodiment, the header fields include IP version vertion, IP datagram byte number payload_len, service type tos, survival time ttl, and protocol pro. Among them, the field length of IP datagram byte number payload_len is 2 bytes, and the field lengths of IP version vertion, service type tos, survival time ttl, and protocol pro are all 1 byte. IP version vertion is recorded as byte A; service type tos is recorded as byte B; IP datagram byte number payload_len is recorded as byte C and byte D; survival time ttl is recorded as byte E; protocol pro is recorded as byte F. Through the above processing, the field information with the same or similar meaning in the header of the IPv4 datagram and the header of the IPv6 datagram is effectively utilized, and the difference between the utilization effects of the datagram header field information using these two different IP protocols can be eliminated to achieve better detection effects.

[0113] Each field in the above header field is arranged in the same preset order. For example, the contents of each byte AF are arranged in the order of A, B, C, D, E, and F. Then, the contents of the arranged header field are filled in the head of each row of the payload matrix according to the number of bytes, forming the following: Figure 7 The 30×56 byte input matrix is ​​shown: At this time, the data packet content is processed as described above and converted into an input matrix composed of the header field content and the payload matrix. Compared with the existing technology, this method can distinguish the header field information of the IP datagram and the content of the payload part, so that the content input into the detection engine has a certain degree of distinction, which is conducive to model training and use, further improving the accuracy of detection and achieving better detection results.

[0114] The above input matrix is ​​input into the second malicious traffic detection engine based on Transformer deep learning model 2. Specifically, the input of deep learning model 2 includes 30 tokens, corresponding to 30 rows of data in the input matrix, and the embedding dimension is 56, corresponding to 56 bytes of data in each row of the input matrix; the output layer has 4 neurons, corresponding to 4 traffic types, namely "normal", "malicious 1", "malicious 2" and "malicious 3", which correspond one-to-one to the traffic types in deep learning model 1.

[0115] Through the above method, a data packet detection result list including labels of various traffic types corresponding to each data packet and their probability values ​​can be obtained. After being processed by the second deep learning model, the output is a data packet detection result list containing 20 records (only a part is shown in Table 3) as shown in the following Table 3: Table 3:

[0116] For the above data packet detection result list, by taking the maximum value of the probability value corresponding to each traffic type, the result set S={normal: 0.9, malicious 1: 0.18, malicious 2: 0.03, malicious 3: 0.1} is calculated; Normalization processing is performed according to the result set S. Specifically, the squared value of the probability value of each traffic type may be divided by the sum of the squares of the probability values ​​of all traffic types to calculate the second intermediate result Result2, as shown below: Result2={Normal: 0.949, Malicious 1: 0.038, Malicious 2: 0.001, Malicious 3: 0.012}.

[0117] In step S5, based on the above intermediate results Result1 and Result2, a weighted average is calculated in the following manner to obtain a temporary result: Temporary result = {Normal: 0.9×0.6+0.949×(1-0.6), Malicious 1: 0.08×0.4+0.038×(1-0.4), Malice 2: 0.02×0.4+0.001×(1-0.4), Malice 3: 0×0.4+0.012×(1-0.4)} ={Normal: 0.9196, Malicious 1: 0.0548, Malicious 2: 0.0086, Malicious 3: 0.0072}; In the above calculation formula, the weight value for normal traffic types is set to 0.6, and the weight value for other malicious traffic types is set to 0.4.

[0118] Normalization is performed based on the above temporary results. Specifically, the probability value of each traffic type can be divided by the sum of the probability values ​​of all traffic types, and the candidate result is calculated as follows: {Normal: 0.9287, Malicious 1: 0.0553, Malicious 2: 0.0087, Malicious 3: 0.0073}.

[0119] Set the normal threshold T Normal =0.8, malicious threshold T Malicious =0.3, according to Figure 4 The process is used for judgment. Since the probability value corresponding to the normal type in the candidate results is 0.9287>0.8, the final detection result of this group of traffic data units is output as follows: ID: 10.1.0.1-10.1.0.2-5799-443-6; Result: OK; Detail:0.9287。

[0120] Then, detection and processing are performed on the second group of traffic data units. The process is basically the same as that of the first group of traffic data units mentioned above. Only the main differences are described below.

[0121] In step S4, since the second group of traffic data units adopts IPv6 and UDP protocols, the 1500-byte generalized payload obtained by the second malicious traffic detection engine is the payload part, which includes an extension header and a data part. The content corresponding to the data part is a UDP data segment, and its data structure is as follows: Figure 8 shown.

[0122] In step S5, the candidate results calculated by the second group of traffic data units are: {Normal: 0.3281, Malicious 1: 0.3123, Malicious 2: 0.3214, Malicious 3: 0.0382}.

[0123] Set the normal threshold T Normal =0.8, malicious threshold T Malicious =0.3, according to Figure 4 process for judging.

[0124] Since the probability value corresponding to the normal type in the candidate results is 0.3281<0.8, it is determined that the group of traffic data units contains malicious traffic, and the next step of judgment is carried out; Since the probability value corresponding to malicious type 1 is 0.3123>0.3, the probability value corresponding to malicious type 2 is 0.3214>0.3, and the probability value corresponding to malicious type 3 is 0.0382<0.3, that is, there are two malicious types that exceed the malicious threshold T at the same time. Malicious Therefore, the malicious types are output from high to low according to the corresponding probability values. The final detection results of this group of traffic data units are as follows: ID: 10.1.0.3-10.1.0.4-8801-53-17; Result: Malice 2, Malice 1; Detail:0.3214,0.3123。

[0125] At this point, the detection process of the above two groups of flow data units is completed.

[0126] The above embodiment is only one specific implementation method. Since it is basically similar to the embodiment described in the method of the present invention, the description is relatively simple. For relevant specific instructions, please refer to the method description part.

[0127] The above are only some of the embodiments created by the present invention, and the protection scope of the present invention is not limited thereto. Although the present invention has been described in detail with reference to the aforementioned embodiments, a person of ordinary skill in the art should understand that the description of the above embodiments is only used to help understand the method and core idea of ​​the present invention, and the technical solutions recorded in the aforementioned embodiments can still be modified, or some or all of the technical features therein can be replaced by equivalents; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present invention, and they should all be included in the scope of the claims and description of the present invention. Therefore, those skilled in the art make non-substantial changes or replacements based on the present invention, which still fall within the protection scope of the present invention.

Claims

1. A dual-engine encrypted malicious traffic detection method based on deep learning, characterized in that: The following steps are involved: S1: Collect encrypted traffic data; S2: grouping the data packets in the encrypted traffic data in units of sessions to obtain multiple groups of traffic data units; S3: extract the content of the basic information field corresponding to each data packet in each group of traffic data units; the basic information field includes a header field, a timestamp, a data packet transmission direction, a packet byte number, and a flag bit; the header field is an IP version, an IP datagram byte number, a service type, a survival time, and a protocol taken from an IP datagram header; Performing statistical operations on the contents of each basic information field of each data packet in each group of traffic data units to obtain a plurality of statistical features corresponding to the basic information fields, and forming a feature list of the group of traffic data units based on the statistical features; S4: numerically process the non-numerical statistical features in the feature list of the traffic data unit, and then input the feature list into a first malicious traffic detection engine based on deep learning for detection processing, to obtain labels of various traffic types and their probability values ​​as a first intermediate result; Input each data packet of the traffic data unit into the second malicious traffic detection engine based on deep learning for detection and processing, and obtain the labels of various traffic types corresponding to each data packet and their probability values; then take the maximum value of the probability values ​​corresponding to each traffic type, normalize them, and obtain the labels of various traffic types corresponding to the traffic data unit and their processed probability values, which are used as the second intermediate result; S5: Integrate the first intermediate result and the second intermediate result corresponding to each group of traffic data units to obtain a candidate result of the traffic data unit, and determine whether the traffic data unit is malicious traffic based on the candidate result.

2. According to the deep learning-based dual-engine encrypted malicious traffic detection method of claim 1, it is characterized in that: In step S4, before each data packet of the traffic data unit is input into the second malicious traffic detection engine based on deep learning for detection processing, each data packet is processed as follows: The generalized payload in the data packet is adjusted in bytes by padding the end with zeros or truncating the end, and then the byte contents are arranged from beginning to end in a matrix with the same number of rows and columns to form a payload matrix; wherein the generalized payload includes the payload part of the IP datagram; Arrange each field in the header field corresponding to the data packet in the same order, and then fill the content of the arranged header field into the head of each row of the payload matrix according to its byte number to form an input matrix corresponding to the data packet.

3. According to the deep learning-based dual-engine encrypted malicious traffic detection method of claim 1, it is characterized in that: In step S4, before each data packet of the traffic data unit is input into the second malicious traffic detection engine based on deep learning for detection processing, each data packet is processed as follows: The generalized payload in the data packet is adjusted in bytes by padding the end with zeros or truncating the end, and then the byte contents are arranged from beginning to end in a matrix with the same number of rows and columns to form a payload matrix; wherein the generalized payload includes the payload part of the IP datagram; Arrange each field in the header field corresponding to the data packet in the same order, and then fill the content of the arranged header field at the end of each row of the payload matrix according to its byte number to form an input matrix corresponding to the data packet.

4. A dual-engine encrypted malicious traffic detection method based on deep learning according to claim 2 or 3, characterized in that: In a data packet using the IPv4 protocol, the generalized payload also includes optional fields in its IP datagram header.

5. A dual-engine encrypted malicious traffic detection method based on deep learning according to any one of claims 1 to 3, characterized in that: In a data packet using the IPv4 protocol, the contents corresponding to the fields in the header field are as follows: The IP version field corresponds to the version field and header length field in the IPv4 datagram header; The IP datagram byte number field corresponds to the total length field in the IPv4 datagram header; The service type field corresponds to the service type field in the IPv4 datagram header; The survival time field corresponds to the lifetime field in the IPv4 datagram header; The protocol field corresponds to the protocol field in the IPv4 datagram header.

6. A dual-engine encrypted malicious traffic detection method based on deep learning according to any one of claims 1 to 3, characterized in that: In a data packet using the IPv6 protocol, the contents corresponding to the fields in the header field are as follows: The IP version field corresponds to the version field in the IPv6 datagram header; The IP datagram byte number field corresponds to the payload length field in the IPv6 datagram header; The service type field corresponds to the flow label field in the IPv6 datagram header; The survival time field corresponds to the hop limit field in the IPv6 datagram header; The protocol field corresponds to the next header field in the IPv6 datagram header.

7. A dual-engine encrypted malicious traffic detection method based on deep learning according to any one of claims 1 to 3, characterized in that: In step S2, the data packets in the encrypted traffic data are grouped in units of sessions, specifically: The five-tuple of the data packet is used as the session identification number for grouping, and the data packets with the same content in each part of the five-tuple are divided into the same group of traffic data units; wherein the five-tuple includes the source IP address, the destination IP address, the source port, the destination port, and the protocol number.

8. A dual-engine encrypted malicious traffic detection method based on deep learning according to any one of claims 1 to 3, characterized in that: The normalization process used in step S4 is specifically: The square of the probability value of each traffic type is divided by the sum of the squares of the probability values ​​of all traffic types, and the result obtained is used as the normalized probability value of each traffic type.

9. A dual-engine encrypted malicious traffic detection method based on deep learning according to any one of claims 1 to 3, characterized in that: In step S5, the first intermediate result and the second intermediate result corresponding to each group of traffic data units are integrated to obtain the candidate result of the traffic data unit, specifically: The probability values ​​of the same traffic type in the first intermediate result and the second intermediate result are weighted averaged, and then the probability values ​​of each traffic type are normalized to obtain labels of various traffic types and their processed probability values ​​as candidate results.

10. A dual-engine encrypted malicious traffic detection method based on deep learning according to claim 9, characterized in that: In the step of normalizing the probability values ​​of each traffic type to obtain the labels of various traffic types and their processed probability values ​​as candidate results, the normalization process used is specifically: The probability value of each traffic type is divided by the sum of the probability values ​​of all traffic types, and the result obtained is used as the normalized probability value of each traffic type.