Model training method and device, domain name detection method and device, electronic equipment and storage medium
By initially training the training samples of malicious domain names and benign domain names, and using incremental training and game training methods to improve the model, the problem of low accuracy of the existing malicious domain name detection model is solved, and higher detection accuracy and adversariality are achieved.
Patent Information
- Application Number
- CN202411695340.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-25
- Publication Date
- 2025-04-15
AI Technical Summary
The existing malicious domain name detection model has low accuracy and is easily bypassed by attackers.
Through a model training method, initial training samples of malicious domain names and benign domain names are used for initial training, and then the accuracy of the domain name detection model is gradually improved through incremental training and game training.
Improve the accuracy of the domain name detection model, allowing it to more effectively identify complex and unknown malicious domain names, and reduce the dependence on static features.
Smart Images

Figure CN119834998A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of network technology, and in particular to a model training, domain name detection method, device, electronic device and storage medium. Background Art
[0002] Malicious domain names are domain names that are used to spread malware, conduct phishing, or perform other harmful activities. These domain names may be used to disguise as legitimate websites or services to deceive users into visiting and performing malicious operations. The existence of malicious domain names poses a serious threat to Internet security and user experience. They may lead to personal information leakage, property loss, and other network security issues. Therefore, many security agencies and experts are committed to detecting and combating the activities of malicious domain names.
[0003] The current malicious domain name detection methods are mainly based on statistics, graphs, and machine learning. The methods based on statistics, graphs, and machine learning first perform feature engineering on the domain name based on expert experience or own observations, and then input these features into the machine learning model for training. However, this method is simple to train, and once the feature engineering is understood, it is easy to be cracked. Therefore, the accuracy of the domain name detection model currently used for detecting malicious domain names is low. Summary of the invention
[0004] In view of the above problems, the embodiments of the present application propose a model training, domain name detection method, device, electronic device and storage medium to solve the problem of low accuracy of the domain name detection model.
[0005] According to one aspect of an embodiment of the present application, a model training method is provided, the method comprising:
[0006] Obtaining a first malicious domain name training sample and a benign domain name training sample, and training a first domain name detection model using the first malicious domain name training sample and the benign domain name training sample to obtain a trained first domain name detection model;
[0007] Repeat the following training process: train the malicious domain name generation model after the previous training based on the target domain name detection model to obtain the malicious domain name generation model after the current training; generate malicious domain name adversarial samples based on the malicious domain name generation model after the current training, and perform incremental training on the second domain name detection model after the previous training using the malicious domain name adversarial samples and the benign domain name training samples to obtain the second domain name detection model after the current training;
[0008] After the first preset condition is met, the target domain name detection model is used as the trained domain name detection model;
[0009] Among them, the target domain name detection model in the first training is the first domain name detection model after the training, and the target domain name detection model in other trainings is the second domain name detection model after the previous training; the second domain name detection model is obtained by incrementally improving the first domain name detection model after the training.
[0010] Optionally, the first domain name detection model includes multiple first classifiers and second classifiers; the first malicious domain name training sample and the benign domain name training sample are used to train the first domain name detection model to obtain the trained first domain name detection model, including: merging the first malicious domain name training sample and the benign domain name training sample as a first overall sample, and dividing the first overall sample into a first training sample and a second training sample; using the first training sample to train the multiple first classifiers to obtain multiple trained first classifiers; using the trained multiple first classifiers to perform category prediction on the second training sample respectively to obtain multiple prediction results of the second training sample; using the second training sample and the multiple prediction results of the second training sample to train the second classifier to obtain a trained second classifier; using the trained multiple first classifiers and the trained second classifier as the trained first domain name detection model.
[0011] Optionally, the target domain name detection model is used to train the malicious domain name generation model after the previous training to obtain the malicious domain name generation model after the current training, including: using the malicious domain name generation model after the previous training to generate a second malicious domain name training sample; using the target domain name detection model to perform category prediction on the second malicious domain name training sample to obtain a prediction result of the second malicious domain name training sample; when the prediction result of the second malicious domain name training sample does not meet the second preset condition, iteratively adjusting the malicious domain name generation model after the previous training, and returning to the step of generating the second malicious domain name training sample using the malicious domain name generation model after the previous training, until the prediction result of the second malicious domain name training sample meets the second preset condition, and the malicious domain name generation model after the current training is obtained.
[0012] Optionally, the trained first domain name detection model includes multiple trained first classifiers, and the second domain name detection model includes multiple trained first classifiers, multiple third classifiers and fourth classifiers; the incremental training of the second domain name detection model after the previous training using the malicious domain name adversarial samples and the benign domain name training samples to obtain the second domain name detection model after this training includes: using the malicious domain name adversarial samples and the benign domain name training samples to train the multiple third classifiers after the previous training and the fourth classifier after the previous training contained in the second domain name detection model after the previous training to obtain the second domain name detection model after this training.
[0013] Optionally, the method of using the malicious domain name adversarial sample and the benign domain name training sample to train multiple third classifiers after previous training and the fourth classifier after previous training contained in the second domain name detection model after previous training to obtain the second domain name detection model after current training includes: merging the malicious domain name adversarial sample and the benign domain name training sample as a second overall sample, and dividing the second overall sample into a third training sample and a fourth training sample; using the third training sample to train the multiple third classifiers after previous training to obtain multiple third classifiers after current training; using the multiple third classifiers after current training and the multiple first classifiers after training to perform category prediction on the fourth training sample respectively to obtain multiple prediction results of the fourth training sample; using the fourth training sample and the multiple prediction results of the fourth training sample to train the fourth classifier after previous training to obtain the fourth classifier after current training; using the multiple first classifiers after training, the multiple third classifiers after current training and the fourth classifier after current training as the second domain name detection model after current training.
[0014] According to another aspect of an embodiment of the present application, a domain name detection method is provided, the method comprising:
[0015] Get the domain name to be tested;
[0016] Inputting the domain name to be detected into a trained domain name detection model to obtain output information of the trained domain name detection model, wherein the output information is used to indicate a category of the domain name to be detected, wherein the category is one of a malicious domain name and a benign domain name;
[0017] The trained domain name detection model is obtained by training using the model training method described in any one of the above items.
[0018] According to another aspect of an embodiment of the present application, a model training device is provided, the device comprising:
[0019] A first training model is used to obtain a first malicious domain name training sample and a benign domain name training sample, and train a first domain name detection model using the first malicious domain name training sample and the benign domain name training sample to obtain a trained first domain name detection model;
[0020] The second training module is used to repeatedly perform the following training process: training the malicious domain name generation model after the previous training based on the target domain name detection model to obtain the malicious domain name generation model after the current training; generating malicious domain name adversarial samples based on the malicious domain name generation model after the current training, and performing incremental training on the second domain name detection model after the previous training using the malicious domain name adversarial samples and the benign domain name training samples to obtain the second domain name detection model after the current training; until the first preset condition is met, the target domain name detection model is used as the trained domain name detection model;
[0021] Among them, the target domain name detection model in the first training is the first domain name detection model after the training, and the target domain name detection model in other trainings is the second domain name detection model after the previous training; the second domain name detection model is obtained by incrementally improving the first domain name detection model after the training.
[0022] Optionally, the first domain name detection model includes multiple first classifiers and second classifiers; the first training module is specifically used to: merge the first malicious domain name training sample and the benign domain name training sample as a first overall sample, and divide the first overall sample into a first training sample and a second training sample; use the first training sample to train the multiple first classifiers to obtain multiple trained first classifiers; use the trained multiple first classifiers to perform category prediction on the second training sample respectively to obtain multiple prediction results of the second training sample; use the second training sample and the multiple prediction results of the second training sample to train the second classifier to obtain a trained second classifier; use the trained multiple first classifiers and the trained second classifier as the trained first domain name detection model.
[0023] Optionally, the second training module includes: a first training submodule, used to generate a second malicious domain name training sample using the malicious domain name generation model after the previous training; use the target domain name detection model to perform category prediction on the second malicious domain name training sample to obtain a prediction result of the second malicious domain name training sample; when the prediction result of the second malicious domain name training sample does not meet the second preset condition, iteratively adjust the malicious domain name generation model after the previous training, and return to the step of generating the second malicious domain name training sample using the malicious domain name generation model after the previous training, until the prediction result of the second malicious domain name training sample meets the second preset condition, and the malicious domain name generation model after this training is obtained.
[0024] Optionally, the trained first domain name detection model includes multiple trained first classifiers, and the second domain name detection model includes the multiple trained first classifiers, multiple third classifiers and fourth classifiers; the second training module includes: a second training submodule, which is used to use the malicious domain name adversarial samples and the benign domain name training samples to train the multiple third classifiers and the fourth classifier contained in the second domain name detection model after the previous training, so as to obtain the second domain name detection model after this training.
[0025] Optionally, the second training submodule is specifically used to: merge the malicious domain name adversarial sample and the benign domain name training sample as a second overall sample, and divide the second overall sample into a third training sample and a fourth training sample; use the third training sample to train the multiple third classifiers after the previous training to obtain multiple third classifiers after this training; use the multiple third classifiers after this training and the multiple first classifiers after training to perform category prediction on the fourth training sample respectively to obtain multiple prediction results of the fourth training sample; use the fourth training sample and the multiple prediction results of the fourth training sample to train the fourth classifier after the previous training to obtain the fourth classifier after this training; use the multiple first classifiers after training, the multiple third classifiers after this training, and the fourth classifier after this training as the second domain name detection model after this training.
[0026] According to another aspect of an embodiment of the present application, a domain name detection device is provided, the device comprising:
[0027] An acquisition module is used to obtain the domain name to be detected;
[0028] A detection module, used for inputting the domain name to be detected into a trained domain name detection model, and obtaining output information of the trained domain name detection model, wherein the output information is used for indicating a category of the domain name to be detected, wherein the category is one of a malicious domain name and a benign domain name;
[0029] The trained domain name detection model is obtained by training using the model training method described in any one of the above items.
[0030] According to another aspect of an embodiment of the present application, an electronic device is provided, comprising a processor and a computer-readable storage medium, wherein a computer program is stored on the computer-readable storage medium; when the computer program is executed by the processor, the processor executes the model training method as described in any one of the above items, or executes the domain name detection method as described above.
[0031] According to another aspect of an embodiment of the present application, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the processor executes the model training method as described in any one of the above items, or executes the domain name detection method as described above.
[0032] In the embodiment of the present application, initial training is first performed to obtain a first domain name detection model, and then incremental improvements are performed on the basis of the trained first domain name detection model to obtain a second domain name detection model. Game training is performed on the malicious domain name generation model and the second domain name detection model, so that the malicious domain name generation model can continuously adjust its strategy for generating malicious domain names to generate malicious domain names that are more difficult to identify, and at the same time, the second domain name detection model can continuously face various complex malicious domain name challenges, thereby continuously improving its detection accuracy. At the same time, the second domain name detection model is incrementally trained during the game training process, thereby reducing the complexity of the training process. This method does not rely on artificial feature engineering, and the domain name detection model obtained by this training method has higher accuracy and can better cope with various unknown and complex malicious domain name scenarios.
[0033] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] In order to more clearly illustrate the technical solution of the embodiment of the present application, the drawings required for use in the description of the embodiment of the present application will be briefly introduced below. Obviously, the drawings described below are only some drawings of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0035] Figure 1 It is a flowchart of the steps of a model training method in an embodiment of the present application;
[0036] Figure 2 is a schematic diagram of an incremental training process of an embodiment of the present application;
[0037] Figure 3 is a schematic diagram of a game training process of an embodiment of the present application;
[0038] Figure 4 It is a flowchart of the steps of a domain name detection method in an embodiment of the present application;
[0039] Figure 5 is a structural block diagram of a model training device in an embodiment of the present application;
[0040] Figure 6 It is a structural block diagram of a domain name detection device according to an embodiment of the present application;
[0041] Figure 7 is a structural block diagram of an electronic device according to an embodiment of the present application;
[0042] Figure 8 It is a structural block diagram of a computer-readable storage medium in an embodiment of the present application. DETAILED DESCRIPTION
[0043] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0044] The current malicious domain name detection method is a static feature engineering method, which is mainly based on statistics, graphs, machine learning and neural networks. First, the domain name is feature engineered based on expert experience or own observation, and then these features are input into the machine learning model for training. However, this method has limitations. Once the feature engineering is understood by the attacker, it is easy to be broken.
[0045] In the embodiments of the present application, in order not to rely on artificial feature engineering, a method using a neural network is considered. It is different from a machine learning method that relies on artificial feature engineering. It automatically extracts features from the original domain name through a neural network, and can directly output the test domain name category without manual operation. However, further considering that the neural network model is trained in advance, its detection ability is limited by the diversity of training data. Once a new malicious domain name that has not been learned appears, its detection effect will decrease. Therefore, it is necessary to continuously improve its ability to identify unknown malicious domain names.
[0046] Further considering the malicious domain name generation model that can generate malicious domain names, it continuously inputs data into the domain name detection model, and inputs the results fed back by the domain name detection model as rewards into the malicious domain name generation model, thereby enhancing the ability of the malicious domain name generation model, thereby generating malicious domain names that cannot be detected by the domain name detection model. This method can be used for any domain name detection method, and does not even need to know the specific implementation of the domain name detection model, but only needs to obtain the detection results of the domain name detection model. The above malicious domain name generation model poses a great challenge to the existing domain name detection model. The domain name detection model cannot compete with the malicious domain name generation model because the domain name detection model is trained by inputting the data set in advance, and cannot form an effective resistance to the malicious domain names dynamically generated by the malicious domain name generation model, and can only be broken.
[0047] In view of the limitations and challenges mentioned above, the model training method in the embodiments of the present application aims to solve the following problems:
[0048] Limitations of static feature engineering: Traditional methods based on statistics, graphs, and machine learning rely on artificial feature engineering. Once these features are known by attackers, they can be easily bypassed. In the embodiments of the present application, by introducing incremental learning algorithms, new malicious domain name patterns can be continuously adapted, reducing the reliance on static features.
[0049] Disadvantages of the neural network method: Although the neural network can automatically extract features from the original domain name, its detection ability is limited by the diversity of the training data. Once a new malicious domain name that has not been learned appears, its detection effect will decrease. In the embodiments of the present application, incremental learning and adversarial training can continuously improve the detector's ability to identify unknown malicious domain names.
[0050] Lack of response to dynamically generated malicious domain names: Current domain name detection models cannot effectively respond to malicious domain names generated based on reinforcement learning adversarial methods, because they are usually trained in advance and cannot be used in real time to fight against malicious domain name generation models. In the embodiments of the present application, by conducting game training with adversarial malicious domain name generation models, the domain name detection model can be updated in real time to form an effective dynamic defense.
[0051] The embodiments of the present application are intended to solve the problem that the domain name detection model is difficult to deal with new malicious domain names, especially adversarial malicious domain names, when it does not need to be updated for a long time. The purpose of the embodiments of the present application is to provide an incremental domain name detection model that can compete with the adversarial malicious domain name generation model, and maintain the continued effectiveness of the detection method by continuously learning and adapting to new malicious domain names, ensuring that the detection system is not compromised and continues to effectively detect malicious domain names. The following is a detailed introduction.
[0052] Reference Figure 1 , showing a step flow chart of a model training method in an embodiment of the present application.
[0053] like Figure 1 As shown, the model training method may include the following steps:
[0054] Step 101, obtaining a first malicious domain name training sample and a benign domain name training sample, and using the first malicious domain name training sample and the benign domain name training sample to train a first domain name detection model to obtain a trained first domain name detection model.
[0055] This step belongs to the initial training process, and its purpose is to train an initial first domain name detection model.
[0056] Malicious domain names are domain names that are used for cyber attacks, fraud or other malicious activities.
[0057] Benign domains are domains used for normal, legitimate services and are not used for malicious activities.
[0058] Malicious domain names and benign domain names of known categories are obtained from historical data. In order to distinguish them from other malicious domain names, the malicious domain names obtained from historical data are referred to as first malicious domain names in this embodiment. The first malicious domain name obtained from historical data is categorized and labeled to obtain the categorized score of the first malicious domain name. The first malicious domain name and the categorized score of the first malicious domain name are used as first malicious domain name training samples. The benign domain names obtained from historical data are categorized and labeled to obtain the categorized score of the benign domain names. The benign domain names and the categorized score of the benign domain names are used as benign domain name training samples. The categorized score refers to the categorized score obtained by labeling.
[0059] Each category score mentioned in the embodiments of the present application can indicate the maliciousness of the domain name. The larger the category score, the less malicious the domain name is, and the smaller the category score, the greater the maliciousness of the domain name. For example, the category score of a malicious domain name is 0, the category score of a benign domain name is 1, and so on. Therefore, the category score of the first malicious domain name can be marked as 0, the category score of the benign domain name can be marked as 1, and so on.
[0060] The first malicious domain name training sample and the benign domain name training sample are used to train the first domain name detection model to obtain the trained first domain name detection model. The first domain name detection model can be any applicable model with classification function.
[0061] Exemplarily, in the process of training the first domain name detection model using the first malicious domain name training sample and the benign domain name training sample, when the input of the first domain name detection model is the first malicious domain name, the output of the first domain name detection model is the predicted category score of the first malicious domain name; when the input of the first domain name detection model is a benign domain name, the output of the first domain name detection model is the predicted category score of the benign domain name. Among them, the predicted category score refers to the predicted category score. According to the predicted category score output by the first domain name detection model and the labeled category score obtained by labeling, the loss function of the first domain name detection model can be calculated. When the loss function of the first domain name detection model is greater than or equal to the first loss threshold, the parameters of the first domain name detection model are iteratively adjusted to continue training; when the loss function of the first domain name detection model is less than the first loss threshold, it can be determined that the training is completed and the trained first domain name detection model is obtained.
[0062] The loss function of the first domain name detection model may include but is not limited to a cross entropy loss function, a classification loss function, etc. The specific value of the first loss threshold may be set according to actual experience, and this embodiment does not limit this.
[0063] In an optional implementation, in order to further improve the accuracy of the first domain name detection model, an ensemble learning method is used to train the first domain name detection model. Ensemble learning is a type of machine learning framework, and its core idea is to complete the learning task by constructing and combining multiple learners (also called base learners or individual learners). In ensemble learning, a group of base learners are first generated, and then they are combined through a certain strategy, such as averaging, voting, and learning. The purpose of this is to improve the performance of the overall model through the mutual cooperation of multiple base learners. Exemplarily, the ensemble learning method may include but is not limited to Boosting (boosting method or enhancement method), Bagging (bagging method or self-help aggregation method), Stacking (stacking method or stacking generalization method), etc. This ensemble learning machine learning method can reduce the generalization error of the model and improve the accuracy and stability of model prediction.
[0064] In an embodiment of the present application, in order to perform ensemble learning, the first domain name detection model may include multiple first classifiers and second classifiers. Among them, multiple first classifiers serve as base learners in ensemble learning, and the second classifier serves as a meta-learner in ensemble learning. The specific forms of the first classifier and the second classifier can be set according to actual needs, and this embodiment does not limit this. For example, KNN (K-Nearest Neighbor) can be selected as the first classifier, and a suitable K value can be set. KNN is an instance-based learning that classifies by measuring the distance between different data points, and so on. For example, LSTM (Long Short-Term Memory) is selected as the second classifier, and so on.
[0065] Exemplarily, the process of training the first domain name detection model using the first malicious domain name training sample and the benign domain name training sample to obtain the trained first domain name detection model may include the following steps A1 to A5. By adopting an integrated learning method, the accuracy of the first domain name detection model can be further improved.
[0066] Step A1: combine the first malicious domain name training sample and the benign domain name training sample as a first overall sample, and divide the first overall sample into a first training sample and a second training sample.
[0067] The first malicious domain name training sample and the benign domain name training sample are combined as a first overall sample, and the first overall sample is divided into two groups, which are respectively used as a first training sample and a second training sample.
[0068] For example, there are m first malicious domain training samples and m benign domain training samples. Combine the m first malicious domain training samples and the m benign domain training samples into 2m first overall samples, and randomly divide the 2m first overall samples into two groups, each of which has about m / 2 first malicious domain training samples and m / 2 benign domain training samples. The purpose of this is to achieve ensemble learning in subsequent steps.
[0069] Step A2: training the plurality of first classifiers using the first training samples to obtain a plurality of trained first classifiers.
[0070] Exemplarily, in the process of training multiple first classifiers using first training samples, the first training samples are divided into multiple groups of first training samples, the number of groups of first training samples is the same as the number of first classifiers, and then each group of first training samples is used to train a first classifier. The training process of each first classifier is independent, and the training processes of multiple first classifiers can be executed in parallel, thereby improving training efficiency.
[0071] For any first classifier, when the input of the first classifier is the first malicious domain name, the output of the first classifier is the predicted category score of the first malicious domain name; when the input of the first classifier is a benign domain name, the output of the first classifier is the predicted category score of the benign domain name. According to the predicted category score output by the first classifier and the labeled category score obtained by labeling, the loss function of the first classifier can be calculated. When the loss function of the first classifier is greater than or equal to the second loss threshold, the parameters of the first classifier are iteratively adjusted to continue training; when the loss function of the first classifier is less than the second loss threshold, it can be determined that the training is completed and the trained first classifier is obtained. The loss function of the above-mentioned first classifier may include but is not limited to the cross entropy loss function, the classification loss function, etc. The specific value of the above-mentioned second loss threshold can be set according to actual experience, and this embodiment does not limit this.
[0072] Step A3: Use the trained multiple first classifiers to perform category prediction on the second training samples respectively to obtain multiple prediction results of the second training samples.
[0073] The trained multiple first classifiers are used to perform category prediction on the second training samples respectively, and each first classifier predicts a prediction result of the second training sample, thereby obtaining multiple prediction results of the second training sample. The number of prediction results of the second training sample is the same as the number of first classifiers.
[0074] The prediction result of the second training sample includes the predicted category score of the second training sample. For any first classifier, when the input of the first classifier is the first malicious domain name, the output of the first classifier is the predicted category score of the first malicious domain name; when the input of the first classifier is a benign domain name, the output of the first classifier is the predicted category score of the benign domain name.
[0075] Step A4: training the second classifier using the second training sample and a plurality of prediction results of the second training sample to obtain a trained second classifier.
[0076] The second training sample and the multiple prediction results of the second training sample are combined to form a fifth training sample. The fifth training sample includes a fifth malicious domain name training sample and a fifth benign domain name training sample. The fifth malicious domain name training sample includes a first malicious domain name and a feature obtained by combining the multiple prediction results of the first malicious domain name, and a labeled category score of the first malicious domain name. The fifth benign domain name training sample includes a benign domain name and a feature obtained by combining the multiple prediction results of the benign domain name, and a labeled category score of the benign domain name.
[0077] The task of the second classifier is to combine the predictions of multiple first classifiers to make a final decision.
[0078] Exemplarily, in the process of training the second classifier, when the input of the second classifier is the first malicious domain name and the features obtained by combining multiple prediction results of the first malicious domain name, the output of the second classifier is the predicted category score of the first malicious domain name; when the input of the second classifier is the benign domain name and the features obtained by combining multiple prediction results of the benign domain name, the output of the second classifier is the predicted category score of the benign domain name. According to the predicted category score output by the second classifier and the labeled category score obtained by labeling, the loss function of the second classifier can be calculated. When the loss function of the second classifier is greater than or equal to the third loss threshold, the parameters of the second classifier are iteratively adjusted to continue training; when the loss function of the second classifier is less than the third loss threshold, it can be determined that the training is completed and the trained second classifier is obtained. The loss function of the above-mentioned second classifier may include but is not limited to the cross entropy loss function, the classification loss function, etc. The specific value of the above-mentioned third loss threshold can be set according to actual experience, and this embodiment does not limit this.
[0079] Step A5: using the trained multiple first classifiers and the trained second classifier as the trained first domain name detection model.
[0080] Step 102, repeatedly performing the following training process: training the malicious domain name generation model after the previous training based on the target domain name detection model to obtain the malicious domain name generation model after the current training; generating malicious domain name adversarial samples based on the malicious domain name generation model after the current training, and performing incremental training on the second domain name detection model after the previous training using the malicious domain name adversarial samples and the benign domain name training samples to obtain the second domain name detection model after the current training; until the first preset condition is met, using the target domain name detection model as the trained domain name detection model.
[0081] The target domain name detection model in the first training is the first domain name detection model after the training, and the target domain name detection model in other trainings (also referred to as retraining) other than the first training is the second domain name detection model after the previous training. The second domain name detection model is obtained by incrementally improving the first domain name detection model after the training.
[0082] During the first training in step 102, the target domain name detection model is the first domain name detection model after training; the malicious domain name generation model after the previous training is the basic malicious domain name generation model; the second domain name detection model after the previous training is the domain name detection model obtained by incrementally improving the first domain name detection model after training, and the incremental improved part is not trained.
[0083] For the above-mentioned basic malicious domain name generation model, any malicious domain name generation model that can generate malicious domain names can be used, and this embodiment does not limit this. For the above-mentioned incremental improvement, multiple third classifiers can be added on the basis of the multiple first classifiers after training contained in the trained first domain name detection model, and the function of the third classifier is the same as that of the first classifier, and the number of the third classifiers is less than the number of the first classifiers, thereby realizing incremental training of the second domain name detection model.
[0084] Exemplarily, the process of training the malicious domain name generation model after the previous training based on the target domain name detection model to obtain the malicious domain name generation model after the current training may include the following steps B1 to B3. In this way, the complexity of the malicious domain name generated by the malicious domain name generation model can be improved.
[0085] Step B1, using the malicious domain name generation model trained the last time to generate a second malicious domain name training sample.
[0086] The malicious domain name generation model after the previous training can generate malicious domain names using a corresponding malicious domain name generation algorithm, and the malicious domain names generated by the malicious domain name generation model after the previous training are used as second malicious domain name training samples.
[0087] Step B2: Use the target domain name detection model to perform category prediction on the second malicious domain name training sample to obtain a prediction result of the second malicious domain name training sample.
[0088] In the process of using the target domain name detection model to perform category prediction on the second malicious domain name training sample, the input of the target domain name detection model is the second malicious domain name training sample, and the output of the target domain name detection model is the predicted category score of the second malicious domain name training sample. The predicted category score of the second malicious domain name training sample is the prediction result of the second malicious domain name training sample.
[0089] Step B3, when the prediction result of the second malicious domain name training sample does not meet the second preset condition, iteratively adjust the malicious domain name generation model after the previous training, and return to step B1 until the prediction result of the second malicious domain name training sample meets the second preset condition, and obtain the malicious domain name generation model after this training.
[0090] Exemplarily, the second preset condition may be that the predicted category score of the second malicious domain name training sample reaches a maximum value.
[0091] When the prediction result of the second malicious domain name training sample does not meet the second preset condition, iteratively adjust the internal parameters of the malicious domain name generation model after the previous training to generate a malicious domain name that is more difficult to identify, until the prediction result of the second malicious domain name training sample meets the second preset condition, that is, when the prediction category score of the second malicious domain name training sample cannot be further improved, the adjusted malicious domain name generation model is used as the malicious domain name generation model after this training.
[0092] In implementation, a gradient descent method or other optimization algorithms may be used to maximize the predicted category score of the second malicious domain name training sample, which is not limited in this embodiment.
[0093] Generate malicious domain names based on the malicious domain name generation model after this training, call the malicious domain name generated by the malicious domain name generation model after this training the third malicious domain name, label the third malicious domain name by category, obtain the labeled category score of the third malicious domain name, and use the third malicious domain name and the labeled category score of the third malicious domain name as malicious domain name adversarial samples. For example, label the category score of the third malicious domain name as 0, and so on.
[0094] The malicious domain name adversarial sample and the benign domain name training sample are used to perform incremental training on the second domain name detection model after the previous training to obtain the second domain name detection model after this training, and the second domain name detection model after this training is used as the target domain name detection model for the next training.
[0095] Incremental learning is a learning method in the field of machine learning. Its core idea is to update and optimize the existing model by continuously adding new data without retraining the entire model. Incremental learning allows the model to learn in real time when receiving new data, thereby gradually adapting to and processing new data distributions and features.
[0096] In the embodiment of the present application, the second domain name detection model may include the trained multiple first classifiers, multiple third classifiers and fourth classifiers. Among them, the multiple third classifiers are used as base learners in ensemble learning, and the fourth classifier is used as a meta-learner in ensemble learning. The specific forms of the third classifier and the fourth classifier can be set according to actual needs, and this embodiment does not limit this. For example, KNN can be selected as the third classifier, LSTM can be selected as the fourth classifier, and so on.
[0097] Exemplarily, the second domain name detection model after the previous training is incrementally trained using the malicious domain name adversarial samples and the benign domain name training samples to obtain the second domain name detection model after the current training, including: using the malicious domain name adversarial samples and the benign domain name training samples to train multiple third classifiers after the previous training and the fourth classifier after the previous training contained in the second domain name detection model after the previous training to obtain the second domain name detection model after the current training. In this way, multiple fourth classifiers are added on the basis of the first domain name detection model, so that multiple first classifiers are no longer retrained, which can simplify the training process and improve training efficiency.
[0098] Exemplarily, the process of using the malicious domain name adversarial sample and the benign domain name training sample to train multiple third classifiers and the fourth classifier contained in the second domain name detection model after the previous training to obtain the second domain name detection model after the current training may include the following steps C1 to C5. By adopting the ensemble learning method, the accuracy of the second domain name detection model can be further improved.
[0099] Step C1, combining the malicious domain name adversarial sample and the benign domain name training sample as a second overall sample, and dividing the second overall sample into a third training sample and a fourth training sample.
[0100] The malicious domain adversarial samples and the benign domain training samples are combined as a second overall sample, and the second overall sample is divided into two groups, which are respectively used as a third training sample and a fourth training sample. The number of the malicious domain adversarial samples and the number of the benign domain training samples are equal or similar, and correspondingly, the number of the third training samples and the fourth training samples are the same or similar.
[0101] Step C2: using the third training sample to train the plurality of third classifiers trained in the previous time, to obtain the plurality of third classifiers trained this time.
[0102] Exemplarily, in the process of using third training samples to train multiple third classifiers after previous training, the third training samples are divided into multiple groups of third training samples, and the number of groups of third training samples is the same as the number of third classifiers. Then, each group of third training samples is used to train a third classifier after previous training. The training process of each third classifier after previous training is independent, and the training processes of multiple third classifiers after previous training can be executed in parallel, thereby improving the training efficiency.
[0103] For any third classifier after the previous training, when the input of the third classifier is a third malicious domain name, the output of the third classifier is the predicted category score of the third malicious domain name; when the input of the third classifier is a benign domain name, the output of the third classifier is the predicted category score of the benign domain name. According to the predicted category score output by the third classifier and the labeled category score obtained by labeling, the loss function of the third classifier can be calculated. When the loss function of the third classifier is greater than or equal to the fourth loss threshold, the parameters of the third classifier are iteratively adjusted to continue training; when the loss function of the third classifier is less than the fourth loss threshold, it can be determined that the training is completed and the third classifier after this training is obtained. The loss function of the above-mentioned third classifier may include but is not limited to the cross entropy loss function, the classification loss function, etc. The specific value of the above-mentioned fourth loss threshold can be set according to actual experience, and this embodiment does not limit this.
[0104] Step C3: Use the multiple third classifiers trained this time and the multiple first classifiers trained this time to perform category prediction on the fourth training samples respectively, to obtain multiple prediction results of the fourth training samples.
[0105] The fourth training sample is respectively predicted by using the multiple third classifiers after this training and the multiple first classifiers after this training, each third classifier after this training predicts a prediction result of the fourth training sample, and each first classifier after this training predicts a prediction result of the fourth training sample, thereby obtaining multiple prediction results of the fourth training sample. The number of prediction results of the fourth training sample is the same as the total number of the first classifiers and the third classifiers after training.
[0106] The prediction result of the fourth training sample includes the predicted category score of the fourth training sample. For any trained first classifier or third classifier, when the input of the trained first classifier or third classifier is the third malicious domain name, the output of the trained first classifier or third classifier is the predicted category score of the third malicious domain name; when the input of the trained first classifier or third classifier is a benign domain name, the output of the trained first classifier or third classifier is the predicted category score of the benign domain name.
[0107] Step C4, training the fourth classifier after the previous training using the fourth training sample and a plurality of prediction results of the fourth training sample to obtain the fourth classifier after the current training.
[0108] The fourth training sample and the multiple prediction results of the fourth training sample are combined to form a sixth training sample. The sixth training sample includes a sixth malicious domain name training sample and a sixth benign domain name training sample. The sixth malicious domain name training sample includes a feature obtained by combining the third malicious domain name and the multiple prediction results of the third malicious domain name, and the labeled category score of the third malicious domain name. The sixth benign domain name training sample includes a benign domain name and the feature obtained by combining the multiple prediction results of the benign domain name, and the labeled category score of the benign domain name.
[0109] The task of the fourth classifier is to combine the prediction results of multiple first classifiers and multiple third classifiers to make the final decision.
[0110] Exemplarily, in the process of training the fourth classifier after the previous training, when the input of the fourth classifier after the previous training is the third malicious domain name and the features obtained by combining multiple prediction results of the third malicious domain name, the output of the fourth classifier after the previous training is the predicted category score of the third malicious domain name; when the input of the fourth classifier after the previous training is the benign domain name and the features obtained by combining multiple prediction results of the benign domain name, the output of the fourth classifier after the previous training is the predicted category score of the benign domain name. According to the predicted category score output by the fourth classifier after the previous training and the labeled category score obtained by labeling, the loss function of the fourth classifier after the previous training can be calculated. When the loss function of the fourth classifier after the previous training is greater than or equal to the fifth loss threshold, the parameters of the fourth classifier after the previous training are iteratively adjusted to continue training; when the loss function of the fourth classifier after the previous training is less than the fifth loss threshold, it can be determined that the training is completed and the fourth classifier after this training is obtained.
[0111] The loss function of the fourth classifier may include but is not limited to a cross entropy loss function, a classification loss function, etc. The specific value of the fifth loss threshold may be set according to actual experience, and this embodiment does not limit this.
[0112] Step C5: using the trained multiple first classifiers, the trained multiple third classifiers and the trained fourth classifier as the trained second domain name detection model.
[0113] Repeat the above training process until the first preset condition is met and then stop the training, and use the currently obtained target domain name detection model as the trained domain name detection model. The trained domain name detection model may include multiple trained first classifiers (i.e., multiple first classifiers after the above training), multiple trained third classifiers (i.e., multiple third classifiers after the last training) and a trained fourth classifier (i.e., the fourth classifier after the last training).
[0114] For example, the first preset condition may be that the predicted category score of the second malicious domain name training sample reaches a maximum value. That is, when the domain name generation model cannot generate a new malicious domain name that can effectively improve the category score, the training process ends, which means that the second domain name detection model is powerful enough to resist attacks within the current capability of the domain name generation model.
[0115] In the embodiment of the present application, an incremental training method is adopted for a separate domain name detection model. Figure 2 Schematic diagram of an incremental training process in an embodiment of the present application. Figure 2 As shown, n weak learners (ie, the third classifier mentioned above) are used to predict the training data (ie, the third training sample mentioned above) to obtain n prediction results, and then the final result is predicted based on the training data and the n prediction results of the training data.
[0116] In the embodiment of the present application, a game training method is adopted for the domain name detection model and the domain name generation model. Figure 3 Schematic diagram of a game training process in an embodiment of the present application. Figure 3 As shown, the generator G (that is, the domain name generation model mentioned above) is used to generate malicious domain names; the detector D (that is, the target domain name detection model mentioned above) is used to feedback the score (that is, the category score of that number) for the malicious domain names; the generator G is updated according to the score, and the detector D is also updated during the training process, and the above process is executed in a loop to achieve game training.
[0117] Through the above-mentioned game training process, the domain name detection model can gradually adapt to and identify various complex malicious domain names, thereby improving its overall performance. At the same time, this also requires the domain name generation model to continuously evolve its generation algorithm to generate more hidden malicious domain names, thereby promoting the continuous improvement of the entire detection algorithm.
[0118] In the embodiment of the present application, initial training is first performed to obtain a first domain name detection model, and then incremental improvements are performed on the basis of the trained first domain name detection model to obtain a second domain name detection model. Game training is performed on the malicious domain name generation model and the second domain name detection model, so that the malicious domain name generation model can continuously adjust its strategy for generating malicious domain names to generate malicious domain names that are more difficult to identify, and at the same time, the second domain name detection model can continuously face various complex malicious domain name challenges, thereby continuously improving its detection accuracy. At the same time, the second domain name detection model is incrementally trained during the game training process, thereby reducing the complexity of the training process. This method does not rely on artificial feature engineering, and the domain name detection model obtained by this training method has higher accuracy and can better cope with various unknown and complex malicious domain name scenarios.
[0119] Reference Figure 4 , shows a step flow chart of a domain name detection method according to an embodiment of the present application.
[0120] like Figure 4 As shown, the domain name detection method may include the following steps:
[0121] Step 401, obtaining the domain name to be detected.
[0122] The domain names to be tested can be collected in real time or extracted from a test set.
[0123] For example, a domain name collection module can be deployed in front of a DNS (Domain Name System) server. The module is responsible for real-time monitoring and collecting domain names to be detected. The domain name collection module organizes the captured domain names to be detected to form a domain name data set to be detected.
[0124] Step 402: input the domain name to be detected into the trained domain name detection model to obtain output information of the trained domain name detection model, wherein the output information is used to indicate the category of the domain name to be detected, which is one of a malicious domain name and a benign domain name.
[0125] The trained domain name detection model is obtained by training using the model training method described in any one of the above embodiments.
[0126] The domain name to be detected is input into the trained domain name detection model. Specifically, the domain name to be detected is respectively input into multiple trained first classifiers and multiple trained third classifiers. Each trained first classifier predicts the input domain name to be detected according to the knowledge it has learned, and outputs a prediction result of the domain name to be detected. Each trained third classifier also predicts the input domain name to be detected according to the knowledge it has learned, and outputs a prediction result of the domain name to be detected.
[0127] The prediction results of all the trained first classifiers and the trained third classifiers for the same domain name to be detected are collected, and the features obtained by combining the domain name to be detected and multiple prediction results of the domain name to be detected are used as new feature vectors, which are input into the trained fourth classifier. The trained fourth classifier has learned how to combine these features to make a final prediction through the previous training process, so the trained fourth classifier can output the final prediction result of the domain name to be detected.
[0128] The final prediction result of the domain name to be detected output by the trained fourth classifier is the output information of the trained domain name detection model.
[0129] The above prediction result can be a category score of the domain name to be detected (or a category label, such as "malicious" or "benign", etc.). The output information is used to indicate the category of the domain name to be detected, which is one of a malicious domain name and a benign domain name.
[0130] In the embodiment of the present application, if the domain name to be detected is detected as a malicious domain name, an alarm notification will be issued for the domain name to be detected. The alarm notification can be sent in a variety of ways, such as email, SMS or system log, so that relevant personnel can be informed in time and take corresponding treatment measures. At the same time, the detected malicious domain name can be added to the blacklist to prevent it from being resolved or accessed again.
[0131] Through the method described in this embodiment, real-time detection and warning of malicious domain names can be achieved, thereby improving the efficiency and accuracy of network security protection.
[0132] The embodiments of the present application mainly include the following parts:
[0133] Incremental learning algorithm: The domain name detection model uses an incremental learning algorithm, which is a method that can continuously learn new data and update the model. Unlike traditional machine learning algorithms, incremental learning does not require retraining the entire model every time new data is added, but can integrate new data with the existing model for update to achieve incremental improvement of the model. In an embodiment of the present application, the incremental learning algorithm is used to train a new weak learner (i.e., the third classifier) with the help of newly generated malicious domain names, thereby continuously improving the performance of the domain name detection model.
[0134] Adversarial Domain Name Generation: An adversarial domain name generation model is introduced to generate malicious domain names and compete with the incremental domain name detection model. The domain name generation model can continuously adjust its generation strategy to generate malicious domain names that are more difficult to be identified by the domain name detection model. In this way, a dynamic confrontation process is formed between the domain name generation model and the domain name detection model, which drives both sides to continuously improve their performance.
[0135] The embodiments of this application can achieve the following beneficial effects:
[0136] Improve detection efficiency: Through the incremental learning algorithm, the domain name detection model can continuously learn and adapt to new malicious domain names without retraining the entire model. This greatly improves the efficiency and response speed of the domain name detection model, enabling it to identify new malicious domain names more quickly.
[0137] Improve detection accuracy: The game training process between the adversarial domain name generation model and the domain name detection model enables the domain name detection model to continuously face various complex malicious domain name challenges, thereby continuously improving its detection accuracy. This dynamic adversarial training method helps to discover possible loopholes and weaknesses in the domain name detection model and prompts it to improve.
[0138] Enhance system robustness: Through continuous confrontation and training, both the domain name generation model and the domain name detection model will become more powerful and robust. This mutual improvement process makes the entire system more robust and better able to cope with various unknown and complex attack scenarios.
[0139] Saving resources and time: Since the incremental learning algorithm only needs to learn the newly added data instead of retraining the entire model, it can greatly save computing resources and time costs. This is especially important for application scenarios that process large-scale data sets and real-time data streams.
[0140] Reference Figure 5 , shows a structural block diagram of a model training device in an embodiment of the present application.
[0141] like Figure 5 As shown, the model training device may include the following modules:
[0142] The first training model 501 is used to obtain a first malicious domain name training sample and a benign domain name training sample, and train a first domain name detection model using the first malicious domain name training sample and the benign domain name training sample to obtain a trained first domain name detection model;
[0143] The second training module 502 is used to repeatedly perform the following training process: training the malicious domain name generation model after the previous training based on the target domain name detection model to obtain the malicious domain name generation model after the current training; generating malicious domain name adversarial samples based on the malicious domain name generation model after the current training, and performing incremental training on the second domain name detection model after the previous training using the malicious domain name adversarial samples and the benign domain name training samples to obtain the second domain name detection model after the current training; until the first preset condition is met, the target domain name detection model is used as the trained domain name detection model;
[0144] Among them, the target domain name detection model in the first training is the first domain name detection model after the training, and the target domain name detection model in other trainings is the second domain name detection model after the previous training; the second domain name detection model is obtained by incrementally improving the first domain name detection model after the training.
[0145] Optionally, the first domain name detection model includes multiple first classifiers and second classifiers; the first training module 501 is specifically used to: merge the first malicious domain name training sample and the benign domain name training sample as a first overall sample, and divide the first overall sample into a first training sample and a second training sample; use the first training sample to train the multiple first classifiers to obtain multiple trained first classifiers; use the trained multiple first classifiers to perform category prediction on the second training samples respectively to obtain multiple prediction results of the second training samples; use the second training sample and the multiple prediction results of the second training sample to train the second classifier to obtain a trained second classifier; use the trained multiple first classifiers and the trained second classifier as the trained first domain name detection model.
[0146] Optionally, the second training module 502 includes: a first training submodule, used to generate a second malicious domain name training sample using the malicious domain name generation model after the previous training; use the target domain name detection model to perform category prediction on the second malicious domain name training sample to obtain a prediction result of the second malicious domain name training sample; when the prediction result of the second malicious domain name training sample does not meet the second preset condition, iteratively adjust the malicious domain name generation model after the previous training, and return to the step of generating the second malicious domain name training sample using the malicious domain name generation model after the previous training, until the prediction result of the second malicious domain name training sample meets the second preset condition, and the malicious domain name generation model after this training is obtained.
[0147] Optionally, the trained first domain name detection model includes multiple trained first classifiers, and the second domain name detection model includes multiple trained first classifiers, multiple third classifiers and fourth classifiers; the second training module 502 includes: a second training submodule, which is used to use the malicious domain name adversarial samples and the benign domain name training samples to train the multiple third classifiers and the fourth classifier contained in the second domain name detection model after the previous training, so as to obtain the second domain name detection model after this training.
[0148] Optionally, the second training submodule is specifically used to: merge the malicious domain name adversarial sample and the benign domain name training sample as a second overall sample, and divide the second overall sample into a third training sample and a fourth training sample; use the third training sample to train the multiple third classifiers after the previous training to obtain multiple third classifiers after this training; use the multiple third classifiers after this training and the multiple first classifiers after training to perform category prediction on the fourth training sample respectively to obtain multiple prediction results of the fourth training sample; use the fourth training sample and the multiple prediction results of the fourth training sample to train the fourth classifier after the previous training to obtain the fourth classifier after this training; use the multiple first classifiers after training, the multiple third classifiers after this training, and the fourth classifier after this training as the second domain name detection model after this training.
[0149] Reference Figure 6 , shows a structural block diagram of a domain name detection device according to an embodiment of the present application.
[0150] like Figure 6 As shown, the domain name detection device may include the following modules:
[0151] The acquisition module 601 is used to acquire the domain name to be detected;
[0152] A detection module 602 is used to input the domain name to be detected into the trained domain name detection model to obtain output information of the trained domain name detection model, where the output information is used to indicate the category of the domain name to be detected, where the category is one of a malicious domain name and a benign domain name;
[0153] The trained domain name detection model is obtained by training using the model training method described in any of the above embodiments.
[0154] In the embodiment of the present application, initial training is first performed to obtain a first domain name detection model, and then incremental improvements are performed on the basis of the trained first domain name detection model to obtain a second domain name detection model. Game training is performed on the malicious domain name generation model and the second domain name detection model, so that the malicious domain name generation model can continuously adjust its strategy for generating malicious domain names to generate malicious domain names that are more difficult to identify, and at the same time, the second domain name detection model can continuously face various complex malicious domain name challenges, thereby continuously improving its detection accuracy. At the same time, the second domain name detection model is incrementally trained during the game training process, thereby reducing the complexity of the training process. This method does not rely on artificial feature engineering, and the domain name detection model obtained by this training method has higher accuracy and can better cope with various unknown and complex malicious domain name scenarios.
[0155] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0156] In an embodiment of the present application, an electronic device is also provided. The electronic device may include a processor and a computer-readable storage medium, wherein a computer program is stored on the computer-readable storage medium; when the computer program is executed by the processor, the processor executes the model training method described in any of the above embodiments, or executes the domain name detection method described in any of the above embodiments.
[0157] Reference Figure 7 , shows a structural block diagram of an electronic device according to an embodiment of the present application. Figure 7 As shown, the electronic device 70 includes a processor 701 and a computer-readable storage medium 702 , on which a computer program 7021 is stored.
[0158] The processor 701 is used to execute the computer program 7021 stored on the computer-readable storage medium 702. When executing the computer program 7021, the processor 701 executes the model training method described in any of the above embodiments, or executes the domain name detection method described in any of the above embodiments, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0159] The processor 701 mentioned above may include but is not limited to: a central processing unit (CPU), a network processor (NP), a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
[0160] The computer-readable storage medium 702 mentioned above may include but is not limited to: read-only memory (ROM), random access memory (RAM), compact disc read-only memory (CD-ROM), electronic erasable programmable read-only memory (EEPROM), hard disk, floppy disk, flash memory, etc.
[0161] In an embodiment of the present application, a computer-readable storage medium is further provided, on which a computer program is stored. The computer program can be executed by a processor of an electronic device. When the computer program is executed by the processor, the processor executes the model training method described in any of the above embodiments, or executes the domain name detection method described in any of the above embodiments.
[0162] Reference Figure 8 , shows a block diagram of a computer-readable storage medium according to an embodiment of the present application. Figure 8 As shown, a computer program 801 is stored on a computer-readable storage medium 80. When the computer program 801 is executed by a processor, the processor executes the model training method described in any of the above embodiments, or executes the domain name detection method described in any of the above embodiments, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0163] The various embodiments in this specification are interrelated, and each embodiment is described in a progressive manner. Each embodiment focuses on the differences from other embodiments, and the same or similar parts between the various embodiments can be referenced to each other.
[0164] It should be noted that all actions to obtain signals, information or data in this application are carried out in compliance with the relevant data protection laws and policies of the location and with the authorization given by the owner of the corresponding device.
[0165] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "comprise one..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements.
[0166] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application.
[0167] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.
[0168] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed in the present application can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0169] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0170] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0171] The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, each functional unit in each embodiment of the present application may be integrated into a processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0172] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. In summary, the content of this specification should not be understood as limiting the present application.
Claims
1. A model training method, characterized in that: The method comprises: Obtaining a first malicious domain name training sample and a benign domain name training sample, and training a first domain name detection model using the first malicious domain name training sample and the benign domain name training sample to obtain a trained first domain name detection model; Repeat the following training process: train the malicious domain name generation model after the previous training based on the target domain name detection model to obtain the malicious domain name generation model after the current training; generate malicious domain name adversarial samples based on the malicious domain name generation model after the current training, and perform incremental training on the second domain name detection model after the previous training using the malicious domain name adversarial samples and the benign domain name training samples to obtain the second domain name detection model after the current training; After the first preset condition is met, the target domain name detection model is used as the trained domain name detection model; Among them, the target domain name detection model in the first training is the first domain name detection model after the training, and the target domain name detection model in other trainings is the second domain name detection model after the previous training; the second domain name detection model is obtained by incrementally improving the first domain name detection model after the training.
2. The method according to claim 1, characterized in that The first domain name detection model includes a plurality of first classifiers and second classifiers; the first malicious domain name training sample and the benign domain name training sample are used to train the first domain name detection model to obtain the trained first domain name detection model, including: Combining the first malicious domain name training sample and the benign domain name training sample as a first overall sample, and dividing the first overall sample into a first training sample and a second training sample; Using the first training samples to train the plurality of first classifiers to obtain a plurality of trained first classifiers; Using the trained multiple first classifiers to perform category prediction on the second training samples respectively, to obtain multiple prediction results of the second training samples; Training the second classifier using the second training sample and a plurality of prediction results of the second training sample to obtain a trained second classifier; The trained multiple first classifiers and the trained second classifier are used as the trained first domain name detection model.
3. The method according to claim 1, characterized in that The method of training the malicious domain name generation model trained previously based on the target domain name detection model to obtain the malicious domain name generation model trained this time includes: Generate a second malicious domain name training sample by using the malicious domain name generation model trained previously; Using the target domain name detection model to perform category prediction on the second malicious domain name training sample to obtain a prediction result of the second malicious domain name training sample; When the prediction result of the second malicious domain name training sample does not meet the second preset condition, iteratively adjust the malicious domain name generation model after the previous training, and return to the step of generating the second malicious domain name training sample using the malicious domain name generation model after the previous training, until the prediction result of the second malicious domain name training sample meets the second preset condition, and obtain the malicious domain name generation model after this training.
4. The method according to claim 1, characterized in that The trained first domain name detection model includes a plurality of trained first classifiers, and the second domain name detection model includes the plurality of trained first classifiers, a plurality of third classifiers, and a fourth classifier; The method of using the malicious domain name adversarial samples and the benign domain name training samples to incrementally train the second domain name detection model after the previous training to obtain the second domain name detection model after the current training includes: using the malicious domain name adversarial samples and the benign domain name training samples to train multiple third classifiers after the previous training and a fourth classifier after the previous training contained in the second domain name detection model after the previous training to obtain the second domain name detection model after the current training.
5. The method according to claim 4, characterized in that The method uses the malicious domain name adversarial sample and the benign domain name training sample to train the multiple third classifiers and the fourth classifier contained in the second domain name detection model after the previous training to obtain the second domain name detection model after the current training, including: Combining the malicious domain name adversarial sample and the benign domain name training sample as a second overall sample, and dividing the second overall sample into a third training sample and a fourth training sample; Using the third training sample to train the plurality of third classifiers trained in the previous time, to obtain the plurality of third classifiers trained this time; Using the multiple third classifiers trained this time and the multiple first classifiers trained this time to perform category prediction on the fourth training samples respectively, to obtain multiple prediction results for the fourth training samples; Using the fourth training sample and a plurality of prediction results of the fourth training sample to train the fourth classifier after the previous training, to obtain the fourth classifier after the current training; The trained multiple first classifiers, the trained multiple third classifiers and the trained fourth classifier are used as the trained second domain name detection model.
6. A domain name detection method, characterized in that: The method comprises: Get the domain name to be tested; Inputting the domain name to be detected into a trained domain name detection model to obtain output information of the trained domain name detection model, wherein the output information is used to indicate a category of the domain name to be detected, wherein the category is one of a malicious domain name and a benign domain name; The trained domain name detection model is obtained by training using the model training method described in any one of claims 1 to 5.
7. A model training device, characterized in that: The device comprises: A first training model is used to obtain a first malicious domain name training sample and a benign domain name training sample, and train a first domain name detection model using the first malicious domain name training sample and the benign domain name training sample to obtain a trained first domain name detection model; The second training module is used to repeatedly perform the following training process: training the malicious domain name generation model after the previous training based on the target domain name detection model to obtain the malicious domain name generation model after the current training; generating malicious domain name adversarial samples based on the malicious domain name generation model after the current training, and performing incremental training on the second domain name detection model after the previous training using the malicious domain name adversarial samples and the benign domain name training samples to obtain the second domain name detection model after the current training; until the first preset condition is met, the target domain name detection model is used as the trained domain name detection model; Among them, the target domain name detection model in the first training is the first domain name detection model after the training, and the target domain name detection model in other trainings is the second domain name detection model after the previous training; the second domain name detection model is obtained by incrementally improving the first domain name detection model after the training.
8. A domain name detection device, characterized in that: The device comprises: An acquisition module is used to obtain the domain name to be detected; A detection module, used for inputting the domain name to be detected into a trained domain name detection model, and obtaining output information of the trained domain name detection model, wherein the output information is used for indicating a category of the domain name to be detected, wherein the category is one of a malicious domain name and a benign domain name; The trained domain name detection model is obtained by training using the model training method described in any one of claims 1 to 5.
9. An electronic device, characterized in that: The electronic device comprises a processor and a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program; When the computer program is executed by the processor, the processor executes the model training method as described in any one of claims 1 to 5, or executes the domain name detection method as described in claim 6.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program. When the computer program is executed by a processor, the processor executes the model training method according to any one of claims 1 to 5, or executes the domain name detection method according to claim 6.
Citation Information
Patent Citations
Malicious software detection method and device, storage medium and electronic equipment
CN112380537A
Domain name generation method, device and equipment based on generative adversarial network
CN114726823A
Domain name recognition model training method and device, electronic equipment and storage medium
CN115022001A
Malicious domain name detection method and device based on self-attention generative adversarial network
CN115086054A
Malicious domain name detection method and device
CN116684144A