Domain name adversarial sample generation method and device

The domain name adversarial sample generation algorithm that combines strategic generation and discrimination solves the problems of long iteration cycle and poor robustness of the DGA detection algorithm, and improves the detection capability and timeliness of the detector.

CN114154550BActive Publication Date: 2024-10-18TSINGHUA UNIVERSITY
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111187519.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-10-12
Publication Date
2024-10-18
Estimated Expiration
2041-10-12

AI Technical Summary

Technical Problem

It is difficult for the existing DGA detection algorithm to quickly obtain a sufficient amount of the latest DGA domain name training samples, resulting in a long iteration cycle of the detection model, poor timeliness and robustness, and the existing adversarial sample generation algorithm is ineffective and cannot be effective. Improve the detection capability of the detector.

Method used

Adopt a policy-based domain name adversarial sample generation algorithm, use the generator and language model discriminator to generate domain name adversarial data character by character, and use a binary classifier to determine authenticity, calculate the cross-entropy loss value, and alternately train the generator, discriminator to improve the quality of adversarial examples and the robustness of the detector.

Benefits of technology

By generating high-quality adversarial samples, the detection capability of the DGA detector is enhanced, the iteration cycle is shortened, the detection timeliness and robustness are improved, and the problem of poor adversarial sample generation in the existing technology is solved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114154550B_ABST
    Figure CN114154550B_ABST
Patent Text Reader

Abstract

The present disclosure is about a domain name adversarial sample generation method and device, which relates to the field of network security, including: obtaining a domain name training sample, inputting the domain name training sample into a generator to obtain first domain name adversarial data; inputting the first domain name adversarial data into a binary classifier to obtain the authenticity probability of the domain name training sample, and calculating a first loss value according to the authenticity probability and the real data of the domain name training sample; at each moment when the generator generates the first domain name adversarial data character by character, using a language model discriminator and the domain name training sample, calculating the cross entropy loss value at each moment when the generator generates the first domain name adversarial data character by character; training the generator, the binary classifier and the language model discriminator according to the first loss value and the cross entropy loss value at each moment; generating a domain name adversarial sample based on the trained generator in response to a domain name adversarial sample generation request. The present disclosure improves the timeliness and robustness of detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of network security, and in particular to a method and device for generating domain name adversarial samples. Background Art

[0002] As technology continues to develop, attackers have begun to design machine learning-based DGA algorithms to specifically bypass the detection capabilities of DGA detectors. However, due to the high cost of annotation, it is difficult for existing DGA detection algorithms to quickly obtain sufficient training samples of the latest DGA domain names, and models trained only on limited real-world data sets are difficult to achieve the expected results when dealing with new DGA algorithms, which makes the iteration cycle of the detection model too long, and the timeliness and robustness of the detection are poor. Summary of the invention

[0003] In order to overcome the problems existing in the related art, the present disclosure provides a method and device for generating domain name adversarial samples.

[0004] According to a first aspect of an embodiment of the present disclosure, a method for generating a domain name adversarial sample is provided, comprising:

[0005] Obtain a domain name training sample, and input the domain name training sample into a generator to obtain first domain name adversarial data;

[0006] Inputting the first domain name adversarial data into the binary classifier to obtain the authenticity probability of the domain name training sample, and calculating the first loss value according to the authenticity probability and the real data of the domain name training sample;

[0007] At each moment when the generator generates the first domain name adversarial data character by character, using the language model discriminator and the domain name training sample, calculate the cross entropy loss value at each moment when the generator generates the first domain name adversarial data character by character;

[0008] According to the first loss value and the cross entropy loss value at each moment, the generator, binary classifier and language model discriminator are trained;

[0009] In response to a domain name adversarial sample generation request, a domain name adversarial sample is generated based on the trained generator.

[0010] According to a second aspect of an embodiment of the present disclosure, a domain name adversarial sample generating device is provided, including:

[0011] An acquisition module, used for acquiring a domain name training sample, and inputting the domain name training sample into a generator to obtain first domain name adversarial data;

[0012] A binary judgment module, used for inputting the first domain name adversarial data into a binary classifier to obtain the authenticity probability of the domain name training sample, and calculating a first loss value according to the authenticity probability and the real data of the domain name training sample;

[0013] A language judgment module is used to calculate the cross entropy loss value at each moment when the generator generates the first domain name adversarial data character by character, using the language model discriminator and the domain name training sample;

[0014] A training module, used for training a generator, a binary classifier, and a language model discriminator according to a first loss value and a cross entropy loss value at each moment;

[0015] The generation module is used to respond to domain name adversarial sample generation requests and generate domain name adversarial samples based on the trained generator.

[0016] According to a third aspect of an embodiment of the present disclosure, there is provided an electronic device, including:

[0017] at least one processor; and,

[0018] a memory communicatively coupled to at least one processor; wherein:

[0019] The memory stores instructions that can be executed by at least one processor, and the instructions are executed by at least one processor to enable the at least one processor to perform the method of the first aspect described above.

[0020] According to a fourth aspect of an embodiment of the present disclosure, there is provided a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to enable a computer to execute the method of the aforementioned first aspect.

[0021] The technical solution provided by the embodiments of the present disclosure may have the following beneficial effects:

[0022] By setting up a binary classifier and a language simulation discriminator, the language model discriminator provides more discrimination for the learning of the generator. At the same time, the loss value of the discriminator can be fed back to the generator at the middle moment of domain name generation. The binary classifier is still retained to judge the authenticity of the input domain name, thereby solving the problem that the discriminator can only play a limited guiding role and cannot bring significant improvements to the generator. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0024] Figure 1 A flowchart of a domain name adversarial generation algorithm provided in an embodiment of the present disclosure.

[0025] Figure 2 A flowchart of a method for generating domain name adversarial samples provided in an embodiment of the present disclosure.

[0026] Figure 3 A flowchart of another domain name adversarial sample generation method provided in an embodiment of the present disclosure.

[0027] Figure 4 A loss value feedback flow chart provided for an embodiment of the present disclosure.

[0028] Figure 5 A structural block diagram of a domain name adversarial sample generation device provided in an embodiment of the present disclosure.

[0029] Figure 6 A structural block diagram of another domain name adversarial sample generation device provided in an embodiment of the present disclosure.

[0030] Figure 7 A structural block diagram of an electronic device for a domain name adversarial sample generation method provided in an embodiment of the present disclosure. DETAILED DESCRIPTION

[0031] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Instead, they are merely examples of devices and methods consistent with some aspects of the present invention as detailed in the appended claims.

[0032] It should be noted that with the continuous development of technology, attackers have begun to design DGA (Domain Generation Algorithm) algorithms based on machine learning to specifically bypass the detection capabilities of DGA detectors. However, due to the high cost of annotation, it is difficult for existing DGA detection algorithms to quickly obtain sufficient and latest DGA domain name training samples, and models trained only on limited real-world data sets are difficult to achieve the expected results when dealing with new DGA algorithms, which makes the iteration cycle of the detection model too long, and the detection effectiveness and robustness are poor.

[0033] To solve the above technical problems, researchers have proposed some solutions. Among them, the simplest method is to increase the amount of data annotation and generate sufficient new samples. However, this method has the following disadvantages: it is difficult to formulate rules, and the samples created by the rules are too rigid, which makes it easy for the model to learn a fixed pattern, which is not conducive to improving the generalization performance of the detection model. The most commonly used and effective method is to use the idea of ​​adversarial learning to generate "fake" DGA adversarial sample data to enhance the training set of the detector and strengthen the detector's detection ability for unknown DGA domain names.

[0034] It should be noted that someone first proposed DeepDGA (an algorithm) using this idea. The algorithm uses GAN (generative adversarial network) to generate adversarial samples that are difficult to be recognized by the detector, and uses it to expand the training set of the original detector to enhance the robustness of the model. DeepDGA is pre-trained based on the codec structure of the autoencoder, and uses the original decoder as the generative model and the original encoder as the discriminative model for generative adversarial training. However, the autoencoder structure used by DeepDGA is too simple, resulting in poor results in both generating domain names and distinguishing authenticity. After the advent of DeepDGA, authors have successively proposed MaskDGA (algorithm), DomainGAN (algorithm), Khaos (algorithm) and other algorithms that also use GAN to generate adversarial samples. Among them, the idea of ​​Khaos algorithm is the most innovative and the effect is the best. The author of Khaos found that normal legal domain names are generally composed of syllables and acronyms, so the author believes that a deep learning model can be used to arrange different syllables and acronyms to imitate legal domain names. In addition, the authors of Khaos also took some significant improvement measures, such as using an improved version of GAN, WGAN-GP, to solve the problem of adversarial training being difficult to converge, using the ResNet structure to solve the problem of gradient disappearance during deep network training, and treating "n-gram" (i.e., a processing unit consisting of n consecutive characters) instead of a single character as the basic word-building unit. The combination of these optimization strategies enabled Khaos to beat all other DGA adversarial sample generation algorithms at the time in all indicators. However, the shortcomings of the Khaos algorithm are also obvious. Since its minimum processing unit is "n-gram", it cannot accurately identify DGA domain names generated based on pseudo-random strings.

[0035] At the same time when Khaos was proposed, CharBot (algorithm) was also widely used for its simplicity and black-box nature. The algorithm logic of CharBot is very simple: add simple perturbations to normal domain names (for example, randomly select two characters in the domain name and replace them with other arbitrary characters) to make them unrecognizable by the detector. Experimental verification shows that although the algorithm is simple, it is very effective and does not require relevant knowledge of the target DGA detector. It is a typical black-box model. However, CharBot also has some limitations: first, CharBot is too random, the algorithm is too simple, and the generation quality is poor; second, the availability of DGA adversarial sample data generated by the CharBot algorithm is very low, most of which are registered normal domain names or simple samples that are easily recognized by the detector and do not have adversarial properties. Therefore, simply adding perturbations to normal domain names or malicious domain names to create adversarial samples is incomplete, and it is also necessary to use certain strategies to distinguish them during the generation process and filter out invalid parts to improve the availability of the algorithm.

[0036] The domain name, also known as the network domain, is the name of a computer or a group of computers on the Internet, consisting of a string of names separated by dots, and is used to locate the computer during data transmission.

[0037] It should be noted that since its birth, GAN was first used in the field of images, and soon became a hot topic in the research community; but it has not achieved satisfactory results in the field of NLP (neural linguistic programming). This is because, in the process of natural language generation, the output of the GAN generator needs to sample discrete markers, which makes it impossible for the gradient to be transmitted from the discriminator back to the generator during back propagation, thus hindering the parameter update of the GAN model and making it impossible to complete the training.

[0038] In response to this, scholars have proposed a series of solutions. They believe that the problem of discrete and non-differentiable text generation process can be solved by replacing the Softmax (function) at the end of the GAN generator with Gumbel-Softmax (function). Gumbel-Softmax cleverly simulates the discrete distribution of Softmax with continuous functions by reparameterizing discrete variables, thereby turning the discrete sampling process at the output of GAN into a continuous and differentiable sampling process. This algorithm is highly innovative, but its disadvantages are that it requires a large amount of calculation and is highly complex, which has a certain impact on the speed of the algorithm.

[0039] Based on the above problems, the present disclosure proposes a domain name adversarial sample generation method and device. The present disclosure aims to generate malicious domain names that can invalidate the DGA detector, that is, to generate malicious domain names that can invalidate the DGA detector, so as to achieve the purpose of enhancing the detection effect of the DGA domain name detector.

[0040] Optionally, the present disclosure proposes a policy-based adversarial sample generation algorithm. The algorithm regards the generator as a parameterized stochastic policy and directly optimizes it, thereby using the policy gradient update theorem to circumvent the gradient non-differentiability problem caused by discrete sampling. The algorithm regards the generator as a stochastic policy in reinforcement learning, the character sequence generated so far as the current state, the next character to be generated as the next action, and the evaluation score of the discriminator on the current generated sequence as the returned reward.

[0041] It should be noted that it is a more direct and efficient approach to directly parameterize the strategy and then adjust the parameters to obtain the optimal strategy.

[0042] It should be noted that the embodiment of the present disclosure can learn the character distribution of normal domain names and generate a set of "fake" DGA domain names. The algorithm is named Policy-based DGAN domain name adversarial generation algorithm, referred to as DGAN.

[0043] Figure 1 A flowchart of a domain name adversarial generation algorithm provided in an embodiment of the present disclosure. Figure 2 This is a flowchart of a domain name adversarial sample generation method provided in an embodiment of the present disclosure. It should be noted that the domain name adversarial sample generation method in an embodiment of the present disclosure can be applied to the domain name adversarial sample generation device in an embodiment of the present application. The generation device can be configured on an electronic device.

[0044] like Figure 1 and Figure 2 As shown, the domain name adversarial sample generation method includes the following steps:

[0045] Step 201, obtaining a domain name training sample, and inputting the domain name training sample into a generator to obtain first domain name adversarial data;

[0046] It should be noted that the generator is a shallow Transformer (a model architecture) encoder-decoder that provides powerful feature extraction and text generation capabilities to learn the feature distribution of real legitimate domain names and generate "fake" DGA domain names that can bypass the discriminator.

[0047] Optionally, the domain name training samples are real and legal domain names. The domain name training samples are obtained from the corpus and used as input values ​​of the generator to learn the feature distribution of the domain name training samples, and the output is as close to the domain name training samples as possible based on the feature distribution of the domain name training samples.

[0048] In one implementation, the generator needs to be pre-trained before adversarial training, and the pre-training process of the generator is as follows;

[0049] Given an input sample X, the generator G θ The loss function is as follows, and the pre-training goal is to maximize the following loss function:

[0050]

[0051] The target output Y is the value of the input X offset to the right by one position. When calculating the conditional probability of generating the next character as represented by the above loss function, the algorithm selects the previous character Y in the true value. t-1 Instead of the character y generated by the model t-1 As input, the deviation between training and prediction may continue to accumulate. Therefore, adversarial training is needed to fine-tune the generator and use the feedback from the discriminator to correct the deviation.

[0052] Step 202: input the first domain name adversarial data into a binary classifier to obtain the authenticity probability of the domain name training sample, and calculate the first loss value according to the authenticity probability and the real data of the domain name training sample.

[0053] Among them, the binary classifier is a series of dynamically configurable binary classifiers, which are used to determine whether the input domain name is real. In order to prove that the forged DGA domain name generated by the algorithm is capable of bypassing most detectors, the present invention reproduces a variety of DGA domain name detectors based on a single domain name, and selects several of them with stronger detection capabilities and adds them in parallel to the binary classifier module.

[0054] Step 203, at each moment when the generator generates the first domain name adversarial data character by character, using the language model discriminator and the domain name training sample, calculate the cross entropy loss value at each moment when the generator generates the first domain name adversarial data character by character.

[0055] Among them, the language model discriminator is an LSTM language model that models the distribution of real legal domain names. It is responsible for learning the distribution and composition of real legal domain names. It calculates the current cross entropy loss at each moment when the domain name is generated character by character, and feeds it back as the instant loss value of the current state.

[0056] It should be noted that the design idea of ​​the generator is: if the domain name adversarial data generated by the generator does not match the distribution pattern of the domain name training samples, then when the language model that models the distribution of real legal domain names is used for evaluation, the result will have a high degree of perplexity; if the domain name adversarial data generated by the generator matches the distribution pattern of the domain name training samples, then when the language model that models the distribution of real legal domain names is used for evaluation, the result will have a very low degree of perplexity.

[0057] Among them, perplexity is an evaluation indicator that can be used to evaluate the quality of a language model, and the present disclosure is specifically used to evaluate the quality of domain name adversarial data.

[0058] In one implementation, the language model discriminator needs to be pre-trained before adversarial training. The pre-training process of the language simulation discriminator is:

[0059] The input of the language model discriminator is the real legal domain name (domain name training sample). Given the input domain name X = {x1, x2, ..., x n}, x i represents the i-th character of the domain name. The model learns the distribution probability of the k+1-th character given the first k characters, that is, P(x k+1 |x1,x2,...,x kThere are many ways to solve the conditional probability, such as constructing a statistical language model, a neural network language model, or a language model based on an RNN (Recurrent Neural Network). The method adopted in the present disclosure is to construct an LSTM (Long Short-Term Memory) network to model the input sequence.

[0060] It should be noted that LSTM is a special type of RNN that can learn long-term patterns. LSTM is explicitly designed to avoid the problem of long-term dependencies. All recurrent neural network structures are made up of replicated (neural network) modules with exactly the same structure. In a standard RNN, this repeated module has only a very simple structure, such as a tanh (a function) layer, and LSTM also has a similar structure. But it is no longer just a single tanh layer, but four interacting layers.

[0061] Step 204: train the generator, the binary classifier, and the language model discriminator according to the first loss value and the cross entropy loss value at each moment.

[0062] Step 205: In response to the domain name adversarial sample generation request, generate a domain name adversarial sample based on the trained generator.

[0063] According to the domain name adversarial sample generation method of the embodiment of the present disclosure, since the traditional discriminator only has a binary classifier that provides a probability of being true or false as a loss value, and for the binary classifier, it is very easy to distinguish between real domain names and forged domain names, while it is quite difficult for the generator to generate domain names, the discriminator can only play a limited guiding role and cannot bring significant improvements to the generator. By setting a binary classifier and a language model discriminator, wherein the language model discriminator provides more discrimination for the learning of the generator, and at the same time can feed back the loss value of the discriminator to the generator at the middle moment of domain name generation, the binary classifier is still retained to judge the authenticity of the input domain name, thereby solving the problem that the discriminator can only play a limited guiding role and cannot bring significant improvements to the generator.

[0064] It should be noted that in order to update and improve the generator through training, the generator, binary classifier and language model discriminator can be trained alternately. Figure 3 As shown, according to the first loss value and the cross entropy loss value at each moment, training the generator, the binary classifier and the language model discriminator may include the steps of:

[0065] Step 301, calculate the guidance signal of the generator according to the first loss value and the cross entropy loss value at each moment, and perform a training operation on the generator according to the guidance signal.

[0066] In one implementation, the probability distribution p of the generator at the current moment is θ (y t |Y t-1 , X) as a random strategy to be optimized, and define r t is the loss value fed back by the discriminator at time t, then the training goal of the generator in the adversarial training stage is to maximize the expected cumulative reward. The expected cumulative reward function formula of the generator is:

[0067]

[0068] Use the policy gradient theorem to solve the above objective function:

[0069]

[0070] In the formula, r t The cross entropy loss value at each moment, p θ (y t |Y t-1 , X) is the probability distribution of the generator at the current moment, X is the domain name training sample, Y is the domain name adversarial data, θ is the sequence length of the generator T to generate the entire sequence (it can also be understood as a moment, that is, an element in the generated sequence is a moment), t is a moment in the generation process, and y is the model prediction value generated by the generator.

[0071] Among them, Figure 4 As shown, r t Provided jointly by two types of discriminators, during the domain name generation process, the loss value is provided by the language model discriminator, i.e., r t<T =logD LM (y t |Y <T ); After the domain generation is completed, the loss value is provided by the binary classifier, i.e. r T =D CLS (Y 1:T ).

[0072] Step 302, fix the parameters of the generator, and input the domain name training sample into the generator to obtain the second domain name adversarial data, and perform a training operation on the language simulation discriminator and the binary classifier respectively according to the second domain name adversarial data; wherein the language simulation discriminator is trained using the cross entropy loss value and the domain name training sample at each moment; and the binary classifier is trained using the first loss value and the second domain name adversarial data.

[0073] It should be noted that the language simulation discriminator provides a loss value for the generator at each moment when the domain name is generated character by character. Therefore, during the training process, there is no need to use the domain name adversarial data generated by the generator. The main thing is to continue training with real and legal domain name training samples and complete the training operation through the cross entropy loss value at each moment.

[0074] Among them, the language simulation discriminator feeds back the loss value to the generator at the intermediate moment of each domain name adversarial data generation, that is, in the domain name generation process, the loss value is provided by the language model discriminator.

[0075] The binary classifier provides a judgment result at the end of each domain name adversarial data generation, that is, after the domain name generation is completed, the loss value is provided by the binary classifier.

[0076] It should be noted that the optimization goal of the binary classifier is to minimize the sum of single sample classification errors, and the formula is:

[0077]

[0078] where y i Refers to the input of the binary classifier, that is, the domain name training sample or the domain name adversarial data generated by the generator, label i is the label of the input sample, indicating its authenticity, R θ represents the regularization term, function f represents the prediction result of the specific discriminant model, L i Represents the classification error of a single sample. It should be noted that, depending on the different discriminant models used by the binary classifier module, the objective function and solution method of this optimization goal are slightly different.

[0079] Step 303, execute the training operations of the generator, language model discriminator and binary classifier in the above operations in a sequential loop iteration, wherein when the generator is trained, the parameters of the binary classifier and the language model discriminator are fixed, and when the binary classifier and the language model discriminator are trained, the parameters of the generator are fixed.

[0080] As an example, after the generator completes the training operation through the first loss value and the cross entropy loss value at each moment, the updated generator parameters are fixed, the domain name training sample is obtained, and the domain name training sample is input into the generator, and the generator outputs the second domain name adversarial data. The language model discriminator continuously uses normal and legal domain name training samples as training data, implements the training operation of the language model discriminator according to the training data, and fixes the updated language model discriminator parameters until the next language model discriminator training is completed. The binary classifier obtains the authenticity probability of the domain name adversarial data by obtaining the second domain name adversarial data, and after the domain name adversarial data generation is completed, the first loss value is calculated based on the authenticity probability and the real data of the domain name training sample. The binary classifier completes the training operation with the domain name training sample through the first loss value, and the updated binary classifier parameters are fixed until the next binary classifier training is completed. Finally, the training operations of the generator, language model discriminator and binary classifier in the above operations are performed in a sequential loop iteration. When the generator is trained, the parameters of the binary classifier and the language model discriminator are fixed, and when the binary classifier and the language model discriminator are trained, the parameters of the generator are fixed.

[0081] According to the domain name adversarial sample generation method of the embodiment of the present disclosure, the generator, language model discriminator and binary classifier are trained in an alternating training manner, thereby ensuring that the generator can be greatly improved while ensuring accuracy and low complexity, and preventing the situation where most of the loss values ​​provided by the binary classifier are zero, resulting in the generator being unable to undergo significant changes.

[0082] In order to implement the above embodiments, the present disclosure also proposes a domain name adversarial sample generation device.

[0083] Figure 5 This is a structural block diagram of a domain name adversarial sample generation device provided by an embodiment of the present disclosure. Figure 5 As shown, the domain name adversarial sample generating device may include: an acquisition module 510, a binary judgment module 520, a language judgment module 530, a training module 540 and a generation module 550.

[0084] The acquisition module 510 is used to acquire a domain name training sample, and input the domain name training sample into the generator to obtain first domain name adversarial data.

[0085] The binary judgment module 520 is used to input the first domain name adversarial data into the binary classifier to obtain the authenticity probability of the domain name training sample, and calculate the first loss value according to the authenticity probability and the real data of the domain name training sample. In one implementation, the binary classifier provides a judgment result when the domain name adversarial data generation is completed, that is, after the domain name generation is completed, the loss value is provided by the binary classifier.

[0086] The language determination module 530 is used to calculate the cross entropy loss value at each moment when the generator generates the first domain name adversarial data character by character, using the language model discriminator and the domain name training sample.

[0087] The training module 540 is used to train the generator, the binary classifier and the language model discriminator according to the first loss value and the cross entropy loss value at each moment.

[0088] The generation module 550 is used to respond to the domain name adversarial sample generation request and generate the domain name adversarial sample based on the trained generator.

[0089] According to the domain name adversarial sample generation device of the embodiment of the present disclosure, since the traditional discriminator only has a binary classifier that provides a probability of true or false as a loss value, and for the binary classifier, it is very easy to distinguish between real domain names and forged domain names, while it is quite difficult for the generator to generate domain names, the discriminator can only play a limited guiding role and cannot bring significant improvements to the generator. By setting a binary classifier and a language model discriminator, wherein the language model discriminator provides more discrimination for the learning of the generator, and at the same time can feed back the loss value of the discriminator to the generator at the middle moment of domain name generation, the binary classifier is still retained to judge the authenticity of the input domain name, thereby solving the problem that the discriminator can only play a limited guiding role and cannot bring significant improvements to the generator.

[0090] In some embodiments of the present disclosure, Figure 6 As shown, Figure 6 This is a structural block diagram of a domain name adversarial sample generating device according to another embodiment of the present disclosure. The training module 640 in the domain name adversarial sample generating device includes: a generation training unit 641, a language training unit 642, a binary training unit 643 and a loop unit 644.

[0091] The training generating unit 641 is used to calculate the guidance signal of the generator according to the first loss value and the cross entropy loss value at each moment, and perform a training operation on the generator according to the guidance signal. In one implementation, the calculation formula of the expected cumulative reward function of the generator is:

[0092]

[0093] In the formula, r t The cross entropy loss value at each moment, p θ (y t |Y t-1 ,X) is the generator probability distribution at the current moment, X is the domain name training sample, Y is the domain name adversarial data, T refers to the sequence length of the entire sequence (it can also be understood as a moment, that is, an element in the generated sequence is a moment), t is a moment in the generation process, and y is the model prediction value generated by the generator.

[0094] The discriminator training unit 642 is used to fix the parameters of the generator, input the domain name training sample into the generator to obtain the second domain name adversarial data, and perform a training operation on the language simulation discriminator and the binary classifier respectively according to the second domain name adversarial data; wherein the language simulation discriminator is trained using the cross entropy loss value and the domain name training sample at each moment; and the binary classifier is trained using the first loss value and the second domain name adversarial data.

[0095] It should be noted that the language simulation discriminator provides a loss value for the generator at each moment when the domain name is generated character by character. Therefore, during the training process, there is no need to use the domain name adversarial data generated by the generator. The main thing is to continue training with real and legal domain name training samples and complete the training operation through the cross entropy loss value at each moment.

[0096] Among them, the language simulation discriminator feeds back the loss value to the generator at the intermediate moment of each domain name adversarial data generation, that is, in the domain name generation process, the loss value is provided by the language model discriminator.

[0097] The binary classifier provides a judgment result at the end of each domain name adversarial data generation, that is, after the domain name generation is completed, the loss value is provided by the binary classifier.

[0098] It should be noted that the optimization goal of the binary classifier is to minimize the sum of single sample classification errors, and the formula is:

[0099]

[0100] where y i Refers to the input of the binary classifier, that is, the domain name training sample or the domain name adversarial data generated by the generator, label i is the label of the input sample, indicating its authenticity, R θ represents the regularization term, function f represents the prediction result of a specific discriminant model (such as LSTM.MI or D3N.CNN), L i Represents the classification error of a single sample. It should be noted that, depending on the different discriminant models used by the binary classifier module, the objective function and solution method of this optimization goal are slightly different.

[0101] The loop unit 643 is used to perform the training operations of the generator, language model discriminator and binary classifier in the above operations in a sequential loop iteration, wherein when the generator is trained, the parameters of the binary classifier and the language model discriminator are fixed, and when the binary classifier and the language model discriminator are trained, the parameters of the generator are fixed.

[0102] According to the domain name adversarial sample generation device of the embodiment of the present disclosure, by adopting the form of alternating training to train the generator, language model discriminator and binary classifier, it is ensured that while ensuring accuracy and low complexity, a significant improvement can be brought to the generator, preventing the situation where most of the loss values ​​provided by the binary classifier are zero, resulting in the generator being unable to obtain significant changes.

[0103] in, Figure 6 Medium 610-650 and Figure 5 510-550 have the same function and structure.

[0104] Figure 7 700 is a block diagram of an electronic device for generating a domain name adversarial sample according to an exemplary embodiment. For example, the device 700 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.

[0105] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device and a readable storage medium.

[0106] like Figure 7 , is a block diagram of an electronic device for implementing a domain name adversarial sample generation method according to an embodiment of the present disclosure. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.

[0107] like Figure 7As shown, the electronic device includes: one or more processors 701, a memory 702, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. The various components are interconnected using different buses and can be installed on a common mainboard or installed in other ways as needed. The processor can process instructions executed in the electronic device, including instructions stored in or on the memory to display the graphical information of the GUI on an external input / output device (such as a display device coupled to the interface). In other embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple electronic devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 7 A processor 701 is taken as an example.

[0108] The memory 702 is a non-transitory computer-readable storage medium provided by the present disclosure. The memory stores instructions executable by at least one processor to enable at least one processor to perform the domain name adversarial sample generation method provided by the present disclosure. The non-transitory computer-readable storage medium of the present disclosure stores computer instructions, which are used to enable a computer to perform the domain name adversarial sample generation method provided by the present disclosure.

[0109] The memory 702 is a non-transient computer-readable storage medium that can be used to store non-transient software programs, non-transient computer executable programs and modules, such as the program instructions / modules corresponding to the domain name adversarial sample generation method in the embodiment of the present disclosure (for example, the attached Figure 5 The processor 701 executes various functional applications and data processing of the server by running the non-transient software programs, instructions and modules stored in the memory 702, that is, the domain name adversarial sample generation method in the above method embodiment is implemented.

[0110] The memory 702 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and applications required for at least one function; the data storage area may store data created according to the use of an electronic device for a domain name adversarial sample generation method, etc. In addition, the memory 702 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory 702 may optionally include a memory remotely disposed relative to the processor 701, and these remote memories may be connected to the electronic device for domain name adversarial sample generation via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0111] The electronic device used for the domain name adversarial sample generation method may further include: an input device 703 and an output device 704. The processor 701, the memory 702, the input device 703 and the output device 704 may be connected via a bus or other means. Figure 7 The example of connecting through bus is taken in the following.

[0112] The input device 703 can receive input digital or character information, and generate key signal input related to user settings and function control of the electronic device for generating domain name adversarial samples, such as a touch screen, a keypad, a mouse, a trackpad, a touchpad, an indicator rod, one or more mouse buttons, a trackball, a joystick and other input devices. The output device 704 may include a display device, an auxiliary lighting device (e.g., an LED) and a tactile feedback device (e.g., a vibration motor), etc. The display device may include, but is not limited to, a liquid crystal display (LCD), a light emitting diode (LED) display and a plasma display. In some embodiments, the display device may be a touch screen.

[0113] Various implementations of the systems and techniques described herein can be realized in digital electronic circuit systems, integrated circuit systems, dedicated ASICs (application specific integrated circuits), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0114] These computer programs (also referred to as programs, software, software applications, or code) include machine instructions for programmable processors and can be implemented using high-level procedural and / or object-oriented programming languages, and / or assembly / machine languages. As used herein, the terms "machine-readable medium" and "computer-readable medium" refer to any computer program product, device, and / or means (e.g., disk, optical disk, memory, programmable logic device (PLD)) for providing machine instructions and / or data to a programmable processor, including a machine-readable medium that receives machine instructions as a machine-readable signal. The term "machine-readable signal" refers to any signal for providing machine instructions and / or data to a programmable processor.

[0115] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).

[0116] The systems and techniques described herein can be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), the Internet, and a blockchain network.

[0117] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship between the client and the server is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services ("Virtual Private Server", or "VPS" for short). The server may also be a server of a distributed system, or a server combined with a blockchain.

[0118] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this application can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution disclosed in this disclosure can be achieved, and this document is not limited here.

[0119] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.

Claims

1. A method for generating domain name adversarial samples, characterized by: Obtaining a domain name training sample, and inputting the domain name training sample into a generator to obtain first domain name adversarial data; Inputting the first domain name adversarial data into a binary classifier to obtain the authenticity probability of the domain name training sample, and calculating a first loss value according to the authenticity probability and the real data of the domain name training sample; At each moment when the generator generates the first domain name adversarial data character by character, using a language model discriminator and the domain name training sample, calculating a cross entropy loss value at each moment when the generator generates the first domain name adversarial data character by character; According to the first loss value and the cross entropy loss value at each moment, training the generator, the binary classifier and the language model discriminator; In response to a domain name adversarial sample generation request, generate a domain name adversarial sample based on a trained generator; The training of the generator, the binary classifier and the language model discriminator according to the first loss value and the cross entropy loss value at each moment includes: Calculating a guidance signal of the generator according to the first loss value and the cross entropy loss value at each moment, and performing a training operation on the generator according to the guidance signal; The parameters of the generator are fixed, and the domain name training sample is input into the generator to obtain the second domain name adversarial data, and the language model discriminator and the binary classifier are respectively trained once according to the second domain name adversarial data; wherein the language model discriminator is trained using the cross entropy loss value at each moment and the domain name training sample; and the binary classifier is trained using the first loss value and the second domain name adversarial data; The training operations of the generator, the language model discriminator and the binary classifier in the above operations are performed in a sequential loop iteration, wherein when the generator is trained, the parameters of the binary classifier and the language model discriminator are fixed, and when the binary classifier and the language model discriminator are trained, the parameters of the generator are fixed.

2. The method according to claim 1, characterized in that The calculation formula of the expected cumulative reward function of the generator is: In the formula, The cross entropy loss value at each moment, is the generator probability distribution at the current moment, X is the domain name training sample, Y is the domain name adversarial data, is the generator, T is the sequence length of the entire sequence, t is a moment in the generation process, and y is the model prediction value generated by the generator.

3. The method according to claim 1, characterized in that The objective function of the binary classifier is: In the formula, Refers to the input of the binary discriminator, is the label of the input sample indicating its authenticity, represents the regularization term, and the function f represents the prediction result of the specific discriminant model. Represents the classification error of a single sample.

4. A domain name adversarial sample generation device, characterized by: An acquisition module, used for acquiring a domain name training sample, and inputting the domain name training sample into a generator to obtain first domain name adversarial data; A binary judgment module, used for inputting the first domain name adversarial data into a binary classifier to obtain the authenticity probability of the domain name training sample, and calculating a first loss value according to the authenticity probability and the real data of the domain name training sample; A language determination module, configured to calculate a cross entropy loss value at each moment when the generator generates the first domain name adversarial data character by character, using a language model discriminator and the domain name training sample; A training module, used for training the generator, the binary classifier and the language model discriminator according to the first loss value and the cross entropy loss value at each moment; The generation module is used to respond to the domain name adversarial sample generation request and generate domain name adversarial samples based on the trained generator; The training module comprises: Generate a training unit, configured to calculate a guidance signal of the generator according to the first loss value and the cross entropy loss value at each moment, and perform a training operation on the generator according to the guidance signal; A discriminator training unit, used to fix the parameters of the generator, input the domain name training sample into the generator to obtain the second domain name adversarial data, and perform a training operation on the language model discriminator and the binary classifier respectively according to the second domain name adversarial data; wherein the language model discriminator is trained using the cross entropy loss value at each moment and the domain name training sample; and the binary classifier is trained using the first loss value and the second domain name adversarial data; A loop unit is used to perform the training operations of the generator, the language model discriminator and the binary classifier in the above operations in a sequential loop iteration, wherein when the generator is trained, the parameters of the binary classifier and the language model discriminator are fixed, and when the binary classifier and the language model discriminator are trained, the parameters of the generator are fixed.

5. The device according to claim 4, characterized in that The calculation formula of the expected cumulative reward function of the generator is: In the formula, The cross entropy loss value at each moment, is the generator probability distribution at the current moment, X is the domain name training sample, Y is the domain name adversarial data, is the generator, T refers to the sequence length of the entire sequence, t is a moment in the generation process, and y is the model prediction value generated by the generator.

6. The device according to claim 4, characterized in that The objective function of the binary classifier is: In the formula, Refers to the input of the binary discriminator, is the label of the input sample indicating its authenticity, represents the regularization term, and the function f represents the prediction result of the specific discriminant model. Represents the classification error of a single sample.

7. An electronic device, characterized in that: include; at least one processor; as well as, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 3.

8. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1 to 3.

Citation Information

Patent Citations

  • Adversarial generative network for defending text malicious sample and training method thereof

    CN111046673A

  • Zero-sample image recognition method and system based on generative adversarial network

    CN111476294A