SQL attack recognition method and system based on deep learning dynamic target range feature fusion

Through the deep learning dynamic range feature fusion method, combined with the word frequency text frequency index and SuperTerm_Vector word vector algorithm, the LC-CNN model is used to identify SQL injection attacks, solving the problems of data set scarcity and imperfect feature extraction, and achieving high accuracy and low performance. SQL injection attack detection with false positive rate.

CN118535951APending Publication Date: 2024-08-23HUNAN UNIV OF SCI & ENG
View PDF 0 Cites 3 Cited by

Patent Information

Application Number
CN202410613633.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-17
Publication Date
2024-08-23

AI Technical Summary

Technical Problem

The publicly available SQL injection attack data sets collected in existing network SQL attack detection are limited, resulting in high missed detection and false positive rates, and traditional detection methods are difficult to adapt to the diversity and variability of attacks.

Method used

A dynamic range feature fusion method based on deep learning is used to simulate real SQL injection attacks by building a targeted server to obtain injection attack samples. The word frequency text frequency index and the SuperTerm_Vector word vector algorithm are combined to perform word segmentation processing and feature extraction on SQL injection attack statements using LC-CNN model is used for classification training and recognition.

Benefits of technology

It achieves more accurate and reliable detection of SQL injection attacks, improves the data quality and prevention capabilities of research and experiments, reduces the rate of missed detections and false positives, and improves the robustness and generalization capabilities of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118535951A
    Figure CN118535951A
Patent Text Reader

Abstract

The invention discloses an SQL attack recognition method and system based on deep learning dynamic target range feature fusion, and the method comprises the steps: S1, building a target server, simulating a real SQL injection attack, and obtaining an injection attack sample; s2, decoding and detecting the obtained injection attack sample data packet to obtain an injection attack statement text data set; s3, in combination with the word frequency text frequency index and a SuperTermVector word vector algorithm, converting the text data with the attack statements injected into the data set into corresponding numerical features; s4, inputting the injected attack statement numerical value vector features into the LC-CNN model to perform classification model training; and S5, identifying test data by using the trained LC-CNN model, and judging whether an SQL attack exists or not. The method has significant advantages in training efficiency and classification accuracy, and has good robustness and generalization ability on the whole.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a SQL attack identification method based on deep learning dynamic target range feature fusion, which specifically belongs to the intersection technology of network security and artificial intelligence deep learning. Background Art

[0002] With the widespread use of Web systems and the huge value created by big data, database security issues are attracting more and more attention. Among the many security risks faced by databases, Web applications are vulnerable to SQL injection attacks during operation. SQL injection attackers obtain sensitive information of web sites by injecting malicious SQL statements. When these statements are input into the backend for execution, they will attack the database, thereby obtaining the permissions of the underlying database of the application, allowing attackers to freely access the database and the potential information it contains, such as stealing database information, personal privacy data, user passwords, etc., and then achieve arbitrary malicious deletion and tampering, etc., which brings security threats to Web system data, user privacy or sensitive data. According to the data published by the latest national information security vulnerability database, SQL injection vulnerabilities currently account for 11.67% of Web vulnerabilities reported on the Internet. Therefore, it is crucial to detect and defend against SQL injection attacks.

[0003] The datasets used in SQL injection detection research include public datasets, custom datasets, and datasets that are a mixture of public and custom datasets. Traditional SQL injection detection methods mainly rely on techniques such as rule matching and feature extraction, but these methods are often difficult to adapt to the ever-changing attack methods. Machine learning, as an emerging technology, can learn and analyze large amounts of data to identify and predict unknown attack methods, but how to obtain large amounts of reliable data is a difficult problem. In addition, although research on SQL injection attack identification and feature extraction has made important progress in recent years, and various models have their own advantages in detecting SQL injection attacks, there are still some key issues that need to be resolved, including:

[0004] (1) Data imbalance problem. In actual application scenarios, normal queries far outnumber malicious queries, which will directly affect the model during the learning process and tend to classify most queries as normal queries, directly leading to the problem of data imbalance. In addition, attackers can construct malicious SQL queries in a variety of ways to bypass detection, thereby reducing the ability to identify malicious queries.

[0005] (2) Attack diversity and variability. This is a serious problem for models that rely on known samples. It is possible that legitimate queries are mistakenly marked as malicious attacks, resulting in a high false positive rate, while some malicious queries are not detected, resulting in a high false negative rate. This further weakens the accuracy and reliability of the prediction, resulting in missed attacks or high false positive rates.

[0006] In addition, the current publicly available SQL injection attack datasets are very limited. This is mainly due to legal and data security restrictions, as well as the data protection policies of website owners. Generally, website owners do not allow unauthorized scanning and attack behaviors, and they often use data encryption technology to protect the transmission of sensitive information. These factors make it difficult to publicly obtain SQL injection attack data. Even if there are some public datasets, these datasets may only contain limited types of SQL injection attack samples, lack sufficient variation and complexity, and cannot fully reflect the various forms and techniques of SQL injection attacks. There is also a problem of insufficient diversity, which cannot meet the needs of extensive research and experiments. Summary of the invention

[0007] The technical problem solved by the present invention is: to provide a SQL attack identification method based on deep learning dynamic target range feature fusion to address the problems of missed detection and high false alarm rate caused by limited publicly available SQL injection attack data sets collected in existing network SQL attack detection.

[0008] The present invention is implemented by the following technical solutions:

[0009] On the one hand, a SQL attack identification method based on deep learning dynamic target range feature fusion is provided, comprising the following steps:

[0010] S1. Build a targeted server to simulate a real SQL injection attack and obtain injection attack samples;

[0011] S2, decoding and detecting the acquired injection attack sample data packets, obtaining the injection attack sentence text data set, and performing word segmentation processing on the injection attack sentences in the text data set;

[0012] S3. Combine the word frequency index and the SuperTerm_Vector word vector algorithm to process the text data set after word segmentation, and convert the text data of the attack sentence injected in the data set into the corresponding numerical vector features;

[0013] S4, combining the numerical vector features of the injection attack statements obtained by S3 and the numerical vector features of the normal SQL query statements as a training data set, and inputting them into the LC-CNN model for classification model training, wherein the LC-CNN model is provided with two convolutional layers, the convolutional layers are connected to a flattening layer, and then to a fully connected layer;

[0014] S5. Use the LC-CNN model trained in S4 to identify the test data and determine whether there is a SQL attack.

[0015] In the SQL attack identification method based on deep learning dynamic target range feature fusion of the present invention, specifically, in step S1, the PHP Study tool is used to establish a simulation environment, a local sqli-libs target range server is built, the SQLMAP interface function is used to detect and scan the WEB application in the local target range server, the SQLMAP automation tool is used to simulate and automatically execute SQL injection attacks, and the real and effective injection data is captured by the Wireshark packet capture tool to obtain injection attack samples.

[0016] In the SQL attack identification method based on deep learning dynamic target range feature fusion of the present invention, specifically, in step S2, the encrypted data in the injection attack sample data packet obtained by S1 is identified and decoded, and the injection attack sample data is judged in turn whether it belongs to the Base64 decoding format and the Unicode decoding format, and is decoded and converted into the UTF-8 encoding format to output the injection attack statement text, and the output injection attack statement text is simplified, the decimal numbers therein are converted into 0×12, the date and time are replaced with 1-1-1, only one rewritten keyword is retained, and the noise characters in the injection attack statement are deleted.

[0017] In the SQL attack identification method based on deep learning dynamic target range feature fusion of the present invention, specifically, step S2 uses a space segmentation method to perform word segmentation on the decoded injection attack statement, divides the SQL injection attack statement into a string sequence, and adds spaces before and after it.

[0018] In the SQL attack identification method based on deep learning dynamic target range feature fusion of the present invention, specifically, in step S3, the word frequency text frequency index is calculated by the following formula:

[0019]

[0020]

[0021] TF-IDF=TF×IDF,

[0022] Where TF-IDF represents the term frequency index, TF(i) represents the frequency of word i in the text, IDF(i) represents the importance index of word i, Total(i) represents the frequency of word i in the injected attack sentence, Total represents the total number of words in the injected attack sentence, T(i) represents the frequency of sentences containing word i, and φ represents the offset.

[0023] In the SQL attack identification method based on deep learning dynamic target range feature fusion of the present invention, specifically, the SuperTerm_Vector word vector algorithm represents each word in the injected attack sentence as a vector, and maps the input text data to a multidimensional space, including the following process:

[0024] Build a corpus, collect public text data as the corpus, and preprocess the text data in the corpus, including word segmentation, punctuation removal, conversion to lowercase, and stop word removal to obtain clean text data;

[0025] Build a vocabulary from the preprocessed corpus, containing all the unique words that appear in the corpus;

[0026] Construct training samples. Construct training samples based on the vocabulary. Each training sample consists of a central word and its surrounding context words.

[0027] Define the model structure, select the Skip-gram model to predict the surrounding context words through the central word, input the training samples into the defined Skip-gram model structure for training, and use the negative log-likelihood loss function to maximize the probability of predicting the context words to adjust the model parameters during the training process;

[0028] Obtain word vectors. Input the text dataset after word segmentation in step S2 into the trained Skip-gram model. Each word in the text dataset is mapped to the word vector space. Each word is represented as a length vector of the corresponding mapping. According to the principle that words with close similarity in the semantic space in the injection attack sentence are also close in distance in the vector space, the distance of the spatial word vectors is calculated in the following way:

[0029] The injection attack statement contains n words w1, w2, w, ..., w n , the word vector list of all words in the attack sentence in the SuperTerm_Vector algorithm is represented as v1, v2, v3, ..., v n , given two word vectors v using cosine similarity μ and v v The cosine similarity(v μ , v v ) is calculated as follows:

[0030]

[0031] where · represents the dot product of the vectors, ||v μ || and ||υ ν ||represents word vector v μ and v v The norm of is used to calculate the similarity between different words in the injected attack sentence according to the cosine similarity, and the distance between different words in the word vector space is obtained accordingly.

[0032] In the SQL attack identification method based on deep learning dynamic target range feature fusion of the present invention, specifically, for each word in the injection attack sentence, its corresponding spatial word vector is multiplied by TF-IDF to obtain the weighted word vector V′ of each word w , the average weighted word vector of the injected attack sentence is expressed as n represents the number of words contained in the injection attack sentence, W represents the words contained in the injection attack sentence, and D represents the injection attack sentence. The average weighted word vector of the injection attack sentence is used as the numerical vector feature to train the LC-CNN model for classification.

[0033] In the SQL attack identification method based on deep learning dynamic target range feature fusion of the present invention, specifically, in step S4, the convolution layer adopts the ReLU function as the activation function, the fully connected layer adopts the Sigmoid function as the activation function, and the flattened layer adopts the Tanh function as the activation function.

[0034] In the SQL attack identification method based on deep learning dynamic target range feature fusion of the present invention, specifically, the LC-CNN model adds a model.compile() function to define the optimizer, loss function and evaluation index of the model, the optimizer adopts the Adam optimizer, the loss function uses binary cross entropy, the evaluation index includes accuracy, F1 value and confusion matrix, and the optimal model parameter setting is determined by determining the iteration with the highest classification accuracy during multiple iterative training of the classification model.

[0035] The present invention also discloses a SQL attack identification system based on deep learning dynamic target range feature fusion, including:

[0036] Data collection module, builds a target server to simulate real SQL injection attacks and obtain injection attack samples;

[0037] The data cleaning module decodes and detects the acquired injection attack sample data packets, obtains the injection attack sentence text data set, and performs word segmentation processing on the injection attack sentences in the text data set;

[0038] The feature extraction module combines the word frequency index and the SuperTerm_Vector word vector algorithm to process the text data set after word segmentation, and converts the text data injected into the attack statement in the data set into corresponding numerical features;

[0039] The LC-CNN classifier has a built-in LC-CNN model. The LC-CNN model has two convolutional layers, which are connected to a flattening layer and then to a fully connected layer. The classification model is trained by inputting a training data set composed of the numerical features of the injection attack statements of the feature extraction module and the numerical vector features of the normal SQL query statements. The trained LC-CNN model is then used to identify the test data to determine whether there is an SQL attack.

[0040] The present invention adopts the above technical solution to achieve the following beneficial effects:

[0041] (1) The present invention independently creates a SQL injection attack range, builds a local sqli-libs range server, and uses the global detection and automatic scanning functions based on the SQLMAP interface function to deeply detect and scan the local target machine WEB application, actively simulate SQL injection attacks and observe the response of the WEB application, collect attack data and vulnerability information, ensure that the data collection process is controlled, and can meet the needs of research and experiments, and realize the improvement of research and defense capabilities against SQL injection attacks. At the same time, it can also accurately control and monitor attack scenarios to ensure security and compliance. It helps to overcome the limitations of data acquisition and provide more comprehensive and diverse SQL injection attack data samples to meet the needs of research and experiments, and also helps to improve the prevention and detection capabilities of SQL injection attacks.

[0042] (2) The present invention uses the Wireshark tool to capture data from the local loopback network card. These data packets contain requests, responses, and transmission data during the attack process. Finally, because the captured data packets may contain encrypted or obfuscated information, it is necessary to identify and decode the encrypted data, detect the existence of SQL injection statements, and perform preprocessing such as word segmentation. Through these processing steps, clear and understandable data can be prepared, making it suitable for training and analysis of machine learning models, thereby improving the accuracy and adaptability of the model.

[0043] (3) The present invention uses a space segmentation method to divide the SQL injection statement into a string sequence, and adds spaces before and after it to maintain its integrity. This processing step helps to capture the occurrence position and context of special characters, facilitates a better understanding of the structure and grammar of the SQL injection attack statement, thereby identifying potential attack patterns, and provides clear and meaningful input data for the machine learning model, thereby improving the prevention and detection capabilities of SQL injection attacks.

[0044] (4) The present invention is a process of converting text data into structured data with numerical features. Since the word frequency text frequency index can more accurately reflect the information in the text data, and the SuperTerm_Vector word vector algorithm based on the Word2Vec word vector model can accurately improve its performance in capturing text semantics and contextual relationships, the present invention combines the word frequency text frequency index and the SuperTerm_Vector word vector algorithm to convert the text data of SQL injection attacks, and converts the data into numerical features that can be understood by the classification model, so as to ensure that the final structured data can be effectively used for the training of the classification model.

[0045] (5) The present invention adopts an improved LC-CNN model. First, two convolution layers are set up with a convolution kernel size of 64×1, a depth of 64, and a step size of 1. Then a flatten layer is connected, and finally a fully connected layer is connected. The number of parameters after the first round of convolution is 203,392. On this basis, another convolution layer is added to extract more features. The number of parameters after the second round of convolution is 1,056. In traditional CNN models, the pooling layer is usually used to reduce the number of parameters, but after two convolutions, the parameters are not suitable for pooling operations. Therefore, the present invention cancels the pooling layer and directly performs a flattening operation for subsequent binary classification. This design aims to enhance the model's ability to process one-dimensional text data and provide strong support for subsequent training tasks.

[0046] In summary, in response to the challenges of scarce SQL injection attack data sets and imperfect feature extraction, the present invention proposes a feature extraction model that integrates the word frequency text frequency index and the SuperTerm_Vector word vector algorithm, and studies the method of simulating attack scenarios with targeted servers. The standardized SQL injection data set is trained through machine learning technology, and the model parameters in the convolutional neural network are optimized. Compared with the traditional Web application source code SQL injection attack detection method, the present invention has achieved significant advantages in training efficiency and classification accuracy, and has achieved a detection effect of more than 90% in SQL attack action recognition and different graded vulnerability detection, and has good overall robustness and generalization ability.

[0047] The present invention is further described below in conjunction with the accompanying drawings and specific embodiments. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] Figure 1 This is a flowchart of the steps of the SQL attack identification method based on deep learning dynamic target range feature fusion of the present invention.

[0049] Figure 2 This is a system schematic diagram of the SQL attack identification system based on deep learning dynamic target range feature fusion of the present invention.

[0050] Figure 3 Schematic diagram of the confusion matrix of the LC-CNN classifier model trained by the present invention in the embodiment.

[0051] Figure 4 Schematic diagram of the comparison of training results of the data set constructed by the present invention and the existing public data set in the embodiment.

[0052] Figure 5a , 5b Schematic diagram of the change in accuracy and recall curves of the LC-CNN classifier model and the logistic regression model of the present invention when trained separately in the embodiment.

[0053] Figure 6a , 6b It is a schematic diagram of the change of accuracy and recall rate curves of the LC-CNN classifier model of the present invention and the random forest model in the embodiment for separate comparison training.

[0054] Figure 7a , 7b Schematic diagram of the change of accuracy and recall curves of the LC-CNN classifier model of the present invention and the Bayesian model when trained separately in the embodiment.

[0055] Figure 8a , 8b Schematic diagram of the change in accuracy and recall curves of the LC-CNN classifier model and the decision tree model of the present invention when trained separately in the embodiment. DETAILED DESCRIPTION

[0056] Example

[0057] See also Figure 1 , the figure shows a schematic diagram of the steps of the SQL attack identification method based on deep learning dynamic target range feature fusion of the present invention, which specifically includes the following steps:

[0058] S1. Build a targeted server to simulate a real SQL injection attack and obtain injection attack samples.

[0059] The PHP Study tool is used to establish a simulation environment, and a local sqli-libs target range server is built. The SQLMAP interface function is used to detect and scan the WEB applications in the local target range server. The SQLMAP automation tool is used to simulate and automatically execute SQL injection attacks. The Wireshark packet capture tool is used to capture real and effective injection data to obtain injection attack samples.

[0060] S2. Decode and detect the acquired injection attack sample data packets to obtain an injection attack sentence text data set, and perform word segmentation processing on the injection attack sentences in the text data set.

[0061] The encrypted data in the acquired injection attack sample data packet is identified and decoded. The injection attack sample data is judged in turn whether it belongs to the Base64 decoding format and the Unicode decoding format, and is decoded and converted into the UTF-8 encoding format to output the injection attack statement text. The output injection attack statement text is simplified, the decimal numbers are converted into 0×12, the date and time are replaced with 1-1-1, only one rewritten keyword is retained, and the noise characters in the injection attack statement are deleted. Then, the decoded injection attack statement is segmented using the space segmentation method, and the SQL injection attack statement is divided into a string sequence, and spaces are added before and after it.

[0062] After decoding the obtained injection attack sample data packet to obtain the original request information, the obtained injection attack statement is also detected in the following manner to determine whether it is an SQL injection attack statement.

[0063] (1) Collect existing injection attack samples. Search for known SQL injection attack samples in public vulnerability reports, security forums, or known security datasets. These samples usually include SQL statements that malicious users attempt to exploit vulnerabilities or injection attacks.

[0064] (2) Constructing a dataset. The collected injection attack samples are organized into a dataset, including injection attack statements and corresponding labels, such as normal query labels or injection attack labels.

[0065] (3) Based on known SQL injection attack samples or patterns, an attack list is constructed, which includes known injection attack statement patterns. At the same time, a safe list can also be constructed, which includes normal SQL query statement patterns. Then, by comparing the injection attack sample to be detected with the statement patterns in the above list, it is determined whether there is an injection attack.

[0066] (4) Existing deep learning models can be used to train SQL injection attack datasets, and supervised learning methods can be used to build classification models to distinguish normal SQL queries from injection attack statements.

[0067] S3. Combine the word frequency index and the SuperTerm_Vector word vector algorithm to process the text data set after word segmentation, and convert the text data injected into the attack statement in the data set into corresponding numerical features.

[0068] In step S3, the word frequency text frequency index is calculated by the following formula:

[0069]

[0070]

[0071] TF-IDF=TF×IDF,

[0072] Where TF-IDF represents the term frequency index, TF(i) represents the frequency of word i in the text, IDF(i) represents the importance index of word i, Total(i) represents the frequency of word i in the injected attack sentence, Total represents the total number of words in the injected attack sentence, T(i) represents the frequency of sentences containing word i, and φ represents the offset.

[0073] The SuperTerm_Vector word vector algorithm represents each word in the injection attack sentence as a vector, maps the input text data to a multidimensional space, and represents each word as a length vector of the corresponding mapping, so that words in the injection attack sentence that are close in distance in the semantic space are also close in distance in the vector space.

[0074] S4, add the numerical vector features of the injection attack statements and the normal SQL query statements obtained by S3 as training data sets, input the LC-CNN model for classification model training, and set two convolutional layers in the LC-CNN model, connect the flattening layer after the convolutional layer, and then connect to the fully connected layer. The convolutional layer filter size used is 64×1, the depth is 64, and the step size is 1. There are 203392 parameters after convolution. On this basis, another convolutional layer is added to extract features. After this extraction, there are 1056 parameters. The main function of the pooling layer in the traditional neural network model is to reduce the number of parameters, but in the present invention, the parameters are not suitable for pooling after two convolutions. Therefore, the present invention cancels the pooling layer and directly performs the flattening operation to prepare for the following binary judgment. This design enables the model to better process one-dimensional text data and provides strong support for subsequent task training.

[0075] In step S4, the convolution layer uses the ReLU function as the activation function, the fully connected layer uses the Sigmoid function as the activation function, and the flattened layer uses the Tanh function as the activation function. On this basis, the LC-CNN model adds the model.compile() function to define the optimizer, loss function, and evaluation index of the model. The optimizer uses the Adam optimizer, the loss function uses binary cross entropy, and the evaluation indicators include accuracy, F1 value, and confusion matrix. During the multiple iterative training of the classification model, the optimal model parameter settings are determined by determining the iteration with the highest classification accuracy.

[0076] The training of the LC-CNN classification model also requires the collection of normal SQL query statements as training data sets. Ensure that the data sets are sufficiently representative and diverse to improve the generalization ability of the model. Perform preprocessing of steps S2 and S3 on normal SQL query statement data to convert the SQL query statements into a format suitable for neural network input. Use a data set containing normal SQL query statements and SQL injection attack statement data to train the LC-CNN model. During the training process, the model will learn how to distinguish between normal SQL query statements and malicious SQL injection attack statements.

[0077] S5. Use the LC-CNN model trained in S4 to identify the test data and determine whether there is a SQL attack.

[0078] See also Figure 2 This embodiment also provides a system using the above-mentioned SQL attack identification method, including a data collection module 100, a data cleaning module 200, a feature extraction module 300 and an LC-CNN classifier 400.

[0079] The data collection module 100 is used to build a target server to simulate a real SQL injection attack and obtain injection attack samples.

[0080] The data collection module 100 uses sqli-libs as a target range, builds a target server locally, effectively combines automation tools and real attack scenarios, and first uses the PHP Study tool to establish a simulation environment when building a SQL injection attack target range, aiming to simulate common vulnerabilities and weaknesses in applications in real networks, so as to conduct SQL injection attacks in a controlled environment and collect attack data. Combined with the automatic scanning and detection functions of SQLMAP, continuous SQL injection attacks are simulated to obtain diversified and authentic injection attack samples.

[0081] SQL injection attack usually inserts special characters to construct illegal SQL statements after the system form or URL query string, and propagates to the sink aggregation node via the source node as an input parameter, and then passes it to the Web application. When the target server-side executes the input illegal SQL statement, the attacker will attack the XML document vulnerability stored in the relational database, thereby realizing the malicious operation to be performed by himself. To simulate the execution process of SQL injection attack, the data acquisition module 100 of the present invention captures real and effective injection data through the Wireshark packet capture tool, and uses the SQLMAP automation tool to simulate and automatically execute SQL injection attack. Utilize the Wireshark tool to capture local network card data samples, judge whether the target website has SQL injection vulnerability according to the response information, find whether the injection statement in the http sent to the target website successfully returns the database information in the local network card data sample, and success indicates that the injection is successful, indicating that there is an injection vulnerability, strengthening the comprehensiveness and authenticity of the data, and laying a solid foundation for further analysis.

[0082] The data cleaning module 200 decodes and detects the acquired injection attack sample data packets, obtains an injection attack sentence text data set, and performs word segmentation processing on the injection attack sentences in the text data set.

[0083] The data acquisition module 100 saves the new SQL injection attack sample when it finds it, until the SQLMAP automatic scan is completed. Because the captured data packet may contain encrypted or obfuscated information, the data cleaning module 200 is required to identify and decode the encrypted data in the injection attack sample, detect the existence of SQL injection statements, and perform data cleaning work such as word segmentation. In the data cleaning process, it is necessary to decrypt or restore the modified injection statement to obtain the original SQL injection content. The data acquisition module 100 first uses the SQL dynamic target range data feature decoding algorithm to first determine whether the input injection attack text data belongs to the Base64 decoding format. If it is, it is Base64 decoded and then output. If not, it is determined whether it is in the Unicode decoding format. If it is, it is Unicode decoded. If not, 0 is returned to indicate that it cannot be decoded. The output injection attack statement text is simplified, the hexadecimal numbers in the text data are converted to 0x12, the date and time are all replaced with "1-1-1", only one over-rewritten keyword is retained, and the meaningless noise characters in the SQL statement are deleted, and then word segmentation is performed.

[0084] The accuracy of the word segmentation process and the way special characters are handled are crucial to subsequent model training and detection tasks. When considering the key role of special characters in SQL injection attack statements, in order to maintain the original form of special characters in the word segmentation process, they need to be identified as independent tags. Therefore, the data cleaning module 200 uses a space segmentation method to divide the SQL injection statement into a string sequence, and adds spaces before and after it to maintain its integrity. Through this processing step, it is helpful to capture the occurrence position and context of special characters, facilitate a better understanding of the structure and grammar of SQL injection attack statements, thereby identifying potential attack patterns, and providing clear and meaningful input data for machine learning models, thereby improving the prevention and detection capabilities of SQL injection attacks.

[0085] The feature extraction module 300 is used to process the text data set after word segmentation by combining the word frequency text frequency index and the SuperTerm_Vector word vector algorithm, and convert the text data injected into the attack sentence in the data set into corresponding numerical features.

[0086] The injection attack data is cleaned, and the next step is to convert them into feature vectors, converting the injection data into numerical features that can be understood by the machine learning model to facilitate model training. The converted features include keywords in the SQL injection attack statement, the frequency of occurrence of special characters, the length of the statement, etc. After the feature extraction is completed, these feature vectors can be used to build a machine learning model to identify SQL injection attacks. The feature extraction module 300 processes the cleaned injection attack data based on the Bag-of-Words Model, combined with the word frequency text frequency index and the SuperTerm_Vector word vector algorithm, and converts the data into numerical features that can be understood by the classification model to ensure that the final structured data can be effectively used for the training of the classification model.

[0087] Specifically, the term frequency text frequency index algorithm (TF-IDF for short) is a keyword extraction algorithm, which is calculated by the following formula:

[0088]

[0089]

[0090] TF-IDF=TF×IDF,

[0091] In the formula, TF-IDF represents the frequency index of the word frequency text, that is, the frequency of the word in the text and the importance of the word are multiplied to get the weight value. The larger the weight value, the more important the word is. TF(i) represents the frequency of word i in the text, which is calculated by dividing the number of times a word appears in the text by the total number of all words in the text. IDF(i) represents the importance index of word i. Because words with high frequency of appearance are not necessarily keywords, they may also be common words. Therefore, the purpose of IDF(i) is to reduce the weight of common words and increase the weight of keywords in disguise. Total(i) represents the frequency of word i in the injected attack sentence. Total represents the total number of words in the injected attack sentence. T(i) represents the frequency of sentences containing word i. Indicates the offset, which is used to prevent the log function from calculating incorrectly when the total document library is zero.

[0092] However, if the word frequency text frequency index algorithm is directly applied to the feature modeling of SQL injection attacks, on the one hand, the algorithm pays too much attention to the weight of the keyword and ignores the relationship between the location of the keyword and other words. On the other hand, the word frequency text frequency index algorithm is an algorithm generated based on the bag-of-words model. The defect of this algorithm is that the dimension of the text after vectorization will be as high as thousands, which will lead to the problem of excessive subsequent model training and inaccurate model training. Therefore, the feature extraction module 300 of the present invention also introduces the SuperTerm_Vector word vector algorithm for further dimensionality reduction and optimization to improve the accuracy and efficiency of keyword extraction.

[0093] The SuperTerm_Vector algorithm represents each word in the SQL injection attack statement as a vector, maps the input text data into a multi-dimensional space, and each word can be represented as a vector of a certain length, and makes the words that are close in the semantic space close in the vector space. The word vector converted by the SuperTerm_Vector algorithm contains both the connection between the context and the location information of the word. This solves the problem of too many dimensions in the model.

[0094] The process of obtaining the word vector of each word in the injection attack sentence by the SuperTerm_Vector algorithm is as follows:

[0095] Build a corpus and collect public text data as the corpus. It can be any form of text data, such as articles, news, blogs, Wikipedia, etc. Preprocess the text data in the corpus, including word segmentation, punctuation removal, conversion to lowercase, and stop word removal to obtain clean text data;

[0096] Build a vocabulary from the preprocessed corpus, containing all the unique words that appear in the corpus;

[0097] Construct training samples based on the vocabulary. Each training sample consists of a central word and surrounding context words. The context words can be words within a fixed window size before and after the central word.

[0098] Define the model structure, select the Skip-gram model as the model that predicts the surrounding context words through the central word, input the training samples into the defined Skip-gram model structure for training, and use the negative log-likelihood loss function to maximize the probability of predicting the context words to adjust the model parameters during the training process;

[0099] Obtain word vectors, input the text data set after word segmentation in step S2 into the trained Skip-gram model, and each word in the text data set is mapped to the word vector space. Each word is represented as a length vector of the corresponding mapping, so that words with close similarity in the semantic space in the injected attack sentence are also close in distance in the vector space.

[0100] The distance of the spatial word vector is calculated as follows:

[0101] The corpus contains all unique words that appear. For each word w i , we use a pre-trained word vector representation, denoted as v i . Then the word w i The word vector can be expressed as: i →v i .

[0102] The injection attack sentence S contains n words w1, w2, w, ..., w n , the sentence is represented in the SuperTerm_Vector algorithm as a list of word vectors S→[v1, v2, v3, ..., v n ], using cosine similarity to give two word vectors υ μ and v v The cosine similarity(v μ , v v ) is calculated as follows:

[0103]

[0104] where · represents the dot product of the vectors, ||v μ || and ||v ν ||represents word vector v μ and v vThe norm of the word injection attack sentence is obtained by calculating the cosine similarity. If the similarity between two words in the semantic space is very high, their distance representation in the vector space will also be very close.

[0105] For each word W in the injected attack sentence, find its corresponding spatial word vector V W , multiply the cosine similarity representing the word vector distance in the vector space by its corresponding TF-IDF score to obtain the weighted word vector V′ of each word w , the average weighted word vector of the injected attack sentence is expressed as n represents the number of words contained in the injection attack sentence, W represents the words contained in the injection attack sentence, and D represents the injection attack sentence.

[0106] Through this process, we obtain a weighted word vector representation for each injection attack statement document, where the weight of the word vector is determined by its corresponding TF-IDF score. Such a representation comprehensively considers the frequency and semantic information of the word.

[0107] Although the TF-IDF algorithm and the SuperTerm_Vector algorithm can solve the problem of keyword feature word frequency weights and too many dimensions after feature extraction and difficult training, it is difficult for traditional convolutional neural networks (CNNs) to achieve good training results when facing the grammatical structure of malicious code or complex nonlinear relationships. Therefore, the present invention is based on the convolutional neural network (CNN) to parse the complex nonlinear relationship in SQL injection attacks, automatically learn the characteristics of input data, and efficiently identify the grammatical structure or specific attack mode of malicious code in SQL injection attacks. At the same time, the convolutional neural network (CNN) model is used to quickly infer and detect the input data, and the LC-CNN classifier model of the present invention is constructed, thereby greatly improving the real-time detection efficiency and accuracy of SQL injection attacks.

[0108] The LC-CNN classifier model sets up two convolutional layers, which are connected to a flattening layer and then to a fully connected layer. The classification model is trained by inputting the numerical features of the injected attack statements into the feature extraction module, and then the trained LC-CNN model is used to identify the test data to determine whether there is a SQL attack.

[0109] In the LC-CNN classifier model, two convolutional layers are first set up with a kernel size of 64×1, a depth of 64, and a stride of 1. A flatten layer is then connected, and finally a fully connected layer is connected. The number of parameters after the first round of convolution is 203,392. On this basis, another convolutional layer is added to extract more features, and the number of parameters after the second round of convolution is 1,056. Pooling layers are usually used to reduce the number of parameters, but after two convolutions, the parameters are not suitable for pooling operations, so the pooling layer is cancelled and the flattening operation is directly performed for subsequent binary classification. This design aims to enhance the model's ability to handle one-dimensional text data and provide strong support for subsequent training tasks.

[0110] The LC-CNN classifier model is constructed for binary classification tasks, that is, to determine the category of input data. The ReLU activation function is selected as the activation function of the convolutional layer due to its advantages in calculation speed, training stability, and convergence speed. In the fully connected layer, in order to output a numerical value that can be interpreted as a category probability, the Sigmoid function is selected as the activation function, and the flattened layer uses the Tanh function as the activation function. This combination of functions enables the model to complete binary classification tasks more effectively and plays an important role in improving performance and efficiency.

[0111] The Sigmoid function limits the output to the range between 0 and 1. The specific calculation is shown in the following formula:

[0112]

[0113] The Tanh function compresses the output to a range between -1 and 1. The specific calculation is shown in the following formula:

[0114]

[0115] The ReLU function returns all negative values ​​in the input to zero, and leaves the positive values ​​unchanged. The specific calculation is shown in formula (6):

[0116]

[0117] On this basis, the LC-CNN classifier model adds the model.compile() function to define the model's optimizer, loss function, and evaluation indicators. The optimizer here uses the Adam optimizer, and the loss function uses the binary cross entropy. These functions will output the classification accuracy of the model on the training set and the test set during the training process, so as to monitor and evaluate the training process and effect of the model, which helps to monitor and evaluate the effect of the model. The LC-CNN classifier model training process goes through multiple iterations, and the model parameters of the iteration with the highest accuracy are selected as the parameters of this classifier.

[0118] In the present invention, accuracy and F1 value can be used to measure the overall performance of the LC-CNN classifier model, while the confusion matrix can provide detailed classification result information to help analyze the performance of the LC-CNN classifier model in different categories. Through these comparisons, it can be proved whether feature extraction and attack identification are effective in our LC-CNN classifier model, and whether the construction of this data set is successful. Therefore, the LC-CNN classifier model of the present invention uses accuracy, F1 value and confusion matrix as evaluation indicators to more accurately understand the performance of the model in the attack detection task, verify the quality of the data set, and evaluate the performance of the model.

[0119] Precision refers to the ratio of the number of positive examples correctly predicted by the LC-CNN classifier model to the number of all samples predicted as positive examples. A high precision means that the LC-CNN classifier can misclassify negative examples as positive examples less often, thus providing more reliable prediction results. However, in some unbalanced data sets, a high precision may not always be the most appropriate evaluation metric, because it may ignore the performance of the classifier on minority categories. Therefore, in different cases, the precision needs to be considered together with the recall rate, F1 value, etc. to comprehensively evaluate the performance of the classifier. The specific calculation of the precision is as follows:

[0120]

[0121] True Positives (True Positives TP) indicates the number of attack samples that the LC-CNN classifier correctly predicts as positive examples, that is, the samples are positive and the prediction result is positive; False Positives (False Positives FP) indicates the number of negative attack samples that the LC-CNN classifier incorrectly predicts as positive examples, that is, the samples are negative and the prediction result is positive; True Negatives (True Negatives TN) indicates the number of attack samples that the LC-CNN classifier correctly predicts as negative examples, that is, the samples are negative and the prediction result is negative; False Negatives (False Negatives FN) indicates the number of positive attack samples that the LC-CNN classifier incorrectly predicts as negative examples, that is, the samples are positive and the prediction result is negative.

[0122] Recall refers to the ratio of the number of positive examples correctly predicted by the LC-CNN classifier to the total number of actual positive examples. It is mainly used to measure the coverage and comprehensiveness of the LC-CNN classifier in identifying positive examples. There is a trade-off between recall and precision. The range of recall is between 0 and 1. The closer to 1, the better the model performs in detecting positive examples. The specific calculation of recall is as follows:

[0123]

[0124] The F1 value is an indicator used to comprehensively evaluate the performance of the LC-CNN classifier. It can more comprehensively reflect the performance of the LC-CNN classifier. It takes into account the recall rate and precision rate of the classifier at the same time, and combines the effects of misclassification and missed classification. It is used to balance the performance of the model in the classification of positive and negative examples. The range of the F1 value is between 0 and 1. The closer it is to 1, the better the model has achieved in terms of recall rate and precision rate. The specific calculation is shown in the following formula:

[0125]

[0126] The confusion matrix is ​​a tabular form used to measure the classification results of the LC-CNN classifier. The accuracy calculation of the confusion matrix P is shown as follows:

[0127]

[0128] The following specific examples are used to illustrate the comparative training of the SQL attack identification method of the present invention and a conventional machine learning algorithm model.

[0129] The experimental environment CPU of the SQL attack identification system of the present invention is Intel (R) Core (TM) i7-8565U CPU @ 1.80GHz, the system used is window10 version, python3.7.3, anaconda3, jupyter6.5.2, tensorflow2.12. Among the 27,000 test data prepared for the experiment, 80% of the data are randomly used as training data and 20% as test data.

[0130] In the training results of the LC-CNN classifier model of the present invention, conv1D is a one-dimensional convolution layer, each layer has 32 filters and a sliding window with a step size of 1. This layer has 203392 trainable parameters, and there are 1056 parameters after the second convolution. Then the flatten layer flattens the output into a one-dimensional vector so that it can be input into the fully connected layer. Binary classification is performed in the fully connected layer, and a total of eight iterations are performed. The training loss value is 5.60%, the accuracy rate is 98.16%, and the validation set loss value is 9%. This indicator is used to evaluate the generalization ability of the model, that is, the performance of the model on unseen data. The validation set accuracy is 97%, indicating a similar validation loss set.

[0131] The confusion matrix is ​​constructed using the test data and the LC-CNN classifier model prediction data. The results are as follows Figure 3 As shown in the figure, after comparison, it is found that when the sample value is positive, the predicted value is also positive, and when the sample value is negative, the predicted value is also negative. This shows that the model predicts the data accurately and the model setting parameters are in line with expectations.

[0132] Furthermore, this embodiment selects the public dataset on GitHub (https: / / github.com / sql-injection / test-dataset) and the SQL injection dataset of Kaggle (https: / / www.kaggle.com / datasets / kholoodsalah / sql-injection-dataset) to conduct a comparative experiment with the dataset of the LC-CNN classifier to explore the differences in model performance between different datasets. By preprocessing these two public datasets, the GitHub dataset has 4521 dimensions, and the Kaggle dataset has 6674 dimensions. The training results of different datasets are compared. Figure 4As shown, the performance of the dataset model constructed by the present invention is not much different from that of the Kaggle dataset, while the GitHub dataset is slightly better than the other two datasets, mainly because the data volume is small, making the model easier to learn and producing better results. Comprehensively considered, the training effect of the LC-CNN classifier model shows satisfactory performance in the comparative test with the public dataset, indicating that it may play an important role in the actual SQL detection task.

[0133] Then, the data set constructed by the present invention is used for comparative training with other existing machine learning models. The existing machine learning models selected for comparison in this embodiment include logistic regression model, random forest model, Bayesian model, and decision tree model.

[0134] The accuracy results of the model comparison training are shown in Table 1 below.

[0135] Iterations Logistic Regression Random Forest Bayesian Decision Tree LC-CNN 1 0.90591631 0.86176046 0.8745465 0.80880231 0.9299 2 0.90649351 0.88946609 0.87281497 0.81168831 0.9762 3 0.90822511 0.90305828 0.87418065 0.81240981 0.9795 4 0.92929293 0.90591631 0.87401575 0.81782107 0.9803 5 0.9304674 0.91370851 0.87335614 0.81926407 0.9815 6 0.9304674 0.92323232 0.87405697 0.82077173 0.9812 7 0.96017316 0.93795094 0.87269654 0.82575758 0.9816 8 0.94141414 0.92844778 0.8734386 0.82431457 0.9816

[0136] Table 1. Accuracy results compared with training table

[0137] It can be seen from the table that the highest accuracy is that of the LC-CNN classifier model, and the lowest is that of the decision tree model.

[0138] The recall results of the model comparison training are shown in Table 2 below.

[0139]

[0140]

[0141] Table 2. Recall results compared to training table

[0142] It can be seen that the recall rates of the LC-CNN classifier model and the Bayesian model are very stable, while the recall rate of the decision tree model is very unstable.

[0143] The LC-CNN classifier model of the present invention and the logistic regression model are trained separately. Figure 5a As shown in the figure, the accuracy of the LC-CNN classifier model increased to about 98% after the second iteration, which is much higher than the logistic regression model. The highest cross-validation accuracy of logistic regression is only 96%, and the average accuracy is 92.7%. Although the gap is obvious, among all algorithms in the control group, the accuracy of the logistic regression algorithm ranks second, while the LC-CNN classifier model has a higher accuracy than it. It can be seen that the training results of the LC-CNN classifier model of the present invention are very excellent. Figure 5bAs shown in the figure, in terms of recall rate, the recall rate of the LC-CNN classifier model of the present invention quickly rises to more than 94% after the second iteration, indicating that the coverage rate of the LC-CNN classifier for positive samples has reached an excellent training level. The logistic regression cross-validation recall rate performed poorly, with most recall rates around 80%, and the lowest falling to 75.4%, the lowest average recall rate, which is equivalent to one-fifth of the SQL injection statements not being detected. Therefore, in terms of comprehensive accuracy and recall rate, the LC-CNN classifier model has better performance.

[0144] The LC-CNN classifier model of the present invention and the random forest model are trained separately for comparison. Figure 6a As shown in the figure, the advantage of the LC-CNN classifier model is more obvious. The highest accuracy of the random forest model is only about 1% higher than the first iteration of the LC-CNN classifier model. The random forest model algorithm has a very good processing ability for classification problems, but in the face of the large data in this experiment, too many features lead to a decline in performance, and the average accuracy is 90.8%. In comparison, the LC-CNN classifier model has a better accuracy. Figure 6b As shown in the figure, in terms of recall rate, the recall rate of the random forest model fluctuates too much. The reason is that the leaf nodes are relatively small compared to the number of features. Adding nodes will increase the tree height and double the training time. In this case, the average recall rate of the random forest model is 84.2%, which is only higher than the logistic regression model. In terms of comprehensive accuracy and recall rate, the LC-CNN classifier model of the present invention has better performance.

[0145] The LC-CNN classifier model of the present invention and the Bayesian model are trained separately for comparison. Figure 7a It can be seen that the accuracy of the Bayesian model is stable at 87.4%, indicating that the model has a good performance on the given data set and has good generalization ability for untrained data, which means that the model can maintain a high performance level on different sample sets without excessive errors or instability. However, the recognition rate is only slightly higher than that of the decision tree model among the five algorithms, and is significantly lower than the LC-CNN classifier model of the present invention. Figure 7b As shown, the Bayesian algorithm uses all the features and makes full use of the independence assumptions between the features, and can comprehensively classify the SQL injection attack samples, thereby performing well in recall rate. The only drawback is that the accuracy rate is not high. In terms of comprehensive accuracy and recall rate, the LC-CNN classifier model of the present invention has better performance.

[0146] The LC-CNN classifier model of the present invention and the decision tree model were trained separately. Figure 8aFrom the above, the decision tree model has the lowest accuracy among all the models compared, with an average accuracy of only 81.8%. This is because random forest is an algorithm based on ensemble learning, which combines multiple decision trees, thereby reducing the risk of overfitting of a single decision tree, which means that the decision tree algorithm may not generalize well to new data, resulting in poor performance on the test data. Figure 8b , the recall rate of most decision tree models is not low, only the seventh recall rate is too poor, only 66%. In terms of comprehensive accuracy and recall rate, the LC-CNN classifier model of the present invention performs better in stability.

[0147] By comprehensively comparing the training of the LC-CNN classifier model of the present invention with four comparative machine learning models, it can be seen that only the accuracy is slightly lower than that of the Bayesian model. This is mainly because the Bayesian model has a certain robustness to the problem of data category imbalance, while the LC-CNN classifier model of the present invention is more sensitive to imbalanced data. In other aspects, the training effect of the LC-CNN classifier model of the present invention is better than that of the comparative machine learning models.

[0148] In this document, the directions or positional relationships indicated by terms such as "up", "down", "front", "back", "left", "right", "top", "bottom", "inside", "outside", "vertical", and "horizontal" are based on the directions or positional relationships shown in the accompanying drawings and are only for the clarity of expressing the technical solutions and the convenience of description, and therefore should not be understood as limitations of the present invention.

[0149] In this document, the terms "comprises," "comprising," or any other variations thereof, are intended to cover a non-exclusive inclusion of elements other than those listed and may also include additional elements not expressly listed.

[0150] The above are only specific embodiments of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art who is familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.

Claims

1. A SQL attack identification method based on deep learning dynamic target range feature fusion, characterized by The steps include: S1. Build a targeted server to simulate a real SQL injection attack and obtain injection attack samples; S2, decoding and detecting the acquired injection attack sample data packets, obtaining the injection attack sentence text data set, and performing word segmentation processing on the injection attack sentences in the text data set; S3, combining the word frequency index and the SuperTerm_Vector word vector algorithm to process the text data set after word segmentation, and convert the text data injected into the attack sentence in the text data set into the corresponding numerical vector features; S4, combining the numerical vector features of the injection attack statements obtained by S3 and the numerical vector features of the normal SQL query statements as a training data set, and inputting them into the LC-CNN model for classification model training, wherein the LC-CNN model is provided with two convolutional layers, the convolutional layers are connected to a flattening layer, and then to a fully connected layer; S5. Use the LC-CNN model trained in S4 to identify the test data and determine whether there is a SQL attack.

2. The SQL attack identification method according to claim 1, characterized in that: In step S1, the PHPStudy tool is used to establish a simulation environment, a local sqli-libs range server is built, the SQLMAP interface function is used to detect and scan the WEB application in the local range server, the SQLMAP automation tool is used to simulate and automatically execute SQL injection attacks, and the Wireshark packet capture tool is used to capture real and effective injection data to obtain injection attack samples.

3. The SQL attack identification method according to claim 1, characterized in that: In the step S2, the encrypted data in the injection attack sample data packet obtained in S1 is identified and decoded, and the injection attack sample data is judged in turn whether it belongs to the Base64 decoding format and the Unicode decoding format, and is decoded and converted into the UTF-8 encoding format to output the injection attack statement text, and the output injection attack statement text is simplified, the decimal numbers therein are converted into 0×12, the date and time are replaced with 1-1-1, only one rewritten keyword is retained, and the noise characters in the injection attack statement are deleted.

4. The SQL attack identification method according to claim 3, characterized in that: The step S2 uses a space segmentation method to perform word segmentation processing on the decoded injection attack statement, divides the SQL injection attack statement into a string sequence, and adds spaces before and after the string sequence.

5. The SQL attack identification method according to claim 1, characterized in that: In step S3, the word frequency text frequency index is calculated by the following formula: TF-IDF=TF×IDF, Where TF-IDF represents the term frequency index, TF(i) represents the frequency of word i in the text, IDF(i) represents the importance index of word i, Total(i) represents the frequency of word i in the injected attack sentence, Total represents the total number of words in the injected attack sentence, T(i) represents the frequency of the sentence containing word i, and φ represents the offset.

6. The SQL attack identification method according to claim 5, characterized in that: The SuperTerm_Vector word vector algorithm represents each word in the injected attack sentence as a vector and maps the input text data into a multi-dimensional space, including the following process: Build a corpus, collect public text data as the corpus, and preprocess the text data in the corpus, including word segmentation, punctuation removal, conversion to lowercase, and stop word removal to obtain clean text data; Build a vocabulary from the preprocessed corpus, containing all the unique words that appear in the corpus; Construct training samples. Construct training samples based on the vocabulary. Each training sample consists of a central word and its surrounding context words. Define the model structure, select the Skip-gram model to predict the surrounding context words through the central word, input the training samples into the defined Skip-gram model structure for training, and use the negative log-likelihood loss function to maximize the probability of predicting the context words to adjust the model parameters during the training process; Obtain word vectors. Input the text dataset after word segmentation in step S2 into the trained Skip-gram model. Each word in the text dataset is mapped to the word vector space. Each word is represented as a length vector of the corresponding mapping. According to the principle that words with close similarity in the semantic space in the injection attack sentence are also close in distance in the vector space, the distance of the spatial word vectors is calculated in the following way: The injection attack statement contains n words w1, w2, w, ..., w n , the word vector list of all words in the attack sentence in the SuperTerm_Vect or algorithm is represented as υ1, υ2, υ3, ..., υ n , using cosine similarity given two word vectors υ μ and v The cosine similarity(υ μ , v ) is calculated as follows: where denoted the dot product of the vectors, ||υ μ || and |υ v ||represents word vector υ respectively μ and v The norm of is used to calculate the similarity between different words in the injected attack sentence according to the cosine similarity, and the distance between different words in the word vector space is obtained accordingly.

7. The SQL attack identification method according to claim 6, characterized in that: For each word in the injected attack sentence, multiply its corresponding spatial word vector by TF-IDF to obtain the weighted word vector V′ of each word W , the average weighted word vector of the injected attack sentence is expressed as n represents the number of words contained in the injection attack sentence, W represents the words contained in the injection attack sentence, and D represents the injection attack sentence. The average weighted word vector of the injection attack sentence is used as the numerical vector feature to train the LC-CNN model for classification.

8. The SQL attack identification method according to claim 1, characterized in that: In step S4, the convolution layer uses the ReLU function as the activation function, the fully connected layer uses the Sigmoid function as the activation function, and the flattened layer uses the Tanh function as the activation function.

9. The SQL attack identification method according to claim 7, characterized in that: The LC-CNN model adds the model.compile() function to define the optimizer, loss function and evaluation index of the model. The optimizer adopts the Adam optimizer, the loss function uses the binary cross entropy, and the evaluation indexes include accuracy, F1 value and confusion matrix. The optimal model parameter setting is determined by determining the iteration with the highest classification accuracy during multiple iterative training of the classification model.

10. A SQL attack identification system based on deep learning dynamic target range feature fusion, characterized in that: include: Data collection module, builds a target server to simulate real SQL injection attacks and obtain injection attack samples; The data cleaning module decodes and detects the acquired injection attack sample data packets, obtains the injection attack sentence text data set, and performs word segmentation processing on the injection attack sentences in the text data set; The feature extraction module combines the word frequency index and the SuperTerm_Vector word vector algorithm to process the text data set after word segmentation, and converts the text data injected into the attack sentence in the text data set into corresponding numerical features; The LC-CNN classifier has a built-in LC-CNN model. The LC-CNN model has two convolutional layers, which are connected to a flattening layer and then to a fully connected layer. The classification model is trained by inputting a training data set composed of the numerical features of the injection attack statements of the feature extraction module and the numerical vector features of the normal SQL query statements. The trained LC-CNN model is then used to identify the test data to determine whether there is an SQL attack.

Citation Information

Cited By

  • Sensitive information automatic encryption storage system and search method

    CN118940301A

  • Sensitive information automatic encryption storage system and search method

    CN118940301B

  • SQL injection attack detection method and system and related equipment

    CN119865377A