A method and device for detecting abnormal behavior of a database

Through the DAGMM model and fixed window sliding processing technology, the problem of insufficient detection of single SQL statements and manual tagging in database exception behavior detection is solved, and abnormal detection of multiple SQL statements and operation time is realized, which improves the accuracy of detection and efficiency.

CN113935023BActive Publication Date: 2024-12-06BEIJING KEDONG ELECTRIC POWER CONTROL SYST CO LTD +2
View PDF 0 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

Existing database abnormal behavior detection methods are poor in detecting malicious behaviors of internal authorized users, and detection based on a single SQL statement is easily bypassed. Most methods require manual labeling of data for model training, which consumes a lot of manpower and may There is a problem of inaccurate marking.

Method used

Using a database abnormal behavior detection model based on DAGMM, multiple SQL statements and operation time are converted into behavior vectors through fixed window sliding processing and encoding technology, and input them into the unsupervised DAGMM model for detection, avoiding the detection of single SQL statements. Dependencies and artificial marking.

Benefits of technology

Effectively detect the abnormal behavior of the combination of multiple SQL statements in the database, reduce the risk of internal users bypassing detection, and reduce the need for manual tags through unsupervised learning, improving the accuracy and efficiency of detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113935023B_ABST
    Figure CN113935023B_ABST
Patent Text Reader

Abstract

The present invention provides a method and device for detecting abnormal behavior of a database. The method comprises: obtaining a database log data set; performing sliding processing on each log using a fixed window, extracting the contents of the three fields of "SQL statement", "run time" and "operation time" in each window as a sliding window database behavior sample, thereby obtaining a sliding window database behavior data set; encoding the SQL statement and operation time of each sliding window database behavior sample in the sliding window database behavior data set to form a sliding window database behavior sample matrix, summing the matrix by column to obtain a sliding window database behavior vector data set; normalizing the sliding window database behavior vector data set, and inputting it into a pre-trained DAGMM database abnormal behavior detection model to obtain a detection result. The present invention well solves the single SQL statement detection loopholes and the need for manual data annotation in previous database abnormal behavior detection research.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to a database abnormal behavior detection method based on DAGMM (Deep AutoEncoder Gaussion Mixture Model, DAGMM), belonging to the technical field of network security. Background Art

[0002] Data is the core asset of enterprise operation, and a lot of valuable information is hidden in the data. At present, most enterprises store daily operation data in databases, so databases have become one of the important attack targets of malicious personnel. According to the data leakage investigation report, most data leakage is caused by internal personnel of the enterprise. Internal personnel are familiar with the security detection system within the enterprise and can effectively evade the detection mechanism; some internal personnel's misoperation will also affect the detection work, which brings considerable difficulties and challenges to the work of abnormal behavior detection in the database.

[0003] Experts have conducted a lot of research on database abnormal behavior detection. Initially, they tried to resist malicious attacks by improving the permission control strategy. However, this method is only effective for malicious attacks carried out under insufficient external authorization, and has poor results in detecting malicious behavior of internal authorized users. With the rise of data mining and artificial intelligence algorithms, research experts have also introduced these technologies into the research of database anomaly detection.

[0004] When using artificial intelligence algorithms to detect abnormal behavior in databases, Karma A et al. used the naive Bayes classification algorithm to build an anomaly detection model based on the query statements and return results in the database; RONAO CA et al. performed fine-grained modeling on database query statements to generate high-dimensional vectors that represent database behavior, and then used PCA to reduce the dimension and input it into the random tree classification algorithm for abnormal behavior detection; in recent years, experts have introduced neural networks into database abnormal behavior detection.

[0005] There are two main problems in the current detection of abnormal database behavior: First, most of the current research methods are based on a single SQL statement for detection. Some internal personnel who are familiar with the detection mechanism can use a combination of multiple SQL statements to effectively avoid this detection method to achieve malicious purposes; second, most methods have supervised learning methods, which are trained based on labeled data, while the database log data collected in the network system are unlabeled, and the collected database log data cannot be directly used to train the model. Manual data labeling consumes a lot of manpower and may have inaccurate labeling problems, resulting in unsatisfactory detection results of the trained model. Summary of the invention

[0006] The purpose of the present invention is to overcome the shortcomings of the prior art and provide a database abnormal behavior detection model based on DAGMM to solve the problems of single SQL statement detection defects and the need to manually mark data for model training in the current application of machine learning algorithms for database abnormal behavior detection.

[0007] In order to solve the above technical problems, the present invention adopts the following technical solutions:

[0008] In one aspect, the present invention provides a method for detecting abnormal behavior of a database, comprising:

[0009] Get the database log data set;

[0010] Performing fixed window sliding processing on each log in the database log data set, and extracting the data of SQL statements, running time and operation time in each window to obtain each corresponding sliding window database behavior sample, and all sliding window database behavior samples constitute a sliding window database behavior data set;

[0011] Encoding the SQL statement and operation time of each sliding window database behavior sample in the sliding window database behavior data set to obtain a sliding window database behavior sample matrix set;

[0012] Sum each sliding window database behavior sample matrix of the window database behavior sample matrix set by column to obtain a sliding window database behavior vector data set;

[0013] After the sliding window database behavior vector data set is normalized, it is input into a pre-trained DAGMM database abnormal behavior detection model, and the model outputs a detection result of whether the database log data is abnormal.

[0014] Furthermore, the obtaining of the database log data set specifically includes:

[0015] The database operation logs including login user name, host IP information, SQL statements, running time and operation time are collected, and the collected database operation logs are summarized and sorted to obtain the database log data set.

[0016] Furthermore, the fixed window sliding processing is performed on each log in the database log data set, including:

[0017] Set the length of the fixed window to m log records and the fixed step size to s. When sliding, the data in the first window is the 1st to mth log records. After sliding once according to the fixed step size s, the data in the second window is the 1st+sth to m+sth log records, and so on, until all records in the log have appeared in the window.

[0018] Perform sliding window processing on log records according to a fixed number of records and a fixed step size. For example, a database log has 100 records. Set the length of the fixed window to 10 and the step size to 2. When sliding, the data in the first window are the records numbered 0-9 in the log. After sliding once with a step size of 2, the data in the second window are the records numbered 2-11 in the log, and so on.

[0019] Furthermore, encoding processing is performed on the SQL statement of each sliding window database behavior sample in the sliding window database behavior data set, including:

[0020] The SQL statement is segmented by spaces to obtain a series of words, which contain SQL instructions, table names, and field names.

[0021] The length of the SQL statement is organized into 16 words. If the SQL statement length is greater than 16, it is truncated. If it is less than 16, "None" is added to make it 16.

[0022] Use the historical database word encoding table to convert the word in the SQL statement into encoding.

[0023] Furthermore, the method for constructing the word coding table of the historical database is:

[0024] The number of times each word appears in the historical SQL statements of the database is counted and sorted in descending order by the number of occurrences; the word is encoded according to the sorting result, and the more times it appears, the higher the encoding, and the historical database word encoding table is obtained.

[0025] Further, encoding processing is performed on the operation time of each sliding window database behavior sample in the sliding window database behavior data set, including:

[0026] Divide the time in a day into n time points evenly, encode the n time points in chronological order as 0 to n-1, find the time point to which the operation time belongs, and encode the operation time according to the code corresponding to the time point.

[0027] For example, if 10 minutes is a time point in a day, there are 144 time points in total, which are coded in chronological order as 0 to 143. When coding, the operation time is found to correspond to the time point, and the operation time is coded according to the code corresponding to the time point.

[0028] Furthermore, the calculation formula for the normalization process is:

[0029]

[0030] Among them, x' is the normalized sliding window database behavior vector; x is the original sliding window database behavior vector; x max is the maximum value of the corresponding dimension of the behavior vector of the sliding window database; min is the minimum value of the corresponding dimension of the behavior vector of the sliding window database.

[0031] Furthermore, the training method of the DAGMM database abnormal behavior detection model includes:

[0032] Select the historical data of the same database and the artificially simulated abnormal behavior data of the database, and divide them into training set T1 and test set T2 at a ratio of 8:2;

[0033] Perform fixed window sliding, encoding, summing, and normalization on the training set T1 and the test set T2 to obtain the training set T1′ and the test set T′2;

[0034] The abnormal behavior detection model of DAGMM database is trained using the training set T1′;

[0035] The test set T′2 is used to test the model training effect.

[0036] Furthermore, the database abnormal behavior detection method further includes:

[0037] The sliding window database behavior vectors with abnormal detection results are placed in the pre-built database abnormal behavior table, and the DAGMM database abnormal behavior detection model is regularly retrained and updated using samples from the database abnormal behavior table and samples with normal recent detection results.

[0038] In another aspect, the present invention provides a database abnormal behavior detection device, comprising:

[0039] An acquisition module, configured to acquire a database log data set;

[0040] a sliding window processing module configured to perform fixed window sliding processing on each log in the database log data set, and extract the data of SQL statements, running time and operation time in each window to obtain each corresponding sliding window database behavior sample, and all sliding window database behavior samples constitute a sliding window database behavior data set;

[0041] an encoding module configured to encode the SQL statement and operation time of each sliding window database behavior sample in the sliding window database behavior data set to obtain a sliding window database behavior sample matrix set;

[0042] A summing module, configured to sum each sliding window database behavior sample matrix of the window database behavior sample matrix set by column to obtain a sliding window database behavior vector data set;

[0043] The detection module is configured to normalize the sliding window database behavior vector data set and then input it into a pre-trained DAGMM database abnormal behavior detection model, and the model outputs a detection result of whether the database log data is abnormal.

[0044] Beneficial technical effects achieved by the present invention:

[0045] The present invention first performs fixed window sliding window processing on the SQL statements in the database log; then uses coding technology to encode the SQL statements and operation time in the sliding window and convert them into database behavior vectors; the obtained vectors are input into the DAGMM database abnormal behavior detection model to realize database behavior anomaly detection. The fixed window sliding processing adopted in the present invention can effectively combine the SQL statements, running time and operation time in multiple records in the window, avoiding the defects of single SQL statement detection in previous studies; the adopted DAGMM model is an unsupervised anomaly detection algorithm, which can effectively solve the problem that the data needs to be manually marked before anomaly detection can be performed in past studies. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0047] Figure 1 It is a structural diagram of the DAGMM model;

[0048] Figure 2 It is a flowchart of a method for detecting abnormal behavior of a database in an embodiment of the present invention. DETAILED DESCRIPTION

[0049] The present invention will be further described below in conjunction with specific examples. The following examples are only used to more clearly illustrate the technical solutions of the present invention, and are not intended to limit the scope of protection of the present invention.

[0050] As mentioned above, the current application of machine learning algorithms to detect database abnormal behavior has the problem that a single SQL statement detection amount requires manual data labeling before model training.

[0051] To this end, an embodiment of the present invention provides a method for detecting abnormal behavior of a database. Figure 2 As shown, the method comprises the following steps:

[0052] Step 1, obtain the database log data set;

[0053] The log collection tool Agent is used to collect database logs. Each record of the collected log contains the user name (USER_NAME), host IP information (HOST_IP), SQL statement (SQL), run time (EXECUTIME) and operation time (TIME) fields. The specific meaning of each field is shown in Table 1. The collected logs are summarized and sorted to obtain the database log data set D log .

[0054] Table 1 Specific meaning of each field in the log

[0055] Field Name Specific meaning Login User Name (USER_NAME) User name for operating the database Host IP information (HOST_IP) IP address for connecting to the database SQL Statements (SQL) SQL statement content EXECUTIME SQL statement execution time Operation time (TIME) SQL statement operation time

[0056] Step 2, performing fixed window sliding processing on each log in the database log data set, and extracting the data of SQL statements, running time and operation time in each window to obtain each corresponding sliding window database behavior sample, and all sliding window database behavior samples constitute a sliding window database behavior data set;

[0057] In this embodiment, each log contains approximately 100,000 records. The length of the fixed window is set to 1000 and the step size is 10. When sliding, the first sliding window contains records numbered 0-999 in the log. After sliding once according to the step size, the second window contains records numbered 10-1009 in the log. The sliding stops until all the records in the log appear in the window.

[0058] After that, the contents of the three fields of SQL statement, running time and operation time in 1000 records in a sliding window are extracted to form a sliding window database behavior sample. After all windows perform the same field extraction, they form their own sliding window database behavior samples, and these samples are aggregated into a sliding window database behavior dataset D. wdb ;

[0059] Step 3, encoding the SQL statement and operation time of each sliding window database behavior sample in the sliding window database behavior data set to obtain a sliding window database behavior sample matrix set;

[0060] 1) Sliding window database behavior dataset D wdb Encode all the SQL statements recorded in each sliding window database behavior sample. The encoding process is as follows:

[0061] 11) SQL statements are segmented by spaces to obtain a series of words, each of which contains SQL instructions, table names, field names, etc.;

[0062] 12) The length of the SQL statements in the sliding window database behavior samples is sorted into 16 words. When the SQL statement length is greater than 16 words, it is truncated. When it is less than 16 words, "None" is added to make it reach the average length;

[0063] 13) Use the historical word encoding table of the database to convert the word into the corresponding encoding.

[0064] The historical word encoding table is used in the SQL statement encoding process. It is based on the SQL statements in the past 100 logs of the database. The number of occurrences of each word in these SQL statements is counted and sorted in descending order by the number of occurrences. The word is encoded according to the sorting result. The more times it appears, the higher the encoding is, thus forming the historical word encoding table of the database. This table is used to encode the SQL statements in the sliding window database behavior samples.

[0065] In this embodiment, the coding table is stored in the form of a dictionary of {"word":coding}, and "None" is added to the end of the dictionary to replace the word that does not exist in the historical data found during the detection process. The constructed word coding table example is as follows: {"AND":0, "SELECT":1, "UPDATE":2, "FROM":3, "WHERE":4,... "None":2302}.

[0066] 2) Sliding window database behavior dataset D wdb Encode the operation time of all records in each sliding window database behavior sample;

[0067] In this embodiment, 10 minutes is a time point in a day, so there are 144 time points in total, which are coded in chronological order as 0 to 143. When coding, the operation time is found to correspond to the time point, and the operation time is time-coded according to the code corresponding to the time point.

[0068] For example, in a certain sliding window in the detection, a record is "16:22,SELECT*FROM USER_TABLEWHERE ID BETWEEN 1 AND 10000,1(ms)", and the operation time "16:22:" is encoded as

[98] ; the SQL statement "SELECT*FROM USER_TABLE WHERE ID BETWEEN 1 AND After the length of "10000" is padded to 16 with "None", the encoding is: [1,24,3,233,4,254,143,34,0,94,2302,2302,2302,2302,2302,2302]; the running time 1ms remains unchanged; the final encoding of this record is: [98, 1,24,3,233,4,254,143,34,0,94,2302,2302,2302,2302,2302,2302,2302,1].

[0069] Step 4, summing each sliding window database behavior sample matrix of the window database behavior sample matrix set by column to obtain a sliding window database behavior vector data set;

[0070] The encoded sliding window database behavior sample is a matrix, which is summed up by column to obtain a sliding window database behavior vector. After the same summation is performed on each sliding window database behavior sample of the entire sliding window database behavior data set, a sliding window database behavior vector data set is obtained.

[0071] In this embodiment, after each sliding window database behavior sample is encoded in step 3, a 1000×18 matrix is ​​obtained, and the matrix is ​​summed by column to obtain a sliding window database behavior vector. wdb After the same operation, we get the sliding window database behavior vector data set D wdb '.

[0072] Step 5, after normalizing the sliding window database behavior vector data set, input it into a pre-trained DAGMM database abnormal behavior detection model, and the model outputs a detection result of whether the database log data is abnormal;

[0073] Among them, the sliding window database behavior vector data set is normalized, and the calculation process is shown in the following formula:

[0074]

[0075] Among them, x' is the normalized sliding window database behavior vector; x is the original sliding window database behavior vector; x max is the maximum value of the corresponding dimension of the behavior vector of the sliding window database; minis the minimum value of the corresponding dimension of the behavior vector of the sliding window database.

[0076] After the present invention performs fixed time window sliding window processing on the database log and encodes the SQL statements in the window to obtain the database behavior vector, the behavior vector is input into the trained DAGMM database abnormal behavior detection model for abnormality detection. DAGMM is an unsupervised anomaly detection model, and its overall model structure is as follows: Figure 1 As shown in the figure, it is divided into two parts: the encoding network and the estimation network. The encoding network part is a deep autoencoding neural network, which is used to obtain low-dimensional vectors and calculate reconstruction errors; the estimation network part is used to calculate Gaussian mixture model parameters and sample likelihood estimates.

[0077] The DAGMM model can combine the two parts to achieve an end-to-end optimization process, avoiding the problem of falling into the local optimal value when the two parts are trained separately. The database behavior vector is input into the encoding network part to obtain the low-dimensional behavior vector z c and the behavior reconstruction error vector z r ; z c and z r The concatenation is used as the input of the estimation network. After calculation by the multi-layer neural network, the output is a softmax probability distribution, which represents the weight probability of each Gaussian model in the Gaussian mixture model. That is, it replaces the EM algorithm to solve the distribution of the single Gaussian distribution coefficient in the GMM. This process can be expressed by equations (1)-(2):

[0078] p=MLN(z;θ m ) (1)

[0079]

[0080] In the formula Represents a K-dimensional vector, where the k-th dimension represents the weight of the k-th Gaussian model in the Gaussian mixture model; p represents the model parameters of the estimated network part.

[0081] Given N database behavior samples and their Gaussian mixture model member weight prediction vectors We can estimate the parameters of the Gaussian mixture model through the process of equations (3)-(5).

[0082]

[0083]

[0084]

[0085] In the formula Represents the member weight prediction vector of the Gaussian mixture model of the i-th sample; and They represent the mixing probability, mean and covariance matrix of the kth Gaussian model in the Gaussian mixture model respectively.

[0086] Combining the above formulas, we can get the sample likelihood estimate E(z) as shown in formula (6):

[0087]

[0088] The objective function of the DAGMM model is shown in formula (7):

[0089]

[0090] In the formula, the first term represents the reconstruction error of the self-dimensionality reduction network; the second term represents the likelihood function of the Gaussian mixture model; the third term is used to prevent the values ​​on the diagonal of the covariance matrix in the GMM from becoming 0 and eventually causing the matrix to be irreversible.

[0091] When using the DAGMM model to detect abnormal database behavior, the value of E(z) is calculated to determine whether the behavior is abnormal; the larger the value of E(z), the more likely the database behavior is abnormal; the prior threshold is determined during the training process, and when the calculated E(z) exceeds the threshold during the test, it indicates that the database behavior is abnormal.

[0092] Next, the abnormal behavior detection model of the DAGMM database is trained. The training process is as follows:

[0093] Based on the past 100 logs of the same database, these historical logs were subjected to the same sliding window, encoding and column summing operations to organize them into 9682 sliding window database behavior samples as normal samples; 150 abnormal samples were simulated based on these normal data;

[0094] After mixing all samples, randomly divide them into training set T1 and test set T2 in the ratio of 8:2, and ensure that both data sets contain normal samples and abnormal samples;

[0095] Use T1 to train the abnormal behavior detection model of the DAGMM database. When the recall rate of abnormal data detection exceeds 0.85, stop training and conduct a detection effect test.

[0096] T2 is used to test the model detection effect. When the recall rate of abnormal sample detection also reaches 0.85, it means that the training effect is good and can be used for database abnormal behavior detection. Otherwise, the training process is adjusted.

[0097] After training, the sliding window database behavior vector dataset D wdb'After normalization, input the abnormal behavior detection model of the DAGMM database and output the detection results.

[0098] In a further embodiment, the aforementioned method for detecting abnormal behavior of a database further includes:

[0099] Step 6: Put the sliding window database behavior vectors with abnormal detection results into the pre-built database abnormal behavior table, and use the samples of the database abnormal behavior table and the samples with normal recent detection results to regularly retrain the DAGMM database abnormal behavior detection model and update the model.

[0100] First, a database abnormal behavior table Ab_db_Table is constructed to store sliding window database behavior vectors whose detection results are abnormal.

[0101] Secondly, the DAGMM database abnormal behavior detection model is regularly retrained using Ab_db_Table and the recent detection results as normal sliding window database behavior vectors to ensure that it can also achieve good detection results for new abnormal behaviors.

[0102] A database abnormal behavior detection method proposed based on the above embodiments includes: using an agent to collect logs in a database and organize them into a database log data set; using a fixed window to perform fixed window sliding processing on the database log, and extracting the data of "SQL statement", "running time" and "operation time" in each sliding window to obtain each corresponding sliding window database behavior sample, and organizing all sliding windows into a sliding window database behavior data set after extraction is completed; using a coding technology to encode the instructions and operation time in the SQL statement of the sliding window database behavior sample, the encoded window behavior sample is a matrix, and the window database behavior vector is obtained by summing up by column, and all the sliding window database behavior samples are encoded and summed in the same way to obtain a sliding window database behavior vector data set; normalizing the data set and inputting it into a pre-trained DAGMM database anomaly detection model to obtain a detection result, and putting the database behavior data with abnormal detection results into a database abnormal behavior table; using the database abnormal behavior table and the database behavior data with normal detection results in the recent period, the DAGMM is regularly retrained to update the model. The present invention utilizes fixed window sliding processing and an unsupervised anomaly detection model DAGMM to effectively solve the problems of single SQL statement detection vulnerabilities and the need for manual data annotation in previous database abnormal behavior detection research.

[0103] In another embodiment, the present invention provides a database abnormal behavior detection device, comprising:

[0104] An acquisition module, configured to acquire a database log data set;

[0105] a sliding window processing module configured to perform fixed window sliding processing on each log in the database log data set, and extract the data of SQL statements, running time and operation time in each window to obtain each corresponding sliding window database behavior sample, and all sliding window database behavior samples constitute a sliding window database behavior data set;

[0106] an encoding module configured to encode the SQL statement and operation time of each sliding window database behavior sample in the sliding window database behavior data set to obtain a sliding window database behavior sample matrix set;

[0107] A summing module, configured to sum each sliding window database behavior sample matrix of the window database behavior sample matrix set by column to obtain a sliding window database behavior vector data set;

[0108] The detection module is configured to normalize the sliding window database behavior vector data set and then input it into a pre-trained DAGMM database abnormal behavior detection model, and the model outputs a detection result of whether the database log data is abnormal.

[0109] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.

[0110] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0111] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0112] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0113] The present invention has been disclosed above with preferred embodiments, but they are not intended to limit the present invention. Any technical solutions obtained by adopting equivalent replacement or equivalent transformation solutions fall within the protection scope of the present invention.

Claims

1. A method for detecting abnormal behavior of a database, characterized in that: include: Get the database log data set; Performing fixed window sliding processing on each log in the database log data set, and extracting the data of SQL statements, running time and operation time in each window to obtain each corresponding sliding window database behavior sample, and all sliding window database behavior samples constitute a sliding window database behavior data set; Encoding the SQL statement and operation time of each sliding window database behavior sample in the sliding window database behavior data set to obtain a sliding window database behavior sample matrix set; Sum each sliding window database behavior sample matrix of the window database behavior sample matrix set by column to obtain a sliding window database behavior vector data set; After normalizing the sliding window database behavior vector data set, the data set is input into a pre-trained DAGMM database abnormal behavior detection model, and the model outputs a detection result of whether the database log data is abnormal; The step of encoding the SQL statement of each sliding window database behavior sample in the sliding window database behavior data set includes: The SQL statement is segmented by spaces to obtain a series of words, which contain SQL instructions, table names, and field names. The length of the SQL statement is organized into 16 words. If the SQL statement length is greater than 16, it is truncated. If it is less than 16, "None" is added to make it reach 16. Use the historical database word encoding table to convert the word in the SQL statement into a code; The method for constructing the word coding table of the historical database is: The number of times each word appears in the historical SQL statements of the database is counted, and the words are sorted in descending order according to the number of occurrences; the words are encoded according to the sorting results, and the more times they appear, the higher the encoding is, and the historical database word encoding table is obtained; The encoding process of the operation time of each sliding window database behavior sample in the sliding window database behavior data set includes: Divide the time in a day into n time points evenly, encode the n time points in chronological order as 0~n-1, find the time point to which the operation time belongs, and encode the operation time according to the code corresponding to the time point.

2. The database abnormal behavior detection method according to claim 1, characterized in that: The obtaining of the database log data set specifically includes: The database operation logs including login user name, host IP information, SQL statements, running time and operation time are collected, and the collected database operation logs are summarized and sorted to obtain the database log data set.

3. The database abnormal behavior detection method according to claim 1, characterized in that: The fixed window sliding processing is performed on each log in the database log data set, including: Set the length of the fixed window to m log records and the fixed step size to s. When sliding, the data in the first window is the 1st to mth log records. After sliding once according to the fixed step size s, the data in the second window is the 1st+s~m+sth log records, and so on, until all records in the log have appeared in the window.

4. The database abnormal behavior detection method according to claim 1, characterized in that: The calculation formula for the normalization process is: in, is the normalized sliding window database behavior vector; is the original sliding window database behavior vector; is the maximum value of the corresponding dimension of the behavior vector of the sliding window database; is the minimum value of the corresponding dimension of the behavior vector of the sliding window database.

5. The database abnormal behavior detection method according to claim 1, characterized in that: The training method of the DAGMM database abnormal behavior detection model includes: Select the historical data of the same database and the artificially simulated database abnormal behavior data, and divide them into training sets at a ratio of 8:

2. and test set ; For the training set and test set Perform fixed window sliding, encoding, summing, and normalization to obtain the training set and test set ; Using the training set Train the abnormal behavior detection model of DAGMM database; Using the test set Test the model training effect.

6. The database abnormal behavior detection method according to claim 1, characterized in that: Also includes: The sliding window database behavior vectors with abnormal detection results are placed in the pre-built database abnormal behavior table, and the DAGMM database abnormal behavior detection model is regularly retrained and updated using samples from the database abnormal behavior table and samples with normal recent detection results.

7. A database abnormal behavior detection device, characterized in that: include: An acquisition module, configured to acquire a database log data set; a sliding window processing module configured to perform fixed window sliding processing on each log in the database log data set, and extract the data of SQL statements, running time and operation time in each window to obtain each corresponding sliding window database behavior sample, and all sliding window database behavior samples constitute a sliding window database behavior data set; an encoding module configured to encode the SQL statement and operation time of each sliding window database behavior sample in the sliding window database behavior data set to obtain a sliding window database behavior sample matrix set; A summing module, configured to sum each sliding window database behavior sample matrix of the window database behavior sample matrix set by column to obtain a sliding window database behavior vector data set; A detection module is configured to normalize the sliding window database behavior vector data set and then input it into a pre-trained DAGMM database abnormal behavior detection model, and the model outputs a detection result of whether the database log data is abnormal; The step of encoding the SQL statement of each sliding window database behavior sample in the sliding window database behavior data set includes: The SQL statement is segmented by spaces to obtain a series of words, which contain SQL instructions, table names, and field names. The length of the SQL statement is organized into 16 words. If the SQL statement length is greater than 16, it is truncated. If it is less than 16, "None" is added to make it 16. Use the historical database word encoding table to convert the word in the SQL statement into a code; The method for constructing the word coding table of the historical database is: The number of times each word appears in the historical SQL statements of the database is counted, and the words are sorted in descending order according to the number of occurrences; the words are encoded according to the sorting results, and the more times they appear, the higher the encoding is, and the historical database word encoding table is obtained; The encoding process of the operation time of each sliding window database behavior sample in the sliding window database behavior data set includes: Divide the time in a day into n time points evenly, encode the n time points in chronological order as 0~n-1, find the time point to which the operation time belongs, and encode the operation time according to the code corresponding to the time point.