Malicious website identification method and device
By combining network traffic characteristics and artificial URL characteristics, and using self-attention and cross-attention layers to identify malicious websites, the problem of poor identification of malicious websites in the existing technology is solved, and the identification accuracy and interpretability of the model are improved. sex.
Patent Information
- Application Number
- CN202410267180.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-08
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2044-03-08
AI Technical Summary
Existing technologies have problems with poor recognition results in identifying malicious websites. The BERT model has poor recognition results due to domain migration issues. Manually summarized features cannot adapt to new forms of malicious websites in a timely manner, and cannot capture potential features.
By obtaining network traffic features and artificial URL features, they are spliced, converted into vectors, and input into the malicious website identification model for identification. The model uses self-attention layers and cross-attention layers for feature extraction and fusion, and uses the Focal Loss loss function for training. Identification is performed by combining network traffic characteristics and artificial characteristics.
It improves the identification accuracy of malicious websites, avoids domain migration problems and the need for large amounts of data fine-tuning, and enhances the interpretability and identification effect of the model.
Smart Images

Figure CN118802282A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of network security technology, and in particular to a method and device for identifying malicious websites. Background Art
[0002] In recent years, there have been many cases of criminals using malicious websites to defraud money through phishing and fraud. Malicious websites may disguise themselves as legitimate websites to obtain users' personal information, account passwords and other sensitive information, thereby carrying out phishing fraud; malicious websites may also embed viruses or malware, which infect users' computers, mobile phones and other devices through user clicks or downloads, thereby leaking users' private data and paralyzing computer systems. In order to expose and combat malicious websites, it is particularly important to accurately identify malicious websites.
[0003] In current related technologies, the detection and identification of malicious websites usually uses the following two methods:
[0004] The first is based on the BERT model, which directly treats the Uniform Resource Locator (URL) sequence as general text to identify malicious websites. Since the BERT model is pre-trained based on a large-scale corpus, the URL features of malicious websites may be different from regular text data, and there is a migration problem between domains. The domain-specific features of the URLs of malicious websites may not be fully learned by the BERT model, and a large amount of data may be required to fine-tune the model to adapt to specific tasks. In addition, the pre-training of the BERT model is based on the assumption that the masked words can be inferred from the context. This assumption is robust, but in the URL-based malicious website classification task, this assumption does not necessarily exist, resulting in poor malicious website identification results.
[0005] The second method is to use machine learning to identify malicious websites based on manually summarized URL features. Since the forms and features of malicious websites are constantly changing and evolving, new threats and malicious behaviors are constantly emerging. Relying solely on manually summarized features cannot adapt to these new forms in a timely manner. In addition, manually summarized features inevitably lose the word order information of the original URL, and manual features may not capture some potentially important features, thus affecting the identification effect of malicious websites. Summary of the invention
[0006] The embodiment of the present invention provides a malicious website identification method and device, which are used to solve the technical problem of poor identification effect existing in the above-mentioned existing malicious website identification method.
[0007] In a first aspect, an embodiment of the present invention provides a method for identifying a malicious website, comprising:
[0008] Obtain URL strings, network traffic features, and artificial URL features corresponding to network traffic;
[0009] splicing the network traffic feature and the artificial URL feature to obtain a spliced artificial feature, and converting the URL string into a vector;
[0010] Inputting the spliced artificial features and the vector into a malicious website identification model to obtain a malicious website identification result output by the malicious website identification model;
[0011] The malicious website identification model is used to extract features from the vector, fuse the features extracted from the vector with the spliced artificial features, and identify malicious websites based on the fused feature parameters.
[0012] In one embodiment, the malicious website identification model includes a classifier and a plurality of stacked modules, each module consisting of a self-attention layer and a cross-attention layer;
[0013] The self-attention layer is used to obtain the original sequence of the vector, and convert each element in the original sequence into three parts: query, key and value through different linear changes; after performing dot multiplication on the query and the key, the dot multiplication result of the query and the key is normalized to obtain a normalized self-attention value, and then the normalized self-attention value is dot multiplied with the value to obtain a new sequence with the same dimension as the original sequence;
[0014] The cross attention layer is used to obtain the new sequence and the spliced artificial features, convert each element in the new sequence into two parts, key and value, through different linear changes, and use the spliced artificial features as the query part after dimension upgrade; after performing dot multiplication on the key and value, the dot multiplication result of the key and value is normalized to obtain a normalized self-attention value, and then the normalized self-attention value is dot multiplied with the query to obtain a feature parameter;
[0015] The classifier is composed of a multi-layer perceptron and is used to perform classification calculations on the characteristic parameters to obtain identification results of malicious websites.
[0016] In one embodiment, after performing dot product on query and key and before normalizing the dot product result of query and key, the method further includes: scaling the dot product result of query and key; after performing dot product on key and value and before normalizing the dot product result of key and value, the method further includes: scaling the dot product result of key and value;
[0017] Before the spliced artificial features are upgraded in dimension and used as the query part, the method further includes: upgrading the spliced artificial features in dimension so that the query, key and value have the same latitude.
[0018] In one embodiment, the malicious website identification model is obtained by training a training data set, wherein the training data set includes multiple groups of samples, each group of samples includes the spliced artificial features, the vector, and a label for marking whether the sample is a malicious website; the Focal Loss function is used in the training process, and the formula is as follows:
[0019]
[0020] Among them, p represents the prediction confidence of the current sample, y represents the label used to mark whether the sample is a malicious website, α represents the balance factor, and γ represents the modulation factor.
[0021] In one embodiment, the network traffic characteristics include at least one of: the number of bytes exchanged, the number of TCP packets exchanged, the number of packets obtained from the server, the number of packets transmitted from the client and the server, the total number of connected IPs, the number of IP packets generated, the number of bytes transmitted from the client and the server, and the number of bytes obtained from the server;
[0022] The artificial URL features include: URL string length, number of numeric characters, whether the IP address is in the host name, whether there is a " / / " symbol in the URL path, path length, host name length and at least one of the number of preset special symbols.
[0023] In one embodiment, before inputting the spliced artificial features into the malicious website identification model, the method further includes:
[0024] The following formula is used to standardize the data of each feature in the spliced artificial features:
[0025]
[0026] Among them, z represents the result of data standardization, X min represents the maximum value of any feature, X max Represents the minimum value of any feature.
[0027] In a second aspect, an embodiment of the present invention provides a malicious website identification device, comprising:
[0028] A data acquisition module is used to obtain URL strings corresponding to network traffic, network traffic features, and artificial URL features;
[0029] A data preprocessing module, used for concatenating the network traffic feature and the artificial URL feature to obtain a concatenated artificial feature, and converting the URL string into a vector;
[0030] An identification module, used for inputting the spliced artificial features and the vector into a malicious website identification model to obtain a malicious website identification result output by the malicious website identification model;
[0031] The malicious website identification model is used to extract features from the vector, fuse the features extracted from the vector with the spliced artificial features, and identify malicious websites based on the fused feature parameters.
[0032] In a third aspect, an embodiment of the present invention provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of the malicious website identification method as described in any one of the above are implemented.
[0033] In a fourth aspect, an embodiment of the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of any of the malicious website identification methods described above.
[0034] In a fifth aspect, an embodiment of the present invention further provides a computer program product, which, when executed by a processor, implements the steps of any of the malicious website identification methods described above.
[0035] The malicious website identification method and device provided by the embodiment of the present invention obtains the URL string corresponding to the network traffic, the network traffic features and the artificial URL features; splices the network traffic features and the artificial URL features to obtain the spliced artificial features, and converts the URL string into a vector; inputs the spliced artificial features and the vector into the malicious website identification model to obtain the malicious website identification result output by the malicious website identification model. Through the application of the above method and device, the features in the URL string, the artificial URL features constructed based on prior knowledge, and the network traffic features are organically combined, avoiding the migration problem between fields caused by simply using language models such as Bert to process URL features for malicious website identification, and avoiding the problem of needing a large amount of labeled data for model fine-tuning, which helps to improve the interpretability of the model. In addition, by taking network traffic features into consideration, the basis for judging malicious websites is increased, and the accuracy of malicious website identification is improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0037] Figure 1 It is a flowchart of a malicious website identification method provided by an embodiment of the present invention;
[0038] Figure 2 Schematic diagram of the execution process of the malicious website identification method in an embodiment of the present invention;
[0039] Figure 3 Schematic diagram of the self-attention mechanism in an embodiment of the present invention;
[0040] Figure 4 is a schematic diagram of a cross attention mechanism in an embodiment of the present invention;
[0041] Figure 5 It is a schematic diagram of the structure of a malicious website identification device provided by an embodiment of the present invention;
[0042] Figure 6 It is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention.
[0043] Wherein, the accompanying drawings are marked as follows:
[0044] 51: data acquisition module; 52: data preprocessing module; 53: recognition module. DETAILED DESCRIPTION
[0045] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0046] It should be noted that in the description of the present invention, the terms "include", "comprise" or any other variant thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "include one..." do not exclude the existence of other identical elements in the process, method, article or device including the elements. The orientation or position relationship indicated by the terms "upper", "lower" and the like is based on the orientation or position relationship shown in the drawings, which is only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation of the present invention. Unless otherwise clearly specified and limited, the terms "installed", "connected" and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be an indirect connection through an intermediate medium, or it can be a connection between the two elements. For those skilled in the art, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0047] The terms "first", "second", etc. in the present invention are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged under appropriate circumstances, so that the embodiments of the present invention can be implemented in an order other than those illustrated or described herein, and the objects distinguished by "first", "second", etc. are generally of the same type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" means at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.
[0048] Combine the following Figure 1-Figure 4 The malicious website identification method of the present invention is described.
[0049] Figure 1 A schematic diagram of a malicious website identification method provided by an embodiment of the present invention. Figure 1 The embodiment of the present invention provides a method for identifying malicious websites, including but not limited to the following steps:
[0050] S1. Obtain the URL string corresponding to the network traffic, network traffic features and artificial URL features.
[0051] Specifically, the URL string is a string composed of characters in the URL sequence of the website, for example, http: / / 108.179.216.140 / ~bankofamerica / is an example URL string.
[0052] In real scenarios, communication operators can obtain network traffic data for accessing a certain website. The network traffic characteristics in the present invention refer to the network traffic characteristics for accessing a certain website obtained from individual network traffic, as shown in Table 1, including but not limited to at least one of the number of exchanged bytes, the number of exchanged TCP packets, the number of packets obtained from the server, the number of packets transmitted from the client and the server, the total number of connected IPs, the number of generated IP packets, the number of bytes transmitted from the client and the server, and the number of bytes obtained from the server.
[0053] Table 1 Network traffic characteristics diagram
[0054]
[0055]
[0056] Artificial URL features refer to features related to URL sequences that are manually screened with prior knowledge. The common forms of URL sequences corresponding to malicious websites are shown in Table 2.
[0057] Table 2 Common concentrated malicious website URLs
[0058]
[0059] In a preferred embodiment of the present invention, according to the above common malicious website URL sequence, as shown in Table 3, the selected artificial URL features include but are not limited to at least one of the URL string length, the number of numeric characters, whether the IP address is in the host name, whether there is a " / / " symbol in the URL path, the path length, the host name length and the number of preset multiple special symbols. Among them, the number of multiple special symbols includes but is not limited to at least one of the number of special symbols ".", the number of special symbols "-", the number of special symbols "@", the number of special symbols "~", the number of special symbols "%", the number of special symbols "&" and the number of special symbols "#".
[0060] Table 3 Schematic diagram of artificial URL features
[0061]
[0062]
[0063] S2. Concatenate the network traffic features and the artificial URL features to obtain concatenated artificial features, and convert the URL string into a vector.
[0064] Specifically, Figure 2 As shown, in this step, the network traffic features and the artificial URL features are spliced. Assuming that the network traffic features contain 5 features and the artificial URL features contain 6 features, the spliced artificial features obtained after splicing contain a total of 11 features.
[0065] To convert a URL string into a vector, you first need to filter out commonly seen fragments such as "www" and "http", then split the URL string into individual characters, and then use one-hot encoding to convert each character into a number according to a specific correspondence. Since the neural network requires that the length of each input is fixed, and the length of the URL string is not fixed, it is also necessary to set a fixed length L to trim the URL string or fill it with 0, and finally use the embedding layer in the neural network to convert the number into a vector. In addition, since the same field will have different meanings in different areas, it is also necessary to add relative position encoding to the URL string.
[0066] S3. Input the spliced artificial features and vectors into a malicious website identification model to obtain a malicious website identification result output by the malicious website identification model.
[0067] Among them, the malicious website identification model is used to extract features from vectors, and fuse the features extracted from the vectors with the spliced artificial features, and identify malicious websites based on the fused feature parameters.
[0068] Specifically, the malicious website recognition model in the present invention is obtained by training a training data set, and the training data set includes multiple groups of samples, each group of samples includes the spliced artificial features, the vector, and a label for marking whether the sample is a malicious website. In view of the fact that the number of malicious websites in real scenarios is far lower than the number of normal websites, the present invention uses the Focal Loss loss function to optimize the model during the training process, and the formula is as follows:
[0069]
[0070] Among them, p represents the prediction confidence of the current sample, y represents the label used to mark whether the sample is a malicious website, α represents the balance factor, and γ represents the modulation factor.
[0071] The reason why the focal loss function is used is that in reality, if a general loss function such as cross entropy is used, the model tends to classify all websites as normal websites. Using methods such as resampling or undersampling not only changes the original distribution of the input, but also increases the number of samples of smaller categories by oversampling data, and reduces the number of samples of larger categories by undersampling data, which may cause problems such as model overfitting. The use of the Focal Loss loss function can solve the above problems while keeping the input distribution unchanged. The main function of Focal Loss is to readjust the loss contribution of simple samples (low prediction confidence) and difficult samples (high prediction confidence) to increase the network's attention to learning difficult samples. α mainly adjusts the weights of positive and negative samples, and γ dynamically adjusts the loss contribution of samples. For samples with higher confidence, the modulation factor will produce a lower weight, and vice versa. At this time, if the samples are unbalanced, assuming that the negative samples are far more than the positive samples, the model will inevitably overfit the negative samples in the early stage, and the prediction confidence p calculated for all samples is very small. Since p is very small, the loss of negative samples almost decays to 0, while the loss of positive samples hardly decays at all, leaving only a few positive samples that generate losses, and the sample imbalance is automatically resolved.
[0072] like Figure 2 As shown, the malicious website identification model provided by the present invention includes a classifier and multiple stacked modules, each of which is composed of a self-attention layer and a cross-attention layer. The purpose of setting up multiple modules is to increase the representation and fitting capabilities of complex problems, and to add cross-attention layers multiple times to ensure that the spliced artificial features with prior knowledge are considered by the model.
[0073] Since the URL of malicious websites is somewhat different from natural language, using the trained BERT model to process URLs will encounter the problem of domain migration. Since the URL context relevance is weaker than the relevance of natural language, it is not suitable to use MLM loss for training. In view of this feature, the present invention designs a neural network structure that alternately stacks self-attention layers and cross-attention layers, so that the artificially extracted features with prior knowledge guide the neural network to extract features, accelerate the speed of model convergence, and improve the accuracy of recognition.
[0074] Specifically, Figure 3 As shown, the self-attention layer is used to obtain the original sequence of vectors converted from the URL string as input, and convert each element in the original sequence into three parts: query, key and value through different linear changes. Preferably, each element in the original sequence can be multiplied by three learnable, randomly initialized weight matrices to obtain query, key and value vectors respectively.
[0075] The self-attention mechanism is a mechanism used in deep learning models that is good at capturing the internal correlation of data or features. The long-distance dependency problem can be solved by calculating the mutual influence between tokens. The self-attention mechanism first calculates the attention value, that is, the dot product of the key and the query. After the query and the key are dot-multiplied, the dot product of the query and the key is normalized using a normalization function so that the sum of the attention values is 1, and the normalized self-attention value is obtained. Then the normalized self-attention value is dot-multiplied with the value to obtain a new sequence of the same dimension as the original sequence, which is used as the output result of the self-attention layer in the model and input into the next layer in the model, namely the cross-attention layer. In an optional embodiment, in order to avoid the dot product of the key and the query being too large and exceeding the representation capacity of the computer, the result is usually scaled. The self-attention mechanism can be expressed by the following mathematical formula:
[0076]
[0077] Where X is the input sequence, XW Q , XW K and XW v are the weight matrices of query, key and value vectors respectively, d k is the dimension of the key vector.
[0078] like Figure 4 As shown, the cross-attention layer is used to obtain the new sequence of spliced artificial features and the output of the self-attention layer, convert each element in the new sequence into two parts, key and value, through different linear changes, and use the spliced artificial features as the query part after dimensionality upgrading. It should be understood that the present invention does not limit the dimensionality upgrading method used for upgrading the spliced artificial features. Preferably, the embedding method can be used to upgrade the spliced artificial features. The purpose of dimensionality upgrading is to make the query, key and value have the same dimension.
[0079] After performing dot multiplication on the key and value, the normalization function is used to normalize the dot product of the key and value to obtain the normalized self-attention value, and then the normalized self-attention value is dot multiplied with the query to obtain the feature parameter.
[0080] The difference between the cross-attention mechanism and the self-attention mechanism is that the query, key, and value of the self-attention mechanism all come from the same sequence (the original sequence of vectors converted from the URL string), but are the products of different linear transformations, while in the cross-attention mechanism, the key and value still come from the features extracted from the URL string (the new sequence output by the self-attention layer), and the query comes from the artificially extracted spliced artificial features. By using the cross-attention mechanism, the neural network is required to accept the guidance of artificially extracted features with prior knowledge during the feature extraction process, and this process is repeated multiple times in the neural network (multiple modules) to ensure that the neural network can be combined with the prior knowledge in the artificially extracted features.
[0081] Preferably, the present invention uses global average pooling to process the feature parameters output by the cross-attention layer. Since relative position encoding is added to the URL string in step S2, using global average pooling will not lose too much position information and can achieve a higher operating speed.
[0082] The classifier is composed of a multi-layer perceptron, which is used to classify and calculate the feature parameters to obtain the identification results of malicious websites. The last layer in a series of derivative algorithms of the neural network is a classifier composed of a multi-layer perceptron, which is used to perform the final classification calculation on the processed feature parameters to obtain the probability corresponding to each sample label. After obtaining the prediction results, the parameters in the model can also be continuously trained and updated through the back-propagation mechanism.
[0083] In an optional embodiment of the present invention, in view of the fact that the ranges of the numerical features in the artificial URL features and network traffic features extracted from malicious websites are inconsistent, before the spliced artificial features are input into the malicious website recognition model, it is necessary to perform a standardization operation on the data to avoid that some features with a larger range or a larger variance occupy a larger proportion in the training of the model, thereby affecting the performance and trade-off of the model. Specifically, the following formula is used to perform data standardization on each feature in the spliced artificial features:
[0084]
[0085] Among them, z represents the result of data standardization, X min represents the maximum value of any feature, X max Represents the minimum value of any feature.
[0086] In summary, the malicious website identification method provided by the present invention organically combines the advantages of the features in the URL string, the artificial URL features constructed based on prior knowledge, and the network traffic features, so that the artificially summarized features guide the feature learning of the neural network, avoiding the migration problem between fields caused by simply using language models such as Bert to process URL features for malicious website identification, and avoiding the problem of needing a large amount of annotated data for model fine-tuning, which helps to improve the interpretability of the model. In addition, by taking network traffic features into consideration, the basis for judging malicious websites is increased, the accuracy of malicious website identification is improved, and good application effects are achieved.
[0087] Based on the same application concept, the present invention also provides a malicious website identification device. The malicious website identification device provided by the present invention is described below. The malicious website identification device described below and the malicious website identification method described above can be referenced to each other.
[0088] like Figure 5 As shown, the malicious website identification device provided by the present invention includes:
[0089] A data acquisition module 51 is used to acquire URL strings corresponding to network traffic, network traffic features and artificial URL features;
[0090] A data preprocessing module 52, configured to concatenate the network traffic feature and the artificial URL feature to obtain a concatenated artificial feature, and convert the URL string into a vector;
[0091] An identification module 53, used for inputting the spliced artificial features and the vector into a malicious website identification model to obtain a malicious website identification result output by the malicious website identification model;
[0092] The malicious website identification model is used to extract features from the vector, fuse the features extracted from the vector with the spliced artificial features, and identify malicious websites based on the fused feature parameters.
[0093] Figure 6 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 6 As shown, the electronic device may include: a processor 610, a communication interface 620, a memory 630 and a communication bus 640, wherein the processor 610, the communication interface 620 and the memory 630 communicate with each other through the communication bus 640. The processor 610 may call the logic instructions in the memory 630 to execute any of the above-mentioned malicious website identification methods, which include:
[0094] Get the URL string, network traffic features, and artificial URL features corresponding to the network traffic.
[0095] The network traffic feature and the artificial URL feature are concatenated to obtain a concatenated artificial feature, and the URL character string is converted into a vector.
[0096] The spliced artificial features and the vector are input into a malicious website identification model to obtain a malicious website identification result output by the malicious website identification model.
[0097] The malicious website identification model is used to extract features from the vector, fuse the features extracted from the vector with the spliced artificial features, and identify malicious websites based on the fused feature parameters.
[0098] In addition, the logic instructions in the above-mentioned memory 630 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0099] On the other hand, the present invention further provides a computer program product, the computer program product includes a computer program, the computer program can be stored on a non-transitory computer-readable storage medium, when the computer program is executed by a processor, the computer can execute the malicious website identification method provided by the above methods, the method includes:
[0100] Get the URL string, network traffic features, and artificial URL features corresponding to the network traffic.
[0101] The network traffic feature and the artificial URL feature are concatenated to obtain a concatenated artificial feature, and the URL character string is converted into a vector.
[0102] The spliced artificial features and the vector are input into a malicious website identification model to obtain a malicious website identification result output by the malicious website identification model.
[0103] The malicious website identification model is used to extract features from the vector, fuse the features extracted from the vector with the spliced artificial features, and identify malicious websites based on the fused feature parameters.
[0104] In another aspect, the present invention further provides a processor-readable storage medium, wherein the processor-readable storage medium stores a computer program, wherein the computer program is used to enable a processor to execute the malicious website identification method provided in the above embodiments, the method comprising:
[0105] Get the URL string, network traffic features, and artificial URL features corresponding to the network traffic.
[0106] The network traffic feature and the artificial URL feature are concatenated to obtain a concatenated artificial feature, and the URL character string is converted into a vector.
[0107] The spliced artificial features and the vector are input into a malicious website identification model to obtain a malicious website identification result output by the malicious website identification model.
[0108] The malicious website identification model is used to extract features from the vector, fuse the features extracted from the vector with the spliced artificial features, and identify malicious websites based on the fused feature parameters.
[0109] In another aspect, the present invention further provides a computer program, wherein the computer program is used to enable a processor to execute the malicious website identification method provided in the above embodiments, the method comprising:
[0110] Get the URL string, network traffic features, and artificial URL features corresponding to the network traffic.
[0111] The network traffic feature and the artificial URL feature are concatenated to obtain a concatenated artificial feature, and the URL character string is converted into a vector.
[0112] The spliced artificial features and the vector are input into a malicious website identification model to obtain a malicious website identification result output by the malicious website identification model.
[0113] The malicious website identification model is used to extract features from the vector, fuse the features extracted from the vector with the spliced artificial features, and identify malicious websites based on the fused feature parameters.
[0114] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0115] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0116] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for identifying malicious websites. It is characterized in that include: Obtain URL strings, network traffic features, and artificial URL features corresponding to network traffic; splicing the network traffic feature and the artificial URL feature to obtain a spliced artificial feature, and converting the URL string into a vector; Inputting the spliced artificial features and the vector into a malicious website identification model to obtain a malicious website identification result output by the malicious website identification model; The malicious website identification model is used to extract features from the vector, fuse the features extracted from the vector with the spliced artificial features, and identify malicious websites based on the fused feature parameters.
2. The method for identifying malicious websites according to claim 1, It is characterized in that The malicious website identification model includes a classifier and multiple stacked modules, each module consisting of a self-attention layer and a cross-attention layer; The self-attention layer is used to obtain the original sequence of the vector, and convert each element in the original sequence into three parts: query, key and value through different linear changes; after performing dot multiplication on the query and the key, the dot multiplication result of the query and the key is normalized to obtain a normalized self-attention value, and then the normalized self-attention value is dot multiplied with the value to obtain a new sequence with the same dimension as the original sequence; The cross attention layer is used to obtain the new sequence and the spliced artificial features, convert each element in the new sequence into two parts, key and value, through different linear changes, and use the spliced artificial features as the query part after dimension upgrade; after performing dot multiplication on the key and value, the dot multiplication result of the key and value is normalized to obtain a normalized self-attention value, and then the normalized self-attention value is dot multiplied with the query to obtain a feature parameter; The classifier is composed of a multi-layer perceptron and is used to perform classification calculations on the characteristic parameters to obtain identification results of malicious websites.
3. The method for identifying malicious websites according to claim 2, It is characterized in that After performing dot product on query and key, and before normalizing the dot product result of query and key, the process further includes: scaling the dot product result of query and key; after performing dot product on key and value, and before normalizing the dot product result of key and value, the process further includes: scaling the dot product result of key and value; Before the spliced artificial features are upgraded in dimension and used as the query part, the method further includes: upgrading the spliced artificial features in dimension so that the query, key and value have the same latitude.
4. The method for identifying malicious websites according to claim 1, It is characterized in that The malicious website identification model is obtained by training a training data set, wherein the training data set includes multiple groups of samples, each group of samples includes the spliced artificial features, the vector, and a label for marking whether the sample is a malicious website; the FocalLoss loss function is used in the training process, and the formula is as follows: Among them, p represents the prediction confidence of the current sample, y represents the label used to mark whether the sample is a malicious website, α represents the balance factor, and γ represents the modulation factor.
5. The method for identifying malicious websites according to claim 1, It is characterized in that The network traffic characteristics include at least one of the number of bytes exchanged, the number of TCP packets exchanged, the number of packets obtained from the server, the number of packets transmitted from the client and the server, the total number of connected IPs, the number of IP packets generated, the number of bytes transmitted from the client and the server, and the number of bytes obtained from the server; The artificial URL features include: URL string length, number of numeric characters, whether the IP address is in the host name, whether there is a " / / " symbol in the URL path, path length, host name length and at least one of the number of preset special symbols.
6. The method for identifying malicious websites according to any one of claims 1 to 5, It is characterized in that Before inputting the spliced artificial features into the malicious website identification model, the method further includes: The following formula is used to standardize the data of each feature in the spliced artificial features: Among them, z represents the result of data standardization, X min represents the maximum value of any feature, X max Represents the minimum value of any feature.
7. A malicious website identification device, It is characterized in that include: A data acquisition module is used to obtain URL strings corresponding to network traffic, network traffic features, and artificial URL features; A data preprocessing module, used for concatenating the network traffic feature and the artificial URL feature to obtain a concatenated artificial feature, and converting the URL string into a vector; An identification module, used for inputting the spliced artificial features and the vector into a malicious website identification model to obtain a malicious website identification result output by the malicious website identification model; The malicious website identification model is used to extract features from the vector, fuse the features extracted from the vector with the spliced artificial features, and identify malicious websites based on the fused feature parameters.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, It is characterized in that When the processor executes the program, the steps of the malicious website identification method according to any one of claims 1 to 6 are implemented.
9. A non-transitory computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the steps of the malicious website identification method according to any one of claims 1 to 6 are implemented.
10. A computer program product comprising a computer program, It is characterized in that When the computer program is executed by a processor, the steps of the malicious website identification method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Malware detection method and system based on network traffic multi-view fusion
CN109117634A
Real-time malicious webpage identification method and system on gateway
CN111447169A
Web injection attack detection method and device, electronic equipment and storage medium
CN114064889A
Malicious software detection method and device, equipment and medium
CN117633793A
Detecting malicious HTTP redirections using user browsing activity trees
US9531736B1
