A hidden malicious behavior detection method based on multi-model fusion

Through multi-model fusion technology, combined with LSTM, 1D-CNN and MLP models, a weighted fusion detection model is generated, which solves the problem of low accuracy and efficiency of DNS hidden tunnel detection in the existing technology, and achieves automation and high accuracy. detection.

CN114629718BActive Publication Date: 2024-10-22ZHEJIANG UNIV OF TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210364305.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-07
Publication Date
2024-10-22
Estimated Expiration
2042-04-07

AI Technical Summary

Technical Problem

Existing technologies are difficult to effectively detect and identify DNS hidden tunnels, resulting in frequent successful malicious attacks. Rule-based detection is easily bypassed. Machine learning-based detection requires a large amount of manual processing and training data, which is inefficient and cannot automatically learn abstract features.

Method used

Using a hidden malicious behavior detection method based on multi-model fusion, by obtaining black sample, white sample and CDN sample data sets of DNS messages, feature extraction and multi-model training are performed, and the LSTM model, 1D-CNN model and MLP model are combined to calculate The weights of each model are fused to generate a covert malicious behavior detection model, which is used to detect DNS covert tunnels in real time.

Benefits of technology

It greatly reduces labor costs, improves the accuracy of DNS hidden tunnel detection, uses deep learning to automatically extract potential features, and achieves stable detection of DNS hidden tunnels.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114629718B_ABST
    Figure CN114629718B_ABST
Patent Text Reader

Abstract

The present invention discloses a hidden malicious behavior detection method based on multi-model fusion, including obtaining black sample, white sample and CDN sample data set of DNS message; extracting features from the black sample, white sample and CDN sample data set; training multiple models based on the extracted features, weight fusion of the trained multiple models to obtain a hidden malicious behavior detection model; and using the hidden malicious behavior detection model to detect and capture DNS hidden tunnels in real time. The present invention can greatly reduce labor costs and improve the accuracy of DNS hidden tunnel detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of network security, and in particular relates to a hidden malicious behavior detection method based on multi-model fusion. Background Art

[0002] In the face of increasingly intelligent network security defenses, a key reason why malicious attacks can still succeed frequently is their hidden nature. The most common means, such as hidden tunneling, can easily bypass current mainstream detection methods such as feature matching or machine learning.

[0003] DNS hidden tunnel is one of the hidden means. Since most firewalls, intrusion detection systems, and intrusion prevention systems rarely detect DNS traffic, this provides conditions for DNS to be used as a hidden tunnel. DNS (Domain Name System) is an Internet service that maps domain names and IP addresses to each other, making it easier for people to access the Internet. Usually, DNS uses port 53, and the length of each domain name is limited to 63 characters, and the total length of the domain name cannot exceed 253 characters.

[0004] DNS tunneling is a technology that encapsulates the content of other protocols in the DNS protocol and then completes data transmission with DNS request and response packets. For functional and friendly considerations, it is impossible for firewalls to completely filter out the DNS protocol. Therefore, attackers can use DNS tunneling technology to achieve dangerous operations such as file transfer and building C&C channels.

[0005] DNS tunnels can be divided into direct tunnels and relay tunnels according to their implementation methods. A direct tunnel means that the client directly connects to the specified target DNS server and communicates by encoding and encapsulating data in the DNS protocol. This method is faster, but less concealed and easy to be detected and tracked. A relay tunnel refers to a relay tunnel implemented through DNS recursive query. It is relatively concealed, but at the same time, because the data packet needs to pass through multiple nodes before reaching the target DNS server, the speed is much slower than the direct tunnel. At the same time, it is also necessary to avoid the DNS cache of the local client. A random domain name generation algorithm (DGA) can be used to generate a random domain name to effectively bypass blacklist detection. In summary, the phenomenon caused by DNS hidden tunnels is that a large number of non-repeated domain names will appear during the tunnel communication time.

[0006] There are two main types of detection technologies for hidden malicious behaviors: rule-based detection and machine learning-based detection. The disadvantage of rule-based detection is that DNS tunnel software can modify features such as domain name length and request frequency to bypass the detection of these rules. Machine learning-based detection requires the collection of training data in advance for modeling. Although it reduces labor costs to a certain extent, it cannot automatically learn abstract features, is inefficient, and still requires manual processing of some data. Summary of the invention

[0007] The purpose of the present invention is to provide a hidden malicious behavior detection method based on multi-model fusion, which can greatly reduce the manpower cost and improve the accuracy of DNS hidden tunnel detection.

[0008] To achieve the above object, the technical solution adopted by the present invention is:

[0009] A method for detecting hidden malicious behavior based on multi-model fusion, the method for detecting hidden malicious behavior based on multi-model fusion comprising:

[0010] Step 1: Obtain black sample, white sample and CDN sample data sets of DNS messages;

[0011] Step 2: Extract features from black samples, white samples and CDN sample data sets;

[0012] Step 3: Perform multi-model training based on the extracted features, and perform weight fusion on the trained multi-models to obtain a hidden malicious behavior detection model, including:

[0013] Step 3.1, performing multi-model training based on the extracted features, wherein the multi-model includes an LSTM model, a 1D-CNN model, and an MLP model;

[0014] Step 3.2: Calculate the weights corresponding to each model as follows:

[0015]

[0016] f(v i )=(v i ) α

[0017] In the formula, w i is the weight of the ith model, v i is the accuracy of the ith model, n is the number of models and n=3, α is a constant greater than 1;

[0018] Step 3.3: Weight fusion of multiple models is as follows:

[0019] p={p MLP ×MLP +p 1D-CNN × 1D-CNN +p RNN × RNN}

[0020] Where p is the detection result output by the hidden malicious behavior detection model, p MLP is the detection result of the MLP model, w MLP is the weight of the MLP model, p 1D-CNN is the detection result of the 1D-CNN model, w 1D-CNN is the weight of the 1D-CNN model, p RNN is the detection result of the LSTM model, w RNN is the weight of the LSTM model;

[0021] Step 4: Use the hidden malicious behavior detection model to perform real-time detection and capture DNS hidden tunnels.

[0022] Several optional methods are also provided below, but they are not intended to be additional limitations on the above-mentioned overall solution, but are merely further supplements or preferences. Under the premise that there are no technical or logical contradictions, each optional method can be combined with the above-mentioned overall solution separately, and multiple optional methods can also be combined.

[0023] Preferably, the step of obtaining a black sample, a white sample, and a CDN sample data set of DNS messages includes:

[0024] Step 1.1: Build a DNS hidden tunnel and obtain a black sample dataset of DNS messages by capturing packets.

[0025] Step 1.2: Capture the internal traffic of the campus network to obtain a white sample data set of DNS messages within the campus network;

[0026] Step 1.3: Obtain the CDN sample data set by capturing CDN traffic packets.

[0027] Preferably, the step of obtaining the black sample, white sample and CDN sample data set of the DNS message further includes:

[0028] Step 1.4: parse each piece of data in the black sample, white sample and CDN sample data sets. During the parsing, first read the source data and extract the features required for multi-model training from the source data, and then convert the extracted features into model-recognizable files.

[0029] Preferably, the feature extraction of the black sample, the white sample and the CDN sample data set includes:

[0030] Step 2.1, filter out illegal sample data;

[0031] Step 2.2, extracting subdomains from the domain name features of each sample data;

[0032] Step 2.3, obtain the number of valid characters in the subdomain as the maximum eigenvalue, and perform integer encoding on the domain name in the subdomain and convert it into a word vector;

[0033] Step 2.4: If the length of the domain name feature is less than the maximum feature value, the word vector is padded with fillers until the length of the domain name feature reaches the maximum feature value, and the padded word vector is output as the extracted feature; otherwise, the word vector in step 2.3 is directly output as the extracted feature.

[0034] Preferably, the multi-model training based on the extracted features comprises:

[0035] The features extracted from the black sample, white sample and CDN sample data sets are randomly sampled and divided into training sets and test sets;

[0036] The training set was used for multi-model training. During the training process, a one-dimensional convolution function was first added to the 1D-CNN model for feature processing, a long short-term memory network function was added to the LSTM model for feature processing, and a hidden layer was added to the MLP model for feature processing. Then, an embedding layer was added to the training process of each of the three models to reduce the data dimension. Then, a dropout layer was added to the 1D-CNN model, the LSTM model, and the MLP model for smoothing.

[0037] Use the test set to verify each model. If the accuracy of each model reaches the preset requirements, the training is terminated. Otherwise, the training set is reused for multi-model training.

[0038] Preferably, the detection result output by the hidden malicious behavior detection model is a two-dimensional vector, the first dimension of the two-dimensional vector represents the probability that the data belongs to the DNS hidden tunnel, and the second dimension represents the probability that the data belongs to normal data.

[0039] The hidden malicious behavior detection method based on multi-model fusion provided by the present invention generates a preliminary model by using the collected DNS samples for multi-model training, and then uses the test set to test the preliminary model, and finally obtains a stable model that can automatically detect DNS hidden tunnels. The ability of deep learning to automatically extract potential features is used to train data, thereby greatly reducing labor costs and improving the accuracy of DNS hidden tunnel detection. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] Figure 1 It is a flow chart of the hidden malicious behavior detection method based on multi-model fusion of the present invention;

[0041] Figure 2 A flowchart for obtaining a data set for the present invention;

[0042] Figure 3 A flow chart of feature extraction for a data set according to the present invention;

[0043] Figure 4 The present invention is a flowchart of performing multi-model training. DETAILED DESCRIPTION

[0044] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0045] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art of the present invention. The terms used in the specification of the present invention herein are only for the purpose of describing specific embodiments and are not intended to limit the present invention.

[0046] In order to overcome the problems in the prior art that hidden malicious behavior detection is easily bypassed, takes a long time, and has low accuracy, this embodiment provides a hidden malicious behavior detection method based on multi-model fusion.

[0047] like Figure 1 As shown, the hidden malicious behavior detection method based on multi-model fusion provided in this embodiment includes the following steps:

[0048] Step 1: Obtain black sample, white sample and CDN sample data sets of DNS messages.

[0049] There are many ways to obtain training data sets in the prior art. In order to improve the model training effect, this embodiment adopts the following method: Figure 2 The data acquisition method shown is as follows:

[0050] Step 1.1: Use the dnscat2 tool to build a DNS hidden tunnel, and use the wireshark packet capture tool to obtain a black sample dataset of DNS messages.

[0051] Step 1.2: Capture the internal traffic of the campus network using the Wireshark packet capture tool to obtain a white sample data set of DNS messages within the campus network.

[0052] Step 1.3: Obtain the CDN sample data set by capturing CDN traffic based on the Wireshark packet capture tool. Since some CDNs use domain names similar to covert tunnels, in order to improve the highest detection accuracy, the CDN data set is also used to train the model.

[0053] The data set includes DNS request response message information, including destination server, source server, port, protocol, number of data packets, domain name information, etc.

[0054] Step 1.4: Since the data obtained by packet capture is complex and diverse and is in a pcap package format that cannot be directly recognized by the model, this embodiment needs to process the data set. When processing, each data in the black sample, white sample and CDN sample data set is first parsed. When parsing, the source data is first read and the features required for multi-model training (including: destination port, response data, query domain name, query data) are extracted from the source data. Then, the extracted features are converted into a file (such as a txt file) that can be recognized by the model (deep learning algorithm).

[0055] Step 2: Extract features from black sample, white sample and CDN sample data sets.

[0056] Feature extraction is to obtain data from sample data for input into the neural network. The data processing process of feature extraction in this embodiment is as follows: Figure 3 shown.

[0057] Step 2.1, filter illegal sample data, that is, filter DNS data; because each sample data includes the characteristics of protocol and port, therefore, filter each sample data, that is, filter illegal data whose protocol is not 17 and port is not 53.

[0058] Step 2.2, extract the subdomain from the domain name feature of each piece of sample data; the domain name feature consists of two parts: the root domain and the subdomain. DNS hidden tunnel transmission data will only encode the data in the subdomain part for transmission, and the root domain will not be affected. Therefore, this embodiment extracts the subdomain from the domain name feature of each piece of data and further processes the subdomain.

[0059] Step 2.3, obtain the number of valid characters in the subdomain as the maximum eigenvalue, and convert the subdomain domain name into a word vector by integer encoding. The integer encoding adopts a conventional encoding method in data processing, which will not be described in detail in this embodiment.

[0060] Step 2.4: If the length of the domain name feature is less than the maximum feature value, the word vector is padded with a filler (such as "0") until the length of the domain name feature reaches the maximum feature value, and the padded word vector is output as the extracted feature; otherwise, the word vector in step 2.3 is directly output as the extracted feature.

[0061] Step 3: Perform multi-model training based on the extracted features, and perform weight fusion on the trained multi-models to obtain a hidden malicious behavior detection model. Figure 4 As shown, the specific steps include:

[0062] Step 3.1: Perform multi-model training based on the extracted features, wherein the multi-model includes an LSTM model, a 1D-CNN model, and an MLP model, including:

[0063] Step 3.1.1, randomly sample the features extracted from the black sample, white sample and CDN sample data set and divide them into training set and test set. For example, 80% of the data is used to train the multi-layer perceptron model (MLP model), convolutional neural network model (1D-CNN model) and long short-term memory network model (LSTM model); the remaining 20% ​​of the data is used to verify the trained models.

[0064] Step 3.1.2, use the training set to perform multi-model training. During the training process, first add a one-dimensional convolution function to the 1D-CNN model for feature processing (the feature here is the word vector of the domain name fragment output in step 2.4), add a long short-term memory network function to the LSTM model for feature processing, and add a hidden layer to the MLP model for feature processing; then, add an embedding layer to the training process of each of the three models to perform data dimensionality reduction, which is essentially the same as word2vec; then, add a dropout layer to the 1D-CNN model, LSTM model, and MLP model for smoothing to prevent overfitting.

[0065] Step 3.1.3: Use the test set to verify each model. If the accuracy of each model reaches the preset requirement, the training is terminated. Otherwise, the training set is reused for multi-model training.

[0066] Step 3.2: After the test model meets the preset requirements, calculate the weight of each model in the final result. The weight corresponding to each model is calculated as follows:

[0067]

[0068] f(v i )=(v i ) α

[0069] In the formula, w i is the weight of the ith model, v i is the accuracy of the i-th model, n is the number of models and n=3, α is a constant greater than 1; introduce the function f(v i )=(v i ) αThe purpose is to increase the weights corresponding to models with high accuracy.

[0070] Step 3.3: Weight fusion of multiple models to solidify the model is as follows:

[0071] p={p MLP × MLP +p 1D-CNN × 1D-CNN +p RNN × RNN}

[0072] Where p is the detection result output by the hidden malicious behavior detection model, p MLP is the detection result of the MLP model, w MLP is the weight of the MLP model, p 1D-CNN is the detection result of the 1D-CNN model, w 1D-CNN is the weight of the 1D-CNN model, p RNN is the detection result of the LSTM model, w RNN is the weight of the LSTM model.

[0073] The detection result output by the hidden malicious behavior detection model obtained in this embodiment is a two-dimensional vector, the first dimension of which represents the probability that the data belongs to the DNS hidden tunnel, and the second dimension represents the probability that the data belongs to normal data.

[0074] Step 4: Use the hidden malicious behavior detection model to perform real-time detection and capture DNS hidden tunnels.

[0075] This embodiment effectively improves the accuracy of hidden malicious behavior detection through multi-model fusion detection, and finally obtains a stable model that can automatically detect DNS covert tunnels. It uses the ability of deep learning to automatically extract potential features to train data, thereby greatly reducing labor costs and improving the accuracy of DNS covert tunnel detection.

[0076] The technical features of the above-described embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above-described embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0077] The above-mentioned embodiments only express several implementation modes of the present invention, and the description thereof is relatively specific and detailed, but it cannot be understood as limiting the scope of the invention. It should be pointed out that, for a person of ordinary skill in the art, several modifications and improvements can be made without departing from the concept of the present invention, and these all belong to the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the attached claims.

Claims

1. A hidden malicious behavior detection method based on multi-model fusion, characterized in that: The hidden malicious behavior detection method based on multi-model fusion includes: Step 1: Obtain black sample, white sample and CDN sample data sets of DNS messages; Step 2: Extract features from black samples, white samples and CDN sample data sets; Step 2.1, filter out illegal sample data; Step 2.2, extracting subdomains from the domain name features of each sample data; Step 2.3, obtain the number of valid characters in the subdomain as the maximum eigenvalue, and perform integer encoding on the domain name in the subdomain and convert it into a word vector; Step 2.4: If the length of the domain name feature is less than the maximum feature value, the word vector is padded with a filler until the length of the domain name feature reaches the maximum feature value, and the padded word vector is output as the extracted feature; otherwise, the word vector in step 2.3 is directly output as the extracted feature; Step 3: Perform multi-model training based on the extracted features, and perform weight fusion on the trained multi-models to obtain a hidden malicious behavior detection model, including: Step 3.1: Perform multi-model training based on the extracted features, wherein the multi-model includes an LSTM model, a 1D-CNN model, and an MLP model, including: The features extracted from the black sample, white sample and CDN sample data sets are randomly sampled and divided into training sets and test sets; The training set is used for multi-model training. During the training process, a one-dimensional convolution function is first added to the 1D-CNN model for feature processing, a long short-term memory network function is added to the LSTM model for feature processing, and a hidden layer is added to the MLP model for feature processing; then, an embedding layer is added to the training process of each of the three models to perform data dimensionality reduction; then, a dropout layer is added to the 1D-CNN model, LSTM model, and MLP model for smoothing; Use the test set to verify each model. If the accuracy of each model reaches the preset requirement, the training is terminated. Otherwise, the training set is reused for multi-model training. Step 3.2: Calculate the weights corresponding to each model as follows: f(v i )=(v i ) α In the formula, w i is the weight of the ith model, v i is the accuracy of the ith model, n is the number of models and n=3, α is a constant greater than 1; Step 3.3: Weight fusion of multiple models is as follows: p={p MLP ×w MLP +p 1D-CNN ×w 1D-CNN +p RNN ×w RNN } Where p is the detection result output by the hidden malicious behavior detection model, p MLP is the detection result of the MLP model, w MLP is the weight of the MLP model, p 1D-CNN is the detection result of the 1D-CNN model, w 1D-CNN is the weight of the 1D-CNN model, p RNN is the detection result of the LSTM model, w RNN is the weight of the LSTM model; Step 4: Use the hidden malicious behavior detection model to perform real-time detection and capture DNS hidden tunnels.

2. The method for detecting hidden malicious behavior based on multi-model fusion as claimed in claim 1, characterized in that: The black sample, white sample and CDN sample data set of the DNS message are obtained, including: Step 1.1: Build a DNS hidden tunnel and obtain a black sample dataset of DNS messages by capturing packets. Step 1.2: Capture the internal traffic of the campus network to obtain a white sample data set of DNS messages within the campus network; Step 1.3: Obtain the CDN sample data set by capturing CDN traffic packets.

3. The method for detecting hidden malicious behavior based on multi-model fusion as claimed in claim 2, characterized in that: The obtaining of the black sample, white sample and CDN sample data set of the DNS message also includes: Step 1.4: parse each piece of data in the black sample, white sample and CDN sample data sets. During the parsing, first read the source data and extract the features required for multi-model training from the source data, and then convert the extracted features into model-recognizable files.

4. The method for detecting hidden malicious behavior based on multi-model fusion as claimed in claim 1, characterized in that: The detection result output by the hidden malicious behavior detection model is a two-dimensional vector, the first dimension of which represents the probability that the data belongs to the DNS hidden tunnel, and the second dimension represents the probability that the data belongs to normal data.