Web traffic anomaly detection method and device based on improved isolation forest algorithm

By improving the isolated forest algorithm, calculating weights based on the distance between abnormal samples and normal samples, and using inconsistency metrics to calculate diversity and symmetric matrices, the identification accuracy and resource consumption problems of traditional algorithms in identifying web traffic anomalies are solved, and the anomalies are improved. Traffic identification accuracy and reduce false alarm rate.

CN114338195BActive Publication Date: 2024-09-06CHINA TELECOM CORP LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111658650.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-30
Publication Date
2024-09-06
Estimated Expiration
2041-12-30

AI Technical Summary

Technical Problem

The traditional isolated forest algorithm has low recognition accuracy when processing web traffic data containing a large number of local relatively sparse points, and the calculation method for most data with unobvious features can easily lead to low correlation features affecting abnormal judgments, making it difficult to effectively deal with 0-day attacks and high resources. Consumption issue.

Method used

By collecting historical log data of web firewalls, extracting multi-dimensional feature data, constructing an improved isolated forest model, calculating weights based on the distance between abnormal samples and normal samples, using inconsistency measures to calculate diversity and determining symmetrical matrices, improving the calculation of abnormal scores, and reducing low correlation Feature influence to improve recognition accuracy.

Benefits of technology

While ensuring the efficiency of the original algorithm, the recognition accuracy of abnormal traffic is improved, the false alarm rate is reduced, and the recognition accuracy of local relatively sparse characteristic traffic data is enhanced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114338195B
    Figure CN114338195B
Patent Text Reader

Abstract

The present disclosure relates to the field of network security technology, and specifically to a web traffic anomaly detection method and device based on an improved isolation forest algorithm, a storage medium, and a terminal device. The method comprises: collecting web firewall historical log data and web firewall test log data; performing feature extraction on the web firewall historical log data to construct an anomaly detection model based on an isolation forest model based on the feature extraction result; inputting the web firewall test log data into the anomaly detection model based on the isolation forest model to obtain an anomaly detection result. The method disclosed in the present disclosure improves the recognition accuracy of abnormal traffic and reduces false positives while ensuring the efficiency of the original algorithm.
Need to check novelty before this filing date? Find Prior Art

Description

Background Art

[0002] Web firewalls are the first line of defense for information security. With the rapid update of network technology, new hacker techniques are emerging in an endless stream, bringing challenges to traditional rule-based firewalls. Traditional web intrusion detection technology intercepts intrusion access by maintaining rule sets. On the one hand, hard rules are easily bypassed by flexible hackers, and rule sets based on previous knowledge are difficult to deal with 0day attacks; on the other hand, the offensive and defensive confrontations are rising, and the construction and maintenance threshold of the defender's rules are high and the resource consumption cost is high. However, the traditional isolation forest anomaly detection algorithm has limitations in calculating anomaly scores. It is not good at processing web traffic data with a large number of relatively sparse points locally. For most web traffic data with unclear features, the average calculation method of searching the depth easily leads to low-correlation features affecting the final anomaly judgment.

[0003] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present disclosure, and therefore may include information that does not constitute the prior art known to ordinary technicians in the field. Summary of the invention

[0004] The purpose of the present disclosure is to provide a web traffic anomaly detection method based on an improved isolation forest algorithm, a web traffic anomaly detection device based on an improved isolation forest algorithm, a storage medium and a terminal device, thereby at least to a certain extent overcoming the limited application of the traditional isolation forest algorithm in the field of web traffic anomaly detection due to the limitations and defects of related technologies.

[0005] Other features and advantages of the present disclosure will become apparent from the following detailed description, or may be learned in part by the practice of the present disclosure.

[0006] According to a first aspect of the present disclosure, a web traffic anomaly detection method based on an improved isolation forest algorithm is provided, the method comprising:

[0007] Collect historical log data of web firewalls and log data to be tested of web firewalls;

[0008] Performing feature extraction on the web firewall historical log data to build an anomaly detection model based on the isolation forest model based on the feature extraction results;

[0009] The web firewall log data to be tested is input into the anomaly detection model based on the isolation forest model to obtain an anomaly detection result.

[0010] In an exemplary embodiment of the present disclosure, the feature extraction of the web firewall historical log data to construct an anomaly detection model based on the isolation forest model based on the feature extraction result includes:

[0011] Parsing the web firewall historical log data to obtain feature data of multiple dimensions, and using the feature data as training samples;

[0012] Constructing an isolated tree set based on the feature data;

[0013] Calculate the first weight w1 based on the distance between the abnormal sample and the center of the normal sample and the distance between the normal sample and the center of the normal sample;

[0014] The diversity between isolated trees is calculated using the incompatibility metric to determine the symmetric matrix, and the second weight coefficient w2 is calculated using the symmetric matrix;

[0015] The anomaly score is calculated by combining the first weight w1 and the second weight w2.

[0016] In an exemplary embodiment of the present disclosure, parsing the web firewall historical log data to obtain feature data of multiple dimensions includes:

[0017] The HTTP requests in the historical log data of the web firewall are generalized, and feature data of multiple dimensions are extracted based on preset feature fields.

[0018] In an exemplary embodiment of the present disclosure, the method further includes:

[0019] A preset proportion of known abnormal samples is added to the feature data of each dimension to construct training samples.

[0020] In an exemplary embodiment of the present disclosure, constructing an isolated tree set based on the feature data includes:

[0021] Based on each type of feature data, a corresponding set of isolated trees is constructed.

[0022] In an exemplary embodiment of the present disclosure, the first weight w1 is an isolated tree weight.

[0023] In an exemplary embodiment of the present disclosure, the second weight coefficient w2 is an isolated tree path depth weight coefficient;

[0024] The method of calculating the diversity between isolated trees using the incompatibility metric to determine a symmetric matrix, and calculating the second weight coefficient w2 using the symmetric matrix, includes:

[0025] The symmetric matrix is ​​determined by calculating the diversity between isolated trees using the incompatibility metric;

[0026] The mean of the symmetric matrix is ​​calculated column by column, and the mean is used as the depth weight coefficient of the isolated tree path.

[0027] According to a second aspect of the present disclosure, a web traffic anomaly detection device based on an improved isolation forest algorithm is provided, the device comprising:

[0028] The data collection module is used to collect the historical log data of the web firewall and the log data to be tested of the web firewall;

[0029] A model training module, used for extracting features from the historical log data of the web firewall, so as to construct an anomaly detection model based on the isolation forest model based on the feature extraction results;

[0030] The detection result output module is used to input the web firewall to-be-tested log data into the anomaly detection model based on the isolation forest model to obtain an anomaly detection result.

[0031] According to a third aspect of the present disclosure, a storage medium is provided, on which a computer program is stored, and when the program is executed by a processor, the above-mentioned web traffic anomaly detection method based on the improved isolation forest algorithm is implemented.

[0032] According to a fourth aspect of the present disclosure, a terminal device is provided, including:

[0033] Processor; and

[0034] A memory, configured to store executable instructions of the processor;

[0035] The processor is configured to execute the above-mentioned web traffic anomaly detection method based on the improved isolation forest algorithm by executing the executable instructions.

[0036] In a web traffic anomaly detection method based on an improved isolation forest algorithm provided by an embodiment of the present disclosure, feature extraction is performed through the collected web firewall historical log data, and an anomaly detection model based on the improved isolation forest model is constructed based on the feature extraction result, so that the model can be used to detect the web firewall log data to be tested and determine the corresponding detection result. While ensuring the efficiency of the original algorithm, the recognition accuracy of abnormal traffic is improved and false positives are reduced.

[0037] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] The accompanying drawings herein are incorporated into the specification and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the specification are used to explain the principles of the present disclosure. Obviously, the accompanying drawings described below are only some embodiments of the present disclosure, and for ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without creative work.

[0039] Figure 1 A schematic diagram schematically illustrates a method for detecting anomalies in web traffic based on an improved isolation forest algorithm in an exemplary embodiment of the present disclosure;

[0040] Figure 2 A schematic diagram schematically illustrates a method for constructing an anomaly detection model based on an isolation forest model in an exemplary embodiment of the present disclosure;

[0041] Figure 3 A schematic diagram schematically illustrates a web traffic anomaly detection device based on an improved isolation forest algorithm in an exemplary embodiment of the present disclosure;

[0042] Figure 4 A schematic diagram schematically shows the composition of a terminal device in an exemplary embodiment of the present disclosure;

[0043] Figure 5 A schematic diagram schematically illustrates a storage medium in an exemplary embodiment of the present disclosure. DETAILED DESCRIPTION

[0044] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that the disclosure will be more comprehensive and complete and to fully convey the concepts of the example embodiments to those skilled in the art. The described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments.

[0045] In addition, the accompanying drawings are only schematic illustrations of the present disclosure and are not necessarily drawn to scale. The same reference numerals in the figures represent the same or similar parts, and their repeated description will be omitted. Some of the block diagrams shown in the accompanying drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities can be implemented in software form, or implemented in one or more hardware modules or integrated circuits, or implemented in different networks and / or processor devices and / or microcontroller devices.

[0046] In related technologies, traditional web intrusion detection technology intercepts intrusion access by maintaining rule sets. On the one hand, hard rules are easily bypassed by flexible hackers, and rule sets based on previous knowledge are difficult to deal with 0day attacks; on the other hand, the construction and maintenance threshold of the defender's rules are high and the resource consumption cost is high as the offensive and defensive confrontations rise. The new generation of web traffic anomaly detection technology based on machine learning technology is expected to make up for the shortcomings of the traditional rule set method and bring new developments and breakthroughs to the defense end of web confrontation. There are also challenges in the application of machine learning to web intrusion detection, the biggest difficulty of which is the lack of label data. Therefore, the web traffic anomaly detection method based on anomaly detection can establish a model for a large number of normal logs, and those that do not match the normal traffic are identified as anomalies, so as to "remain unchanged in the face of changes" in the confrontation. At the same time, it can be applied to the firewall system to initially screen out 100% normal samples. These samples can be directly let go in the firewall detection engine without further detection, reducing the resource consumption of the firewall in the process of protecting large-traffic websites, while improving the efficiency and accuracy of firewall detection. However, the traditional isolation forest anomaly detection algorithm has limitations in calculating anomaly scores. It is not good at processing web traffic data containing a large number of relatively sparse points. In addition, for web traffic data with mostly unclear features, the average search depth calculation method easily leads to low-correlation features affecting the final anomaly judgment.

[0047] In view of the above shortcomings and deficiencies of the prior art, this example embodiment provides a web traffic anomaly detection method based on an improved isolation forest algorithm. Figure 1 As shown in , the above-mentioned web traffic anomaly detection method based on the improved isolation forest algorithm may include the following steps:

[0048] Step S11, collecting web firewall historical log data and web firewall log data to be tested;

[0049] Step S12, performing feature extraction on the web firewall historical log data to construct an anomaly detection model based on the isolation forest model based on the feature extraction result;

[0050] Step S13, inputting the web firewall log data to be tested into the anomaly detection model based on the isolation forest model to obtain an anomaly detection result.

[0051] In the web traffic anomaly detection method based on the improved isolation forest algorithm provided in this example implementation, feature extraction is performed through the collected web firewall historical log data, and an anomaly detection model based on the improved isolation forest model is constructed based on the feature extraction result, so that the model can be used to detect the web firewall log data to be tested and determine the corresponding detection results. While ensuring the efficiency of the original algorithm, the accuracy of identifying abnormal traffic is improved and false alarms are reduced. By combining the abnormal traffic data features and introducing weight coefficients to improve the isolated deep forest algorithm, the influence of isolated trees constructed by low-correlation features on the results can be reduced, while improving the recognition accuracy of traffic data containing relatively sparse local features.

[0052] In the following, each step of the web traffic anomaly detection method based on the improved isolation forest algorithm in this example implementation will be described in more detail with reference to the accompanying drawings and embodiments.

[0053] In step S11, historical log data of the web firewall and log data to be tested of the web firewall are collected.

[0054] In this example implementation, the above method can be executed by the server; or, it can also be implemented by the server and the user terminal working together. For example, a user can send a traffic detection request to the server on the terminal device, and the traffic detection request can include the web firewall log data to be tested that is collected in real time. After receiving the traffic detection request, the server can create a traffic detection task. The server executes the traffic detection task, first training the anomaly detection model, and then using the trained anomaly detection model to perform real-time detection on the web firewall log data to be tested that is collected in real time. Alternatively, in some exemplary implementations, the above-mentioned web traffic anomaly detection method based on the improved isolation forest algorithm can also be executed by a terminal device with certain computing capabilities.

[0055] In step S12, feature extraction is performed on the web firewall historical log data to build an anomaly detection model based on the isolation forest model based on the feature extraction result.

[0056] In this example implementation, reference Figure 2 As shown, the above step S12 may specifically include:

[0057] Step S21, parsing the web firewall historical log data to obtain feature data of multiple dimensions, and using the feature data as training samples;

[0058] Step S22, constructing an isolated tree set based on the feature data;

[0059] Step S23, calculating a first weight w1 based on the distance between the abnormal sample and the center of the normal sample and the distance between the normal sample and the center of the normal sample;

[0060] Step S24, using the incompatibility metric to calculate the diversity between isolated trees to determine a symmetric matrix, and using the symmetric matrix to calculate a second weight coefficient w2;

[0061] Step S25, calculating anomaly score by combining the first weight w1 and the second weight w2.

[0062] Specifically, the number of historical logs of a preset period length can be collected. Also, the HTTP (Hyper Text Transfer Protocol) requests in the historical log data of the web firewall are generalized, and feature data of multiple dimensions are extracted based on preset feature fields. For example, the dimensions can specifically be contained in the header of the http request: cookie, url, user agent, user name, referer, and so on. The specific parameters of each type of feature may include parameter length information, parameter number character distribution information, and text similarity information. Among them, text similarity can be the similarity between the current sample and the normal sample or abnormal sample; or, it can also be the similarity calculation result corresponding to different http requests.

[0063] In this example implementation, the method further includes: adding a preset proportion of known abnormal samples to the feature data of each dimension to construct training samples.

[0064] For example, in addition, a small number of abnormal samples can be randomly added to the training set and parameters can be set to train isolated trees.

[0065] During the training process of the isolation tree, the variance of the distance between the abnormal sample, the normal sample and the center of the normal sample can be calculated respectively to obtain the isolation tree weight w1. The formula may include:

[0066]

[0067] Among them, δ n represents the distance variance from the normal sample to the normal sample center; δ a Represents the variance of the distance from the abnormal sample to the center of the normal sample.

[0068] Specifically, the samples can be projected into the Euclidean space, and the center of the normal sample and the distances from other sample points to the center of the normal sample point can be calculated in the Euclidean space according to the distribution.

[0069] In this example implementation, the constructing of an isolated tree set based on the feature data includes: constructing a corresponding isolated tree set based on each type of feature data, for example, a corresponding isolated tree can be created based on a URL or a cookie.

[0070] In this example implementation, the method of calculating the diversity between isolated trees using the incompatibility metric to determine a symmetric matrix, and calculating the second weight coefficient w2 using the symmetric matrix, includes:

[0071] The symmetric matrix is ​​determined by calculating the diversity between isolated trees using the incompatibility metric;

[0072] The mean of the symmetric matrix is ​​calculated column by column, and the mean is used as the depth weight coefficient of the isolated tree path.

[0073] For example, for the classifier h i and h j , the prediction results of the two isolated trees may include:

[0074]

[0075] Based on the prediction results, the symmetric matrix can be calculated. The formula may include:

[0076]

[0077] Specifically, the differences of isolated trees can be reflected as follows:

[0078]

[0079] The mean of the matrix is ​​calculated by column as the weight coefficient w2 of the tree path depth. The calculation formula may include:

[0080]

[0081] In this example implementation, the traditional isolation forest algorithm anomaly score calculation is improved based on the weight coefficients obtained by the above calculation, and the formula may include:

[0082]

[0083]

[0084] Where n represents the number of isolated trees and h represents the depth of the tree.

[0085] In step S13, the web firewall log data to be tested is input into the anomaly detection model based on the isolation forest model to obtain an anomaly detection result.

[0086] In this example implementation, the anomaly detection model outputs a normalized anomaly score based on the input real-time data. When the anomaly score is greater than the anomaly threshold, the real-time data is abnormal data. Generally, data with a normalized anomaly score greater than 0.6 is defined as abnormal data, and the abnormality of the data is proportional to the normalized anomaly score.

[0087] The web traffic anomaly detection method based on the improved isolation forest algorithm provided by the present disclosure utilizes the historical log data of the web firewall, firstly randomly extracts the feature data of a certain dimension by the isolation forest algorithm, constructs an isolated tree set of a certain size, and introduces the similarity information of the sample to be tested with the normal and abnormal samples in its child nodes. And introduces the incompatibility metric calculation method in the integrated model to calculate and set the isolated tree integration weight coefficient, and finally combines the similarity and diversity of the child nodes of the isolated tree to set the search depth weight coefficient to improve the isolation forest algorithm, so as to realize the identification of abnormal web traffic. A model (Profile) is established for a large number of normal logs, and those that do not conform to the normal traffic are identified as abnormal, so as to "respond to changes with the same". It is connected to the web application firewall to filter the traffic, and the identified normal logs are directly released, and the abnormal logs enter the threat detection engine, which effectively improves the working efficiency of the firewall and reduces resource consumption. In addition, the method disclosed in the present disclosure fully considers the characteristics of the http request data, introduces the weight coefficient to improve the anomaly detection algorithm, and changes the way in which the average contribution of each isolated tree in the isolation forest to the abnormal score in the original algorithm is changed, thereby reducing the error caused by low-correlation features and improving the detection sensitivity of local sparse data. While ensuring the efficiency of the original algorithm, the accuracy of identifying abnormal traffic is improved and false positives are reduced. In addition, the model disclosed in the present invention combines text similarity to discriminate the abnormal identification effect of isolated trees generated by sub-node distance training; changes the calculation method of isolated tree depth, and combines the similarity and diversity of isolated tree sub-nodes to set the search depth weight coefficient.

[0088] It should be noted that the above figures are only schematic illustrations of the processes included in the method according to an exemplary embodiment of the present invention, and are not intended to be limiting. It is easy to understand that the processes shown in the above figures do not indicate or limit the time sequence of these processes. In addition, it is also easy to understand that these processes can be performed synchronously or asynchronously, for example, in multiple modules.

[0089] For further reference, Figure 3 As shown, in the embodiment of this example, a web traffic anomaly detection device 30 based on the improved isolation forest algorithm is also provided, including: a data collection module 301, a model training module 302, and a detection result output module 303. Among them,

[0090] The data collection module 301 can be used to collect web firewall historical log data and web firewall to-be-tested log data.

[0091] The model training module 302 may be used to perform feature extraction on the web firewall historical log data, so as to construct an anomaly detection model based on the isolation forest model based on the feature extraction result.

[0092] The detection result output module 303 can be used to input the web firewall to-be-tested log data into the anomaly detection model based on the isolation forest model to obtain an anomaly detection result.

[0093] In this exemplary embodiment, the model training module 302 can be used to include: parsing the web firewall historical log data to obtain feature data of multiple dimensions, and using the feature data as training samples; constructing an isolated tree set based on the feature data; calculating a first weight w1 based on the distance from the abnormal sample to the center of the normal sample and the distance from the normal sample to the center of the normal sample; using the incompatibility metric to calculate the diversity between the isolated trees to determine the symmetric matrix, and using the symmetric matrix to calculate the second weight coefficient w2; and calculating the anomaly score in combination with the first weight w1 and the second weight w2.

[0094] In this exemplary embodiment, parsing the web firewall historical log data to obtain feature data of multiple dimensions includes: generalizing HTTP requests in the web firewall historical log data, and extracting feature data of multiple dimensions based on preset feature fields.

[0095] In this exemplary embodiment, the model training module 302 may include: adding a preset proportion of known abnormal samples to the feature data of each dimension to construct training samples.

[0096] In this exemplary embodiment, constructing the isolated tree set based on the feature data includes: constructing a corresponding isolated tree set based on each type of feature data.

[0097] In this exemplary embodiment, the first weight w1 is an isolated tree weight.

[0098] In this exemplary embodiment, the second weight coefficient w2 is the isolated tree path depth weight coefficient; the method of using the incompatibility metric to calculate the diversity between isolated trees to determine the symmetric matrix, and using the symmetric matrix to calculate the second weight coefficient w2, includes: using the incompatibility metric to calculate the diversity between isolated trees to determine the symmetric matrix; calculating the mean of the symmetric matrix by column, and using the mean as the isolated tree path depth weight coefficient.

[0099] The specific details of each module in the above-mentioned web traffic anomaly detection device based on the improved isolation forest algorithm have been described in detail in the corresponding web traffic anomaly detection method based on the improved isolation forest algorithm, so they will not be repeated here.

[0100] It should be noted that, although several modules or units of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into multiple modules or units to be embodied.

[0101] In an exemplary embodiment of the present disclosure, a computer system capable of implementing the above method is also provided.

[0102] It will be appreciated by those skilled in the art that various aspects of the present invention may be implemented as a system, method or program product. Therefore, various aspects of the present invention may be specifically implemented in the following forms, namely: a complete hardware implementation, a complete software implementation (including firmware, microcode, etc.), or a combination of hardware and software, which may be collectively referred to herein as a "circuit", "module" or "system".

[0103] Refer to the following Figure 4 The terminal device 500 according to this embodiment of the present invention is described. Figure 4 The terminal device 500 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0104] like Figure 4 As shown, the terminal device 500 is in the form of a general computing device. The components of the computer system 600 may include but are not limited to: at least one processing unit 610, at least one storage unit 620, and a bus 630 connecting different system components (including the storage unit 620 and the processing unit 610).

[0105] The storage unit stores program codes, which can be executed by the processing unit 610, so that the processing unit 610 performs the steps according to various exemplary embodiments of the present invention described in the above “Exemplary Method” section of this specification. For example, the processing unit 610 can perform the following steps: Figure 1 Follow the steps shown in .

[0106] The storage unit 620 may include a readable medium in the form of a volatile storage unit, such as a random access memory unit (RAM) 6201 and / or a cache memory unit 6202 , and may further include a read-only memory unit (ROM) 6203 .

[0107] The storage unit 620 may also include a program / utility 6204 having a set (at least one) of program modules 6205, such program modules 6205 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.

[0108] Bus 630 may represent one or more of several types of bus structures, including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.

[0109] The computer system 600 may also communicate with one or more external devices 700 (e.g., keyboards, pointing devices, Bluetooth devices, etc.), one or more devices that enable a user to interact with the computer system 600, and / or any device that enables the computer system 600 to communicate with one or more other computing devices (e.g., routers, modems, etc.). Such communication may be performed via an input / output (I / O) interface 650. A display unit 640 may also be connected via an input / output (I / O) interface. Furthermore, the computer system 600 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) via a network adapter 660. As shown, the network adapter 660 communicates with other modules of the computer system 600 via a bus 630. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the computer system 600, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0110] Through the description of the above implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to the implementation of the present disclosure.

[0111] In an exemplary embodiment of the present disclosure, a computer-readable storage medium is also provided, on which a program product capable of implementing the above method of the present specification is stored. In some possible implementations, various aspects of the present invention can also be implemented in the form of a program product, which includes a program code, and when the program product is run on a terminal device, the program code is used to enable the terminal device to execute the steps according to various exemplary embodiments of the present invention described in the above "Exemplary Method" section of the present specification.

[0112] refer to Figure 5 As shown, a program product 100 for implementing the above method according to an embodiment of the present invention is described, which can adopt a portable compact disk read-only memory (CD-ROM) and include program code, and can be run on a terminal device, such as a personal computer. However, the program product of the present invention is not limited thereto. In this document, a readable storage medium can be any tangible medium containing or storing a program, which can be used by or in combination with an instruction execution system, an apparatus or a device.

[0113] The program product may use any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.

[0114] Computer readable signal media may include data signals propagated in baseband or as part of a carrier wave, in which readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Readable signal media may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.

[0115] The program code embodied on the readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the foregoing.

[0116] Program code for performing the operations of the present invention may be written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Java, C++, etc., and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving a remote computing device, the remote computing device may be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., through the Internet using an Internet service provider).

[0117] In addition, the above-mentioned figures are only schematic illustrations of the processes included in the method according to an exemplary embodiment of the present invention, and are not intended to be limiting. It is easy to understand that the processes shown in the above-mentioned figures do not indicate or limit the time sequence of these processes. In addition, it is also easy to understand that these processes can be performed synchronously or asynchronously, for example, in multiple modules.

[0118] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary technical means in the art that are not disclosed in the present disclosure. The specification and examples are to be considered as exemplary only, and the true scope and spirit of the present disclosure are indicated by the claims.

[0119] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims

1. A web traffic anomaly detection method based on an improved isolation forest algorithm, characterized in that: The method comprises: In response to receiving a traffic detection request sent by a user on a terminal device to a server, creating a traffic detection task, wherein the traffic detection request includes real-time collected web firewall log data; collecting web firewall historical log data, and web firewall log data to be tested; Performing feature extraction on the web firewall historical log data to build an anomaly detection model based on the isolation forest model based on the feature extraction results; Inputting the web firewall to-be-tested log data into the anomaly detection model based on the isolation forest model to obtain an anomaly detection result; The feature extraction of the web firewall historical log data is performed to construct an anomaly detection model based on the isolation forest model based on the feature extraction result, including: Parse the web firewall historical log data to obtain feature data of multiple dimensions, and use the feature data as training samples; the historical log data is of a preset period length; Based on each type of feature data, a corresponding isolated tree set is constructed respectively; the types of the feature data include url and cookie; Calculating a first weight w1 according to the distance from the abnormal sample to the center of the normal sample and the distance from the normal sample to the center of the normal sample; the first weight w1 is an isolated tree weight; the method further comprises: projecting the abnormal sample and the normal sample into a Euclidean space, and obtaining the distance from the abnormal sample to the center of the normal sample and the distance from the normal sample to the center of the normal sample according to distribution calculation in the Euclidean space; The diversity between isolated trees is calculated using the incompatibility metric to determine the symmetric matrix, and the second weight coefficient w2 is calculated using the symmetric matrix; Calculate the anomaly score by combining the first weight w1 and the second weight coefficient w2; The web firewall historical log data is parsed to obtain feature data of multiple dimensions, including: Generalize HTTP requests in the historical log data of the web firewall and extract feature data of multiple dimensions based on preset feature fields; The dimensions include those contained in the header of the http request: cookie, url, user agent, user name, and referer.

2. The web traffic anomaly detection method based on the improved isolation forest algorithm according to claim 1 is characterized in that: The method further comprises: A preset proportion of known abnormal samples is added to the feature data of each dimension to construct training samples.

3. The web traffic anomaly detection method based on the improved isolation forest algorithm according to claim 1 is characterized in that: The second weight coefficient w2 is the isolated tree path depth weight coefficient; The method of calculating the diversity between isolated trees using the incompatibility metric to determine a symmetric matrix, and calculating the second weight coefficient w2 using the symmetric matrix, includes: The symmetric matrix is ​​determined by calculating the diversity between isolated trees using the incompatibility metric; The mean of the symmetric matrix is ​​calculated column by column, and the mean is used as the depth weight coefficient of the isolated tree path.

4. A web traffic anomaly detection device based on an improved isolation forest algorithm, characterized in that: The device comprises: The data collection module is used to create a flow detection task in response to receiving a flow detection request sent by a user on a terminal device to a server, wherein the flow detection request includes web firewall log data collected in real time; collect web firewall historical log data, and web firewall log data to be tested; A model training module, used for extracting features from the historical log data of the web firewall, so as to construct an anomaly detection model based on the isolation forest model based on the feature extraction results; A detection result output module, used for inputting the web firewall to-be-tested log data into the anomaly detection model based on the isolation forest model to obtain an anomaly detection result; The model training module is configured as follows: Parse the web firewall historical log data to obtain feature data of multiple dimensions, and use the feature data as training samples; the historical log data is of a preset period length; Based on each type of feature data, a corresponding isolated tree set is constructed respectively; the types of the feature data include url and cookie; A first weight w1 is calculated according to the distance from the abnormal sample to the center of the normal sample and the distance from the normal sample to the center of the normal sample; the first weight w1 is the isolated tree weight; the device is further configured to: project the abnormal sample and the normal sample into the Euclidean space, and calculate the distance from the abnormal sample to the center of the normal sample and the distance from the normal sample to the center of the normal sample according to the distribution in the Euclidean space; The diversity between isolated trees is calculated using the incompatibility metric to determine the symmetric matrix, and the second weight coefficient w2 is calculated using the symmetric matrix; Calculate the anomaly score by combining the first weight w1 and the second weight coefficient w2; The web firewall historical log data is parsed to obtain feature data of multiple dimensions, and is configured as follows: Generalize HTTP requests in the historical log data of the web firewall and extract feature data of multiple dimensions based on preset feature fields; The dimensions include those contained in the header of the http request: cookie, url, user agent, user name, and referer.

5. A storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the web traffic anomaly detection method based on the improved isolation forest algorithm according to claim 1 is implemented.

6. A terminal device, characterized in that: include: processor; as well as A memory, configured to store executable instructions of the processor; The processor is configured to execute the web traffic anomaly detection method based on the improved isolation forest algorithm according to claim 1 by executing the executable instructions.