A method and device for identifying harmful websites based on deep learning
By combining static and dynamic crawling, OCR technology and the BERT model with deep learning methods, a harmful detection and classification model is established, which solves the problems of slow identification of new harmful websites and high false alarm rate in the existing technology, and realizes the detection of harmful websites. rapid and accurate identification.
Patent Information
- Application Number
- CN202410792877.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-19
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2044-06-19
AI Technical Summary
Existing technologies have problems such as slow recognition speed, high false alarm rate, and poor identification of short-content web pages when identifying newly emerging harmful websites. It is difficult to achieve efficient and automated research and judgment of harmful Internet domain names.
Adopt a method based on deep learning to obtain website feature data through a combination of static and dynamic crawling, use OCR technology to expand web page content, build a BERT model for feature extraction and model training, and establish a harmful detection and classification model to determine whether a website is harmful and determine its type.
It achieves rapid and accurate identification of harmful websites, reduces the false alarm rate, improves the ability to identify short content web pages, and can efficiently identify new harmful websites.
Smart Images

Figure CN118364190B
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of data processing technology, and specifically relates to a method and device for identifying harmful websites based on deep learning. Background Art
[0002] The current methods for identifying harmful websites mainly include the following three: blacklist and whitelist, heuristic rules, and content matching. The blacklist and whitelist-based method has the advantages of fast identification speed and easy implementation, but it also has the obvious disadvantages of the lag of the blacklist and whitelist database and the inability to identify newly emerging harmful websites. The heuristic rule-based method for identifying harmful websites uses the rules of similar fraudulent websites for detection and identification. It can identify newly emerging websites, but there is a high false alarm rate. The content matching-based method extracts keywords from the web page content for similarity matching, but it relies on the effect of keyword extraction and performs poorly on short content web pages.
[0003] Therefore, how to efficiently and automatically conduct harmful research and identification of Internet domain names is an urgent problem that needs to be solved. Summary of the invention
[0004] In order to solve the above problems, the present invention discloses a harmful website identification method and device based on deep learning, which can efficiently and accurately determine whether a website is harmful and the corresponding harmful category.
[0005] To achieve the above object, the technical solution of the present invention is as follows:
[0006] A method for identifying harmful websites based on deep learning, comprising the following steps:
[0007] Step 1, crawling and collecting feature data of existing harmful websites, and establishing a feature database of harmful websites; including: obtaining the response status code, title, and web page content text information of the website in a static manner; filtering out web pages with abnormal response status codes, and comparing the length of the web page content text with a threshold; when the length of the web page content text is less than the threshold, obtaining a web page snapshot and web page content text by a dynamic crawling method; extracting the text in the web page snapshot by OCR technology, and accumulating it to the web page content text to form a new web page content text;
[0008] Step 2: Input the feature database and its corresponding labels into the pre-training model, and train a harmful detection model and a harmful classification model respectively; the harmful detection model is used to detect whether the website is normal, and the harmful classification model is used to output the harmful type of the website;
[0009] Step 3, crawling website feature information data based on the domain name or IP extracted from the Internet traffic;
[0010] Step 4: input the website feature information into the harmful detection model trained in step 2 to obtain a first analysis result;
[0011] Step 5: If the first analysis result is normal, determine whether it is a counterfeit website based on the feature data;
[0012] Step 6: If the first analysis result is abnormal, the website feature information is input into the harmful classification model trained in step 2 to obtain the specific harmful type of the website.
[0013] Furthermore, in step 1, the new webpage content text is constructed by OCR technology to replace the webpage text obtained in a static manner.
[0014] Furthermore, the characteristic data of the website obtained in step 1 includes: web page snapshot, title, and web page content.
[0015] Furthermore, in step 1, the registration information of harmful websites is also obtained.
[0016] Furthermore, the step 2 specifically includes the following steps:
[0017] (1) Preprocess the harmful URL text in the feature database;
[0018] (2) Build a pre-trained BERT model;
[0019] (3) The web page content information containing tags is used as a training set and input into the BERT model to obtain semantic representation, which is then input into Sigmoid / Softmax to complete the training of the recognition model.
[0020] Furthermore, the step 3 crawls the website feature information data in the same manner as step 1.
[0021] Furthermore, the process of determining a counterfeit website in step 5 is: calculating the similarity between the website's title and text content and the corresponding parts of the website that is easily counterfeited, and then comparing the calculated similarity with a preset threshold. If it is greater than the threshold, the website is a counterfeit website, otherwise it is a normal website.
[0022] Furthermore, the similarity calculation formula is: The similarity calculation formula is: ,in, is the similarity, For the title, For text content, is the Jaccard similarity.
[0023] The present invention also provides a harmful website identification device based on deep learning, comprising a memory, a processor and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of the harmful website identification method based on deep learning described above.
[0024] The present invention also provides a computer-readable storage medium having a computer program or instruction stored thereon, which, when executed by a processor, implements the steps of the harmful website identification method based on deep learning described above.
[0025] The beneficial effects of the present invention are:
[0026] The present invention obtains the characteristic data of the website to be judged by combining static and dynamic crawling, and pre-processes the characteristic data in combination with OCR technology to expand the characteristic data, and then inputs the website characteristic data into the harmful website detection model to obtain a first judgment result, indicating whether it is harmful; then, according to the above first judgment result, respectively conduct counterfeit website judgment or input the characteristic data into the harmful website identification model to obtain a second judgment result of the website, giving the harmful category of the website. The present invention respectively detects and identifies harmful websites through a hierarchical model based on deep learning, so as to accurately realize the harmful analysis and judgment of harmful websites. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] Figure 1 Flowchart of the harmful website identification method based on deep learning provided by the present invention.
[0028] Figure 2 A schematic diagram of the computer device structure provided by the present invention. DETAILED DESCRIPTION
[0029] The technical solution provided by the present invention will be described in detail below in conjunction with specific embodiments. It should be understood that the following specific implementation methods are only used to illustrate the present invention and are not used to limit the scope of the present invention.
[0030] The present invention provides a method for identifying harmful websites based on deep learning, the process of which is as follows: Figure 1 As shown, the following steps are included:
[0031] S1: Crawl and collect feature data of existing harmful websites, and establish a feature database of harmful websites.
[0032] In this step, the website feature data is obtained by combining static and dynamic methods, as follows:
[0033] 1. Obtain the website's response status code, title, web page content text and other information in a static way through the "Python+Requests" framework;
[0034] 2. Filter out web pages with abnormal response status codes and compare the length of the web page content with a pre-set threshold;
[0035] 3. If it is less than the threshold, the snapshot screenshot and webpage content text are obtained through the dynamic crawling method of the "Python+Selenium+WebDriver+Chrome" framework;
[0036] 4. For the website snapshot obtained in step 3, extract the text in the snapshot through OCR technology (the model architecture uses DBNet+CRNN, and the loading model parameters select PaddleOCR), and add it to the web page content text to form a new web page content text and replace the web page text obtained statically in step 1. The final website text is composed of title + OCR result (if any) + web page content text;
[0037] 5. Obtain the record information (white list) of harmful websites through Internet record, offline record and other channels. If the website is included in the record, it is considered to be a normal website and there is no need to use the solution of the present invention for identification.
[0038] S2: Input the feature database and its corresponding labels into the pre-training model, and train the harmful detection model and harmful classification model respectively. The labels are manually marked according to actual needs.
[0039] In this step, the webpage text content and label information of harmful websites are obtained through S1 as a training set, and a binary classification harmful detection model and a multi-classification harmful classification model are trained based on the pre-trained model. The specific steps include the following:
[0040] 1. Preprocess harmful URL texts, remove duplicates, undersample categories with a large number, and oversample categories with a small number.
[0041] 2. Build a pre-trained BERT model and use the BERT pre-trained model to generate vector representations for the text of harmful websites. The most notable feature of the BERT pre-trained model is the feature extractor, which is composed of a bidirectional Transformer encoder. The core module used by the Transformer encoder is Self-Attention.
[0042] The calculation method of attention is shown in formula (1), where The query vectors are , key vector Sum value vector , these three vectors are generated by the word vectors input to the model, is the vector dimension. The core idea of this method is to calculate the relationship between each word and the word itself and other words in the sentence, and believe that this relationship can contain the correlation between the words in the sentence and the importance of the word itself. Formula (1) is as follows:
[0043] (1);
[0044] In addition, in order to increase the representation ability of different positions of the model, Transformer adopts a "multi-head" mode, as shown in Equations (2) and (3):
[0045] (2)
[0046] (3)
[0047] As shown in formula (2), For the The output vector of each head; represents the concatenation function, which concatenates all header output vectors into one vector. is the weight vector. In formula (3), similar to formula (1), each input vector is converted into three vectors Perform attention calculation.
[0048] As for the deep degradation problem existing in neural networks, the Transformer module uses a residual network and layer normalization method, such as equations (4) and (5):
[0049] (4);
[0050] (5);
[0051] In formula (4), is the mean value of the input matrix, is the standard deviation of the input matrix; and is the parameter of the model that needs to be trained. In formula (5), and is the weight, and For bias.
[0052] After residual normalization of the multi-head attention output, a full connection and residual normalization are performed to obtain the output representation of the BERT model.
[0053] For the binary harmful detection model, the Sigmoid harmful classification model is used. The semantic feature vector output by BERT is input into the Sigmoid model. If the output is greater than 0, it is considered normal, otherwise it is abnormal. For the multi-class harmful classification model, it is input into the Softmax model. Assuming that there is category information
[0054] , a total of categories, then for website text features Categorized into categories The probability of , select the category with the highest probability as the website
[0055] The classification result is .
[0056] S3. Crawl website feature information data based on domain names or IP addresses extracted from Internet traffic;
[0057] It should be noted that the method of obtaining website feature data in this step is the same as S1, and the obtained website features are a combination of the text extracted by OCR of the web page snapshot and the web page text.
[0058] S4. Input the website features into the trained harmful detection model to obtain a first judgment result;
[0059] It should be noted that the harmful detection model uses the BERT two-class harmful detection model fine-tuned in S2.
[0060] S5. If the first judgment result is normal, determine whether it is a counterfeit website based on the feature data;
[0061] It should be noted that the Jaccard similarity between the website title and text content and the corresponding parts of the easily counterfeited website is calculated, and the final similarity is , and then the similarity Compare with the preset threshold. If it is greater than the threshold, the website is a counterfeit website, otherwise it is a normal website. In the formula, For the title, For text content.
[0062] S6. If the first judgment result is abnormal, the website feature information is input into the harmful classification model to obtain the specific harmful type of the website. The harmful detection model in this step adopts the BERT multi-classification harmful classification model fine-tuned in S2.
[0063] The embodiment of the present invention crawls and collects feature data of existing harmful websites, trains a harmful detection model and a harmful classification model, and then inputs the feature information data of the website to be detected and identified into the trained detection model to obtain a first judgment result; if the first judgment result is normal, it is judged whether it is a counterfeit website based on the feature data; if the first judgment result is abnormal, the website feature information is input into the harmful classification model to obtain the specific harmful type of the website. This method can quickly and accurately identify whether the target website is harmful and its fraud type.
[0064] Corresponding to the embodiment of the harmful website identification method based on deep learning described above, the present invention also provides an embodiment of a device for identifying harmful websites based on deep learning.
[0065] like Figure 2 As shown, the present invention provides a device for identifying harmful websites based on deep learning, which includes a memory, a processor, and also includes basic structures such as a bus, a storage medium, an internal memory, a display screen, a network interface and an input device. The memory stores an executable computer program. When the processor executes the computer program through the system bus, it is used to implement the steps of the harmful website identification method based on deep learning in the above-described embodiment.
[0066] The embodiment of the device for identifying harmful websites based on deep learning of the present invention can be applied to all devices with data processing capabilities, such as computers and other devices or devices. The implementation of the device embodiment can be software, hardware, or software and hardware. In terms of software implementation, in any similar device, the corresponding computer program code in the readable memory is read by the processor into the memory for execution. On the hardware level, such as Figure 2 As shown, it is a structural diagram of a device where the harmful website identification device based on deep learning of the present invention is located, except Figure 2 The hardware devices shown may include other hardware depending on the actual functions. Any data processing capability device in the embodiment may also include other hardware, which will not be described in detail here.
[0067] 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.
[0068] Those skilled in the art can understand from the description of the above implementation methods that each implementation method can be implemented with the help of hardware or software plus a necessary general hardware platform. Based on this understanding, the technical solution described above is presented in the form of a computer software product, which is stored in a computer-readable storage medium, such as a CD, a disk, ROM / RAM, etc., and includes a number of instructions to drive a computer device to execute all or part of the processes of the above embodiments.
[0069] It should be noted that the above content only illustrates the technical idea of the present invention and cannot be used to limit the protection scope of the present invention. For ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications all fall within the protection scope of the claims of the present invention.
Claims
1. A method for identifying harmful websites based on deep learning, characterized in that: The steps include: Step 1, crawling and collecting feature data of existing harmful websites, and establishing a feature database of harmful websites; including: obtaining the response status code, title, and web page content text information of the website in a static manner; filtering out web pages with abnormal response status codes, and comparing the length of the web page content text with a preset threshold; when the length of the web page content text is less than the threshold, obtaining a web page snapshot and web page content text by dynamic crawling; extracting the text in the web page snapshot by OCR technology, and accumulating it to the web page content text to form a new web page content text, and replacing the web page text obtained by the static manner after the new web page content text is formed; Step 2: Input the feature database and its corresponding labels into the pre-training model, and train the harmful detection model and the harmful classification model respectively; the harmful detection model is used to detect whether the website is normal, and the harmful classification model is used to output the harmful type of the website; specifically, the following steps are included: (1) Preprocessing the harmful URL text in the feature database; (2) Build a pre-trained BERT model; The web page content information containing the label is used as a training set, input into the BERT model to obtain semantic representation, then input into Sigmoid training to obtain a harmful detection model, and then input into Softmax training to obtain a harmful classification model; Step 3, crawling website feature information data based on the domain name or IP extracted from the Internet traffic; Step 4: input the website feature information into the harmful detection model trained in step 2 to obtain a first analysis result; Step 5: If the first analysis result is normal, determine whether it is a counterfeit website based on the feature data; the process of determining a counterfeit website is: calculate the similarity between the title and text content of the website and the corresponding parts of the website that is easily counterfeited, and then compare the calculated similarity with a preset threshold. If it is greater than the threshold, the website is a counterfeit website, otherwise it is a normal website; the similarity calculation formula is: S = Jaccard (title) + Jaccard (content), where S is the similarity, title is the title, content is the text content, and Jaccard () is the Jaccard similarity; Step 6: If the first analysis result is abnormal, the website feature information is input into the harmful classification model trained in step 2 to obtain the specific harmful type of the website.
2. The method for identifying harmful websites based on deep learning according to claim 1, characterized in that: The characteristic data of the website obtained in step 1 includes: web page snapshot, title, and web page content.
3. The method for identifying harmful websites based on deep learning according to claim 1, characterized in that: The step 3 crawls the website feature information data using the method of step 1.
4. A harmful website identification device based on deep learning, comprising a memory, a processor and a computer program stored in the memory, characterized in that: The processor executes the computer program to implement the steps of the harmful website identification method based on deep learning as described in any one of claims 1-3.
5. A computer-readable storage medium having a computer program or instruction stored thereon, characterized in that: When the computer program or instruction is executed by a processor, the steps of the harmful website identification method based on deep learning described in any one of claims 1 to 3 are implemented.
