Domain name sample generation method and device, storage medium and electronic device
By combining variational autoencoders and generative adversarial networks, higher-quality simulated domain name samples are generated, which solves the problems of insufficient diversity and poor authenticity in domain name sample generation methods and improves the recognition accuracy of the domain name detection model.
Patent Information
- Application Number
- CN202510888569.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-30
- Publication Date
- 2025-09-30
- Estimated Expiration
- 2045-06-30
AI Technical Summary
The domain name sample generation method in the existing technology has problems of insufficient diversity and poor authenticity, resulting in insufficient recognition accuracy of the domain name detection model.
By converting reference domain name samples into reference domain name vectors, using variational autoencoders for latent space encoding, combining with generative adversarial networks to generate simulated domain name samples, and decoding them into simulated domain name samples through variational autoencoders, the diversity and authenticity of the samples are improved.
The generated simulated domain name samples are closer to real malicious domain names, enriching the sample data set used to train the domain name detection model and improving the recognition ability of the domain name detection model.
Smart Images

Figure CN120416219B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of network security, and more specifically, to a method and apparatus for generating domain name samples, a storage medium, and an electronic device. Background Art
[0002] In the field of network security, attackers often use Domain Generation Algorithms (DGAs) to dynamically generate large numbers of simulated domain names (also known as generated or malicious domain names) to evade security detection. To improve network security, domain name detection models can be used to verify the legitimacy of domain names and block detected illegal domain names. To improve the domain name detection model's ability to identify simulated domain names, simulated domain name samples can be used to train the model.
[0003] However, with the continuous evolution of domain name generation algorithms, the generated simulated domain names are not only more difficult to predict, but also exhibit a high degree of randomness and deceptiveness in character selection and arrangement. Therefore, these simulated domain names are detected relatively infrequently in real-world environments, and domain names change rapidly, making it difficult for researchers to collect sufficient samples for detection model training. To obtain sufficient simulated domain name samples, generative adversarial networks can be used to generate simulated domain name samples for model training. In theory, generative adversarial networks can simulate and generate samples close to real-world data through an adversarial learning process between their generator and discriminator. However, in related technologies, the simulated domain name samples generated by generative adversarial networks lack diversity and authenticity, which in turn affects the recognition accuracy of the trained domain name detection model.
[0004] It can be seen from this that the domain name sample generation method in the relevant technology has technical problems such as insufficient diversity and poor authenticity. Summary of the Invention
[0005] The embodiments of the present application provide a domain name sample generation method and apparatus, a storage medium, and an electronic device to at least address the technical problems of insufficient diversity and poor authenticity in domain name sample generation methods in related technologies.
[0006] According to one aspect of an embodiment of the present application, a domain name sample generation method is provided, including: converting a reference domain name sample into a reference domain name vector corresponding to the reference domain name sample, wherein the reference domain name sample is a real domain name; performing latent space encoding on the reference domain name vector through an encoder module of a variational autoencoder to obtain a target latent variable corresponding to the reference domain name vector; mixing the target latent variable with a first random noise, and inputting the obtained mixed variable into a generator of a generative adversarial network to obtain a simulated domain name vector output by the generator; and decoding the simulated domain name vector into a simulated domain name sample corresponding to the simulated domain name vector through a decoder module of the variational autoencoder.
[0007] According to another aspect of an embodiment of the present application, a domain name sample generation device is also provided, including: a conversion unit, configured to convert a reference domain name sample into a reference domain name vector corresponding to the reference domain name sample, wherein the reference domain name sample is a real domain name; an encoding unit, configured to perform latent space encoding on the reference domain name vector through an encoder module of a variational autoencoder to obtain a target latent variable corresponding to the reference domain name vector; an execution unit, configured to mix the target latent variable with a first random noise, and input the obtained mixed variable into a generator of a generative adversarial network to obtain a simulated domain name vector output by the generator; and a decoding unit, configured to decode the simulated domain name vector into a simulated domain name sample corresponding to the simulated domain name vector through a decoder module of the variational autoencoder.
[0008] In an exemplary embodiment, the encoder module of the variational autoencoder includes a first fully connected layer and a second fully connected layer; the encoding unit includes: a first execution module, used to linearly transform the reference domain name vector using a first set of network parameters through the first fully connected layer, and activate the reference domain name vector after the linear transformation using a nonlinear activation function to obtain an intermediate latent vector, wherein the first set of network parameters includes a first weight matrix and a first bias vector; an input module, used to input the intermediate latent vector into the second fully connected layer, so that the second fully connected layer uses the second set of network parameters to calculate the mean of the latent space and the logarithmic variance of the latent space using the third set of network parameters to obtain a target mean and a target logarithmic variance, wherein the second set of network parameters includes a second weight matrix and a second bias vector, and the third set of network parameters includes a third weight matrix and a third bias vector; a determination module, used to determine the target latent variable based on the target mean and the target logarithmic variance.
[0009] In an exemplary embodiment, the device further includes: a first sampling unit, configured to randomly sample the first uniform distribution to obtain the second weight matrix and the third weight matrix, wherein the maximum value of the first uniform distribution is the quotient of the square root of six divided by the square root of the sum of the first number of neurons, the minimum value of the first uniform distribution is the negative of the maximum value of the first uniform distribution, the sum of the first number of neurons is the number of input neurons of the second fully connected layer plus the number of first output neurons, and the first number of output neurons is the number of output neurons of the second fully connected layer corresponding to the target mean; a second sampling unit, configured to randomly sample the second uniform distribution to obtain the second bias vector and the third bias vector, wherein the maximum value of the second uniform distribution is the quotient of the square root of six divided by the square root of the sum of the second number of neurons, the minimum value of the second uniform distribution is the negative of the maximum value of the second uniform distribution, the sum of the second number of neurons is the number of input neurons of the second fully connected layer plus the number of second output neurons, and the second number of output neurons is the number of output neurons of the second fully connected layer corresponding to the target logarithmic variance.
[0010] In an exemplary embodiment, the determination module includes: a sampling submodule for sampling random noise from a standard normal distribution to obtain a second random noise; a determination submodule for determining the sum of the result of element-by-element multiplication of the target standard deviation and the second random noise and the target mean as the target latent variable, wherein the target standard deviation is the standard deviation obtained by taking the square root of the variance obtained by performing an exponential operation on the target logarithmic variance.
[0011] In an exemplary embodiment, the conversion unit includes: a processing module for normalizing the string length of the reference domain name sample, wherein the string length of the reference domain name sample after normalization is M, where M is a positive integer greater than or equal to 2; a conversion module for performing character conversion on the normalized reference domain name sample according to a preset character set to obtain the reference domain name sample after character conversion, wherein the preset character set includes N preset characters, and characters in the normalized reference domain name sample that do not belong to the preset character set are converted into preset characters specified in the preset character set, where N is a positive integer greater than or equal to 2; an encoding module for performing one-hot encoding on the reference domain name sample after character conversion to obtain the reference domain name vector, wherein the reference domain name vector is an M×N dimensional matrix.
[0012] In an exemplary embodiment, the processing module includes: a truncation submodule, which is used to truncate the reference domain name sample when the string length of the reference domain name sample is greater than M, so as to obtain the normalized reference domain name sample; and a padding submodule, which is used to pad the reference domain name sample with specified characters when the string length of the reference domain name sample is less than M, so as to obtain the normalized reference domain name sample.
[0013] In an exemplary embodiment, the network layer structure of the decoder module of the variational autoencoder is symmetrical with the network layer structure of the encoder module of the variational autoencoder, and the decoder module of the variational autoencoder includes multiple fully connected layers; the decoding unit includes: a second execution module, which is used to perform the following reverse decoding operation on the simulated domain name vector through the decoder module of the variational autoencoder to obtain a simulated domain name decoding vector: the simulated domain name vector is gradually mapped back to the data space corresponding to the reference domain name vector through multiple fully connected layers of the decoder module of the variational autoencoder, wherein the simulated domain name decoding vector is an M×N dimensional matrix; a decoding module, which is used to perform one-hot decoding on the simulated domain name decoding vector to obtain the simulated domain name sample.
[0014] According to another aspect of the embodiments of the present application, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program is configured to perform the steps of any of the above method embodiments when executed by a processor.
[0015] According to another aspect of the embodiments of the present application, a computer program product or computer program is provided, the computer program product or computer program including computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the steps of any of the above-described method embodiments.
[0016] According to another aspect of the embodiments of the present application, an electronic device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute the steps of any of the above method embodiments through the computer program.
[0017] Through this application, the reference domain name sample is converted into a reference domain name vector corresponding to the reference domain name sample, wherein the reference domain name sample is a real domain name; the reference domain name vector is latently encoded by the encoder module of the variational autoencoder to obtain a target latent variable corresponding to the reference domain name vector; the target latent variable is mixed with the first random noise, and the obtained mixed variable is input into the generator of the generative adversarial network to obtain a simulated domain name vector output by the generator; the simulated domain name vector is decoded into a simulated domain name sample corresponding to the simulated domain name vector by the decoder module of the variational autoencoder. Due to the combination of the generative adversarial network and the variational autoencoder, the latent variable that can better reflect the characteristics of the reference domain name sample is obtained by the variational autoencoder, and this is used as the input of the generative adversarial network, thereby obtaining a higher quality simulated domain name sample. Therefore, the technical problems of insufficient diversity and poor authenticity in the domain name sample generation method in the related art can be solved, and the technical effect of improving the diversity and authenticity of the generated domain name samples can be achieved. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] Figure 1 This is a schematic diagram of an application scenario of a domain name sample generation method according to an embodiment of the present application;
[0019] Figure 2 This is a flowchart of an optional domain name sample generation method according to an embodiment of the present application;
[0020] Figure 3 This is a structural block diagram of an optional domain name sample generating device according to an embodiment of the present application;
[0021] Figure 4 This is a block diagram of a computer system structure of an optional electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0022] In order to enable those skilled in the art to better understand the present invention, the following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of this application.
[0023] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in a sequence other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0024] According to one aspect of the embodiment of the present application, a domain name sample generation method is provided. Optionally, in this embodiment, the domain name sample generation method can be applied to, but is not limited to, Figure 1 The hardware environment shown includes a terminal device 102 and a server 104. The server 104 can be connected to the terminal device 102 via a network and can be used to provide services (e.g., application services, etc.) for the terminal device 102 or a client installed on the terminal device 102. A database can be set on the server 104 or independently of the server 104 to provide data storage services for the server 104.
[0025] The aforementioned network may include, but is not limited to, at least one of the following: a wired network and a wireless network. The aforementioned wired network may include, but is not limited to, at least one of the following: a wide area network, a metropolitan area network, or a local area network. The aforementioned wireless network may include, but is not limited to, at least one of the following: wireless fidelity (Wi-Fi) and Bluetooth. The terminal device 102 may be, but is not limited to, a personal computer (PC), a mobile phone, a tablet computer, etc. The server 104 may be, but is not limited to, a cloud server, a server cluster, or other server types.
[0026] The domain name sample generation method of the embodiment of the present application can be executed by the server 104, or by the terminal device 102, or jointly by the server 104 and the terminal device 102. The domain name sample generation method of the embodiment of the present application can also be executed by a client installed on the terminal device 102.
[0027] Taking the example of the domain name sample generation method in this embodiment executed by the terminal device 102, Figure 2 FIG. 1 is a flow chart of an optional domain name sample generation method according to an embodiment of the present application, such as Figure 2 As shown, the process of the method may include the following steps:
[0028] Step S202: converting the reference domain name sample into a reference domain name vector corresponding to the reference domain name sample, wherein the reference domain name sample is a real domain name;
[0029] Step S204: performing latent space encoding on the reference domain name vector through the encoder module of the variational autoencoder to obtain a target latent variable corresponding to the reference domain name vector;
[0030] Step S206: Mix the target latent variable with the first random noise, and input the obtained mixed variable into the generator of the generative adversarial network to obtain a simulated domain name vector output by the generator;
[0031] Step S208: decode the simulated domain name vector into a simulated domain name sample corresponding to the simulated domain name vector through the decoder module of the variational autoencoder.
[0032] The domain name sample generation method in this embodiment can be applied to the field of network security, and applied to the scenario of generating simulated domain name samples for training domain name detection models.
[0033] In the field of cybersecurity, attackers often use domain name generation algorithms to create simulated malicious domain names to evade security detection. These malicious domain names may be used for malicious activities such as malware distribution, hiding command and control servers, and stealing data. Traditional domain name generation algorithms are mostly based on simple rules or specific random generation algorithms, making them easily detected by security systems using machine learning models.
[0034] However, as domain name generation algorithms continue to evolve, the resulting malicious domain names are not only more difficult to predict, but also exhibit a high degree of randomness and deceptiveness in character selection and arrangement, making them difficult for security systems to detect. To improve network security, domain name detection models are needed to verify the legitimacy of domain names. To improve the detection model's ability to identify malicious domains, a large number of malicious domain name samples are required for training. However, due to the relatively low detection frequency of these malicious domains in real-world environments and the rapid changes in domain names, researchers are unable to collect sufficient samples for detection model training, which in turn affects the accuracy and efficiency of security systems equipped with domain name detection models.
[0035] To obtain sufficient malicious domain examples and address the limited number of training samples, a generative adversarial network (GAN) can be used to generate simulated domain examples for model training. A GAN is a deep learning model that generates data through adversarial training between a generator and a discriminator. The principle is that the generator generates simulated data with the goal of deceiving the discriminator, while the discriminator distinguishes whether the input data is real or fabricated by the generator. The generator and discriminator dynamically optimize through a zero-sum game, ultimately enabling the generator to produce simulated data that is indistinguishable from the real thing.
[0036] In theory, generative adversarial networks (GANs) can simulate and generate simulated domain name samples that closely resemble real malicious domain names through an adversarial learning process between their generator and discriminator. However, the simulated domain name samples generated by GANs in related art fail to fully capture the complex and changing characteristics of real malicious domain names. The generated samples still lack diversity, complexity, and authenticity, making them unsuitable as ideal training samples for domain name detection models. Therefore, the simulated domain name samples generated in related art are insufficient in simulating the characteristics of malicious domain names and differ significantly from the characteristics of real malicious domain names, making them unsuitable for serving as high-quality training samples for domain name detection models.
[0037] In order to at least partially solve the above technical problems, in this embodiment, a generative adversarial network and a variational autoencoder are combined. The latent space encoding capability of the variational autoencoder is used to generate latent variables that can better reflect the characteristics of the reference domain name samples. This is used as the input of the generative adversarial network, so that the generated simulated domain name samples are closer to real malicious domain names, thereby enriching the sample data set used to train the domain name detection model.
[0038] A variational autoencoder is a generative model that combines an autoencoder and variational inference. It can learn the latent representation of data and generate new data with a distribution similar to the original data. It can compress input data into low-dimensional latent variables. Latent variables represent the latent representation of data and can capture the essential characteristics of the data. They are usually defined as random variables such as Gaussian distributions.
[0039] The input to the variational autoencoder needs to be in vector form, while domain names are typically in string form. In this embodiment, the reference domain name samples need to be converted into reference domain name vectors corresponding to the reference domain name samples. The reference domain name samples are real domain names. Since the generated simulated domain name samples are used to train a domain name detection model for detecting malicious domains, the reference domain name samples here are also the real malicious domain names mentioned above.
[0040] Here, the method of converting the reference domain name sample in string form into a reference domain name vector in vector form may include but is not limited to one-hot encoding, embedded encoding or frequency vector encoding, etc., and can be set according to specific application requirements, for example, whether it is necessary to retain the character order, character set size, data dimension considerations and computing resource limitations, etc., which are not limited in this embodiment.
[0041] After this, the reference domain vector can be input into the variational autoencoder. The encoder module of the variational autoencoder performs latent space encoding on the reference domain vector, mapping it to a low-dimensional latent space to obtain the target latent variable corresponding to the reference domain vector. Here, the encoding process of the variational autoencoder can help capture the core features and underlying structure of the reference domain sample.
[0042] After obtaining the target latent variable, the target latent variable is mixed with the first random noise and the resulting mixed variable is input into the generator of the generative adversarial network to obtain the simulated domain name vector output by the generator. Here, the first random noise is noise randomly sampled from a normal distribution with the same dimension as the latent variable. The target latent variable and the first random noise are mixed by concatenation. For example, if the latent variable is (1, 0, 1) and the first random noise is (2, 3, 4), the resulting mixed variable is (1, 0, 1, 2, 3, 4).
[0043] Here, let the mixed variable z be the value of the generator. The generator of the generative adversarial network receives the mixed variable z and generates a fake simulated domain name vector G(z). A generative adversarial network consists of a generator and a discriminator. The generator's goal is to generate fake domain names that are as similar as possible to real domain names, and to create fake domain names that the discriminator cannot distinguish. The discriminator attempts to distinguish between real domain names and fake domain names generated by the generator. It should be noted that the discriminator is only used in the training phase of the generative adversarial network. In actual use, only the trained generator is used, and the discriminator is not required.
[0044] Optionally, during training, the objective function of the generator is as shown in formula (1):
[0045] ; (1)
[0046] The objective function of the discriminator is shown in formula (2):
[0047] ; (2)
[0048] Among them, D represents the discriminator, G represents the generator, and P data(x) Represents the probability distribution of real data, defines the distribution characteristics of x, x represents the real data, that is, the reference domain name vector, P z(z) It represents the probability distribution of the mixed variable z and defines the distribution characteristics of the mixed variable z. 1 / 2 is a normalization factor, the purpose of which is to make the derivative form of the objective function cleaner and avoid additional coefficients interfering with the optimization process.
[0049] D(x) represents the discriminator's judgment result on real data, and D(G(z)) represents the discriminator's judgment result on forged data generated by the generator. The output of the discriminator's judgment result is a probability value ranging from 0 to 1. When the data input to the discriminator is real data, the discriminator's goal is to output a value close to 1; when the data input to the discriminator is forged data, the discriminator's goal is to output a value close to 0.
[0050] During the training process, the discriminator and the generator can optimize their respective performance through mutual game. The goal of the discriminator is to distinguish the generator's forged data as much as possible and accurately identify the real data, that is, to make the result of D(x) as close to 1 as possible and the result of D(G(z)) as close to 0 as possible; the ultimate goal of training is to make the forged data generated by the generator able to deceive the discriminator, that is, to make the result of D(G(z)) and the result of D(x) as similar as possible and both close to 1.
[0051] After inputting the mixed variables into the trained generator and obtaining the simulated domain name vector output by the generator, the simulated domain name vector needs to be decoded back into the simulated domain name sample. Here, the simulated domain name vector can be input into the variational autoencoder, and the simulated domain name vector is decoded by the variational autoencoder's decoder module. The decoding process is the opposite of the encoding process described above. It should be noted that the output of the variational autoencoder's decoder module is similar to the input of the encoder module and is also in the form of a vector sample. The simulated domain name sample in vector form needs to be converted back to string form using the method corresponding to the aforementioned method of converting the reference domain name sample in string form into the reference domain name vector in vector form in order to finally obtain the simulated domain name sample that can be used to train the domain name detection model.
[0052] Through the embodiments provided in the present application, a reference domain name sample is converted into a reference domain name vector corresponding to the reference domain name sample, wherein the reference domain name sample is a real domain name; the reference domain name vector is latent space encoded by the encoder module of the variational autoencoder to obtain a target latent variable corresponding to the reference domain name vector; the target latent variable is mixed with a first random noise, and the obtained mixed variable is input into a generator of a generative adversarial network to obtain a simulated domain name vector output by the generator; the simulated domain name vector is decoded into a simulated domain name sample corresponding to the simulated domain name vector by the decoder module of the variational autoencoder, thereby solving the problems of insufficient diversity and poor authenticity in the domain name sample generation method in the related art and improving the diversity and authenticity of the generated domain name samples.
[0053] In an exemplary embodiment, the encoder module of the variational autoencoder includes a first fully connected layer and a second fully connected layer; the reference domain name vector is latently encoded by the encoder module of the variational autoencoder to obtain a target latent variable corresponding to the reference domain name vector, including: using the first fully connected layer, using a first set of network parameters to linearly transform the reference domain name vector, and using a nonlinear activation function to activate the linearly transformed reference domain name vector to obtain an intermediate latent vector, wherein the first set of network parameters includes a first weight matrix and a first bias vector; the intermediate latent vector is input into the second fully connected layer, so that the second fully connected layer uses the second set of network parameters to calculate the mean of the latent space and the third set of network parameters to calculate the logarithmic variance of the latent space to obtain a target mean and a target logarithmic variance, wherein the second set of network parameters includes a second weight matrix and a second bias vector, and the third set of network parameters includes a third weight matrix and a third bias vector; and the target latent variable is determined according to the target mean and the target logarithmic variance.
[0054] Here, let the reference domain name vector be x, and use the first set of network parameters through the first fully connected layer to perform a linear transformation on the reference domain name vector x as shown in formula (3):
[0055] h=W1×x+b1; (3)
[0056] Where h is the intermediate representation, i.e., the reference domain name vector after linear transformation, W1 is the first weight matrix, and b1 is the first bias vector. It should be noted that the values of W1 and b1 are randomly initialized.
[0057] Then, a nonlinear activation function is used to activate the linearly transformed reference domain name vector to obtain the intermediate potential vector, as shown in formula (4):
[0058] henc=Ø(h); (4)
[0059] Here, henc is the intermediate latent vector after activation, and Ø is the activation function. Activation functions are a crucial component of neural networks. They introduce nonlinear transformations, enabling neural networks to learn and process complex patterns, thereby resolving nonlinear decision boundary problems that linear models struggle with. Typically, activation functions convert the weighted inputs of neurons into outputs, which in turn serve as inputs for the next layer of neurons. Activation functions include Sigmoid (S-shaped growth curve), ReLU (Rectified Linear Unit), Tanh (Hyperbolic Tangent Function), and Softmax (normalized exponential). Choosing the appropriate activation function based on the specific application scenario and model architecture can effectively improve model training speed and performance.
[0060] Optionally, the activation function in this embodiment can be a ReLU function. The ReLU function is simple to calculate and can avoid the gradient vanishing problem. It can ensure that the gradient of the deep neural network does not decrease with the increase of the network depth, thereby accelerating the training of the deep neural network. The form of the ReLU function is shown in formula (5):
[0061] ; (5)
[0062] Here, x is the input of the function. For positive input, the output of the ReLU function is equal to the input; for negative input, the output of the ReLU function is 0. In this embodiment, the ReLU function sets negative input values to 0, reducing unnecessary complexity, thereby enhancing the expressiveness of the model and improving training efficiency.
[0063] After obtaining the above intermediate potential vector h enc After that, h enc Input to the second fully connected layer, use the second fully connected layer distribution to calculate the mean μ and logarithmic variance log(σ of the latent space 2 ), the mean μ is calculated as shown in formula (6):
[0064] μ=W μ ×h enc +b μ ; (6)
[0065] Among them, μ is the mean of the latent space mentioned above, that is, the target mean, W μ is the second weight matrix, b μ is the second bias vector.
[0066] Logarithmic variance log(σ 2 ) is calculated as shown in formula (7):
[0067] log(σ 2 )=W σ ×h enc +b σ ; (7)
[0068] Among them, log(σ 2 ) is the logarithmic variance of the latent space calculated above, that is, the target logarithmic variance, W σ is the third weight matrix, b σ is the third bias vector.
[0069] It should be noted that the second fully connected layer includes two parallel output layers, namely the first network branch and the second network branch. The target mean is calculated in the first network branch of the second fully connected layer, and the target logarithmic variance is calculated in the second network branch of the second fully connected layer.
[0070] Then, based on the target mean and target logarithmic variance, sampling is performed in the corresponding Gaussian distribution to determine the target latent variable.
[0071] Through this embodiment, the target latent variable is obtained through variational autoencoder and nonlinear activation, which can improve the ability to capture the characteristics of reference domain name samples, thereby enhancing the quality of generated samples.
[0072] In an exemplary embodiment, the above method also includes: randomly sampling the first uniform distribution to obtain a second weight matrix and a third weight matrix, wherein the maximum value of the first uniform distribution is the quotient of the square root of six divided by the square root of the sum of the first number of neurons, the minimum value of the first uniform distribution is the negative of the maximum value of the first uniform distribution, the sum of the first number of neurons is the number of input neurons of the second fully connected layer plus the number of first output neurons, and the number of first output neurons is the number of output neurons of the second fully connected layer corresponding to the target mean; randomly sampling the second uniform distribution to obtain a second bias vector and a third bias vector, wherein the maximum value of the second uniform distribution is the quotient of the square root of six divided by the square root of the sum of the second number of neurons, the minimum value of the second uniform distribution is the negative of the maximum value of the second uniform distribution, the sum of the second number of neurons is the number of input neurons of the second fully connected layer plus the number of second output neurons, and the number of second output neurons is the number of output neurons of the second fully connected layer corresponding to the target logarithmic variance.
[0073] In the early stages of deep learning model training, proper initialization of network parameters significantly impacts the model's convergence speed and ultimate performance. Random initialization methods, such as normal distribution or standard uniform distribution, can lead to vanishing or exploding gradients due to improper parameter value distribution. To address this issue and prevent exploding or vanishing gradients caused by excessively large or small weights during forward propagation, in this embodiment, the second set of network parameters and the third set of grid parameters can be initialized using the Xavier initialization method.
[0074] The Xavier initialization method is a weight initialization method designed primarily for activation functions such as the ReLU function and its variants (such as the Leaky ReLU function). Its core idea is to keep the input and output variances nearly equal. By adjusting the weight scale, the variance of the activation values of each layer will not increase or decrease sharply with the increase in the number of layers during the forward propagation process, thereby preventing the problem of gradient vanishing or exploding.
[0075] In this embodiment, the first set of network parameters and the second set of grid parameters are initialized using uniform distribution, that is, parameters are randomly sampled from the uniform distribution [a, b]. Here, the probability density function f(x) of the uniform distribution is shown in formula (8):
[0076] ; (8)
[0077] Sampling parameters from a uniform distribution [a, b] ensures that the sampled parameters meet the initialization range constraints, which can help the effective training and gradient propagation of the model.
[0078] In this embodiment, the lower limit a and upper limit b of the uniform distribution are related to the number of input neurons and the number of output neurons corresponding to the parameters. The expression of the uniform distribution U is shown in formula (9):
[0079] ; (9)
[0080] Among them, n in is the number of input neurons corresponding to the uniform distribution, n out is the number of output neurons corresponding to the uniform distribution. It can be seen that the lower limit a of the uniform distribution is , the upper limit b of the uniform distribution is .
[0081] For the second and third weight matrices, random sampling is required from the first uniform distribution. The number of input neurons corresponding to the first uniform distribution is n. in is the number of input neurons in the second fully connected layer, and the number of output neurons corresponding to the first uniform distribution is n out is the number of the first output neurons, that is, the number of output neurons in the second fully connected layer corresponding to the target mean.
[0082] For the second bias vector and the third bias vector, random sampling is required from the second uniform distribution. The number of input neurons corresponding to the second uniform distribution is n in is the number of input neurons in the second fully connected layer, and the number of output neurons corresponding to the second uniform distribution is n out is the number of the second output neurons, that is, the number of output neurons of the second fully connected layer corresponding to the target logarithmic variance.
[0083] It should be noted that the above-mentioned first number of output neurons is also the number of output neurons of the first network branch of the second fully connected layer, and the above-mentioned second number of output neurons is also the number of output neurons of the second network branch of the second fully connected layer.
[0084] According to this embodiment, the second set of network parameters and the third set of grid parameters are generated by the Xavier initialization method, which can avoid the problems of gradient explosion and gradient disappearance, enhance the stability of the model, and improve the generation effect.
[0085] In an exemplary embodiment, a target latent variable is determined based on a target mean and a target logarithmic variance, including: sampling random noise from a standard normal distribution to obtain a second random noise; and determining the sum of a result of element-wise multiplication of a target standard deviation and the second random noise and the target mean as the target latent variable, wherein the target standard deviation is a standard deviation obtained by taking the square root of the variance obtained by performing an exponential operation on the target logarithmic variance.
[0086] After obtaining the target mean and target logarithmic variance, it is necessary to perform an exponential operation on the target logarithmic variance to obtain the target variance σ 2 , as shown in formula (10):
[0087] σ 2 =exp(log(σ 2 )); (10)
[0088] After obtaining the target variance σ 2 After that, if we go directly from (μ(x),σ 2 (x)) is randomly sampled, making it impossible to calculate the gradient between the sampling process and the model parameters during the backpropagation of the variational autoencoder model training. In this embodiment, reparameterization can be used for sampling to avoid this problem.
[0089] Reparameterization is a core method for dealing with the non-differentiable problem of random sampling operations in deep learning. It is especially important when it comes to probabilistic generative models (such as variational autoencoders) or reinforcement learning. The core idea is to transform the random sampling process into a differentiable operation so that the gradient can optimize the distribution parameters through back propagation. The reparameterization technique can decompose the random variable into deterministic parts (learnable parameters such as μ and σ). 2 ) + random noise (fixed distribution), decoupling randomness and differentiability is achieved, so that the process of sampling the target latent variable z can be optimized through back propagation.
[0090] In this embodiment, random noise is first sampled from the standard normal distribution N(0,1) to obtain the second random noise ε, and then, as shown in formula (11), the target variance σ is 2 Take the square root to get the target standard deviation σ:
[0091] ; (11)
[0092] Then, the sum of the result of element-wise product of the target standard deviation σ and the second random noise ε and the target mean μ is determined as the target latent variable z, as shown in formula (12):
[0093] z=μ(x)+σ(x)⊙ε; (12)
[0094] Where ⊙ represents the element-by-element level, and ε is the second random noise sampled from the standard normal distribution. It should be noted that the dimension of the second random noise is consistent with the target latent variable z.
[0095] Through this embodiment, the target latent variable is determined through the reparameterization technique, which can ensure the differentiability of sampling and improve the overall training efficiency and stability. By introducing random noise in combination with the target mean and standard deviation, the diversity of samples can be enhanced.
[0096] In an exemplary embodiment, converting a reference domain name sample into a reference domain name vector corresponding to the reference domain name sample includes: normalizing the character string length of the reference domain name sample, wherein the character string length of the normalized reference domain name sample is M, where M is a positive integer greater than or equal to 2; performing character conversion on the normalized reference domain name sample according to a preset character set to obtain a character-converted reference domain name sample, wherein the preset character set includes N preset characters, and characters in the normalized reference domain name sample that do not belong to the preset character set are converted into preset characters specified in the preset character set, where N is a positive integer greater than or equal to 2; and performing one-hot encoding on the character-converted reference domain name sample to obtain a reference domain name vector, wherein the reference domain name vector is an M×N dimensional matrix.
[0097] Before inputting the reference domain name samples into the deep learning-based generative model (i.e., the variational autoencoder and generative adversarial network in this solution), the string-based reference domain name samples need to be preprocessed to meet the neural network's input requirements. In this embodiment, the reference domain name samples are normalized, character set matched, and one-hot encoded to ensure that the model can accept standardized input.
[0098] First, the string lengths of the collected reference domain name samples are not necessarily consistent, and the string lengths of the reference domain name samples need to be normalized. The string length of the reference domain name samples after normalization is M, where M is a positive integer greater than or equal to 2. Correspondingly, the string lengths of the reference domain name samples are normalized, including: if the string length of the reference domain name sample is greater than M, truncating the reference domain name sample to obtain the normalized reference domain name sample; if the string length of the reference domain name sample is less than M, padding the reference domain name sample with specified characters to obtain the normalized reference domain name sample.
[0099] The normalized string length M can be set based on experience. Here, taking M as 32 as an example, the string length of the reference domain name samples is uniformly set to 32. For reference domain name samples with a string length exceeding 32, they are truncated to retain 32 characters, so that the string length of the normalized reference domain name samples is equal to 32. For reference domain name samples with a string length less than 32, the reference domain name samples are padded with specified characters to ensure that the string length of the padded reference domain name samples is equal to 32. The type of specified characters can be set based on experience, such as underscores, commas, etc., and is not limited in this embodiment.
[0100] After normalizing the length of the character strings of the reference domain name samples, it is necessary to unify the character sets corresponding to the character strings of the reference domain name samples to ensure that all characters used in the character strings of the reference domain name samples belong to the preset character set. Here, the preset character set includes N preset characters, where N is a positive integer greater than or equal to 2. After the normalization process, all characters in the reference domain name samples that do not belong to the preset character set are converted to the preset characters specified in the preset character set.
[0101] The length N of the preset character set and the preset characters in the preset character set can be set based on experience. Here, taking N as 40 as an example, the preset characters can include "az", "0-9", "-", "_", ".", and the unknown character [unk]. It should be noted that the specified characters used to fill the string must belong to the preset character set.
[0102] After this, the character-converted reference domain name samples are one-hot encoded to obtain a reference domain name vector. One-hot encoding is a method for converting categorical variables into a format suitable for processing by machine learning algorithms. Its basic principle is to convert each possible value of each categorical feature into a new binary feature, where only one feature is activated (labeled as 1) at any given time, and all other features are labeled as 0. After one-hot encoding, each preset character in the preset character set can be mapped to an independent binary N-dimensional vector, and the encoded reference domain name vector is an M×N-dimensional matrix.
[0103] Optionally, the reference domain name samples can be processed in batches. For example, the size of a batch can be 64. Taking M as 32 and N as 40 as an example, a batch of reference domain name vectors is a tensor of 64×32×40 (32×40 is the representation of one of the reference domain name vectors), where 64 is the batch size (dynamically adjustable), 32 is the string length, and 40 is the vector dimension of each character. In addition, in the encoding of the variational autoencoder, the dimension of the first weight matrix W1 is [40,32], the dimension of the first bias vector b1 is
[32] , the intermediate representation h and the intermediate latent vector h enc The dimension is [64, 32, 32], and the second weight matrix W μ and the third weight matrix W σ The dimension is [32,64], the second bias vector b μ and the third bias vector b σ The dimension of is
[64] . And for the second weight matrix W μ and the third weight matrix W σ , the corresponding number of first output neurons is 32×32=1024, and the corresponding number of first input neurons is 32×40=1028; for the second bias vector b μ and the third bias vector b σ , the corresponding number of second output neurons is 40, and the corresponding number of second input neurons is 32×40=1028. In addition, the target mean μ and target variance σ 2 The dimensions of are [64, 32, 40], the dimensions of the target latent variable z and the second random noise ε are [64, 32, 32].
[0104] This embodiment standardizes the string length and character set of the samples to ensure format consistency of the samples input into the model, thus avoiding data processing errors during the model processing. In addition, one-hot encoding provides a unique and clear vector representation for each character, making it easier for the model to capture the relationship between characters and providing a high-quality data foundation for generating simulated domain name samples.
[0105] In an exemplary embodiment, the network layer structure of the decoder module of the variational autoencoder is symmetrical with the network layer structure of the encoder module of the variational autoencoder, and the decoder module of the variational autoencoder includes multiple fully connected layers; the simulated domain name vector is decoded into a simulated domain name sample corresponding to the simulated domain name vector by the decoder module of the variational autoencoder, including: performing the following reverse decoding operation on the simulated domain name vector by the decoder module of the variational autoencoder to obtain a simulated domain name decoding vector: gradually mapping the simulated domain name vector back to the data space corresponding to the reference domain name vector by multiple fully connected layers of the decoder module of the variational autoencoder, wherein the simulated domain name decoding vector is an M×N dimensional matrix; and performing one-hot decoding on the simulated domain name decoding vector to obtain a simulated domain name sample.
[0106] In order to ensure that the simulated domain name vector output by the generator of the adversarial network and the mixed variable input to the generator are in the same format, and to obtain simulated domain name samples that can be used for training the domain name detection model, it is necessary to reversely decode the simulated domain name vector back into a simulated domain name sample in string form through the opposite method of the encoding process in the aforementioned embodiment.
[0107] In this embodiment, the simulated domain name vector is input into the decoder module of the variational autoencoder. The simulated domain name vector is gradually mapped back to the data space corresponding to the reference domain name vector through multiple fully connected layers of the decoder module of the variational autoencoder. Here, the network layer structure of the decoder module of the variational autoencoder is symmetrical with the network layer structure of the encoder module of the variational autoencoder. The decoder module of the variational autoencoder, like the encoder module, includes two fully connected layers. The simulated domain name decoding vector obtained after decoding is an M×N dimensional matrix. Optionally, if the reference domain name samples are processed in batches as described above, and the batch size is 64, M is 32, and N is 40, the simulated domain name decoding vector obtained here is a 64×32×40 tensor.
[0108] After that, based on the mapping relationship between the same characters and vectors in the one-hot encoding, the simulated domain name decoding vector is one-hot decoded to obtain the final simulated domain name sample in string form.
[0109] Through this embodiment, the simulated domain name vector is converted into a simulated domain name sample in the form of a string by reverse decoding the simulated domain name vector. The symmetrical decoding structure can effectively reversely restore the features extracted by the encoder, so that the generated simulated domain name sample is not only structurally close to the real sample, but also maintains its inherent patterns and regularities, thereby improving the quality of the generated sample.
[0110] It should be noted that for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that this application is not limited by the order of the actions described, because according to this application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by this application.
[0111] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus the necessary general hardware platform, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application, or the part that contributes to the existing technology, can be embodied in the form of a software product. The computer software product is stored in a storage medium (such as a read-only memory (ROM) / random access memory (RAM), a magnetic disk, or an optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0112] According to another aspect of the embodiments of the present application, a domain name sample generation device is also provided. This domain name sample generation device can be used to implement the domain name sample generation method provided in the above embodiments. Details already described are not repeated here. As used below, the term "module" can refer to a combination of software and / or hardware that implements a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, implementation using hardware, or a combination of software and hardware, is also possible and contemplated.
[0113] Figure 3 This is a structural block diagram of an optional domain name sample generating device according to an embodiment of the present application, such as Figure 3 As shown in , the domain name sample generating device includes:
[0114] The conversion unit 302 is configured to convert the reference domain name sample into a reference domain name vector corresponding to the reference domain name sample, wherein the reference domain name sample is a real domain name.
[0115] The encoding unit 304 is configured to perform latent space encoding on the reference domain name vector through an encoder module of a variational autoencoder to obtain a target latent variable corresponding to the reference domain name vector.
[0116] The execution unit 306 is configured to mix the target latent variable with the first random noise, and input the obtained mixed variable into the generator of the generative adversarial network to obtain a simulated domain name vector output by the generator.
[0117] The decoding unit 308 is configured to decode the simulated domain name vector into a simulated domain name sample corresponding to the simulated domain name vector through a decoder module of the variational autoencoder.
[0118] It should be noted that the conversion unit 302 in this embodiment can be used to execute the above step S202, the encoding unit 304 in this embodiment can be used to execute the above step S204, the execution unit 306 in this embodiment can be used to execute the above step S206, and the decoding unit 308 in this embodiment can be used to execute the above step S208.
[0119] Through the embodiments provided in the present application, a reference domain name sample is converted into a reference domain name vector corresponding to the reference domain name sample, wherein the reference domain name sample is a real domain name; the reference domain name vector is latent space encoded by the encoder module of the variational autoencoder to obtain a target latent variable corresponding to the reference domain name vector; the target latent variable is mixed with a first random noise, and the obtained mixed variable is input into a generator of a generative adversarial network to obtain a simulated domain name vector output by the generator; the simulated domain name vector is decoded into a simulated domain name sample corresponding to the simulated domain name vector by the decoder module of the variational autoencoder, thereby solving the problems of insufficient diversity and poor authenticity in the domain name sample generation method in the related art and improving the diversity and authenticity of the generated domain name samples.
[0120] In an exemplary embodiment, the encoder module of the variational autoencoder includes a first fully connected layer and a second fully connected layer; the encoding unit includes: a first execution module, which is used to linearly transform the reference domain name vector using a first set of network parameters through the first fully connected layer, and activate the reference domain name vector after the linear transformation using a nonlinear activation function to obtain an intermediate latent vector, wherein the first set of network parameters includes a first weight matrix and a first bias vector; an input module, which is used to input the intermediate latent vector into the second fully connected layer, so that the second fully connected layer uses the second set of network parameters to calculate the mean of the latent space and the logarithmic variance of the latent space using the third set of network parameters to obtain a target mean and a target logarithmic variance, wherein the second set of network parameters includes a second weight matrix and a second bias vector, and the third set of network parameters includes a third weight matrix and a third bias vector; a determination module, which is used to determine the target latent variable based on the target mean and the target logarithmic variance.
[0121] In an exemplary embodiment, the above-mentioned device also includes: a first sampling unit, used to randomly sample the first uniform distribution to obtain a second weight matrix and a third weight matrix, wherein the maximum value of the first uniform distribution is the quotient of the square root of six divided by the square root of the sum of the first number of neurons, the minimum value of the first uniform distribution is the negative of the maximum value of the first uniform distribution, the sum of the first number of neurons is the number of input neurons of the second fully connected layer plus the number of first output neurons, and the number of first output neurons is the number of output neurons of the second fully connected layer corresponding to the target mean; a second sampling unit, used to randomly sample the second uniform distribution to obtain a second bias vector and a third bias vector, wherein the maximum value of the second uniform distribution is the quotient of the square root of six divided by the square root of the sum of the second number of neurons, the minimum value of the second uniform distribution is the negative of the maximum value of the second uniform distribution, the sum of the second number of neurons is the number of input neurons of the second fully connected layer plus the number of second output neurons, and the number of second output neurons is the number of output neurons of the second fully connected layer corresponding to the target logarithmic variance.
[0122] In an exemplary embodiment, the determination module includes: a sampling submodule for sampling random noise from a standard normal distribution to obtain a second random noise; a determination submodule for determining the sum of the result of element-wise multiplication of the target standard deviation and the second random noise and the target mean as the target latent variable, wherein the target standard deviation is the standard deviation obtained by taking the square root of the variance obtained by performing an exponential operation on the target logarithmic variance.
[0123] In an exemplary embodiment, the conversion unit includes: a processing module for normalizing the string length of the reference domain name sample, wherein the string length of the reference domain name sample after normalization is M, where M is a positive integer greater than or equal to 2; a conversion module for performing character conversion on the normalized reference domain name sample according to a preset character set to obtain the reference domain name sample after character conversion, wherein the preset character set includes N preset characters, and in the normalized reference domain name sample, characters that do not belong to the preset character set are converted into preset characters specified in the preset character set, where N is a positive integer greater than or equal to 2; an encoding module for performing one-hot encoding on the reference domain name sample after character conversion to obtain a reference domain name vector, wherein the reference domain name vector is an M×N dimensional matrix.
[0124] In an exemplary embodiment, the processing module includes: a truncation submodule, which is used to truncate the reference domain name sample when the string length of the reference domain name sample is greater than M, so as to obtain a normalized reference domain name sample; and a padding submodule, which is used to pad the reference domain name sample with specified characters when the string length of the reference domain name sample is less than M, so as to obtain a normalized reference domain name sample.
[0125] In an exemplary embodiment, the network layer structure of the decoder module of the variational autoencoder is symmetrical with the network layer structure of the encoder module of the variational autoencoder, and the decoder module of the variational autoencoder includes multiple fully connected layers; the decoding unit includes: a second execution module, which is used to perform the following reverse decoding operation on the simulated domain name vector through the decoder module of the variational autoencoder to obtain a simulated domain name decoding vector: the simulated domain name vector is gradually mapped back to the data space corresponding to the reference domain name vector through multiple fully connected layers of the decoder module of the variational autoencoder, wherein the simulated domain name decoding vector is an M×N dimensional matrix; a decoding module, which is used to perform one-hot decoding on the simulated domain name decoding vector to obtain a simulated domain name sample.
[0126] It should be noted that the above modules can be implemented through software or hardware. For the latter, it can be implemented in the following ways, but not limited to: the above modules are all located in the same processor; or the above modules are located in different processors in any combination.
[0127] According to another aspect of the embodiments of the present application, a computer-readable storage medium is provided. The computer-readable storage medium includes a stored program, wherein the program executes the steps of any of the above method embodiments when it is run.
[0128] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as a USB flash drive, a ROM, a RAM, a mobile hard disk, a magnetic disk, or an optical disk.
[0129] According to another aspect of the embodiments of the present application, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor is configured to execute the steps of any of the above-described method embodiments through the computer program. In an exemplary embodiment, the electronic device may further comprise a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.
[0130] For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary implementation modes, and this embodiment will not be described in detail here.
[0131] According to another aspect of an embodiment of the present application, a computer program product is also provided, comprising a computer program / instruction containing program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network via the communication portion 409, and / or installed from a removable medium 411. When the computer program is executed by the central processing unit 401, the various functions provided by the embodiments of the present application are performed. The serial numbers of the embodiments of the present application are for description only and do not represent the merits of the embodiments.
[0132] Figure 4 The following schematically shows a block diagram of a computer system structure of an electronic device for implementing an embodiment of the present application. Figure 4 As shown, computer system 400 includes a central processing unit (CPU) 401, which can perform various appropriate actions and processes according to programs stored in ROM 402 or programs loaded from storage 408 into RAM 403. Random access memory 403 also stores various programs and data required for system operation. CPU 401, read-only memory 402, and random access memory 403 are interconnected via bus 404. An input / output (I / O) interface 405 is also connected to bus 404.
[0133] The following components are connected to the I / O interface 405: an input section 406 including a keyboard, mouse, and the like; an output section 407 including devices such as a cathode ray tube (CRT), a liquid crystal display (LCD), and speakers; a storage section 408 including a hard disk; and a communication section 409 including a network interface card such as a local area network card or a modem. The communication section 409 performs communication processing via a network such as the Internet. A drive 410 is also connected to the I / O interface 405 as needed. Removable media 411, such as a magnetic disk, an optical disk, a magneto-optical disk, or a semiconductor memory, is installed in the drive 410 as needed, so that computer programs read from the removable media can be installed in the storage section 408 as needed.
[0134] In particular, according to an embodiment of the present application, the processes described in the various method flow charts can be implemented as computer software programs. For example, an embodiment of the present application includes a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for executing the methods shown in the flow charts. In such an embodiment, the computer program can be downloaded and installed from a network via the communication section 409 and / or installed from a removable medium 411. When the computer program is executed by the central processing unit 401, the various functions defined in the system of the present application are performed.
[0135] It should be noted that Figure 4 The computer system 400 of the electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0136] Obviously, those skilled in the art should understand that the modules or steps of the present application described above can be implemented using a general-purpose computing device, they can be concentrated on a single computing device, or distributed across a network composed of multiple computing devices, they can be implemented using program code executable by the computing device, and thus, they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be performed in a different order than herein, or they can be fabricated into separate integrated circuit modules, or multiple modules or steps can be fabricated into a single integrated circuit module for implementation. Thus, the present application is not limited to any specific combination of hardware and software.
[0137] The above are only preferred embodiments of the present application and are not intended to limit the present application. For those skilled in the art, various modifications and variations of the present application are possible. Any modifications, equivalent substitutions, improvements, etc. made within the principles of the present application shall be included in the scope of protection of the present application.
Claims
1. A domain name sample generation method, characterized in that: include: Converting a reference domain name sample into a reference domain name vector corresponding to the reference domain name sample, wherein the reference domain name sample is a real domain name; Performing latent space encoding on the reference domain name vector through an encoder module of a variational autoencoder to obtain a target latent variable corresponding to the reference domain name vector, wherein the encoder module of the variational autoencoder includes a first fully connected layer and a second fully connected layer; Mixing the target latent variable with the first random noise, and inputting the obtained mixed variable into the generator of the generative adversarial network to obtain a simulated domain name vector output by the generator; Decoding the simulated domain name vector into a simulated domain name sample corresponding to the simulated domain name vector by a decoder module of the variational autoencoder; The step of performing latent space encoding on the reference domain name vector by the encoder module of the variational autoencoder to obtain a target latent variable corresponding to the reference domain name vector includes: Performing a linear transformation on the reference domain name vector using a first set of network parameters through the first fully connected layer, and activating the linearly transformed reference domain name vector using a nonlinear activation function to obtain an intermediate latent vector, wherein the first set of network parameters includes a first weight matrix and a first bias vector; Inputting the intermediate latent vector into the second fully connected layer, so that the second fully connected layer calculates the mean of the latent space using a second set of network parameters and calculates the logarithmic variance of the latent space using a third set of network parameters to obtain a target mean and a target logarithmic variance, wherein the second set of network parameters includes a second weight matrix and a second bias vector, and the third set of network parameters includes a third weight matrix and a third bias vector; The target latent variable is determined according to the target mean and the target logarithmic variance.
2. The method according to claim 1, characterized in that The method further comprises: Randomly sampling the first uniform distribution to obtain the second weight matrix and the third weight matrix, wherein the maximum value of the first uniform distribution is the quotient of the square root of six divided by the square root of the sum of the first number of neurons, the minimum value of the first uniform distribution is the negative of the maximum value of the first uniform distribution, the sum of the first number of neurons is the number of input neurons of the second fully connected layer plus the number of first output neurons, and the first number of output neurons is the number of output neurons of the second fully connected layer corresponding to the target mean; Randomly sample the second uniform distribution to obtain the second bias vector and the third bias vector, wherein the maximum value of the second uniform distribution is the quotient of the square root of six divided by the square root of the sum of the second number of neurons, the minimum value of the second uniform distribution is the negative of the maximum value of the second uniform distribution, the sum of the second number of neurons is the number of input neurons of the second fully connected layer plus the number of second output neurons, and the second number of output neurons is the number of output neurons of the second fully connected layer corresponding to the target logarithmic variance.
3. The method according to claim 1, characterized in that Determining the target latent variable according to the target mean and the target logarithmic variance includes: Sampling random noise from a standard normal distribution to obtain a second random noise; The sum of the result of element-wise multiplication of the target standard deviation and the second random noise and the target mean is determined as the target latent variable, wherein the target standard deviation is the standard deviation obtained by taking the square root of the variance obtained by performing an exponential operation on the target logarithmic variance.
4. The method according to any one of claims 1 to 3, characterized in that The converting the reference domain name sample into a reference domain name vector corresponding to the reference domain name sample includes: Normalizing the string length of the reference domain name sample, wherein the string length of the reference domain name sample after normalization is M, where M is a positive integer greater than or equal to 2; Performing character conversion on the normalized reference domain name sample according to a preset character set to obtain the character-converted reference domain name sample, wherein the preset character set includes N preset characters, and characters in the normalized reference domain name sample that do not belong to the preset character set are converted into preset characters specified in the preset character set, where N is a positive integer greater than or equal to 2; The reference domain name sample after character conversion is one-hot encoded to obtain the reference domain name vector, wherein the reference domain name vector is an M*N dimensional matrix.
5. The method according to claim 4, characterized in that The normalizing the character string length of the reference domain name sample includes: When the character string length of the reference domain name sample is greater than M, truncating the reference domain name sample to obtain the normalized reference domain name sample; When the character string length of the reference domain name sample is less than M, the reference domain name sample is padded with designated characters to obtain the normalized reference domain name sample.
6. The method according to claim 4, characterized in that The network layer structure of the decoder module of the variational autoencoder is symmetrical to the network layer structure of the encoder module of the variational autoencoder, and the decoder module of the variational autoencoder includes multiple fully connected layers; The decoding of the simulated domain name vector into a simulated domain name sample corresponding to the simulated domain name vector by a decoder module of the variational autoencoder includes: Performing the following reverse decoding operation on the simulated domain name vector through the decoder module of the variational autoencoder to obtain a simulated domain name decoded vector: progressively mapping the simulated domain name vector back to the data space corresponding to the reference domain name vector through multiple fully connected layers of the decoder module of the variational autoencoder, wherein the simulated domain name decoded vector is an M*N dimensional matrix; One-hot decoding is performed on the simulated domain name decoding vector to obtain the simulated domain name sample.
7. A domain name sample generating device, characterized in that: include: a conversion unit, configured to convert a reference domain name sample into a reference domain name vector corresponding to the reference domain name sample, wherein the reference domain name sample is a real domain name; an encoding unit, configured to perform latent space encoding on the reference domain name vector through an encoder module of a variational autoencoder to obtain a target latent variable corresponding to the reference domain name vector, wherein the encoder module of the variational autoencoder includes a first fully connected layer and a second fully connected layer; an execution unit, configured to mix the target latent variable with a first random noise, and input the obtained mixed variable into a generator of a generative adversarial network to obtain a simulated domain name vector output by the generator; a decoding unit, configured to decode the simulated domain name vector into a simulated domain name sample corresponding to the simulated domain name vector through a decoder module of the variational autoencoder; The encoding unit includes: a first execution module, configured to perform a linear transformation on the reference domain name vector using a first set of network parameters through the first fully connected layer, and activate the reference domain name vector after the linear transformation using a nonlinear activation function to obtain an intermediate latent vector, wherein the first set of network parameters includes a first weight matrix and a first bias vector; an input module, configured to input the intermediate latent vector into the second fully connected layer, so that the second fully connected layer calculates the mean of the latent space using a second set of network parameters and calculates the logarithmic variance of the latent space using a third set of network parameters to obtain a target mean and a target logarithmic variance, wherein the second set of network parameters includes a second weight matrix and a second bias vector, and the third set of network parameters includes a third weight matrix and a third bias vector; A determination module is used to determine the target latent variable according to the target mean and the target logarithmic variance.
8. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, wherein the computer program implements the steps of the method according to any one of claims 1 to 6 when executed by a processor.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Malicious domain name detection method and device based on self-attention generative adversarial network
CN115086054A
Sample generation method and device, storage medium and equipment
CN115374863A