Malicious domain name identification method, device, computer equipment and readable storage medium
Through the combination of convolutional layer, attention mechanism and sequence processing components, the domain name features are extracted and fused, and the problem of insufficient accuracy of traditional methods in asymmetric distribution data and outliers processing is solved, and the accuracy of malicious domain name recognition is improved. The stability of the model.
Patent Information
- Application Number
- CN202411155674.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-22
- Publication Date
- 2024-12-03
- Estimated Expiration
- 2044-08-22
AI Technical Summary
Traditional malicious domain name recognition methods are insufficient in processing asymmetric distributed data or outliers, resulting in a decrease in the accuracy of malicious domain name recognition.
A feature processing component that is coupled with a convolutional layer and attention mechanism is adopted to improve the recognition accuracy of malicious domain names through feature extraction and enhancement representation, and combined with sequence processing components.
It significantly improves the accuracy of malicious domain name recognition, avoids the problem of gradient vanishing, enhances the ability to extract complex features, and improves the robustness and generalization capabilities of the model.
Smart Images

Figure CN118677704B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of domain name identification, and in particular to a method, apparatus, computer device and readable storage medium for identifying malicious domain names. Background Art
[0002] A domain name is an address system used to identify a specific computer or network service on the Internet. For example, www.example.com is a typical domain name that points to a specific server location. In recent years, with the continuous development of network technology, the use of malicious domain names has become more common and more covert. Attackers use malicious domain names to carry out various attacks, including but not limited to phishing, information theft, and malware distribution. These attack methods are constantly escalating, becoming more complex and covert, resulting in traditional network security defense methods not being able to identify malicious domain names. Therefore, it is particularly important to classify and detect domain names in order to take measures in advance to prevent attacks from occurring.
[0003] In the related technology, a large amount of benign domain name data, including high-order statistical features and Domain Name System (DNS) features, is generally collected, and the Hidden Markov Model (HMM) is trained using the extracted features, and the probability density value of each domain name is calculated, and the standard deviation of each feature is calculated and compared with the probability density value. When the probability density value of a feature deviates significantly from its standard deviation, the domain name is marked as malicious. However, this method may have errors in calculating the probability density value of each feature, and for asymmetrically distributed data or when there are many outliers, using only the standard deviation to judge the anomaly may not be accurate enough. In other words, using the above technology to identify malicious domain names will lead to a decrease in the accuracy of malicious domain name identification. Summary of the invention
[0004] The main purpose of the embodiments of the present application is to propose a malicious domain name identification method, device, computer equipment and readable storage medium, which can improve the accuracy of malicious domain name identification.
[0005] To achieve the above-mentioned purpose, a first aspect of an embodiment of the present application proposes a method for identifying a malicious domain name, the method comprising:
[0006] Acquire the data to be classified corresponding to the domain name to be classified, and input the data to be classified into the target model; wherein the target model includes a first feature processing component, a second feature processing component and a classification component;
[0007] Extracting features through the first feature processing component to obtain features to be classified corresponding to the domain name to be classified;
[0008] Performing at least one feature enhancement representation on the feature to be classified based on the attention mechanism by the second feature processing component to obtain a first intermediate feature; wherein the second feature processing component is obtained by coupling a convolutional layer with the attention mechanism;
[0009] Fusing the feature to be classified with the first intermediate feature to obtain a first fused feature;
[0010] The first fusion feature is input into the classification component for feature mapping processing to obtain a malicious domain name identification result of the data to be classified.
[0011] Accordingly, a second aspect of an embodiment of the present application provides a malicious domain name identification device, the device comprising:
[0012] An acquisition module is used to acquire the data to be classified corresponding to the domain name to be classified, and input the data to be classified into a target model; wherein the target model includes a first feature processing component, a second feature processing component and a classification component;
[0013] An extraction module, configured to extract features through the first feature processing component to obtain features to be classified corresponding to the domain name to be classified;
[0014] an enhancement module, configured to perform at least one feature enhancement representation on the feature to be classified based on an attention mechanism through the second feature processing component to obtain a first intermediate feature; wherein the second feature processing component is obtained by coupling a convolutional layer with the attention mechanism;
[0015] A fusion module, used for fusing the feature to be classified with the first intermediate feature to obtain a first fused feature;
[0016] A mapping module is used to input the first fusion feature into the classification component for feature mapping processing to obtain a malicious domain name identification result of the data to be classified.
[0017] In some implementations, the target model further includes a sequence processing component located between the second feature processing component and the classification component, and the malicious domain name identification device further includes a splicing module for fusing the feature to be classified with the first intermediate feature to obtain a first fused feature and then executing:
[0018] By means of the sequence processing component, based on the time sequence information of the plurality of first feature elements in the first fused feature, feature enhancement representation is performed on the plurality of first feature elements to obtain a second intermediate feature;
[0019] Splicing the first fused feature and the second intermediate feature to obtain a first splicing feature;
[0020] Then, the first fusion feature is input into the classification component for feature mapping processing to obtain a malicious domain name recognition result of the data to be classified, including:
[0021] The first splicing feature is input into the classification component for feature mapping processing to obtain a malicious domain name identification result of the data to be classified.
[0022] In some embodiments, the splicing module is further used for:
[0023] Determining, by the sequence processing component, a query vector corresponding to a last time step and at least one hidden vector corresponding to other time steps from the first fused features based on time sequence information of each of the first feature elements in the first fused features;
[0024] Performing dot product calculations on the query vector and the hidden vector of each time step in turn to obtain an attention score corresponding to the hidden vector of each time step; wherein the attention score is used to characterize the similarity between the hidden vector of each time step and the query vector;
[0025] Based on the attention score of each of the hidden vectors, each of the first feature elements in the corresponding hidden vector is adjusted to obtain a second intermediate feature.
[0026] In some embodiments, the splicing module is further used for:
[0027] Adjusting each of the first feature elements in the corresponding hidden vector based on the attention score of each of the hidden vectors to obtain an adjusted first feature element;
[0028] For each feature dimension of the first fusion feature, first feature elements at different time steps corresponding to the feature dimension are added to obtain a target feature element corresponding to the feature dimension;
[0029] A second intermediate feature is obtained according to the multiple target feature elements corresponding to the multiple dimensions.
[0030] In some embodiments, the enhancement module is further used to:
[0031] Inputting the feature to be classified into the first convolutional layer of the second feature processing component for dimensionality reduction processing to obtain the feature to be classified with reduced dimensionality;
[0032] Inputting the feature to be classified into the attention mechanism to obtain an attention weight representing the importance of each second feature element in the feature to be classified;
[0033] Performing attention adjustment processing on each of the second feature elements in the feature to be classified based on the attention weight to obtain an initial intermediate feature;
[0034] The feature dimension of the initial intermediate feature is adjusted according to the second convolutional layer of the second feature processing component to obtain a first intermediate feature.
[0035] In some implementations, the malicious domain name identification device further includes a training module for:
[0036] Obtain a first model trained in a first environment;
[0037] Determining, from the first model, a target level corresponding to each preset level in the candidate preset model of the second environment;
[0038] Obtaining weight information of each target level, and mapping the weight information to the corresponding preset level of the candidate preset model, to obtain the preset model after updating the weight information;
[0039] A training data set corresponding to the second environment is obtained, and the preset model is trained based on the training data set to obtain a target model.
[0040] In some embodiments, the training module is further used to:
[0041] Acquire an initial data set under a second environment, and determine maximum value data and minimum value data from a plurality of initial data of the initial data set;
[0042] Determine a difference between the maximum value data and the minimum value data as a first intermediate value;
[0043] For each of the initial data, determining a difference between the initial data and the minimum value data as a second intermediate value;
[0044] Using the ratio of the second intermediate value to the first intermediate value as sample data corresponding to the initial data;
[0045] Based on the plurality of sample data, a training data set is obtained.
[0046] Correspondingly, the third aspect of the embodiments of the present application proposes a computer device, which includes a memory and a processor, the memory stores a computer program, and the processor implements the malicious domain name identification method described in any one of the embodiments of the first aspect of the present application when executing the computer program.
[0047] Correspondingly, the fourth aspect of the embodiments of the present application proposes a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the malicious domain name identification method described in any one of the embodiments of the first aspect of the present application.
[0048] The embodiment of the present application obtains the data to be classified corresponding to the domain name to be classified, and inputs the data to be classified into the target model; wherein the target model includes a first feature processing component, a second feature processing component and a classification component; the first feature processing component is used to extract features to obtain the features to be classified corresponding to the domain name to be classified; the second feature processing component is used to perform at least one feature enhancement representation on the features to be classified based on the attention mechanism to obtain the first intermediate feature; wherein the second feature processing component is obtained by coupling the convolution layer with the attention mechanism; the features to be classified are fused with the first intermediate feature to obtain the first fused feature; the first fused feature is input into the classification component for feature mapping processing to obtain the malicious domain name recognition result of the data to be classified. In this way, the second feature component obtained by coupling the convolution layer with the attention mechanism can be used to guide the target model to determine important features using the attention mechanism in the early stage of feature extraction, focusing on the processing of key information, which helps the target model to more efficiently and accurately extract information that is conducive to identifying malicious domain names. Moreover, since the features to be classified are represented by feature enhancement at least once, the target model can extract more complex and deeper features and fuse the features to be classified with the first intermediate features, thus avoiding the problem of inaccurate malicious domain name recognition caused by gradient vanishing and improving the accuracy of malicious domain name recognition. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] Figure 1 It is a schematic diagram of the architecture of the malicious domain name identification system provided in an embodiment of the present application;
[0050] Figure 2 is a flow chart of a malicious domain name identification method provided by an embodiment of the present application;
[0051] Figure 3 It is a basic model diagram of the target model provided in the embodiment of the present application;
[0052] Figure 4 is a partial structural diagram of a target model for obtaining a first fusion feature provided in an embodiment of the present application;
[0053] Figure 5 is a partial structural diagram of a target model for obtaining a first splicing feature provided in an embodiment of the present application;
[0054] Figure 6 It is a schematic diagram of the functional modules of the malicious domain name identification device provided in an embodiment of the present application;
[0055] Figure 7 It is a schematic diagram of the hardware structure of the computer device provided in the embodiment of the present application. DETAILED DESCRIPTION
[0056] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0057] It should be noted that, although the functional modules are divided in the device schematic diagram and the logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the device or the order in the flowchart. The terms "first", "second", etc. in the specification, claims and the above drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.
[0058] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0059] A domain name is an address system used to identify a specific computer or network service on the Internet. For example, www.example.com is a typical domain name that points to a specific server location. In recent years, with the continuous development of network technology, the use of malicious domain names has become more common and more covert. Attackers use malicious domain names to carry out various attacks, including but not limited to phishing, information theft, and malware distribution. These attack methods are constantly escalating, becoming more complex and covert, resulting in traditional network security defense methods not being able to identify malicious domain names. Therefore, it is particularly important to classify and detect domain names in order to take measures in advance to prevent attacks from occurring.
[0060] In the related technology, a large amount of benign domain name data, including high-order statistical features and Domain Name System (DNS) features, is generally collected, and the Hidden Markov Model (HMM) is trained using the extracted features, and the probability density value of each domain name is calculated, and the standard deviation of each feature is calculated and compared with the probability density value. When the probability density value of a feature deviates significantly from its standard deviation, the domain name is marked as malicious. However, this method may have errors in calculating the probability density value of each feature, and for asymmetrically distributed data or when there are many outliers, using only the standard deviation to judge the anomaly may not be accurate enough. In other words, using the above technology to identify malicious domain names will lead to a decrease in the accuracy of malicious domain name identification.
[0061] Based on this, the embodiments of the present application provide a malicious domain name identification method, apparatus, computer equipment and readable storage medium, which can improve the accuracy of malicious domain name identification.
[0062] The malicious domain name identification method, apparatus, computer device and readable storage medium provided in the embodiments of the present application are specifically described through the following embodiments. First, the malicious domain name identification system in the embodiments of the present application is described.
[0063] Please refer to Figure 1 In some implementations, an embodiment of the present application provides a malicious domain name identification system, including a terminal 11 and a server 12.
[0064] Exemplarily, the terminal 11 may be a network sensor, a firewall device, a dedicated network monitoring hardware, or a common computer with specific software installed. Specifically, the terminal 11 may collect flow data in a network environment through a dedicated hardware device or software installed on the terminal 11. The terminal 11 may also perform preliminary data preprocessing, such as filtering irrelevant data streams, retaining only flow data related to malicious domain names, and sending the preprocessed data to the server 12 for further processing and analysis.
[0065] Exemplarily, the server side 12 can be a high-performance server cluster, a cloud computing platform, or hardware designed specifically for data processing and analysis. Specifically, the server side 12 can receive data from the terminal, perform more in-depth data preprocessing, including label encoding, data cleaning, feature scaling, etc., and use the preprocessed data to train the preset model. During the training period, the preset model can be updated according to new data or feedback information to adapt to the ever-changing network threat environment. Furthermore, the server side can also run the trained target model to analyze real-time or batch data to detect potential network attack behaviors, and feed back the detection results to the terminal 11 or other related systems so that corresponding protective measures can be taken, thereby achieving efficient and accurate network attack detection and defense.
[0066] The malicious domain name identification method in the embodiment of the present application can be illustrated by the following embodiment.
[0067] It should be noted that in each specific implementation of the present application, when it comes to the need to perform relevant processing based on data related to user identity or characteristics such as user information, user behavior data, user historical data, and user location information, the user's permission or consent will be obtained first. Moreover, the collection, use, and processing of these data will comply with relevant laws, regulations, and standards. In addition, when the embodiment of the present application needs to obtain the user's sensitive personal information, the user's separate permission or separate consent will be obtained through a pop-up window or by jumping to a confirmation page. After clearly obtaining the user's separate permission or separate consent, the necessary user-related data for enabling the normal operation of the embodiment of the present application will be obtained.
[0068] In the embodiment of the present application, the malicious domain name identification device will be described from the perspective of the malicious domain name identification device, which can be specifically integrated into a computer device. Figure 2 , Figure 2 This is a flowchart of the steps of the malicious domain name identification method provided in the embodiment of the present application. The embodiment of the present application takes the malicious domain name identification device as an example, which is specifically integrated in a terminal or a server. When the processor on the terminal or the server executes the program instructions corresponding to the malicious domain name identification method, the specific process is as follows:
[0069] Step 101, obtaining the data to be classified corresponding to the domain name to be classified, and inputting the data to be classified into the target model; wherein the target model includes a first feature processing component, a second feature processing component and a classification component.
[0070] In some embodiments, in order to enable the target model to make decisions based on specific features and thus effectively identify malicious behavior, the data to be classified corresponding to the domain name to be classified can be obtained and input into the target model to facilitate the identification and classification of malicious domain names.
[0071] The domain name to be classified may be a domain name to be identified and classified.
[0072] The data to be classified may be data related to the domain name to be classified. The data to be classified may include but is not limited to the domain name to be classified itself (or the corresponding label code), or may be a combination of Internet Protocol (IP) address data, registration data, Domain Name System (DNS) records, etc. corresponding to the domain name to be classified. The data to be classified may be used as input to the target model to identify malicious domain names.
[0073] Among them, the target model can be a deep learning model for identifying malicious domain names. The target model can use the residual network (ResNet) as a basic model. For example, ResNet-34, ResNet-50, ResNet-101, etc. can be used as basic models. This application takes ResNet-50 as an example, but it is also applicable to other residual networks as long as they do not deviate from the concept of this application.
[0074] Among them, the first feature processing component can be used to extract useful features from the data to be classified.
[0075] Among them, the second feature processing component can be a feature enhancement component obtained by coupling the convolutional layer and the attention mechanism.
[0076] Among them, the classification component may include a fully connected layer for classifying features and then identifying the category of malicious domain names.
[0077] Exemplarily, the packet capture technology of the Data Plane Development Kit (DPDK) can be used to collect traffic data containing malicious domain name information, and the traffic data can be preprocessed to obtain the data to be classified. Alternatively, the data to be classified can be obtained by other means, and the acquired traffic can only contain traffic data of malicious domain name information, or can include both traffic data corresponding to malicious domain name information and traffic data corresponding to benign domain name information. The embodiments of the present application do not impose too many restrictions on this.
[0078] Furthermore, after obtaining the traffic data, the data can be preprocessed to ensure that the processed data is suitable for the data format of the target model. Specifically, the label encoding method can be used to convert the categorical variable values into numerical values, and the traffic data can be processed to delete missing, meaningless and duplicate data to improve the data quality and model performance. Finally, the minimum-maximum scaling technique is used to re-adjust all columns of the traffic data so that the data of the traffic data are on the same scale, so that the data to be classified can be obtained.
[0079] Furthermore, the data to be classified can be input into a pre-trained target model, and a series of processing can be performed on the data to be classified through the target model to obtain malicious domain name identification results of the data to be classified.
[0080] In some embodiments, in order to make the target model have good classification ability, the residual network can be used as the basic model of the preset model, and the preset model can be trained, so that the preset model can extract deep features as much as possible during the training process, while avoiding the problems of gradient disappearance and gradient explosion, thereby improving the accuracy of identifying and classifying the data to be classified. At the same time, in order to improve the detection efficiency of the target model in different scenarios and enhance the robustness and generalization ability of the model, the learned knowledge can be transferred from one field (or task) to another field (or task) to complete the task requirements. For example, the target model can be trained in the following ways:
[0081] (B.1) Obtaining a first model trained in a first environment;
[0082] (B.2) determining, from the first model, a target level corresponding to each preset level in the candidate preset model of the second environment;
[0083] (B.3) Obtaining weight information of each target level, and mapping the weight information to the corresponding preset level of the candidate preset model, to obtain the preset model after updating the weight information;
[0084] (B.4) Obtain a training data set corresponding to the second environment, and train a preset model based on the training data set to obtain a target model.
[0085] The first environment may be an environment corresponding to a large data set (such as ImageNet or other public data sets) used to train the first model, that is, a source environment used to train the first model.
[0086] Among them, the first model can be a model trained in the first environment. During the training of the first model, the weight information that optimizes the performance of the first model can be determined, and the first level corresponding to the weight information can be fixed. After the training is completed, the first model is obtained.
[0087] Among them, the second environment can be the training and application environment of the candidate preset model, corresponding to an environment corresponding to a training data set different from the first environment. The fields and tasks of the second environment and the first environment can be different or the same.
[0088] Among them, the candidate preset model can be an initially set model architecture, which can receive weight information from the first model. The weight information can be learned from a related but different task or environment. The base model of the candidate preset model can be a ResNet model.
[0089] The preset model may be a model obtained by weight mapping the corresponding preset level through weight information.
[0090] The preset level may be a level in the candidate preset models that corresponds to the level of the first model, and the name or function of the preset level is the same as that of the target level.
[0091] The target level may be a level in the first model that corresponds to a preset level of the candidate preset model.
[0092] The weight information may be a parameter value of a target level in the first model.
[0093] The training data set may be a data set used in the second environment for fine-tuning or training a preset model.
[0094] Among them, the target model can be a model trained by a transfer learning method in the second environment. The target model is based on a residual network (ResNet). By fixing (freezing) part or all of the parameters of the first model (the model trained in the first environment) and fine-tuning it in the second environment using a new training data set, the target model can be improved in terms of accuracy in identifying and classifying data to be classified.
[0095] Specifically, during the training of the first model, the weight information when the performance of the first model reaches the optimal state can be determined, and the corresponding weight information can be fixed without updating. After the model training is completed, the first model is obtained. By fixing some or all of the levels of the first model in the first environment, the first model reaches the optimal state, and the weight information of the first model after the training is completed is saved. In the second environment, the load_weights function can be used to import the weight information of the fixed first model, and the weight information of the first model can be imported into the candidate preset model according to the name of the model level. If the structure of the candidate preset model is different from that of the first model, the level of the model with the mismatched name can be skipped, and the preset model can be trained for the task.
[0096] For example, if the first environment is a first website corresponding to a large image classification dataset (such as ImageNet), and the second environment is a second website for malicious domain name identification, the dataset on the first website (such as ImageNet) is used to train the first model (such as ResNet-50), and the ResNet-50 model is trained on ImageNet. Furthermore, in the process of training the first model, the weight information of the hierarchy that makes the performance of the first model better is fixed, and the trained first model can be obtained.
[0097] Furthermore, in the first model, a target layer with the same name as the layer name of the candidate preset model can be determined, for example, the target layer can be an activation function layer, a maximum pooling layer, etc. For example, the weight of the target layer can be mapped to the preset layer of the corresponding candidate preset model, and then a training data set set for the second environment is obtained, and the preset model is trained based on the training data set to obtain the target model.
[0098] In some embodiments, when there are multiple levels in the first model with the same level name as the level of the candidate preset model, the structure and function of the multiple levels with the same name in the first model can be further determined in the first model, and the target level can be determined based on the structure and function. In other words, the target level corresponding to the candidate preset model can be determined in the first model according to the corresponding level name, the structure of the level, and the function of the level, so that the candidate preset model can more accurately match the level in the first model and better utilize the common feature representation in the first model.
[0099] By utilizing the common features learned by the first model in the first environment, the preset model can adapt to new tasks more quickly in the second environment, thereby improving the accuracy of identifying malicious domain names, accelerating the convergence speed of the preset model in the second environment, and reducing training time and computing resource consumption.
[0100] In some implementations, in order to improve the performance, stability and convergence speed of the preset model, after the data is cleaned to obtain the initial data set, the initial data set can be processed using the minimum-maximum scaling technique so that all features of the training data set are at the same scale to avoid deviations caused by feature scale differences. For example, "obtaining a training data set corresponding to the second environment" in (B.4) may include:
[0101] (B.4a.1) obtaining an initial data set in the second environment, and determining maximum value data and minimum value data from a plurality of initial data in the initial data set;
[0102] (B.4a.2) determining the difference between the maximum value data and the minimum value data as the first intermediate value;
[0103] (B.4a.3) For each initial data, determine the difference between the initial data and the minimum value data as the second intermediate value;
[0104] (B.4a.4) taking the ratio of the second intermediate value to the first intermediate value as the sample data corresponding to the initial data;
[0105] (B.4a.5) Based on multiple sample data, a training data set is obtained.
[0106] The initial data set may be an original data set collected from the internal network traffic of the unit, including traffic data of malicious domain name information.
[0107] The maximum value data may be the maximum value of all initial data in the initial data set.
[0108] The minimum value data may be the minimum value of all initial data in the initial data set.
[0109] The first intermediate value may be the difference between the maximum value data and the minimum value data, that is, the range of the characteristic value.
[0110] The second intermediate value may be the difference between each initial data and the minimum value data.
[0111] The sample data may be standardized data obtained after minimum-maximum scaling processing.
[0112] The training data set may be a data set obtained from the initial data set after feature scaling, and is used to train the preset model.
[0113] Specifically, after obtaining the original dataset related to the original malicious domain name, the label encoding method can be used to convert the categorical variable values into numerical values. In the next stage, the data is cleaned to remove missing, meaningless and duplicate data from the original dataset to improve the data quality and the performance of the preset model. Finally, the minimum-maximum scaling technique is used to rescale the data under all feature dimensions (columns) to obtain the training dataset.
[0114] An exemplary mathematical model of the min-max scaling technique is defined as follows:
[0115]
[0116] Where X represents the initial data set, x represents the initial data, min(X) represents the minimum value of all initial data in X, and max(X) represents the maximum value of all initial data. Represents the sample data with the proportions adjusted.
[0117] For example, there is an initial data set A. In the initial data set A, the maximum value of all initial data is 500 and the minimum value is 100. If the initial data a1 is 300, then the sample data corresponding to the initial data a1 can be obtained by the minimum-maximum scaling technique. = (300-100) / (500-100) = 0.5. By taking the ratio of the second intermediate value to the first intermediate value as the sample data corresponding to the initial data, all data can be effectively unified into one range, the sample data corresponding to all initial data can be obtained, and a training data set can be constructed based on multiple sample data.
[0118] Furthermore, minimum-maximum scaling can be performed for different feature dimensions. Specifically, after obtaining the initial data set under the second environment, the maximum value data and the minimum value data under each feature dimension can be determined from multiple initial data of the initial data set; for each feature dimension, the difference between the maximum value data and the minimum value data under the corresponding feature dimension is determined as the first intermediate value; for the initial data corresponding to each feature dimension, the difference between the initial data and the minimum value data is determined as the second intermediate value; the ratio of the second intermediate value to the first intermediate value is used as the sample data corresponding to the initial data; based on multiple sample data under multiple feature dimensions, a training data set is obtained. At this time, the mathematical model of the technology for minimum-maximum scaling according to the feature dimension is defined as follows:
[0119]
[0120] Among them, n represents the feature dimension, x represents the initial data under the feature dimension n, and X represents the initial data set. Represents the minimum value data among all the initial data in X for the feature dimension n, Represents the maximum value of all initial data in X for feature dimension n. Represents the sample data with the proportions adjusted.
[0121] For example, if the initial data set has multiple initial data corresponding to feature dimension a and feature dimension b, the maximum value of feature dimension a in the initial data set is 100, and the minimum value is 0, and the maximum value of feature dimension b in the initial data set is 1000, and the minimum value is 0, then for feature dimension a, if x is 10, then the adjusted sample data = (10-0) / (100-0) = 0.1. For feature dimension b, if x is 500, then the adjusted sample data = (500-0) / (1000-0) = 0.5. In this way, the distinction between different feature dimensions can be better preserved, the scale difference between different features can be preserved, and it is helpful to improve the preset model to better capture the relationship between features and improve the performance of the preset model.
[0122] Exemplarily, the feature dimensions may include domain name length, number of subdomains, etc., and this application does not impose any specific restrictions on this.
[0123] By adjusting the proportion of the initial data in the initial data set, the deviation caused by data differences can be avoided and the learning efficiency and generalization ability of the preset model can be improved.
[0124] In some implementations, in order to balance the various categories, the category weights of sample categories with a small number of samples may be adjusted to effectively increase the attention of the preset model to the sample categories with a small number of samples, thereby improving the overall performance and generalization ability of the preset model. For example, "training the candidate preset model based on the training data set to obtain the target model" in (B.4) may include:
[0125] (B.4b.1) Determine multiple sample categories of sample data contained in the training data set, and determine the number of sample data in each sample category;
[0126] (B.4b.2) Obtaining a sample quantity threshold, and comparing the sample quantity of the sample data under each sample category with the sample quantity threshold to obtain a comparison result;
[0127] (B.4b.3) When the comparison result indicates that there is a target sample category whose sample number is less than the sample number threshold, the category weight of the target sample category is adjusted according to a preset adjustment weight to obtain an adjusted target category weight;
[0128] (B.4b.4) Determine the initial loss of the preset model based on the sample data corresponding to the target sample category, and adjust the initial loss based on the target category weight to obtain the target loss;
[0129] (B.4b.5) Adjust the parameters of the preset model according to the target loss until the preset convergence conditions are reached to obtain the target model.
[0130] The sample categories may be malicious domain names, suspicious domain names, and benign domain names. Alternatively, the sample categories may be specifically classified into malicious domain names used to spread malware, malicious domain names used to conduct phishing attacks, malicious domain names used to distribute spam, normal domain names, etc. The specific classification granularity may be set based on the collected samples.
[0131] The number of samples may be the number of samples in each sample category in the training data set.
[0132] The sample quantity threshold may be a pre-set threshold used to determine whether the number of samples contained in the corresponding sample category is sufficient.
[0133] The comparison result may be a result obtained by comparing the sample quantity with the sample quantity threshold, and is used to determine the target sample category whose weight needs to be adjusted. Further, the comparison result may also be used to determine the scale of the category weight of the target sample category whose weight needs to be adjusted.
[0134] The target sample category may be a sample category whose sample quantity is less than a sample quantity threshold.
[0135] The category weight may be a weight set during the preset model training process in order to balance the impact of different sample categories on the model training.
[0136] The initial loss may be a loss function value during the training of a preset model, and the initial loss is a loss value obtained without weight adjustment after each training of the preset model.
[0137] The target loss may be the loss value after the category weight is adjusted after each training of the preset model, which reflects the gap between the predicted result of the preset model and the actual result.
[0138] Specifically, since the number of samples contained in each sample category is unbalanced in the data set, the preset model tends to learn the category with the majority of samples and ignores the category with the minority of samples. Therefore, the category weights of the minority category (the category with the smaller number of samples) can be increased so that the misclassification of these categories contributes more to the total loss, thereby forcing the preset model to pay more attention to these categories, so as to accelerate the convergence speed of the preset model during training, and improve the overall performance and generalization ability of the preset model. Exemplarily, taking the sample categories including malicious domain names used to spread malware, malicious domain names used to conduct phishing attacks, and malicious domain names used to distribute spam as an example, when the number of samples of malicious domain names used to spread malware is 100, the number of samples of malicious domain names used to conduct phishing attacks is 400, and the number of samples of malicious domain names used to distribute spam is 1000, the sample number threshold is set to 500, and by comparing the number of samples with the sample number threshold, it can be determined from the comparison result that the number of samples of malicious domain names used to spread malware and malicious domain names used to conduct phishing attacks is less than the sample number threshold, and the category weights of the corresponding sample categories can be adjusted according to the adjustment weights.
[0139] Exemplarily, the adjustment weight can be determined based on the gradient ratio of the sample number relative to the sample number threshold when the sample number is less than the sample number threshold. The lower the gradient ratio of the sample number corresponding to the target sample category relative to the sample number threshold, the higher the adjustment weight. For example, when the sample number is in the interval where the gradient ratio of the sample number threshold is 2 / 3 to 1, the adjustment weight can be set to 1.2, that is, the category weight is 1.2 times the original category weight; when the sample number is in the interval of 1 / 3 to 2 / 3 of the sample number threshold, the adjustment weight can be set to 1.4, etc., that is, the category weight is 1.4 times the original category weight. The specific adjustment weight can be set according to the actual situation, for example, it can be set to 2, 3, etc., and the embodiments of the present application do not impose too many restrictions on this.
[0140] In some embodiments, the gradient ratio of each sample category can also be determined based on the ratio of the number of samples of the sample data under the sample category to the total number of samples in the training data set. For example, if the training data set has 1000 samples and the number of samples under sample category A is 100, then the gradient ratio is 1 / 10. The gradient ratios of different target sample categories correspond to different category weights. The smaller the gradient ratio, the larger the corresponding category weight.
[0141] Furthermore, a preset model can be trained based on the training data set to obtain an initial loss. If the sample category used to train the preset model belongs to the target sample category, for example, the sample category is a malicious domain name used to spread malware, then the adjustment weight corresponding to the target sample category is obtained. If the category weight corresponding to the target sample category is 1.4, the calculated initial loss is adjusted by the category weight, that is, the category weight is multiplied by the initial loss to obtain the target loss. The parameters of the preset model are adjusted by the target loss with the adjusted weight until the preset convergence condition is reached. In this way, the preset model can better handle common categories, and effectively handle less common categories, thereby ultimately improving the overall performance.
[0142] Exemplarily, if the preset convergence condition is set as the number of training times of the preset model reaches the preset number of training times, the training of the preset model can be stopped. For example, the preset number of training times can be 1000 times, then when the number of training times of the preset model exceeds 1000 times, the training of the preset model can be stopped to obtain the target model.
[0143] Furthermore, when the parameters of the preset model change very little or do not change, the training of the preset model can be stopped to obtain the target model.
[0144] By adjusting the category weights to increase the preset model's attention to categories with fewer samples, thereby balancing the various sample categories, the overall performance and generalization ability of the preset model can be improved, while also improving the accuracy of the target model in identifying malicious domain names.
[0145] In some embodiments, in order to improve the performance of the target model, as well as the accuracy and coverage of detection, the present application embeds an attention mechanism in the convolutional layer to enhance the representation capability of the feature processing component, and, by setting a residual connection structure, effectively solves the problem of gradient vanishing and gradient explosion that may occur when the target model extracts deep features. Before further introducing the solution, the basic model of the target model of the present application is first introduced.
[0146] Please refer to Figure 3 , exemplarily, applying a one-dimensional convolutional layer (Conv-1D) to a specific model can extract spatial feature representations from the data to be classified, thereby improving the accuracy of classifying the data to be classified. Furthermore, by increasing the number of convolutional layers, deeper features can be extracted to achieve higher classification accuracy, but this improvement is only effective to a certain extent. Therefore, in order to solve the problem of model performance degradation due to gradient vanishing or exploding, a residual network is introduced and a skip connection method is adopted to create a residual block by skipping some layers, and connect the activations of the layer to the subsequent layers. Through the residual connection, the network can better learn the difference between the input and output, while effectively avoiding the problems of gradient vanishing and gradient exploding, thereby improving the performance and training effect of the model. The target model proposed in this application is composed of a residual block with three convolutional layers and a residual link, and is improved on this basis.
[0147] In some embodiments, the target model of the present application defines a 50-layer deep residual network, including multiple residual blocks and convolutional layers. Among them, the first convolution layer uses 64 filters and a convolution kernel of size 7, and the remaining convolutional layers use a convolution kernel of size 3. Each residual block consists of multiple convolutional layers and a normalization layer. The convolutional layer is used to extract features, while the identity block is used to retain the original features and pass them to the next layer. Finally, the network output is downsampled through the average pooling layer to obtain a globally pooled feature vector.
[0148] Step 102: extract features through the first feature processing component to obtain features to be classified corresponding to the domain name to be classified.
[0149] In some implementations, in order to extract features that are useful for classification from the data to be classified, feature extraction may be performed by a first processing component to obtain features to be classified corresponding to the domain name to be classified, thereby improving the accuracy of malicious domain name classification.
[0150] The first feature processing component may be a component for performing feature processing on data to be classified.
[0151] The features to be classified may be features obtained by performing a feature extraction operation on the data to be classified.
[0152] Exemplarily, feature extraction operations are performed on the data to be classified, including but not limited to convolution operations, application of activation functions, and pooling operations, so that the data to be classified can be converted into feature data containing key information of the domain name for subsequent feature enhancement and classification tasks.
[0153] Please refer to Figure 4 , the first feature processing component may include an input layer (Input layer), a zero padding layer (ZeroPadding layer), a one-dimensional convolution layer (Conv-1D layer), an activation function (ReLU layer), and a maximum pooling layer (Max-pooling layer). Among them, the input layer of the target model is used to receive the data to be classified. The data to be classified may be data obtained by processing the minimum-maximum scaling technology after data cleaning. Further, the data to be classified may be input into the zero padding layer to add additional zero-value pixels around the data to be classified, to ensure that the size of the output after the convolution operation is the same as the input, and to ensure the integrity of the feature map. Further, the local features in the input data may be extracted through the one-dimensional convolution layer, and the nonlinear characteristics may be introduced through the activation function ReLU, so that the target model can extract more complex feature representations. Further, the features processed by the activation function may be input into the maximum pooling layer to reduce the dimension of the feature map while retaining the most important information.
[0154] Furthermore, in addition, the first feature processing component may also include other processing layers, such as a normalization layer, to speed up the training process and improve the model performance when training the preset model. Without violating the concept of the present application, the processing layers of the first feature processing component may be increased or decreased according to actual conditions, and the present application does not impose specific restrictions on this.
[0155] By extracting features through the first feature processing component and obtaining the features to be classified corresponding to the domain name to be classified, not only the accuracy of the target model in identifying malicious domain names can be improved.
[0156] Step 103, performing at least one feature enhancement representation on the feature to be classified based on the attention mechanism through the second feature processing component to obtain the first intermediate feature; wherein the second feature processing component is obtained by coupling the convolutional layer with the attention mechanism.
[0157] In some implementations, in order to help the target model achieve more accurate feature selection, an attention mechanism can be applied while extracting features to achieve dynamic feature enhancement, so as to achieve more accurate classification and identification of malicious domain names.
[0158] The second feature processing component can be obtained by embedding an attention mechanism between convolutional layers, that is, by coupling the convolutional layer with the attention mechanism in the convolutional block of the target model. The second feature processing component can enhance the feature representation of the features to be classified, thereby improving the target model's attention to key information and further improving the accuracy of malicious domain name recognition.
[0159] Among them, the attention mechanism can be used to enhance the ability of the target model to capture the important parts of the features to be classified.
[0160] The first intermediate feature may be a feature representation obtained after being processed by a second feature processing component (which may be represented by CRAMC).
[0161] Please refer to Figure 4 Exemplarily, the second feature processing component may include a one-dimensional convolution layer (Conv-1D layer) for further refining the feature representation and performing feature dimensionality reduction on the feature to be classified so that the dimension of the feature to be classified matches the dimension of the attention weight of the subsequent attention mechanism for effective operation. Furthermore, after the feature to be classified passes through the one-dimensional convolution layer, it can pass through an activation function layer (ReLU) to introduce nonlinearity, which helps the target model capture more complex feature representations. Specifically, after passing through the activation function, the feature to be classified can be input into the attention mechanism of the second feature processing component. The attention mechanism may include a fully connected layer (Dense) for generating an attention weight for each feature element based on the feature to be classified. The attention weight is used to characterize the importance of different feature elements.
[0162] Furthermore, the second feature processing component may also include an element-by-element multiplication layer (Multiply) for multiplying the attention weight with the feature element (feature vector) of the feature to be classified to obtain an initial intermediate feature after attention weighting. At this time, the initial intermediate feature is input into another one-dimensional convolutional layer (Conv-1D layer) of the second feature processing component to adjust the feature dimension, so as to obtain a first intermediate feature.
[0163] In some embodiments, without violating the concept of the present application, the processing layer of the second feature processing component can be increased or decreased according to actual conditions, and the present application does not impose specific restrictions on this.
[0164] Further, such as Figure 4 As shown, in order to extract deeper features, multiple second feature processing components can be set, for example, 2, 3, 5 or more. The specific number of second feature processing components can be set according to actual conditions, and the embodiment of the present application does not impose specific restrictions on this. In some embodiments, only one second feature processing component (represented by CRAMC) can also be set.
[0165] By coupling the convolutional layer with the attention mechanism to obtain the second feature processing component, and performing at least one feature enhancement representation on the unclassified features through the second feature processing component, the accuracy of the target model in identifying malicious domain names can be improved. At the same time, coupling the attention mechanism with the convolutional layer to obtain the second feature processing component and jointly completing the feature extraction process can enable the target model to consider the importance of features during the feature extraction process, rather than performing attention processing after the feature extraction is completed, which greatly improves the accuracy of malicious domain name recognition.
[0166] In some implementations, in order to improve the accuracy of malicious domain name classification, the attention mechanism can be used to highlight key features, suppress irrelevant features, and improve the classification performance of the target model, so that the target model can more accurately identify malicious domain names. For example, step 103 may include:
[0167] (103.1) Inputting the feature to be classified into the first convolutional layer of the second feature processing component for dimensionality reduction processing to obtain the feature to be classified with reduced dimensionality;
[0168] (103.2) Inputting the feature to be classified into the attention mechanism to obtain an attention weight representing the importance of each second feature element in the feature to be classified;
[0169] (103.3) performing attention adjustment processing on each second feature element in the feature to be classified based on the attention weight to obtain an initial intermediate feature;
[0170] (103.4) The feature dimension of the initial intermediate feature is adjusted according to the second convolutional layer of the second feature processing component to obtain a first intermediate feature.
[0171] The first convolutional layer may be a part of the second feature processing component, and is used to perform dimensionality reduction processing on the input features to be classified.
[0172] The second feature element may be a plurality of sub-feature vectors in the feature to be classified.
[0173] The attention weight may be a set of values calculated by the attention mechanism, which is used to measure the importance of different second feature elements in the features to be classified.
[0174] Among them, the initial intermediate feature can be a feature representation after the attention weight of the feature to be classified is adjusted.
[0175] Among them, the second convolutional layer can be a part of the second feature processing component, which is used to adjust the dimension of the first intermediate feature and further perform feature extraction and combination to facilitate subsequent feature fusion with the feature to be classified.
[0176] Exemplarily, when the vector length of the feature to be classified is 1000, the dimension of the feature to be classified can be reduced through the first convolutional layer (Conv-1D). For example, the filter size of the one-dimensional convolutional layer is 1×1000. At this time, the vector length of the reduced feature to be classified is 1000, and the number of output channels is 1, so as to match the dimension of the feature to be classified with the dimension of the subsequent attention weight.
[0177] Furthermore, the features to be classified after dimensionality reduction can be normalized through a normalization layer, and the nonlinear expression ability of the target model can be increased through a ReLU activation function. Furthermore, the processed features to be classified can be input into an attention mechanism to obtain the attention weights of each second feature element in the features to be classified, and a sigmoid activation function is used after the attention mechanism to limit the attention weights between 0 and 1 to measure the importance of each second feature element.
[0178] Furthermore, the attention weight can be multiplied element-by-element with each second feature element in the feature to be classified after dimensionality reduction to highlight important features and suppress unimportant features to obtain the initial intermediate features.
[0179] Furthermore, the initial intermediate features can be input into the second convolutional layer (Conv-1D) to adjust the dimensions of the initial intermediate features, and further extract and combine feature representations.
[0180] Through the above method, the computational efficiency of the target model and the accuracy of malicious domain name classification can be improved, which is conducive to the subsequent feature fusion of the feature to be classified with the first intermediate feature to obtain the first fused feature.
[0181] Step 104: Fusing the feature to be classified with the first intermediate feature to obtain a first fused feature.
[0182] In some implementations, in order to avoid the problems of gradient vanishing and gradient exploding, after performing multiple feature enhancement representations on the feature to be classified to obtain the first intermediate feature, the first intermediate feature can be fused with the feature to be classified to obtain the first intermediate feature.
[0183] The first fusion feature may be a feature obtained by performing an element-by-element addition operation on the feature to be classified and the first intermediate feature.
[0184] Exemplarily, the feature to be classified may be further extracted through a one-dimensional convolutional layer, and then added element-by-element to the first intermediate feature to obtain the first fused feature.
[0185] By fusing the feature to be classified with the first intermediate feature to obtain the first fused feature, it is possible to retain the feature information of the original feature to be classified while making full use of all the information in the original feature to be classified, thereby improving the accuracy of the target model in predicting malicious domain names.
[0186] Step 105: input the first fusion feature into the classification component for feature mapping processing to obtain a malicious domain name recognition result of the data to be classified.
[0187] In some implementations, in order to improve the overall performance and stability of the target model, the first fusion feature can be input into the classification component for feature mapping processing to obtain malicious domain name identification results for the data to be classified, so as to improve the accuracy of malicious domain name identification.
[0188] Among them, the classification component may include a flattening layer, an activation function layer, and a fully connected layer.
[0189] The malicious domain name recognition result may be the category corresponding to the maximum probability in the output vector, that is, the result of whether the target model predicts the data to be classified as a malicious domain name, such as a benign domain name, a malicious domain name, a suspected malicious domain name, etc. The malicious domain name recognition result may also be a specific category of malicious domain names, such as malicious domain names used to spread malware, malicious domain names used to conduct phishing attacks, malicious domain names used to distribute spam, etc.
[0190] Exemplarily, the first fused feature can be flattened into a one-dimensional vector through a flattening layer so as to be input into a fully connected layer, and one or more fully connected layers can be used to perform feature mapping on the flattened one-dimensional vector to extract higher-level feature representations and make classification decisions. Furthermore, an activation function (such as ReLU) can be added after each fully connected layer to increase the nonlinear expression ability of the target model. Finally, the Softmax activation function can be used to output a probability distribution indicating the probability that the data to be classified belongs to each category, and the category with the highest probability is used as the malicious domain name identification result.
[0191] The embodiment of the present application obtains the data to be classified corresponding to the domain name to be classified, and inputs the data to be classified into the target model; wherein the target model includes a first feature processing component, a second feature processing component and a classification component; the first feature processing component is used to extract features to obtain the features to be classified corresponding to the domain name to be classified; the second feature processing component is used to perform at least one feature enhancement representation on the features to be classified based on the attention mechanism to obtain the first intermediate feature; wherein the second feature processing component is obtained by coupling the convolution layer with the attention mechanism; the features to be classified are fused with the first intermediate feature to obtain the first fused feature; the first fused feature is input into the classification component for feature mapping processing to obtain the malicious domain name recognition result of the data to be classified. In this way, the second feature component obtained by coupling the convolution layer with the attention mechanism can be used to guide the target model to determine important features using the attention mechanism in the early stage of feature extraction, focusing on the processing of key information, which helps the target model to more efficiently and accurately extract information that is conducive to identifying malicious domain names. Moreover, since the features to be classified are represented by feature enhancement at least once, the target model can extract more complex and deeper features and fuse the features to be classified with the first intermediate features, thus avoiding the problem of inaccurate malicious domain name recognition caused by gradient vanishing and improving the accuracy of malicious domain name recognition.
[0192] In some embodiments, in network security application scenarios, data usually has temporal correlation. For example, certain types of network attacks will continue to occur over a period of time. Therefore, information in the time dimension can be considered to correctly identify malicious domain names. Therefore, after obtaining the first fusion feature by analyzing the spatial dimension, the time information of the first fusion feature can be obtained to accurately capture the temporal pattern between the features and further improve the accuracy of recognition. For example, the target model also includes a sequence processing component located between the second feature processing component and the classification component. After step 104, it also includes:
[0193] (A.1) performing feature enhancement representation on the plurality of first feature elements based on time sequence information of the plurality of first feature elements in the first fused feature through a sequence processing component to obtain a second intermediate feature;
[0194] (A.2) Splicing the first fusion feature and the second intermediate feature to obtain a first splicing feature;
[0195] The first fusion feature is input into the classification component for feature mapping processing to obtain the malicious domain name identification result of the data to be classified, including:
[0196] The first concatenated feature is input into the classification component for feature mapping processing to obtain a malicious domain name identification result of the data to be classified.
[0197] Among them, the sequence processing component can be used to capture the time pattern between the first feature elements of the first fused feature, and the sequence processing component can use the information of the time dimension to perform feature enhancement representation on the first feature elements of the first fused feature.
[0198] The first feature element may be a single feature vector in the first fused feature.
[0199] The second intermediate feature may be a feature representation obtained by processing a plurality of first feature elements in the first fused feature through a sequence processing component.
[0200] The first splicing feature may be a feature representation obtained by splicing the first fusion feature and the second intermediate feature.
[0201] Please refer to Figure 5 , exemplary, sequence processing components may be Figure 5 The components represented by the Context module in . The sequence processing components may include, but are not limited to, a reshape layer (Reshape), a fully connected layer (Dense), a Lambda layer (a custom layer used for branch calculations), a dot product layer (Dot), and an activation function layer (ReLU).
[0202] Exemplarily, the attention layer function can be introduced to obtain the hidden state of the last time step in the first fused feature as the query vector, and the dot product layer in the sequence processing component can be used to perform dot product operations on the query vector and the hidden vectors corresponding to other time steps to obtain the attention score corresponding to the hidden vector of each time step. Furthermore, the attention score can be normalized through the activation function layer, and then the dot product operation can be performed on the attention score and the query vector through the dot product layer to adjust the attention of each first feature element in the hidden vector to obtain the second intermediate feature.
[0203] Furthermore, the first fused feature can be reduced in dimension through an average pooling layer (Avg-Pool) to reduce the feature dimension while retaining key information. After that, the first fused feature after pooling is flattened into a one-dimensional vector for easy input to the fully connected layer. Furthermore, the flattened first fused feature can be feature mapped through one or more fully connected layers to further extract features and enhance representation capabilities.
[0204] Furthermore, the first fusion feature after feature mapping can be concatenated with the second intermediate feature through the concatenation layer to obtain the first concatenation feature, and the first concatenation feature can be classified through the fully connected layer to obtain the malicious domain name recognition result of the data to be classified. The specific classification process has been introduced above and will not be repeated here.
[0205] By combining spatial and temporal features and utilizing attention mechanisms and feature enhancement techniques, the accuracy of the target model in identifying malicious domain names is significantly improved.
[0206] In some implementations, in order to improve the accuracy of the target model in identifying malicious behavior, a sequence processing component may be introduced to consider information in the time dimension so as to more accurately capture the time pattern between the first feature elements and improve the accuracy of identifying malicious behavior. For example, (A.1) may include:
[0207] (A.1.1) determining, by a sequence processing component, a query vector corresponding to a last time step and at least one hidden vector corresponding to other time steps from the first fused features based on time sequence information of each first feature element in the first fused features;
[0208] (A.1.2) Calculate the dot product of the query vector and the hidden vector of each time step in turn to obtain the attention score corresponding to the hidden vector of each time step; where the attention score is used to represent the similarity between the hidden vector and the query vector at each time step;
[0209] (A.1.3) Adjust each first feature element in the corresponding hidden vector based on the attention score of each hidden vector to obtain a second intermediate feature.
[0210] The query vector may be the hidden state of the last time step obtained from the first fused feature, that is, the hidden vector of the last time step.
[0211] The hidden vector may be a feature representation of other time steps except the last time step in the first fusion feature.
[0212] The attention score may be a similarity score between the query vector and each hidden vector calculated by a dot product operation.
[0213] It can be understood that the query vector represents the final state of the hidden vectors of all time steps, which can be used to evaluate the contribution of the states of other time steps to the final decision. Therefore, the query vector can be dot-producted with the hidden vector of each time step in turn to determine the importance of each hidden state to the current query vector, and based on the attention score of each hidden vector, the attention of each first feature element in the corresponding hidden vector is adjusted so that the target model can more efficiently utilize the information in the first fused feature of the input, thereby improving the expressiveness of the target model.
[0214] For example, if there are 3 time steps in total, the hidden state of the last time step, that is, the third time step, is used as the query vector q, q=[0.7, 0.8, 0.9], the hidden vector of the first time step is [0.1, 0.2, 0.3], and the hidden vector of the second time step is [0.4, 0.5, 0.6]. The dot product of the query vector and the hidden vector of the first time step can be obtained as 0.1x0.7+0.2x0.8+0.3 x0.9=0.50; the dot product of the query vector and the hidden vector of the second time step can be obtained as 0.4x0.7+0.5x0.8+0.6x0.9=1.10; the dot product of the query vector and the hidden vector of the third time step can be obtained as 0.7x0.7+0.8x0.8+0.9x0.9=2.14. From this we can get the attention score s=[0.5, 1.10, 2.14].
[0215] Furthermore, based on the attention score of each hidden vector, a dot product calculation can be performed on each first feature element in the corresponding hidden vector to adjust the attention of the hidden vector at each time step to obtain a second intermediate feature.
[0216] By determining the query vector and hidden vector, calculating the attention score, and adjusting the attention based on the attention score, the second intermediate feature is obtained. The target model can more effectively capture the temporal pattern between features, which helps to improve the target model's recognition accuracy of malicious behaviors with time correlation (such as DoS attacks), and significantly improves the overall performance and stability of the target model.
[0217] In some embodiments, in order to enable the target model to more effectively utilize information in the time dimension, attention adjustment can be performed on each first feature element in the corresponding hidden vector based on the attention score of each hidden vector to improve the recognition accuracy of the target model for malicious behaviors with time correlation. For example, (A.1.3) may include:
[0218] (A.1.3.1) adjusting each first feature element in the corresponding hidden vector based on the attention score of each hidden vector to obtain an adjusted first feature element;
[0219] (A.1.3.2) For each feature dimension of the first fused feature, add the first feature elements at different time steps corresponding to the feature dimension to obtain the target feature element corresponding to the feature dimension;
[0220] (A.1.3.3) Obtain a second intermediate feature based on multiple target feature elements corresponding to multiple dimensions.
[0221] The target feature element may be a feature representation obtained by weighted summing of attention scores of the first feature elements at different time steps on each feature dimension of the first fused feature. The target feature element may be used to represent the aggregation of time series information weighted by attention scores on each feature dimension.
[0222] For example, if there are 3 time steps in total, the hidden vector of the first time step is [0.1, 0.2, 0.3], the hidden vector of the second time step is [0.4, 0.5, 0.6], and the hidden vector of the third time step is [0.7, 0.8, 0.9]. The attention score corresponding to the first time step is 0.5, the attention score corresponding to the second time step is 1.1, and the attention score corresponding to the third time step is 2.14.
[0223] Specifically, the attention scores can be normalized by the softmax function, and the attention scores corresponding to the first time step can be w1, the attention scores corresponding to the second time step can be w2, and the attention scores corresponding to the first time step can be w3. Furthermore, the attention of each first feature element in the corresponding hidden vector can be adjusted based on the attention score of each hidden vector. For example, for the hidden vector of the first time step, the adjusted first feature elements are 0.1*w1, 0.2*w1, 0.3 *w1; for the hidden vector of the second time step, the adjusted first feature elements are 0.4*w2, 0.5*w2, 0.6 *w2; for the hidden vector of the third time step, the adjusted first feature elements are 0.7*w3, 0.8*w3, 0.9 *w3.
[0224] It can be understood that 0.1*w1, 0.4*w2, 0.7*w3 is a feature dimension, here called feature dimension 1; 0.2*w1, 0.5*w2, 0.8*w3 is a feature dimension, here called feature dimension 2; 0.3*w1, 0.6*w2, 0.9*w3 is a feature dimension, here called feature dimension 3; that is, the feature dimension can be determined based on the arrangement position of each element in the hidden vector.
[0225] Furthermore, by adding the first feature elements of different time steps corresponding to the feature dimensions, we can obtain the target feature element 1=0.1*w1+0.4*w2+0.7*w3 corresponding to feature dimension 1, the target feature element 2=0.2*w1+0.5*w2+0.8*w3 corresponding to feature dimension 2, and the target feature element 3=0.3*w1+0.6*w2+0.9*w3 corresponding to feature dimension 3.
[0226] Furthermore, multiple target feature elements corresponding to multiple feature dimensions may be combined into a vector according to the arrangement order of the feature dimensions to obtain a second intermediate feature.
[0227] By adjusting the attention of each first feature element in the corresponding latent vector based on the attention score of each latent vector, and further obtaining the target feature element through weighted summation on the feature dimension, and finally forming the second intermediate feature, the target model can more effectively utilize the information in the time dimension, and significantly improve the accuracy of malicious behavior identification by dynamically paying attention to important features in the input.
[0228] Please refer to Figure 4 and Figure 5 In some embodiments, Figure 4 In the example, the first feature processing component can be used to extract features of the input data to be classified, and obtain the features of the domain name to be classified. Furthermore, the second feature processing component is Figure 4 In the "CRAMC", the dimension of the to-be-classified features can be first reduced through the convolution layer of the second feature processing component so as to match the subsequent attention weights. Further, the normalization layer and the ReLU activation function can be applied to enhance the representation ability and nonlinear characteristics of the features. Finally, the attention weights of the to-be-classified features are generated using the fully connected layer, and are limited to between 0 and 1 through the sigmoid activation function. Further, the attention weights can be element-wise multiplied with the reduced-dimensional features to highlight important features and suppress unimportant features. Further, after the attention weights are element-wise multiplied with the reduced-dimensional features, the feature representations can be further extracted and combined through a one-dimensional convolution layer, while retaining the attention-weighted features to obtain the first intermediate features. Further, the first intermediate features can be residually connected with the to-be-classified features to obtain the first fused features. Further, there can be multiple second feature processing components.
[0229] In some implementations, after obtaining the first fusion feature, the domain name to be classified can be classified more accurately based on the first fusion feature. Figure 5 In order to further improve the accuracy of classifying the domain name to be classified, the time sequence information of multiple first feature elements in the first fusion feature can be used to enhance the feature representation of multiple first feature elements using a dot product layer to obtain a second intermediate feature, and the first fusion feature and the second intermediate feature are spliced through a residual structure to obtain a first splicing feature. At this time, the domain name to be classified can be accurately classified through the first splicing feature.
[0230] See also Figure 6 The embodiment of the present application also provides a malicious domain name identification device, which can implement the above malicious domain name identification method. The malicious domain name identification device includes:
[0231] The acquisition module 61 is used to acquire the data to be classified corresponding to the domain name to be classified, and input the data to be classified into the target model; wherein the target model includes a first feature processing component, a second feature processing component and a classification component;
[0232] An extraction module 62, configured to extract features through a first feature processing component to obtain features to be classified corresponding to the domain name to be classified;
[0233] An enhancement module 63 is used to perform at least one feature enhancement representation on the unclassified feature based on the attention mechanism through a second feature processing component to obtain a first intermediate feature; wherein the second feature processing component is obtained by coupling a convolutional layer with the attention mechanism;
[0234] A fusion module 64 is used to fuse the feature to be classified with the first intermediate feature to obtain a first fused feature;
[0235] The mapping module 65 is used to input the first fusion feature into the classification component for feature mapping processing to obtain a malicious domain name recognition result of the data to be classified.
[0236] The specific implementation of the malicious domain name identification device is basically the same as the specific implementation of the malicious domain name identification method described above, and will not be repeated here. On the premise of meeting the requirements of the embodiment of the present application, the malicious domain name identification device can also be provided with other functional modules to implement the malicious domain name identification method in the above embodiment.
[0237] The embodiment of the present application also provides a computer device, the computer device includes a memory and a processor, the memory stores a computer program, and the processor implements the above malicious domain name identification method when executing the computer program. The computer device can be any intelligent terminal including a tablet computer, a car computer, etc.
[0238] See also Figure 7 , Figure 7 The hardware structure of a computer device according to another embodiment is shown, and the computer device includes:
[0239] The processor 71 may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present application;
[0240] The memory 72 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 72 can store an operating system and other application programs. When the technical solution provided in the embodiment of this specification is implemented by software or firmware, the relevant program code is stored in the memory 72, and the processor 71 calls and executes the malicious domain name identification method of the embodiment of this application;
[0241] Input / output interface 73, used to implement information input and output;
[0242] Communication interface 74, used to realize communication interaction between the device and other devices, which can be realized by wired means (such as USB, network cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.);
[0243] A bus 75 that transmits information between the various components of the device (e.g., the processor 71, the memory 72, the input / output interface 73, and the communication interface 74);
[0244] The processor 71 , the memory 72 , the input / output interface 73 and the communication interface 74 are connected to each other in communication within the device via a bus 75 .
[0245] An embodiment of the present application also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the above-mentioned malicious domain name identification method is implemented.
[0246] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0247] The embodiments described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0248] Those skilled in the art will appreciate that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and may include more or fewer steps than shown in the figures, or a combination of certain steps, or different steps.
[0249] The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0250] Those skilled in the art will appreciate that all or some of the steps in the methods disclosed above, and the functional modules / units in the systems and devices may be implemented as software, firmware, hardware, or a suitable combination thereof.
[0251] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0252] It should be understood that in the present application, "at least one (item)" and "several" refer to one or more, and "plurality" refers to two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the previous and subsequent associated objects are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0253] In the several embodiments provided in the present application, it should be understood that the disclosed systems and methods can be implemented in other ways. For example, the system embodiments described above are merely schematic. For example, the division of the above 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 an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0254] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0255] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0256] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including multiple instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store programs.
[0257] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but the scope of the rights of the present invention is not limited thereto. Any modification, equivalent substitution and improvement made by a person skilled in the art without departing from the scope and essence of the present invention should be within the scope of the rights of the present invention.
Claims
1. A method for identifying malicious domain names, characterized in that: The method comprises: Acquire the data to be classified corresponding to the domain name to be classified, and input the data to be classified into the target model; wherein the target model includes a first feature processing component, a second feature processing component, a classification component, and a sequence processing component located between the second feature processing component and the classification component; Extracting features through the first feature processing component to obtain features to be classified corresponding to the domain name to be classified; Performing at least one feature enhancement representation on the feature to be classified based on the attention mechanism by the second feature processing component to obtain a first intermediate feature; wherein the second feature processing component is obtained by coupling a convolutional layer with the attention mechanism; Fusing the feature to be classified with the first intermediate feature to obtain a first fused feature; By means of the sequence processing component, based on the time sequence information of the plurality of first feature elements in the first fused feature, feature enhancement representation is performed on the plurality of first feature elements to obtain a second intermediate feature; Splicing the first fused feature and the second intermediate feature to obtain a first splicing feature; The first splicing feature is input into the classification component for feature mapping processing to obtain a malicious domain name identification result of the data to be classified.
2. The malicious domain name identification method according to claim 1, characterized in that: The step of performing feature enhancement on the plurality of first feature elements based on the time sequence information of the plurality of first feature elements in the first fused feature through the sequence processing component to obtain the second intermediate feature includes: Determining, by the sequence processing component, a query vector corresponding to a last time step and at least one hidden vector corresponding to other time steps from the first fused features based on time sequence information of each of the first feature elements in the first fused features; Performing dot product calculations on the query vector and the hidden vector of each time step in turn to obtain an attention score corresponding to the hidden vector of each time step; wherein the attention score is used to characterize the similarity between the hidden vector of each time step and the query vector; Based on the attention score of each of the hidden vectors, each of the first feature elements in the corresponding hidden vector is adjusted to obtain a second intermediate feature.
3. The malicious domain name identification method according to claim 2, characterized in that: The step of adjusting each of the first feature elements in the corresponding hidden vector based on the attention score of each of the hidden vectors to obtain a second intermediate feature includes: Adjusting each of the first feature elements in the corresponding hidden vector based on the attention score of each of the hidden vectors to obtain an adjusted first feature element; For each feature dimension of the first fusion feature, first feature elements at different time steps corresponding to the feature dimension are added to obtain a target feature element corresponding to the feature dimension; A second intermediate feature is obtained according to the multiple target feature elements corresponding to the multiple dimensions.
4. The malicious domain name identification method according to claim 1, characterized in that: The step of performing at least one feature enhancement representation on the feature to be classified based on the attention mechanism by the second feature processing component to obtain the first intermediate feature includes: Inputting the feature to be classified into the first convolutional layer of the second feature processing component for dimensionality reduction processing to obtain the feature to be classified with reduced dimensionality; Inputting the feature to be classified into the attention mechanism to obtain an attention weight representing the importance of each second feature element in the feature to be classified; Performing attention adjustment processing on each of the second feature elements in the feature to be classified based on the attention weight to obtain an initial intermediate feature; The feature dimension of the initial intermediate feature is adjusted according to the second convolutional layer of the second feature processing component to obtain a first intermediate feature.
5. The malicious domain name identification method according to claim 1, characterized in that: The target model is trained in the following way: Obtain a first model trained in a first environment; Determining, from the first model, a target level corresponding to each preset level in the candidate preset model of the second environment; Obtaining weight information of each target level, and mapping the weight information to the preset level corresponding to the candidate preset model, to obtain the preset model after updating the weight information; A training data set corresponding to the second environment is obtained, and the preset model is trained based on the training data set to obtain a target model.
6. The malicious domain name identification method according to claim 5, characterized in that: The obtaining of a training data set corresponding to the second environment includes: Acquire an initial data set under a second environment, and determine maximum value data and minimum value data from a plurality of initial data of the initial data set; Determine a difference between the maximum value data and the minimum value data as a first intermediate value; For each of the initial data, determining a difference between the initial data and the minimum value data as a second intermediate value; Using the ratio of the second intermediate value to the first intermediate value as sample data corresponding to the initial data; Based on the plurality of sample data, a training data set is obtained.
7. A malicious domain name identification device, characterized in that: The device comprises: An acquisition module, used for acquiring the data to be classified corresponding to the domain name to be classified, and inputting the data to be classified into a target model; wherein the target model includes a first feature processing component, a second feature processing component, a classification component, and a sequence processing component located between the second feature processing component and the classification component; An extraction module, configured to extract features through the first feature processing component to obtain features to be classified corresponding to the domain name to be classified; an enhancement module, configured to perform at least one feature enhancement representation on the feature to be classified based on an attention mechanism through the second feature processing component to obtain a first intermediate feature; wherein the second feature processing component is obtained by coupling a convolutional layer with the attention mechanism; A fusion module is used to fuse the feature to be classified with the first intermediate feature to obtain a first fused feature; through the sequence processing component, based on the time sequence information of multiple first feature elements in the first fused feature, the multiple first feature elements are enhanced to represent the feature to obtain a second intermediate feature; splicing the first fused feature and the second intermediate feature to obtain a first splicing feature; A mapping module is used to input the first splicing feature into the classification component for feature mapping processing to obtain a malicious domain name identification result of the data to be classified.
8. A computer device, characterized in that: The computer device includes a memory and a processor, the memory stores a computer program, and the processor implements the malicious domain name identification method according to any one of claims 1 to 6 when executing the computer program.
9. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the malicious domain name identification method according to any one of claims 1 to 6 is implemented.
