Anomaly detection method, medium and system based on network security
By establishing the baseline model and abnormal fluctuation curve of the Isolation Forest algorithm, we determine the characteristics that contribute a lot to abnormality and output targeted prevention methods. This solves the problem of broad and weakly targeted network security prevention measures and improves the prevention of abnormal behaviors. Effect.
Patent Information
- Application Number
- CN202410386623.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-01
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2044-04-01
AI Technical Summary
Existing network security prevention measures are relatively broad and poorly targeted, and cannot effectively prevent or respond to future security threats in a timely manner.
By collecting users' normal login behavior data, we establish the baseline model of the Isolation Forest algorithm, extract behavioral features, eliminate abnormal features one by one, construct abnormal fluctuation curves, determine the features with large abnormal contributions, and output targeted prevention measures.
It achieves precise output of preventive measures, avoids the problem of preventive measures being too broad or not highly targeted, and improves the pertinence and effectiveness of abnormal behaviors.
Smart Images

Figure CN118054967B
Abstract
Description
Technical Field
[0001] The present application belongs to the field of network security technology, and more specifically, relates to an anomaly detection method, medium and system based on network security. Background Art
[0002] In the digital age, with the rapid development of businesses such as network service platforms, financial transaction systems and social media, the security and integrity of user data have become key issues of concern; with the increasing complexity of the network environment, various fraudulent behaviors have posed a serious threat to user data security; therefore, it is particularly important to establish means of monitoring and preventing abnormal behaviors.
[0003] Currently, for monitoring abnormal behavior, a data set is usually used to train a model, and abnormal behavior is identified based on the trained model. However, although traditional methods perform well in some cases, they usually face the technical challenge of being unable to accurately match abnormal behavior with corresponding prevention measures. This is because these methods can only provide an overall anomaly score without going deep into the specific features that cause the anomaly. This results in the security team knowing that certain behaviors are abnormal, but not knowing what specific measures to take to protect them. Therefore, the preventive measures may be too broad or not targeted enough, resulting in an inability to effectively prevent or respond to future security threats in a timely manner. Summary of the invention
[0004] The present invention provides a network security-based anomaly detection method, medium and system, which are intended to solve the technical problem that current security precautions are relatively broad and not very targeted.
[0005] A network security-based anomaly detection method comprises the following steps:
[0006] Step 1: Collect user normal login behavior data;
[0007] Step 2: Extract features from the collected user normal login behavior data to obtain the user behavior feature data set;
[0008] Step 3: Establish a baseline model of normal user behavior based on the Isolation Forest algorithm;
[0009] Step 4: Use the behavior feature data as input data of the baseline model to train the baseline model;
[0010] Step 5: Determine a score threshold. When the anomaly score obtained by inputting new feature data into the trained baseline model exceeds the score threshold, it is marked as anomaly.
[0011] Step 6: For the new feature data marked as abnormal, remove individual features from the new feature data one by one, and input the feature data formed after the removal into the baseline model one by one to obtain the abnormal score, and establish the abnormal fluctuation curve based on all the abnormal scores obtained in this step;
[0012] Step 7: Based on the abnormal fluctuation curve, obtain the features that contribute most to the abnormality, and then output prevention measures based on the feature type.
[0013] The present invention determines abnormal user behavior feature data by establishing a baseline model, and then adopts an elimination method for the determined abnormal user behavior feature data, eliminates individual features in the user behavior feature data one by one, inputs the feature data of the eliminated individual features into the baseline model one by one to obtain corresponding anomaly scores, and then obtains the feature data of the eliminated individual features with the largest fluctuation in anomaly scores when the data is equivalent to complete data through the abnormal fluctuation curve; the eliminated feature is a feature that contributes greatly to the anomaly, and then the corresponding preventive measures are output based on the feature; in this way, the accurate output of the preventive measures can be achieved, and the effect of the preventive measures not being able to effectively prevent can be effectively avoided. Therefore, the present invention makes the output of the preventive measures highly targeted through the above-mentioned technical scheme, and avoids the technical problem that the targeted measures are broad and cannot play the expected effect.
[0014] Preferably, the user's normal login behavior data includes: login time, login location, unique identification code of the login device, IP address, user's operation sequence in the system and operation time.
[0015] Preferably, the feature extraction includes:
[0016] Login time: extract the hour, minute, whether it is working time, and whether it is a working day from the login timestamp;
[0017] Login location: extract the city name and area name of the login location;
[0018] Unique ID of the login device: Based on the unique ID of the login device, it is used to extract whether the login is made by a common mobile phone or a common PC.
[0019] IP address: Divide IP addresses by administrative region and extract the administrative region to which the IP address belongs;
[0020] User operation sequence in the system: extract the most common operation mode, operation frequency and operation time interval;
[0021] Operation time: record the timestamp of each operation of the user and extract the speed of the operation;
[0022] Feature Transformation:
[0023] Normalization or standardization is used for numerical features;
[0024] The classification features are converted into numerical format using one-hot encoding; among them, whether the extracted features are frequently used mobile phone logins and whether the features are frequently used PCs are converted into numerical format using one-hot encoding.
[0025] Preferably, the data processing of the baseline model comprises the following steps:
[0026] Subsampling: Extracting samples from the behavioral feature dataset based on a preset subsample size;
[0027] Construct an isolation tree: Construct an isolation tree for each sample. The construction process is as follows:
[0028] Randomly select a feature, randomly select a split point between the maximum and minimum values of the feature, and divide the data into two parts according to the split point. One part is all the points on the feature that are less than the split point, and the other part is the points that are greater than or equal to the split point. Repeat the above process until the data point is isolated or the maximum height of the specified tree is reached.
[0029] Calculate path length: For each isolated tree in the forest, calculate the path length of each data point. The path length is the number of edges from the root node to the terminal node of the tree.
[0030] Calculate the anomaly score: For each data point, calculate the average path length based on its path length in all trees, and then calculate the anomaly score based on the average path length:
[0031]
[0032] Where: s(x, n) represents the anomaly score of data point x; (x) represents the data point being evaluated; (n) represents the sample size when constructing a single isolated tree, that is, the size of the subsample; E(h(x)) represents the average path length of the data point (x) in all trees in the isolation forest; c(n) represents the normalization factor of the average non-isolated path length in the isolation forest, which is a constant used to standardize the path lengths of samples of different sizes; where c(n) is calculated by the following formula:
[0033]
[0034] In the formula: H(i) represents the harmonic number, which is approximately (ln(i)+0.5772156649)Euler constant; where H(i) represents H(n-1) in the formula.
[0035] Preferably, the steps for determining the score threshold in step 5 are as follows:
[0036] Based on the baseline model, all feature data are traversed to find the feature that contributes most to the anomaly score in each feature data;
[0037] The features with the greatest contribution found are used to form a category data set divided by category according to the category of the features;
[0038] Find the features that contribute most to the anomaly score in all category data sets; build a threshold to obtain the data set based on the category data in each category data set;
[0039] The threshold acquisition data set is input into the baseline model to obtain an anomaly score, and the anomaly score is used as the score threshold.
[0040] Preferably, the specific steps of traversing all feature data of the baseline model are as follows:
[0041] A. For each feature data, use the elimination method to eliminate individual features in the feature data one by one;
[0042] B. Use the data after removing a single feature as the input of the baseline model to obtain the anomaly score;
[0043] C. Determine the feature that contributes most to the anomaly score based on the fluctuation of the anomaly score after removing different data. That is, if the fluctuation of the anomaly score is the largest after removing a certain feature, it means that the removed feature contributes most to the fluctuation of the anomaly score.
[0044] D. Repeat steps A and C until all feature data are traversed.
[0045] Preferably, the steps of constructing the category data set are as follows:
[0046] Assume that the feature data E i =(a i 、b i 、c i ,...,n i );E i Represents the i-th feature data; a i represents feature a in the i-th feature data; b i represents the b feature in the i-th feature data; c i represents the c feature in the i-th feature data; n i represents the n features in the i-th feature data; where i∈(1, 2, 3, ..., m); m represents a total of m feature data;
[0047] Based on the above, we build a dataset of types:
[0048] a=(a pmax )、b=(b dmax )、c=(c smax )、n=(n rmax );
[0049] Where (a pmax ) represents the dataset where feature a contributes the most to the anomaly score among all feature data, and p represents that there are p features; b=(b dmax ) indicates that among all feature data, feature b contributes the most to the anomaly score. d indicates that there are d features. c=(c smax ) indicates that among all feature data, feature c contributes the most to the anomaly score. s indicates that there are s features. n = (n rmax ) represents the data set with the c feature contributing the most to the anomaly among all feature data, r represents r features, where p+d+s+r=m.
[0050] Preferably, step 7 comprises the following steps:
[0051] Obtain the value of each abnormal fluctuation in the abnormal fluctuation curve;
[0052] Calculating an average value of abnormal fluctuations based on the values of each abnormal fluctuation;
[0053] Find at least one abnormal fluctuation value higher than the average value of the abnormal fluctuation, determine the feature corresponding to the at least one abnormal fluctuation value, and determine at least one feature as the feature that contributes most to the abnormal fluctuation;
[0054] A feature anomaly prevention method mapping table is constructed based on the determined feature call, and the mapping table reflects the prevention methods corresponding to abnormal fluctuations caused by different features.
[0055] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the computer program implements a network security-based anomaly detection method as described in the present invention.
[0056] A network security-based anomaly detection system comprises a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, a network security-based anomaly detection method according to the present invention is implemented.
[0057] The beneficial effects of the present invention include:
[0058] The present invention determines abnormal user behavior feature data by establishing a baseline model, and then adopts an elimination method for the determined abnormal user behavior feature data, eliminates individual features in the user behavior feature data one by one, inputs the feature data of the eliminated individual features into the baseline model one by one to obtain corresponding anomaly scores, and then obtains the feature data of the eliminated individual features with the largest fluctuation in anomaly scores when the data is equivalent to complete data through the abnormal fluctuation curve; the eliminated feature is a feature that contributes greatly to the anomaly, and then the corresponding preventive measures are output based on the feature; in this way, the accurate output of the preventive measures can be achieved, and the effect of the preventive measures not being able to effectively prevent can be effectively avoided. Therefore, the present invention makes the output of the preventive measures highly targeted through the above-mentioned technical scheme, and avoids the technical problem that the targeted measures are broad and cannot play the expected effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0059] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0060] Figure 1 An overall step block diagram provided for an embodiment of the present invention.
[0061] Figure 2 A flowchart of the steps for determining a score threshold provided in an embodiment of the present invention.
[0062] Figure 3 A flowchart of the steps for determining the most contributing abnormal feature provided by an embodiment of the present invention.
[0063] Figure 4 This is an abnormal fluctuation curve diagram provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0064] In order to make the technical problems, technical solutions and beneficial effects to be solved by the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0065] It should be noted that when an element is referred to as being "fixed to" or "disposed on" another element, it can be directly on the other element or indirectly on the other element. When an element is referred to as being "connected to" another element, it can be directly connected to the other element or indirectly connected to the other element.
[0066] It should be understood that the terms "length", "width", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside", etc., indicating the orientation or position relationship, are based on the orientation or position relationship shown in the drawings, and are only for the convenience of describing the present application and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be understood as a limitation on the present application.
[0067] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of this application, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.
[0068] See also Figure 1 As shown, the best embodiment of the present invention is further described;
[0069] See also Figure 1 A network security-based anomaly detection method is shown, comprising the following steps:
[0070] Step 1: Collect user normal login behavior data;
[0071] As a possible implementation of this embodiment, the user's normal login behavior data includes: login time, login location, unique identification code of the login device, IP address, user's operation sequence in the system and operation time.
[0072] Step 2: Extract features from the collected user normal login behavior data to obtain the user behavior feature data set;
[0073] As a possible implementation of this embodiment, the feature extraction includes:
[0074] Login time: extract the hour, minute, whether it is working time, and whether it is a working day from the login timestamp;
[0075] Login location: extract the city name and area name of the login location;
[0076] Login device unique identifier: Based on the unique identifier of the login device, extract whether it is a common mobile phone login or a common PC login; for example, see the following Table 1:
[0077] Table 1
[0078] Device Type Daily mobile login Daily PC Login Other Logins Daily mobile login 1 0 0 Daily PC Login 0 1 0 Other Logins 0 0 1
[0079] IP address: Divide IP addresses by administrative region and extract the administrative region to which the IP address belongs;
[0080] Exemplary: query the geographic location corresponding to the IP address through the public IP address geographic location database (MaxMind GeoIP, IP2Location); the public IP address geographic location database contains IP address ranges and corresponding geographic location information (such as country, province, city, postal code); based on this, the administrative region to which the IP address belongs can be extracted.
[0081] User operation sequence in the system: extract the most common operation mode, operation frequency and operation time interval;
[0082] Operation time: record the timestamp of each operation of the user and extract the speed of the operation;
[0083] Feature Transformation:
[0084] Normalization or standardization is used for numerical features;
[0085] The classification features are converted into numerical format using one-hot encoding; among them, whether the extracted features are frequently used mobile phone logins and whether the features are frequently used PCs are converted into numerical format using one-hot encoding.
[0086] Step 3: Establish a baseline model of normal user behavior based on the Isolation Forest algorithm;
[0087] As a possible implementation of this embodiment, the data processing of the baseline model includes the following steps:
[0088] Subsampling: Extracting samples from the behavioral feature dataset based on a preset subsample size;
[0089] Construct an isolation tree: Construct an isolation tree for each sample. The construction process is as follows:
[0090] Randomly select a feature, randomly select a split point between the maximum and minimum values of the feature, and divide the data into two parts according to the split point. One part is all the points on the feature that are less than the split point, and the other part is the points that are greater than or equal to the split point. Repeat the above process until the data point is isolated or the maximum height of the specified tree is reached.
[0091] Calculate path length: For each isolated tree in the forest, calculate the path length of each data point. The path length is the number of edges from the root node to the terminal node of the tree.
[0092] Calculate the anomaly score: For each data point, calculate the average path length based on its path length in all trees, and then calculate the anomaly score based on the average path length:
[0093]
[0094] Where: s(x, n) represents the anomaly score of data point x; (x) represents the data point being evaluated; (n) represents the sample size when constructing a single isolated tree, that is, the size of the subsample; E(h(x)) represents the average path length of the data point (x) in all trees in the isolation forest; c(n) represents the normalization factor of the average non-isolated path length in the isolation forest, which is a constant used to standardize the path lengths of samples of different sizes; where c(n) is calculated by the following formula:
[0095]
[0096] In the formula: H(i) represents the harmonic number, which is approximately (ln(i)+0.5772156649)Euler constant; where H(i) represents H(n-1) in the formula.
[0097] Step 4: Use the behavior feature data as input data of the baseline model to train the baseline model;
[0098] Step 5: Determine a score threshold. When the anomaly score obtained by inputting new feature data into the trained baseline model exceeds the score threshold, it is marked as anomaly.
[0099] As a possible implementation of this embodiment, the steps for determining the score threshold in step 5 are as follows:
[0100] Based on the baseline model, all feature data are traversed to find the feature that contributes most to the anomaly score in each feature data;
[0101] As a possible implementation of this embodiment, the specific steps of traversing all feature data by the baseline model are as follows:
[0102] A. For each feature data, use the elimination method to eliminate individual features in the feature data one by one;
[0103] For example, if there is feature data E1 = (a1, b1, c1, n1), remove a1, b1, c1 and n1 respectively; the following feature data is obtained:
[0104] E′1=(a1, b1, c1); E″1= (a1, c1, n1); E″′1= (b1, c1, n1); E″′1= (a1, b1, n1);
[0105] B. Use the data after removing a single feature as the input of the baseline model to obtain the anomaly score;
[0106] Continuing with the above example, E′1, E″1, E″′1, and E″′1 are input into the baseline model, and the anomaly scores corresponding to E′1, E″1, E″′1, and E″′1 are obtained respectively;
[0107] C. Determine the feature that contributes most to the anomaly score based on the fluctuation of the anomaly score after removing different data. That is, if the fluctuation of the anomaly score is the largest after removing a certain feature, it means that the removed feature contributes most to the fluctuation of the anomaly score.
[0108] Continuing with the above example, subtract the anomaly score of E1 from the anomaly scores of E′1, E″1, E″′1, and E″′1, respectively. The one with the largest difference is the anomaly score with the largest fluctuation. Assume that the anomaly score of E′1 fluctuates the most here, and E′1 eliminates feature n1; it can be seen that n1 in the feature data E1 is the feature that causes the largest fluctuation in the anomaly score.
[0109] D. Repeat steps A and C until all feature data are traversed. Assume there are m feature data in total, so it is necessary to traverse m times until all feature data are traversed;
[0110] See also Figure 2 As shown, the features with the greatest contribution found are used to form a category data set divided by category according to the category of the features;
[0111] As a possible implementation of this embodiment, the steps for constructing the type data set are as follows:
[0112] Assume that the feature data E i =(a i 、b i 、c i ,...,n i );E i Represents the i-th feature data; a i represents feature a in the i-th feature data; b i represents the b feature in the i-th feature data; c i represents the c feature in the i-th feature data; n i represents the n features in the i-th feature data; where i∈(1, 2, 3, ..., m); m represents a total of m feature data;
[0113] Based on the above, we build a dataset of types:
[0114] a=(a pmax )、b=(b dmax )、c=(c smax )、n=(n rmax );
[0115] Where (apmax ) represents the dataset where feature a contributes the most to the anomaly score among all feature data, and p represents that there are p features; b=(b dmax ) indicates that among all feature data, feature b contributes the most to the anomaly score. d indicates that there are d features. c=(C smax ) indicates that among all feature data, feature c contributes the most to the anomaly score. s indicates that there are s features. n = (n rmax ) represents the data set with the c feature contributing the most to the anomaly among all feature data, r represents r features, where p+d+s+r=m.
[0116] Continuing with the above example: Assuming that there are a total of m=10, after the above steps, there are the following types of data sets:
[0117] a=(a1, a3), b=(b2, b7, b8), c=(c4, c 10 )、n=(n5,n6,n9);
[0118] Based on the above, feature category data sets a, b, c, and n are obtained.
[0119] Find the features that contribute most to the anomaly score in all category data sets; build a threshold to obtain the data set based on the category data in each category data set;
[0120] Continuing with the above example, find the feature that contributes most to the anomaly score in the feature class data set a, b, c, n;
[0121] Assume that a1>a3; b7>b2>b8; c4>c 10 ; n9>n5>n6;
[0122] Based on the above, we can know that a1 in category data set a has the largest anomaly fluctuation score; b7 in category data set b has the largest anomaly fluctuation score; c4 in category data set c has the largest anomaly fluctuation score; and n9 in category data set has the largest anomaly fluctuation score;
[0123] Therefore, a1, b7, c4, and n9 are extracted as thresholds to obtain the features of the data set; e = (a1, b7, c4, n9);
[0124] The threshold acquisition data set is input into the baseline model to obtain an anomaly score, and the anomaly score is used as the score threshold.
[0125] Input the constructed e into the baseline model to obtain the anomaly score, and use the obtained anomaly score as the score threshold;
[0126] Since the data set collected in the present invention is a data set of normal login, in this embodiment, the single data features that have the greatest impact on the anomaly in the normal login data set are combined with each other to form the input data of the input baseline model, and the score threshold for judging whether the data is normal or abnormal is obtained based on the output of the baseline model; in this way, the maximum normal baseline is taken into account, so that the detection result is more accurate; and the false alarm of normal login operations is reduced.
[0127] Step 6: For the new feature data marked as abnormal, remove individual features from the new feature data one by one, and input the feature data formed after the removal into the baseline model one by one to obtain the abnormal score, and establish the abnormal fluctuation curve based on all the abnormal scores obtained in this step;
[0128] See also Figure 4 As shown, for example: there is characteristic data E y =(a y 、b y 、a y 、n y ), respectively remove a y 、b y 、c y and n y ; The following characteristic data is obtained:
[0129] E′ y =(a y 、b y 、c y );E″ y =(a y 、c y 、n y );E″′ y =(b y 、c y 、n y );E″′ y =(a y 、b y 、n y );
[0130] The constructed feature data E′ y , E″ y , E″′ y and E″′ y In the input value baseline model, an anomaly score is obtained; and an anomaly fluctuation curve is established based on the obtained anomaly score.
[0131] based on Figure 4 It can be seen that E″ y The outlier value in has the highest fluctuation; the outlier fluctuation value is E y Outliers minus E″ y The abnormal value of E″y Feature b is proposed in y ; From this we can see that b y It is the feature that has the greatest impact on the anomaly, that is, the feature that contributes the most to the anomaly.
[0132] Step 7: Based on the abnormal fluctuation curve, obtain the features that contribute most to the abnormality, and then output prevention measures based on the feature type.
[0133] See also Figure 3 As shown, as a possible implementation of this embodiment, step 7 includes the following steps:
[0134] Obtain the value of each abnormal fluctuation in the abnormal fluctuation curve;
[0135] Calculating an average value of abnormal fluctuations based on the values of each abnormal fluctuation;
[0136] Find at least one abnormal fluctuation value higher than the average value of the abnormal fluctuation, and determine the feature corresponding to the at least one abnormal fluctuation value, and determine at least one feature as the feature that contributes most to the abnormal fluctuation; see Figure 4 As shown:
[0137] E′ y Fluctuation = 0.3; E″ y Fluctuation 0.4; E″ y Fluctuation = 0.2; E″′ y Fluctuation = 0.1;
[0138] Based on the above, the average value is: (0.3+0.4+0.2+0.1) / 4=0.25;
[0139] By comparison, we can see that: E′ y Fluctuation and E″ y Fluctuation exceeds the mean; then E′ y The features n removed y and E″ y The feature b removed y These are the features that contribute most to abnormal fluctuations;
[0140] There may be two abnormal fluctuation values that are higher than the average abnormal fluctuation value, such as: the administrative region to which the non-routine IP address belongs, the non-routine login PC, etc.
[0141] Based on the determined feature call, a feature abnormality prevention method mapping table is constructed, and the mapping table reflects the prevention methods corresponding to abnormal fluctuations caused by different features; an exemplary mapping table in this embodiment is as follows:
[0142] Table 2 Mapping table
[0143]
[0144]
[0145] The present invention can provide a one-to-one solution through the above-mentioned mapping method, which makes it highly targeted. For example, if a mobile phone is stolen and cracked, it may identify unconventional user behavior patterns, non-routine access time, non-routine access frequency, and the administrative region to which the non-routine IP address belongs. After a collection of such situations occurs, it is obviously unreasonable to use SMS authentication. Therefore, it can be set to face recognition, which can effectively avoid the problem of user information being stolen or further loss of user property.
[0146] The present invention determines abnormal user behavior feature data by establishing a baseline model, and then adopts an elimination method for the determined abnormal user behavior feature data, eliminates individual features in the user behavior feature data one by one, inputs the feature data of the eliminated individual features into the baseline model one by one to obtain corresponding anomaly scores, and then obtains the feature data of the eliminated individual features with the largest fluctuation in anomaly scores when the data is equivalent to complete data through the abnormal fluctuation curve; the eliminated feature is a feature that contributes greatly to the anomaly, and then the corresponding preventive measures are output based on the feature; in this way, the accurate output of the preventive measures can be achieved, and the effect of the preventive measures not being able to effectively prevent can be effectively avoided. Therefore, the present invention makes the output of the preventive measures highly targeted through the above-mentioned technical scheme, and avoids the technical problem that the targeted measures are broad and cannot play the expected effect.
[0147] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the computer program implements a network security-based anomaly detection method as described in the present invention.
[0148] A network security-based anomaly detection system comprises a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, a network security-based anomaly detection method according to the present invention is implemented.
[0149] The above are only preferred embodiments of the present application and are not intended to limit the present application. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present application should be included in the protection scope of the present application.
Claims
1. A network security-based anomaly detection method, characterized in that: The following steps are involved: Step 1: Collect user normal login behavior data; Step 2: Extract features from the collected user normal login behavior data to obtain the user behavior feature data set; Step 3: Establish a baseline model of normal user behavior based on the Isolation Forest algorithm; Step 4: Use the behavior feature data as input data of the baseline model to train the baseline model; Step 5: Determine a score threshold. When the anomaly score obtained by inputting new feature data into the trained baseline model exceeds the score threshold, it is marked as anomaly. The steps for determining the score threshold in step 5 are as follows: Based on the baseline model, all feature data are traversed to find the feature that contributes most to the anomaly score in each feature data; The specific steps of traversing all feature data of the baseline model are as follows: A. For each feature data, use the elimination method to eliminate individual features in the feature data one by one; B. Use the data after removing a single feature as the input of the baseline model to obtain the anomaly score; C. Determine the feature that contributes most to the anomaly score based on the fluctuation of the anomaly score after removing different data. That is, after removing a certain feature, the fluctuation of the anomaly score is the largest, which means that the removed feature contributes most to the fluctuation of the anomaly score. D. Repeat steps A and C until all feature data are traversed; The features with the greatest contribution found are used to form a category data set divided by category according to the category of the features; Find the features that contribute most to the anomaly score in all categories of datasets; Building a threshold based on the category data in each category data set to obtain the data set; Inputting the threshold acquisition data set into the baseline model to obtain an anomaly score, and using the anomaly score as a score threshold; Step 6: For the new feature data marked as abnormal, remove individual features from the new feature data one by one, and input the feature data formed after the removal into the baseline model one by one to obtain the abnormal score, and establish the abnormal fluctuation curve based on all the abnormal scores obtained in this step; Step 7: Based on the abnormal fluctuation curve, obtain the features that contribute most to the abnormality, and then output prevention measures based on the feature type.
2. The anomaly detection method based on network security according to claim 1, characterized in that: The user's normal login behavior data includes: login time, login location, unique identification code of the login device, IP address, user's operation sequence in the system and operation time.
3. The method for anomaly detection based on network security according to claim 2, characterized in that: The feature extraction comprises: Login time: extract the hour, minute, whether it is working time, and whether it is a working day from the login timestamp; Login location: extract the city name and area name of the login location; Unique ID of the login device: Based on the unique ID of the login device, it is used to extract whether the login is made by a common mobile phone or a common PC. IP address: Divide IP addresses by administrative region and extract the administrative region to which the IP address belongs; User operation sequence in the system: extract the most common operation mode, operation frequency and operation time interval; Operation time: record the timestamp of each operation of the user and extract the speed of the operation; Feature Transformation: Normalization or standardization is used for numerical features; The classification features are converted into numerical format using one-hot encoding; among them, whether the extracted features are frequently used mobile phone logins and whether the features are frequently used PCs are converted into numerical format using one-hot encoding.
4. The method for anomaly detection based on network security according to claim 3, characterized in that: The data processing of the baseline model includes the following steps: Subsampling: Extracting samples from the behavioral feature dataset based on a preset subsample size; Construct an isolation tree: Construct an isolation tree for each sample. The construction process is as follows: Randomly select a feature, randomly select a split point between the maximum and minimum values of the feature, and divide the data into two parts according to the split point. One part is all the points on the feature that are less than the split point, and the other part is the points that are greater than or equal to the split point. Repeat the above process until the data point is isolated or the maximum height of the specified tree is reached. Calculate path length: For each isolated tree in the forest, calculate the path length of each data point. The path length is the number of edges from the root node to the terminal node of the tree. Calculate the anomaly score: For each data point, calculate the average path length based on its path length in all trees, and then calculate the anomaly score based on the average path length: Where: s(x, n) represents the anomaly score of data point x; (x) represents the data point being evaluated; (n) represents the sample size when constructing a single isolated tree, that is, the size of the subsample; E(h(x)) represents the average path length of the data point (x) in all trees in the isolation forest; c(n) represents the normalization factor of the average non-isolated path length in the isolation forest, which is a constant used to standardize the path lengths of samples of different sizes; where c(n) is calculated by the following formula: In the formula: H(i) represents the harmonic number, which is approximately (ln(i)+0.5772156649)Euler constant; where H(i) represents H(n-1) in the formula.
5. The method for anomaly detection based on network security according to claim 1, characterized in that: The steps for constructing the dataset are as follows: Assume that the feature data E i =(a i , b i 、c i ,…,n i );E i Represents the i-th feature data; a i represents feature a in the i-th feature data; b i represents the b feature in the i-th feature data; c i represents the c feature in the i-th feature data; n i Represents the n features in the i-th feature data; Where i∈(1, 2, 3, …, m); m means there are m feature data in total; Based on the above, we build a dataset of types: a=(a pmax )、b=(b dmax )、c=(c smax )、n=(n rmax ); Where (a pmax ) represents the dataset where feature a contributes the most to the anomaly score among all feature data, and p represents that there are p features; b =(b dmax ) indicates that among all feature data, feature b contributes the most to the anomaly score. d indicates that there are d features. c=(c smax ) indicates that among all feature data, feature c contributes the most to the anomaly score. s indicates that there are s features. n =(n rmax ) represents the data set with n features contributing the most to the anomaly among all feature data, r represents r features, where p+d+s+r=m.
6. The method for anomaly detection based on network security according to claim 1, characterized in that: The step 7 comprises the following steps: Obtain the value of each abnormal fluctuation in the abnormal fluctuation curve; Calculating an average value of abnormal fluctuations based on the values of each abnormal fluctuation; Find at least one abnormal fluctuation value higher than the average value of the abnormal fluctuation, determine the feature corresponding to the at least one abnormal fluctuation value, and determine at least one feature as the feature that contributes most to the abnormal fluctuation; A feature anomaly prevention method mapping table is constructed based on the determined feature call, and the mapping table reflects the prevention methods corresponding to abnormal fluctuations caused by different features.
7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the anomaly detection method based on network security as claimed in any one of claims 1 to 6 is implemented.
8. A network security-based anomaly detection system, characterized in that: The invention comprises a memory, a processor and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the anomaly detection method based on network security as claimed in any one of claims 1 to 6 is implemented.
