Malicious domain name training data generation method based on generative adversarial network
By generating malicious domain name training data from the adversarial network, the problems of long and low efficiency of detection model update cycles in the existing technology are solved, and the performance and efficiency of DGA domain name detection are improved.
Patent Information
- Application Number
- CN202211607919.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-14
- Publication Date
- 2024-12-03
- Estimated Expiration
- 2042-12-14
AI Technical Summary
Due to the lack of the latest and rich training sample data, the existing DGA domain name detectors have a long update cycle and low efficiency in detection of unknown domain names, and are not efficient.
Using the malicious domain name training data generation method based on the generative adversarial network, by building a domain name autoencoder and generating adversarial network model, the maximum mean difference MMD is used to test whether the generator output sample comes from the same distribution as the real domain name, and generate effective malicious domain name training. data.
By pre-training the autoencoder and combining with the GAN network, learning the potential characteristics of real domain names, the generated malicious domain name data can effectively reduce the efficiency of the detection model, improve the detection performance, and ensure the effectiveness and authenticity of the generated data.
Smart Images

Figure CN115913764B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of network information security technology, and in particular to a method for generating malicious domain name training data based on a generative adversarial network. Background Art
[0002] While the Internet industry is booming, various network security incidents such as cyber fraud, DDoS attacks, ransomware, and computer malware infection are emerging in an endless stream. According to monitoring by the National Computer Network Emergency Response Technical Processing Coordination Center CNCERT / CC, in 2020, the number of IP addresses of servers controlled by Trojans or zombie programs in my country was 12,810, and the number of IP addresses of hosts controlled by Trojans or zombie programs in the country was 5,338,246. The zombie network thus formed has become a huge threat to the current network security field.
[0003] Botnets widely use domain name generation algorithms to generate a large number of random domain names to evade security detection. Accurate detection and identification of malicious domain names has become an important issue in current network security management. Deep learning algorithms based on neural networks have excellent performance in malicious domain name detection. Woodbridge et al. first used long short-term memory networks to build a DGA domain name detector, which has obvious advantages over traditional machine learning models in terms of detection accuracy and recall rate. Yu et al. used different convolutional neural networks to train DGA domain name detectors with a detection accuracy of more than 90%. Yuan Chen et al. proposed a generation model for DGA domain name training data. The model combines the idea of generative adversarial networks and directly inputs data into the original GAN model for learning and training, maintaining the true characteristics of the data. Anderson et al. integrated autoencoders into generative adversarial networks and proposed a DGA generation model and detection model DeepDGA. After multiple iterations of training the generative adversarial network, the generator can simulate real DGA domain names with similar features, which significantly reduces the performance of the DGA detector using the random forest algorithm.
[0004] Existing DGA detectors are all trained and constructed based on public DGA domain name datasets, lacking the latest and rich DGA domain name training sample data, resulting in a detection model update cycle that is too long and too slow, the effectiveness and speed of detection are not strong, and the efficiency of detecting unknown DGA domain names is low. Summary of the invention
[0005] The present invention provides a method for generating malicious domain name training data based on a generative adversarial network, aiming to solve the shortcomings existing in the prior art.
[0006] In order to achieve the above object, the present invention provides the following technical solution: a method for generating malicious domain name training data based on a generative adversarial network, comprising the following steps:
[0007] Obtain real domain names and build a domain name dataset;
[0008] Construct a domain name autoencoder network, input the domain name data set into the domain name autoencoder network for pre-training, and obtain a trained domain name autoencoder network;
[0009] Use the trained domain name autoencoder network to build a domain name generation adversarial network model, judge the malicious domain name data generated by the domain name generation adversarial network model by comparing the real data with the real data, and output the judgment result;
[0010] The domain name generation adversarial network model is trained, and the maximum mean difference (MMD) test is used to determine whether the output samples of the domain name generation adversarial network model come from the same distribution as the real domain name. If the test passes, the training is stopped and the malicious domain name training data after training is output.
[0011] Preferably, the constructing of the domain name autoencoder network includes:
[0012] The domain name autoencoder network is formed by cascading three parallel convolutional networks and one LSTM network;
[0013] The n-gram information between the characters of the domain name data is captured by the convolution filter kernel sizes of the three convolutional networks;
[0014] The LSTM network is used to mine and represent the potential features of variable-length domain name sequences and generate variable-length sequences.
[0015] Preferably, the step of inputting the domain name dataset into the domain name autoencoder for pre-training comprises the following steps:
[0016] Sequence-mark the real domain name and perform one-hot encoding;
[0017] Input the one-hot encoded sequence into the cascaded convolutional layer, and concatenate the output results of the cascaded convolutional layer in parallel and then input them into another convolutional layer;
[0018] Inputting the output result of another convolutional layer into a flattening layer, and using the flattening layer to flatten the input sequence into a one-dimensional vector matrix as the output of the encoder;
[0019] The one-dimensional input sequence is reorganized into a two-dimensional vector matrix through the reconstruction layer;
[0020] Input the two-dimensional vector matrix into the cascade convolution layer and output it, and then concatenate the output results in parallel and send them into the output convolution layer;
[0021] Remove the sequence mark from the output convolutional layer to get the original domain name.
[0022] Preferably, the method of constructing a domain name generative adversarial network model using the trained domain name autoencoder comprises the following steps:
[0023] Use the decoder to build a GAN network generator and train it;
[0024] Use the encoder to build the GAN network discriminator and train it;
[0025] The GAN network generator and the GAN network discriminator form a domain name generation adversarial network model.
[0026] Preferably, the network structure of the GAN network generator is composed of a fully connected layer and a decoder, and the training step of constructing the GAN network generator using the decoder and training it includes:
[0027] Use a random noise generator to generate noise uniformly distributed on [-1,1];
[0028] The random noise is linearly transformed through the fully connected layer to obtain a dimension consistent with the encoder output dimension;
[0029] Use the ReLU function to activate the linearly transformed random noise;
[0030] The activated random noise is fed into the decoder to obtain labeled samples of the output domain name.
[0031] Preferably, the network structure of the GAN network discriminator is composed of an encoder and a fully connected layer, and the training steps of constructing the GAN network discriminator using the encoder and training it include:
[0032] The encoder receives a real domain name or a fake domain name sequence generated by a generator and encodes it;
[0033] Transforming the encoded data into low-dimensional data through a fully connected layer;
[0034] The low-dimensional data is activated by a Sigmoid function and the result is output.
[0035] Preferably, when training the network of the GAN network generator, the weight parameters of the pre-trained encoder are frozen, and then the fully connected network of the GAN network generator is trained;
[0036] When training the network of the GAN network discriminator, the weight parameters of the pre-trained encoder are frozen, and then the fully connected network of the GAN network discriminator is trained.
[0037] Preferably, the domain name generative adversarial network model is trained, and label smoothing and improved loss updating are used to improve the stability of model training.
[0038] Preferably, the maximum mean difference MMD is specifically defined as:
[0039]
[0040] Among them, p and q are two distributions, x and y are the samples generated by p and q respectively, E x ,E y The means of the function values on the two generated samples f are x and y respectively. The difference between the two means is used to obtain the mean difference MeanDiscrepancy of the two distributions corresponding to the function f. The goal of the maximum mean difference is to find an f that maximizes the mean difference, that is, to obtain the maximum mean difference; F is taken as the unit ball of the Hilbert space, and the pre-set kernel functions are used in actual operations.
[0041] Compared with the prior art, the present invention has the following beneficial effects:
[0042] 1. By pre-training the autoencoder and applying it to the GAN network, the potential characteristics of the real domain name are learned to the greatest extent.
[0043] 2. A two-sample test method based on Maximum Mean Discrepancy (MMD) is used to verify that the output samples of the generator and the real Alexa domain name samples come from the same distribution, ensuring the validity of the generated model and generated data.
[0044] 3. In addition to designing the convolution layer to extract the n-gram information of the domain name in the autoencoder structure, the LSTM network layer is also introduced to better capture the potential features between domain name characters, thereby generating a character sequence of variable length.
[0045] 4. The generated data was verified on the DGA domain name detector based on the LSTM network, and it was found that it can effectively reduce the efficiency of the detection model. After further training the domain name detector with generated data, the performance of the model was significantly improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] Figure 1 This is a structural diagram of the domain name self-encoder of the present invention;
[0047] Figure 2 Generate an adversarial network structure diagram for the present invention;
[0048] Figure 3 Generate an adversarial network generator structure diagram for the present invention;
[0049] Figure 4 Generate an adversarial network discriminator structure diagram for the present invention;
[0050] Figure 5This is the training loss graph of the autoencoder of the present invention;
[0051] Figure 6 is a sequence length distribution diagram of the present invention;
[0052] Figure 7 It is the character frequency distribution diagram of the present invention. DETAILED DESCRIPTION
[0053] The specific implementation of the present invention is further described below in conjunction with the accompanying drawings. The following embodiments are only used to more clearly illustrate the technical solution of the present invention, and cannot be used to limit the protection scope of the present invention.
[0054] The present invention uses real domain name data to train an autoencoder, and uses the encoding network and decoding network of the autoencoder as the discriminator and generator of the GAN network respectively, thereby constructing a GAN-based DGA sequence generator.
[0055] Among them, AutoEncoder (AE) is usually regarded as an unsupervised learning network, which is often used to help data classification, visualization and storage. Its core function is to compress and reduce the dimension of the input sequence, and then reconstruct and restore it. A typical autoencoder consists of two parts: an encoder and a decoder. The encoder encodes the input sequence into a corresponding low-dimensional vector through a series of pre-designed neural network structures, which is called the encoding process; the encoded data is reconstructed through the hidden layer in the decoder, which is the decoding process. By defining a suitable loss function, selecting an appropriate network model, and training it, the input sequence can be reconstructed almost perfectly, so that the low-dimensional vector output by the encoder can fully express the intrinsic characteristics of the original sequence.
[0056] The Generative Adversarial Network (GAN), proposed by Goodfellow et al. in 2014, is an unsupervised deep learning model. Its principle is to learn sample features through the game between two neural networks, so as to generate new data that is indistinguishable from the original data set. The Generative Adversarial Network contains two independent neural networks - the generative network G and the discriminative network D. D is responsible for judging whether the input data is fake data generated by G or real data; while G continuously improves its counterfeiting ability in order to generate adversarial samples that can successfully deceive D. During the confrontation process, both parties adopt an alternating iterative method to continuously optimize their own networks, thus forming a confrontation and eventually reaching a balance.
[0057] like Figure 1-4 As shown, the method for generating malicious domain name training data based on a generative adversarial network includes the following steps:
[0058] Step 1: Obtain real domain names and build a domain name dataset.
[0059] Step 2: Build a domain name autoencoder network, input the domain name dataset into the domain name autoencoder network for pre-training, and obtain the trained domain name autoencoder network.
[0060] Step 3: Use the trained domain name autoencoder network to build a domain name generative adversarial network model, judge the malicious domain name data generated by the real data and the domain name generative adversarial network model, and output the judgment result.
[0061] Step 4: Train the domain name generation adversarial network model, and use the maximum mean difference (MMD) test to determine whether the output samples of the domain name generation adversarial network model come from the same distribution as the real domain name. If the test passes, stop training and output the malicious domain name training data after training.
[0062] The domain name autoencoder network in step 2 is composed of three parallel convolutional networks and one LSTM network cascaded together. The convolution filter kernel sizes of the three convolutional networks correspond to the n-gram information between the characters of the domain name data. The LSTM network is used to mine and represent the potential features of the variable-length domain name sequence to generate a variable-length sequence.
[0063] In step 2, the domain name dataset is input into the domain name autoencoder for pre-training, which includes the following steps:
[0064] The real domain names are sequenced and one-hot encoded.
[0065] The one-hot encoded sequence is input into the cascaded convolutional layer, and the output results of the cascaded convolutional layer are concatenated in parallel and sent to another convolutional layer.
[0066] The output of another convolutional layer is input into the flattening layer, and the flattening layer is used to flatten the input sequence into a one-dimensional vector matrix as the output of the encoder.
[0067] The one-dimensional input sequence is reorganized into a two-dimensional vector matrix through the reconstruction layer.
[0068] The two-dimensional vector matrix is input into the cascade convolution layer and output, and the output results are concatenated in parallel and sent to the output convolution layer.
[0069] Remove the sequence mark from the output convolutional layer to get the original domain name.
[0070] In step 3, using the trained domain name autoencoder to construct a domain name generative adversarial network model includes the following steps:
[0071] Use the decoder to build the GAN network generator.
[0072] Use the encoder to build the GAN network discriminator.
[0073] The domain name generation adversarial network model is constructed through the GAN network generator and the GAN network discriminator.
[0074] The network structure of the GAN network generator consists of a fully connected layer and a decoder. The GAN network generator is trained. The training steps include:
[0075] Use a random noise generator to generate noise uniformly distributed on [-1,1];
[0076] The random noise is linearly transformed through the fully connected layer to obtain a dimension consistent with the encoder output dimension;
[0077] Use the ReLU function to activate the linearly transformed random noise;
[0078] The activated random noise is fed into the decoder to obtain labeled samples of the output domain name.
[0079] The network structure of the GAN network discriminator consists of an encoder and a fully connected layer. The GAN network discriminator is trained. The training steps include:
[0080] The encoder receives the real Alexa domain name or the fake domain name sequence generated by the generator and encodes it;
[0081] The encoded data is transformed into low-dimensional data through a fully connected layer;
[0082] The low-dimensional data is activated through the Sigmoid function and the result is output.
[0083] When training the network of the GAN network generator, the weight parameters of the pre-trained encoder are frozen, and then the fully connected network of the GAN network generator is trained;
[0084] When training the network of the GAN network discriminator, the weight parameters of the pre-trained encoder are frozen, and then the fully connected network of the GAN network discriminator is trained.
[0085] When training the domain-generative adversarial network model, label smoothing and improved loss update are used to improve the stability of model training.
[0086] In step 4, the maximum mean difference MMD is specifically defined as:
[0087]
[0088] Among them, p and q are two distributions, x and y are the samples generated corresponding to p and q respectively, F is taken as the unit ball of Hilbert space, and the pre-set kernel function is used in actual operation.
[0089] The following is a detailed explanation of the various steps of the malicious domain name training data generation method based on the generative adversarial network:
[0090] (1) Domain Autoencoder
[0091] A general domain name encoder / decoder is often implemented by establishing a one-to-one mapping from a single domain name character to a digital code. For example, in existing literature, domain name characters are converted into an ASCII-based encoding method to implement vector mapping and inverse mapping.
[0092] In order to better capture the potential relationship between domain name characters and compress long domain names, the autoencoder encoding network designed in this paper is mainly composed of 3 parallel convolutional networks and 1 LSTM network cascade. The 3 parallel convolutional layers each have 100 filter kernels, and the convolution kernel sizes are 2, 3, and 4, respectively, corresponding to the capture of n-gram information between domain name data characters. The LSTM network is used to mine and represent the potential features of variable-length domain name sequences, thereby realizing the generation of variable-length sequences. Specifically, the Alexa domain name is first sequenced and tokenized, and then one-hot encoded. The encoded sequence is then input into the cascaded convolutional layer, and then the output of the cascaded convolutional layer is parallel spliced and sent to another convolutional layer. Finally, the input sequence is flattened into a 1-dimensional vector through the flattening layer as the output of the encoder. This output expresses the core information of the original sequence data after compression and extraction by the encoder. The output of the encoder is used as the input of the decoder. The one-dimensional input sequence is first reorganized into a two-dimensional matrix through the reconstruction layer, and then the two-dimensional matrix is input into the cascade convolution layer with a similar structure to the encoder. After that, the output of the cascade convolution layer is concatenated in parallel and sent to the output convolution layer. The output convolution layer has 37 convolution kernels. The number of convolution kernels corresponds to the length of the domain name serialization dictionary, and the activation function is Softmax. The output of the Softmax activation function represents the probability distribution of each character of the domain name on the tag dictionary. The autoencoder network structure is as follows: Figure 1 shown.
[0093] (2) Generative Adversarial Network Structure Design
[0094] The encoder designed in (1) realizes the compressed representation of complex domain name character sequences in a low-dimensional feature space, and the decoder can restore the compressed representation to the original domain name. Based on this, we use the decoder to construct the GAN network generator and the encoder to the GAN network discriminator, thereby designing a new domain name generation network model. The generator of the GAN model will be trained to generate domain names that are as similar as possible to the Alexa Top 1 million data, while the discriminator will try to identify whether the input domain name data is generated by the generator network or sampled from the real data set, as follows Figure 2 This is a diagram of the structure of the generated adversarial network.
[0095] The network structure of the generator consists of a fully connected layer and a decoder. First, a random noise generator is used to generate noise uniformly distributed on [-1,1]. Then, the random noise is linearly transformed through the fully connected layer to make its dimension consistent with the output dimension of the encoder. Finally, it is activated by the ReLU function and sent to the pre-trained decoder to obtain the labeled sampling of the output domain name. Intuitively, the fully connected layer learns the mapping from the uniformly distributed noise space to the low-dimensional encoding feature space, and this low-dimensional space is the feature space used by the encoder to learn to generate real domain names. In order to ensure that the output of the decoder is the generated domain name data, this article freezes the parameter values of the decoder when training the generator. The structure of the generator is as follows: Figure 3 shown.
[0096] The structure of the discriminator is similar to that of the generator, consisting of an encoder and a fully connected network. The pre-trained encoder acts as a discriminator network to receive the real Alexa domain name or the fake domain name sequence generated by the generator, and then transforms its output into low-dimensional data through a fully connected layer, and finally outputs it after being activated by a Sigmoid function. When training the discriminator network, the weight parameters of the pre-trained encoder are also frozen before training. The structure of the discriminator is as follows: Figure 4 shown.
[0097] (3) In addition to using strategies such as label smoothing and improved loss updating to improve the stability of model training, this paper also considers using the idea of two-sample test in statistics to guide the model training process. In some experiments, the training quality of the generated network is often judged by observing the changes in training loss, visually judging the domain name similarity, and drawing histograms of generated samples. However, these operations are difficult to give clear indicators to determine the training quality of the GAN network. This paper considers introducing the MMD test in the middle of the GAN model training process to determine whether the output samples of the current generated network come from the same distribution as the real Alexa domain name samples, that is, performing a two-sample test. Gretton gave the application of MMD in the two-sample test. Its basic assumption is: for two distributions p and q, given all function families F with the sample space generated by the distribution as input, if the means of the images of the samples x and y corresponding to p and q on each function f in F are equal, then the two distributions can be considered to be the same. The specific definition of MMD is as follows:
[0098]
[0099] Here, F is taken as the unit ball of the Hilbert space, and in actual operation, it is represented by a preset kernel function, such as a Gaussian kernel function.
[0100] In the experiment, if the MMD test passes, it means that the quality of the generated samples is good and it is impossible to distinguish them from the real domain names from the perspective of statistical tests. At this time, training can be stopped.
[0101] The present invention has carried out experiments and analysis on the above method, and the specific contents are as follows:
[0102] (1) Experimental environment and dataset
[0103] This paper mainly uses the PyTorch deep learning framework. The specific experimental environment configuration is shown in Table 1.
[0104] Table 1 Specific configuration of the experimental environment
[0105] Environment Configuration parameter operating system Operating system Ubuntu desktop version 64bit Memory 16GB 2400MHz DDR4 CPU Intel Corei7-9700K 8-core 3.6GHz GPU GPU NVIDIA GeForce RTX2070 PyTorch 1.9.0
[0106] The dataset used in this experiment consists of two parts. The first part is the domain names of the top 1 million real websites obtained from the Alexa website, which is used as the training data for our model.
[0107] The second part is the existing DGA domain name dataset from 360 Security Lab, which is used for comparative experiments. Before the experiment, the data used was preprocessed, and all the first-level domain names and second-level domain names such as .com, .net, .org, etc. were removed, and only the host domain name was retained for model training.
[0108] (2) Experimental design
[0109] 1) Training the Autoencoder
[0110] Before training the GAN model, the autoencoder needs to be pre-trained. This step is necessary because if the autoencoder is not pre-trained using the Alexa domain, the subsequent training of the GAN network will be highly unstable and difficult to converge. The specific experimental steps are as follows:
[0111] a) We extracted 100,000 Alexa data points, randomly shuffled them, and divided them into training and test sets at a ratio of 80 / 20. We tried different batch sizes, such as 64, 128, and 256. Finally, we chose 64 as the optimal batch size after comprehensively considering the training efficiency and model performance.
[0112] b) The number of hidden neurons in the designed LSTM network in the encoder of the autoencoder was compared by ablation experiments with different values, such as 5, 10, 50, 100, etc. According to the training time of the autoencoder and the subsequent performance of the GAN network, the number of hidden neurons in the LSTM network was selected as 10.
[0113] c) Use cross entropy as the loss function for training, that is, measure the loss size of the decoder Softmax output.
[0114] d) The initial learning rate is set to 0.0001. As the loss decreases, the learning rate decreases accordingly, resulting in better and more stable training results.
[0115] e) During training, the adaptive moment estimation Adam optimization algorithm is used to update the weights of the autoencoder network, and the weight decay rate is set to 0.8, that is, L2 regularization is used to prevent overfitting in training.
[0116] Experiments show that after less than 10 training cycles, the autoencoder can restore the input Alexa domain name almost losslessly. The mean square error (MSE) on the test set is calculated to be about 3.234×10-5. This shows that the designed autoencoder structure can completely capture almost all the information in the complex normal domain name and give the corresponding low-dimensional vector representation. Figure 5 The figure shows the change of the autoencoder loss value during the training process, where the horizontal axis represents the training cycle and the vertical axis represents the model loss on the test set. It can be clearly seen that as the number of training times increases, the autoencoder loss value gradually decreases and remains stable, and the network parameters are very stable.
[0117] 2) Training and testing of GAN-generated adversarial models
[0118] In this stage, the trained autoencoder will be split into an encoder and a decoder, and embedded into the discriminant network and the generator network of the GAN network respectively. The training process of GAN is described in detail as follows.
[0119] a) Two parts of data are selected as training data, one is the real Alexa domain name after division, and the other is the sample generated by the randomly selected, uniformly distributed noise vector after passing through the generative network, and the dimension of the noise is set to 8. 50,000 samples are used for each part, of which the Alexa domain name is used as a positive sample and the generated domain name is used as a negative sample for the training of the discriminant network; in addition, another 50,000 generated domain names are used as positive samples for the synchronous training of the generative network.
[0120] b) We tried different batch sizes of 64, 128, and 256 for ablation comparison experiments. According to the training efficiency and stability of the GAN network, we selected the optimal batch size of 128 and the training cycle of 50.
[0121] c) The discriminator uses cross entropy as the loss function.
[0122] d) In the experiment, the label of the negative sample is set to 0, and the label of the positive sample is smoothed, that is, randomly transformed from 1 to a decimal between 0.8 and 1, to improve the stability of training.
[0123] e) Considering that the discriminator converges much faster than the generator in the experiment, when back-propagating to update the network parameters, this paper selects a stronger Adam optimizer to train the generative network, and uses the simpler momentum stochastic gradient descent and SGD optimizers to train the discriminator. The learning rates are set to 0.000001 and 0.0000001 respectively, and weight decay is used to reduce overfitting in training.
[0124] f) During the training process, at some periodic intervals with small losses, the sequences generated by the generator in the trained GAN network are subjected to MMD two-sample tests to determine whether to perform early stopping and complete the training of the GAN network. The process of MMD two-sample tests is further explained in detail, noting that the problems to be tested here are:
[0125] H0:P 真实域名 =P 生成域名 ,
[0126] Among them, P 真实域名 and P 生成域名Represent the probability distribution of the real domain name and the domain name generated by the GAN network. In the experiment, by calculating the MMD test statistic and performing Bootstrap sampling, the p-value of the test can be estimated. The smaller the p-value, the greater the confidence in rejecting the null hypothesis. Table 2 lists the p-values calculated based on the corresponding generated samples in some selected training cycles. It can be seen that in the early stage of training, although the generated samples look close to the Alexa domain name, the p-value of the corresponding test is very small. Obviously, the domain name output by the generated network is still different from the real domain name; but in the later stage of training, the p-value increases. If the significance level is selected as 0.05, we can no longer reject the null hypothesis, indicating that from the perspective of statistical testing, we can no longer distinguish whether the generated samples and Alexa samples come from different distributions, which ensures the quality of the generated samples. In summary, the training of the GAN network finally converges after 85 cycles of backpropagation updates.
[0127] Table 2 Generative model MMD two-sample test p-value
[0128] Training cycle 0 10 30 50 85 p-value 0 0.00004 0.0037 0.65 0.997
[0129] (3) Experimental results analysis
[0130] The generator in the GAN model trained in the experiment was used to generate 200,000 data and deduplicated them as a validation dataset for the experimental results analysis. A comparative analysis was conducted on the generated sequence display, generated sequence character frequency distribution, generated sequence length statistics, and their performance in the DGA detector. The specific results are as follows.
[0131] 1) Generate sequence results using the generative adversarial network
[0132] Table 3 below shows the real Alexa domain name, the real DGA domain name, and the character sequence data generated using the adversarial generative network. Through observation, it is found that the length of the generated sequence is variable, and the character sequence representation is already similar to the real DGA domain name and can be used as a domain name.
[0133] Table 3 Comparison of Alexa domain names, real DGA domain names and generated sequences
[0134] Alexa Domain Real DGA domain name Generate Sequence tmall Ekqnou Gritzro google thinkmayor gsivrsjm facebook ufloafhawfq aheshfuffo microsoftonline aaaqbmnansnan apiortwheyhgcw reserver-vos-voy teswpukmvttjigbj pohesrhh1yohhigwa
[0135] 2) Generate sequence and real domain name length distribution diagram
[0136] DGA domain name detectors usually use the length feature of a sequence as a feature to determine whether the sequence is an Alexa domain name or a DGA domain name. Therefore, if the length feature of the generated sequence is similar to that of the real Alexa domain name, it is more likely to evade detection by the DGA domain name detector. Figure 6The figure shows the length distribution of Alexa's real domain names and generated sequences. The horizontal axis represents the length of the domain name sequence, and the vertical axis represents the proportion of domain names of different lengths. It can be seen from the figure that the length distribution of the generated sequence and the real domain name is very close. This feature can effectively avoid some DGA domain name detectors that use domain name length as a detection feature, reducing the probability of the generated sequence being discovered.
[0137] It should be noted here that by analyzing the statistical characteristics of real domain name data, it can be concluded that the length of most normal domain names is within 20 characters. Therefore, when training the model, this article selects the Alexa real domain name with a length of 20 characters as training data, and the length of the generated sequence is also within 20 characters.
[0138] 3) Generate sequence and real domain name length distribution diagram
[0139] Like the sequence length, the character frequency distribution characteristics of the sequence are also important factors for the DGA domain name detector to distinguish between real domain names and DGA domain names. If the character frequency distribution characteristics of the generated sequence can be as similar as possible to the Alexa real domain name, it is very likely to reduce the detection rate. Figure 7 This is the character frequency distribution diagram of Alexa's real domain name and generated sequence. The horizontal axis in the figure represents each character in the domain name sequence, and the vertical axis represents the proportion of each character in all domain name sequences. It can be seen from the figure that the character frequency distribution of the generated sequence is very similar to that of the Alexa domain name, and the probability of evading the DGA domain name detector is relatively high.
[0140] 4) DGA domain name detector verification results
[0141] This paper uses the DGA domain name detector built based on the LSTM network to verify the generated data. Table 4 shows the test results. The specific test process is as follows.
[0142] a) The DGA domain name detector based on LSTM network was trained using real Alexa domain name data and DGA data, and then the real DGA data was used as the validation set. It was found that the accuracy and recall of the model were both above 91%.
[0143] b) After deduplication, the 200,000 sequences generated in this paper were divided into two parts according to the ratio of 1:9. The first part of the data was used as a validation set, mixed with the real domain name data, and then input into the DGA domain name detector trained in a) for verification. It was found that the accuracy and recall rate of the model on the generated data dropped significantly, and the detection performance was significantly reduced, indicating that the generated sequence achieved good results in combating the DGA domain name detector and had a high probability of evading the detection of the model.
[0144] c) using the second part of the generated sequence data, i.e. 90% of the generated data, as a training set and a test set to train the DGA domain name detector;
[0145] d) Verify the trained model in c) on the validation set prepared in b). It can be seen that after training with the generated data, the model finds that the performance of generating sequences has improved again and has almost returned to the previous level.
[0146] Table 4 DGA domain name detector test results
[0147]
[0148] By comparing the generated sequences in terms of character sequence representation, sequence length, and character frequency distribution, as well as using the generated sequences to detect and strengthen the training of the LSTM-based DGA domain name detector, the generated sequences are compared and verified in all aspects. The results fully demonstrate that the generated sequences have both the characteristics of real domain names and the characteristics of being able to fight against existing DGA domain name detectors. Using them can not only effectively solve the problem of insufficient model training data, but also improve the robustness of the model on adversarial malicious domain name data, thus achieving the purpose of this article.
[0149] The collection of malicious domain name datasets is a very important part of training DGA domain name detectors. This paper attempts to combine autoencoders and generative adversarial networks to generate malicious DGA domain name sequences, enrich malicious domain name datasets, and thus improve the performance of the detection model. The feasibility of this method is verified through experiments. The next step of this paper will be to combine existing deep learning technology to continue to improve the domain name feature extraction algorithm, in order to further improve the types and quality of generated domain names, and evaluate the performance of the generated model.
[0150] The embodiments described above are only preferred specific implementation modes of the present invention, and the protection scope of the present invention is not limited thereto. Any simple changes or equivalent replacements of the technical solutions that can be obviously obtained by any technician familiar with the field within the technical scope disclosed in the present invention belong to the protection scope of the present invention.
Claims
1. A method for generating malicious domain name training data based on a generative adversarial network, characterized in that: The steps include: Obtain real domain names and build a domain name dataset; Construct a domain name autoencoder network, input the domain name data set into the domain name autoencoder network for pre-training, and obtain a trained domain name autoencoder network; Use the trained domain name autoencoder network to build a domain name generation adversarial network model, judge the malicious domain name data generated by the domain name generation adversarial network model by comparing the real data with the real data, and output the judgment result; The domain name generation adversarial network model is trained, and the maximum mean difference (MMD) test is used to determine whether the output samples of the domain name generation adversarial network model come from the same distribution as the real domain name. If the test passes, the training is stopped and the malicious domain name training data after training is output; The construction of the domain name autoencoder network includes: The domain name autoencoder network is formed by cascading three parallel convolutional networks and one LSTM network; The n-gram information between the characters of the domain name data is captured by the convolution filter kernel sizes of the three convolutional networks; The LSTM network is used to mine and represent the potential features of variable-length domain name sequences and generate variable-length sequences; The maximum mean difference MMD is specifically defined as: Among them, p and q are two distributions, x and y are the samples generated by p and q respectively, E x ,E y The means of the function values on the two generated samples f are x and y respectively. The difference between the two means is used to obtain the mean difference MeanDiscrepancy of the two distributions corresponding to the function f. The goal of the maximum mean difference is to find an f that maximizes the mean difference, that is, to obtain the maximum mean difference; F is taken as the unit ball of the Hilbert space, and the pre-set kernel functions are used in actual operations.
2. The method for generating malicious domain name training data based on a generative adversarial network according to claim 1, characterized in that: The step of inputting the domain name dataset into the domain name autoencoder for pre-training includes the following steps: Sequence-mark the real domain name and perform one-hot encoding; Input the one-hot encoded sequence into the cascaded convolutional layer, and concatenate the output results of the cascaded convolutional layer in parallel and then input them into another convolutional layer; Inputting the output result of another convolutional layer into a flattening layer, and using the flattening layer to flatten the input sequence into a one-dimensional vector matrix as the output of the encoder; The one-dimensional input sequence is reorganized into a two-dimensional vector matrix through the reconstruction layer; Input the two-dimensional vector matrix into the cascade convolution layer and output it, and then concatenate the output results in parallel and send them into the output convolution layer; Remove the sequence mark from the output convolutional layer to get the original domain name.
3. The method for generating malicious domain name training data based on a generative adversarial network according to claim 1, characterized in that: The method of using the trained domain name autoencoder to construct a domain name generative adversarial network model includes the following steps: Use the decoder to build a GAN network generator and train it; Use the encoder to build the GAN network discriminator and train it; The GAN network generator and the GAN network discriminator form a domain name generation adversarial network model.
4. The method for generating malicious domain name training data based on a generative adversarial network as claimed in claim 3, characterized in that: The network structure of the GAN network generator is composed of a fully connected layer and a decoder. The training steps of constructing the GAN network generator using the decoder and training the GAN network generator include: Use a random noise generator to generate noise uniformly distributed on [-1,1]; The random noise is linearly transformed through the fully connected layer to obtain a dimension consistent with the encoder output dimension; Use the ReLU function to activate the linearly transformed random noise; The activated random noise is fed into the decoder to obtain labeled samples of the output domain name.
5. The method for generating malicious domain name training data based on a generative adversarial network as claimed in claim 3, characterized in that: The network structure of the GAN network discriminator is composed of an encoder and a fully connected layer. The training steps of using the encoder to construct the GAN network discriminator and train it include: The encoder receives and encodes a real Alexa domain name or a fake domain name sequence generated by a generator; Transforming the encoded data into low-dimensional data through a fully connected layer; The low-dimensional data is activated by a Sigmoid function and the result is output.
6. The method for generating malicious domain name training data based on a generative adversarial network according to claim 5, characterized in that: When training the network of the GAN network generator, freezing the weight parameters of the pre-trained encoder, and then training the fully connected network of the GAN network generator; When training the network of the GAN network discriminator, the weight parameters of the pre-trained encoder are frozen, and then the fully connected network of the GAN network discriminator is trained.
7. The method for generating malicious domain name training data based on a generative adversarial network according to claim 1, characterized in that: The domain name generative adversarial network model is trained, and label smoothing and improved loss update are used to improve the stability of model training.
