SQL attack detection method, system and storage medium
Identifying SQL injection attacks through pre-judgment and re-judgment reduces detection time and server load, solves the problems of low SQL attack detection efficiency and high server load in the existing technology, and achieves more efficient attack identification and defense.
Patent Information
- Application Number
- CN202210587829.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-26
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2042-05-26
AI Technical Summary
Existing SQL attack detection methods have low efficiency, heavy server load, high cost, and are difficult to effectively identify and defend against SQL injection attacks.
Using pre-judgment and re-judgment methods, by analyzing the number of IP accesses and characteristic information of HTTP requests, potential SQL injection attacks are identified and intercepted, reducing judgment time and improving efficiency.
It effectively reduces the judgment time of SQL attack detection, improves detection efficiency, reduces server load, and extends the service life of the server.
Smart Images

Figure CN115065507B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of information security detection, and in particular to a SQL attack detection method, system and storage medium. Background Art
[0002] SQL (Structured Query Language) injection attack is one of the common methods used by hackers to attack databases. With the development of B / S mode application development, more and more programmers use this mode to write applications. However, due to the uneven level and experience of programmers, a considerable number of programmers do not judge the legitimacy of user input data when writing codes, which makes the application have security risks. Users can submit a database query code and obtain some data they want to know based on the results returned by the program. This is the so-called SQL Injection.
[0003] Simply put, SQL injection attacks refer to constructing special inputs as parameters passed into web applications. Most of these inputs are combinations of SQL syntax, and the attacker's desired operations are performed by executing SQL statements. The main reason is that the program does not carefully filter the user's input data, causing illegal data to invade the system.
[0004] The current SQL attack detection methods generally use firewalls to detect HTTP requests sent by clients to servers, or directly identify different characters in each piece of data entered by users to determine the degree of danger. This results in long detection time, low efficiency, large server load, short lifespan, and high cost. Summary of the invention
[0005] In view of the problems existing in the prior art, the purpose of the present invention is to provide a SQL attack detection method, system and storable medium, which can reduce the system judgment time and improve efficiency through pre-judgment and re-judgment.
[0006] To achieve the above object, the technical solution adopted by the present invention is:
[0007] A SQL attack detection method, the method comprising:
[0008] When the server receives the HTTP request sent by the requester, it determines whether the number of accesses of the IP address of the HTTP request within the first access time is within the first preset number range, and if so, the request is approved;
[0009] If not, determine whether the IP of the HTTP request has continuously exceeded the second access time and exceeded the second preset number of times. If so, directly determine it as a SQL injection attack, otherwise perform HTTP request identification and judgment.
[0010] The identification and judgment method of the HTTP request is as follows:
[0011] Detecting whether the HTTP request contains dangerous attack HTTP requests and safe attack HTTP requests; if so, sending the safe attack HTTP request to the server, and intercepting the detected dangerous attack HTTP request;
[0012] The server returns the corresponding HTTP response to the security attack HTTP request, and detects whether the SQL injection attack sample set contains the preset feature information of the HTTP response. If so, it is confirmed that there is a SQL injection vulnerability;
[0013] The SQL injection attack sample set is data stored in a database.
[0014] The preset characteristic information is information carried in the HTTP response, which includes attack type information, attack service type information and network address information for launching the attack.
[0015] A SQL attack detection method, the method comprising:
[0016] Step 1: For the Hypertext Transfer Protocol (HTTP) request sent by the requesting end to the server, detect whether the IP of the HTTP request is a new IP; if it is a new IP, identify and judge the HTTP request of the new IP. If it passes safely, it is regarded as a safe IP and stored in the safe IP set; if the IP of the HTTP request is not a new IP, execute step 2;
[0017] Step 2: Determine whether the IP address of the HTTP request is in the safe IP set or in the dangerous IP set. If the IP address of the HTTP request is in the safe IP set, execute step 3. If the IP address of the HTTP request is in the dangerous IP set, the request passes safely.
[0018] Step 3: If the number of accesses of the IP address of the HTTP request within the first access time is within the first preset number range, the request is passed safely;
[0019] Otherwise, determine whether the IP address of the HTTP request has continuously exceeded the second access time and exceeded the second preset number of times. If so, directly determine it as a SQL injection attack; otherwise, perform identification and judgment of the HTTP request;
[0020] The safe IP set and the dangerous IP set are stored in a database.
[0021] The identification and judgment method of the HTTP request is as follows:
[0022] Detecting whether the HTTP request contains dangerous attack HTTP requests and safe attack HTTP requests; if so, sending the safe attack HTTP request to the server, and intercepting the detected dangerous attack HTTP request;
[0023] The server returns the corresponding HTTP response to the security attack HTTP request, and detects whether the SQL injection attack sample set contains the preset feature information of the HTTP response. If so, it is confirmed that there is a SQL injection vulnerability;
[0024] The SQL injection attack sample set is data stored in a database.
[0025] The preset characteristic information is information carried in the HTTP response, which includes attack type information, attack service type information and network address information for launching the attack.
[0026] In step 3, after determining that it is a SQL injection attack, the access of the IP address of the HTTP request is suspended, or it is transferred to manual processing.
[0027] When the system load is low, HTTP requests from secure IP addresses are randomly selected to identify and judge the HTTP requests.
[0028] A SQL attack detection system includes a data acquisition module, a pre-judgment module and an attack detection module;
[0029] The data acquisition module is used to obtain the HTTP request sent by the request form;
[0030] A pre-judgment module is used to determine whether the number of visits of the IP address of the HTTP request within the first access time is within a first preset number range. If yes, the request is approved; if not, it continues to determine whether the HTTP request has continuously exceeded the second access time and exceeded the second preset number. If yes, it is determined to be a SQL injection attack, otherwise the HTTP request is sent to the attack detection module;
[0031] The attack detection module is used to identify and judge HTTP requests to determine whether they are SQL injection attacks.
[0032] The attack detection module identifies and judges HTTP requests as follows:
[0033] Detecting whether the HTTP request contains dangerous attack HTTP requests and safe attack HTTP requests; if so, sending the safe attack HTTP request to the server, and intercepting the detected dangerous attack HTTP request;
[0034] The server returns the corresponding HTTP response to the security attack HTTP request, and detects whether the SQL injection attack sample set contains the preset feature information of the HTTP response. If so, it is confirmed that there is a SQL injection vulnerability;
[0035] The SQL injection attack sample set is data stored in a database.
[0036] The preset characteristic information is information carried in the HTTP response, which includes attack type information, attack service type information and network address information for launching the attack.
[0037] A SQL attack detection system includes a database, a data acquisition module, an IP address judgment module, a pre-judgment module and an attack detection module;
[0038] Database, used to store safe IP sets and dangerous IP sets;
[0039] The data acquisition module is used to obtain the HTTP request sent by the request form;
[0040] The IP address judgment module is used to judge whether the IP of the HTTP request is a new IP. If so, the HTTP request is sent to the attack detection module; otherwise, it is judged whether the IP of the HTTP request is an IP in the safe IP set or an IP in the dangerous IP set. If it is an IP in the dangerous set, the HTTP request is sent to the attack detection module; if it is an IP in the safe set, the HTTP request is sent to the pre-judgment module;
[0041] A pre-judgment module is used to determine whether the number of accesses to the HTTP address within the first access time is within a first preset number range. If yes, the request is passed; if not, it continues to determine whether the HTTP request is continuously longer than the second access time and longer than the second preset number. If yes, it is determined to be a SQL injection attack, otherwise, it is safely passed;
[0042] The attack detection module is used to identify and judge HTTP requests to determine whether they are SQL injection attacks.
[0043] The attack detection module identifies and judges HTTP requests as follows:
[0044] Detecting whether the HTTP request contains dangerous attack HTTP requests and safe attack HTTP requests; if so, sending the safe attack HTTP request to the server, and intercepting the detected dangerous attack HTTP request;
[0045] The server returns the corresponding HTTP response to the security attack HTTP request, and detects whether the SQL injection attack sample set contains the preset feature information of the HTTP response. If so, it is confirmed that there is a SQL injection vulnerability;
[0046] The SQL injection attack sample set is data stored in a database.
[0047] The preset characteristic information is information carried in the HTTP response, which includes attack type information, attack service type information and network address information for launching the attack.
[0048] After determining that it is a SQL injection attack, the pre-judgment module and the attack detection module will suspend access to the IP address of the HTTP request or transfer it to manual processing.
[0049] When the system load is low, the attack detection module randomly extracts HTTP requests from secure IP addresses and performs identification and judgment of the HTTP requests.
[0050] A computer-readable storage medium stores instructions, and when the instructions are executed on a terminal device, the terminal device executes the SQL attack detection method as described above.
[0051] After adopting the above scheme, the present invention uses the access passability as the basis for pre-judgment when performing SQL attack detection. Those that pass the pre-judgment can be regarded as safe, and those HTTP requests that may have problems in access behavior are re-judged, thereby reducing the number of identification and judgment of HTTP requests, reducing the judgment time, and improving the judgment efficiency. It can also effectively reduce the load of the server and extend the service life of the server. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] Figure 1 This is a flow chart of Embodiment 1;
[0053] Figure 2 This is a flow chart of Example 2. DETAILED DESCRIPTION
[0054] In order to more clearly understand the above-mentioned purpose, features and advantages of the present invention, the present invention is described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be noted that the embodiments of the present invention and the features in the embodiments can be combined with each other without conflict.
[0055] In the following description, many specific details are set forth to facilitate a full understanding of the present invention. The embodiments described are only a part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0056] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art of the present invention. The terms used in the specification of the present invention herein are only for the purpose of describing specific embodiments and are not intended to limit the present invention.
[0057] The terms "first", "second", "third", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the term "comprising" and any variation thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device comprising a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units that are not listed, or may optionally include other steps or units that are inherent to these processes, methods, products or devices.
[0058] In SQL injection attacks, the data input by the user is the source of the problem; in normal access, the data input by the user is fine and basically passes in one go; while the data input in SQL injection attacks generally has various problems, which requires multiple repeated attempts, and the probability of passing in one go is extremely low. Therefore, from this perspective, the present invention discloses a SQL attack detection method, which identifies the SQL injection attack by identifying the data input by the user that does not pass in one go.
[0059] Embodiment 1
[0060] A SQL attack detection method of this embodiment includes:
[0061] When the server receives the HTTP request sent by the requester, it determines whether the number of accesses of the IP address of the HTTP request within the first access time is within the first preset number range, and if so, the request is approved;
[0062] If not, determine whether the IP of the HTTP request has continuously exceeded the second access time and exceeded the second preset number of times. If so, directly determine it as a SQL injection attack; if not, perform identification and judgment of the HTTP request.
[0063] There are many ways to identify and judge HTTP requests, such as using security dogs, WAF, etc. Among them, WAF is an identification and judgment method, as follows:
[0064] WAF is a basic security protection module, mainly for HTTP access Web program protection, deployed in front of the Web application, before the user request reaches the Web server to scan and filter the user request, analyze and verify each user request network packet, to ensure that each user request is valid and safe, to intercept or isolate invalid or attacking requests. SQL injection detection method is: in WAF (application firewall) for user submitted data, cookies, refer and other fields rule matching, matching methods mainly include the following:
[0065] 1. Keyword matching
[0066] 1) Collect common SQL injection syntax keywords (eg: and 1=1);
[0067] 2) Perform keyword search on the information input by the user. If it matches the keyword in 1), it is determined to be SQL injection and intercepted.
[0068] 2. Regular expression matching
[0069] 1) Collect common SQL injection methods (eg: and*=*);
[0070] 2) Based on the information collected in 1), construct a SQL injection regular expression;
[0071] 3) Perform regular expression matching on the information input by the user. If it matches the regular expression constructed in 2), it is determined to be SQL injection and intercepted.
[0072] 3. Rule matching based on syntax analysis
[0073] 1) Collect common SQL injection methods;
[0074] 2) Based on the information collected in 1), a rule feature library based on SQL syntax elements is constructed;
[0075] 3) Perform SQL lexical and grammatical analysis on the information input by the user and construct a syntax tree;
[0076] 4) Traverse each SQL syntax element and syntax context information of the syntax tree constructed in 4) to perform rule detection. If the rule in the rule base constructed in 2) is hit, it is determined to be SQL injection and intercepted.
[0077] Among them, rule matching based on syntax analysis takes into account the semantics of SQL, can identify some variant SQL (such as bypassing through some symbol encoding, adding comments, etc.), reduces the false positive rate and missed negative rate, and also greatly improves the execution efficiency.
[0078] In this embodiment, the identification and judgment method of the HTTP request is as follows:
[0079] Detecting whether the HTTP request contains dangerous attack HTTP requests and safe attack HTTP requests; if so, sending the safe attack HTTP request to the server, and intercepting the detected dangerous attack HTTP request;
[0080] The server returns the corresponding HTTP response to the security attack HTTP request, and detects whether the SQL injection attack sample set contains the preset feature information of the HTTP response. If so, it is confirmed that there is a SQL injection vulnerability;
[0081] The SQL injection attack sample set is data stored in a database.
[0082] Preferably, the identification and judgment of the HTTP request in this embodiment is as follows:
[0083] Detect whether the HTTP request contains dangerous attack HTTP requests and safe attack HTTP requests; if it contains safe attack HTTP requests, send the safe attack HTTP requests to the server for processing; if it contains dangerous attack HTTP requests, intercept the detected dangerous attack HTTP requests and determine them as SQL injection attacks; if it does not contain dangerous attack HTTP requests and safe attack HTTP requests, pass safely;
[0084] The server returns the corresponding HTTP response to the security attack HTTP request, and detects whether the SQL injection attack sample set contains the preset feature information of the HTTP response. If it does, it is confirmed that there is an SQL injection vulnerability; if not, it passes safely.
[0085] The preset characteristic information is information carried in the HTTP response, which includes attack type information, attack service type information and network address information for launching the attack.
[0086] Embodiment 2
[0087] This embodiment first establishes a local database, which stores a safe IP set, a dangerous IP set, and a SQL injection attack sample set. The specific detection is as follows:
[0088] Step 1: For the Hypertext Transfer Protocol (HTTP) request sent by the requesting end to the server, check whether the IP of the HTTP request is a new IP (the address where the user initiates the data); if it is a new IP, identify and judge the HTTP request of the new IP. If it passes safely, it is regarded as a safe IP and stored in the safe IP set; if the IP of the HTTP request is not a new IP, execute step 2.
[0089] For IP addresses that have been accessed multiple times in a row and are not from the region where the partner is located, these IP addresses will be stored in the dangerous IP set. For example, if our company does not cooperate with any company in Myanmar, but the access IP address suddenly appears in Myanmar, the IP address will be placed in the dangerous IP set.
[0090] Step 2: Determine whether the IP of the HTTP request belongs to the safe IP set or the dangerous IP set. When the IP of the HTTP request belongs to the safe IP set, execute step 3; when the IP of the HTTP request belongs to the dangerous IP set, identify and determine the HTTP request.
[0091] In this embodiment, the identification and judgment method for HTTP requests can adopt the identification and judgment methods such as security dog and WAF. It can also use sample sets for identification and judgment, as follows:
[0092] Detect whether the HTTP request contains dangerous attack HTTP requests and safe attack HTTP requests; if it contains safe attack HTTP requests, send the safe attack HTTP requests to the server for processing; if it contains dangerous attack HTTP requests, intercept the detected dangerous attack HTTP requests and determine them as SQL injection attacks; if it does not contain dangerous attack HTTP requests and safe attack HTTP requests, pass safely;
[0093] The server returns the corresponding HTTP response to the security attack HTTP request, and detects whether the SQL injection attack sample set contains the preset feature information of the HTTP response. If it does, it is confirmed that there is an SQL injection vulnerability; if not, it passes safely.
[0094] The preset characteristic information is information carried in the HTTP response, which includes attack type information, attack service type information and network address information for launching the attack.
[0095] Step 3: If the number of visits of the IP of the HTTP request within the first access time is within the first preset number range, it passes safely; otherwise, determine whether the IP of the HTTP request has continuously exceeded the second access time and exceeded the second preset number of times. If so, it is directly determined as a SQL injection attack and passes safely.
[0096] The first access time refers to a reasonable access time to the server, and the first preset number refers to a reasonable number of accesses to the server within the reasonable access time. This can be set according to the actual application scenario. In this embodiment, the access time is set to 1-10 minutes, and the first preset number is 1 time.
[0097] The second access time refers to the time required for attack adjustment, and the second preset number of times refers to the number of trial and error times required for a general attack.
[0098] After determining that it is a SQL injection attack, the IP address of the HTTP request can be suspended or directly transferred to manual processing. When the IP address is suspended, an alarm can be issued and the IP address can be recorded. The IP address user whose access is suspended can appeal, or the IP address can be automatically unblocked after a period of time, such as 1 day, 7 days, 30 days, 3 months, 6 months, 1 year, 3 years or permanent ban.
[0099] In addition, in the present invention, when the system load is low, a safe IP is randomly selected to identify and judge the HTTP request. The specific conditions for low system load can be set as needed. In this embodiment, the number of visits is used to determine whether the system load is low. For example, when the number of visits is half of the average number of visits per day in the previous month, it can be determined that the system load is low.
[0100] The number of IP accesses in the safe IP set is counted. If the number of safe accesses is higher, the probability of extraction is lower, and the more times it passes in one go, the probability of being extracted gradually decreases. When it decreases to 0, it no longer decreases (for example, if it passes in one out of 10 times, the probability of being extracted decreases to 0).
[0101] The SQL injection attack sample set in the present invention can be crawled from various websites and forums, and then a database is established. The database established in this way is faster than the database update.
[0102] Embodiment 3
[0103] This embodiment is a SQL attack detection system corresponding to the detection method of the first embodiment. The SQL attack detection system includes a data acquisition module, a pre-judgment module and an attack detection module.
[0104] Among them, the data acquisition module is used to obtain the HTTP request sent by the request form;
[0105] The pre-judgment module is used to determine whether the number of visits of the IP address of the HTTP request within the first access time is within the first preset number range. If so, the request is approved; if not, it continues to determine whether the HTTP request has continuously exceeded the second access time and exceeded the second preset number. If so, it is determined to be a SQL injection attack, otherwise the HTTP request is sent to the attack detection module.
[0106] The attack detection module is used to identify and judge HTTP requests to determine whether they are SQL injection attacks.
[0107] Similarly, in this embodiment, there are many methods for the attack detection module to identify and judge HTTP requests, such as using a security dog, WAF, etc., as long as it can identify whether the HTTP request is safe.
[0108] Preferably, the attack detection module of this embodiment performs the following identification and judgment when performing HTTP request:
[0109] Detecting whether the HTTP request contains dangerous attack HTTP requests and safe attack HTTP requests; if so, sending the safe attack HTTP request to the server, and intercepting the detected dangerous attack HTTP request;
[0110] The server returns the corresponding HTTP response to the security attack HTTP request, and detects whether the SQL injection attack sample set contains the preset feature information of the HTTP response. If so, it is confirmed that there is a SQL injection vulnerability;
[0111] The SQL injection attack sample set is data stored in a database.
[0112] The preset characteristic information is information carried in the HTTP response, which includes attack type information, attack service type information and network address information for launching the attack.
[0113] Embodiment 4
[0114] This embodiment is a SQL attack detection system corresponding to the SQL attack detection method of the second embodiment. The SQL attack detection system includes a database, a data acquisition module, an IP address judgment module, a pre-judgment module and an attack detection module.
[0115] The database is used to store safe IP sets, dangerous IP sets and SQL injection attack sample sets.
[0116] The data acquisition module is used to obtain the HTTP request sent by the request form.
[0117] The IP address judgment module is used to determine whether the IP of the HTTP request is a new IP. If so, the HTTP request is sent to the attack detection module; otherwise, it is used to determine whether the IP of the HTTP request is in the safe IP set or in the dangerous IP set. If it is in the dangerous set, the HTTP request is sent to the attack detection module; if it is in the safe set, the HTTP request is sent to the pre-judgment module.
[0118] The pre-judgment module is used to determine whether the number of visits to the HTTP address within the first access time is within the first preset number range. If so, the request is passed; if not, it continues to determine whether the HTTP request is continuously exceeded by the second access time and exceeds the second preset number. If so, it is determined to be a SQL injection attack, otherwise, it is safely passed.
[0119] The attack detection module is used to identify and judge HTTP requests to determine whether they are SQL injection attacks.
[0120] In this embodiment, there are many methods for the attack detection module to identify and judge HTTP requests, such as using a security dog, WAF, etc., as long as it can identify whether the HTTP request is safe.
[0121] Preferably, the attack detection module of this embodiment performs the following identification and judgment when performing HTTP request:
[0122] Detecting whether the HTTP request contains dangerous attack HTTP requests and safe attack HTTP requests; if so, sending the safe attack HTTP request to the server, and intercepting the detected dangerous attack HTTP request;
[0123] The server returns the corresponding HTTP response to the security attack HTTP request, and detects whether the SQL injection attack sample set contains the preset feature information of the HTTP response. If so, it is confirmed that there is a SQL injection vulnerability;
[0124] The SQL injection attack sample set is data stored in a database.
[0125] The preset characteristic information is information carried in the HTTP response, which includes attack type information, attack service type information and network address information for launching the attack.
[0126] In addition, after determining that it is a SQL injection attack, the pre-judgment module and the attack detection module will suspend access to the IP address of the HTTP request or transfer it to manual processing.
[0127] When the system load is low, the attack detection module randomly extracts HTTP requests from secure IP addresses and performs identification and judgment of the HTTP requests.
[0128] In addition to the above embodiments, the present invention further discloses a computer-readable storage medium, in which instructions are stored. When the instructions are executed on a terminal device, the terminal device executes the SQL attack detection method described in Embodiment 1 or Embodiment 2.
[0129] In summary, the present invention uses the access passability as the basis for pre-judgment when performing SQL attack detection. Those that pass the pre-judgment can be considered safe, and those HTTP requests that may have problems in access behavior are re-judged, thereby reducing the number of identification and judgment of HTTP requests, reducing the judgment time, and improving the judgment efficiency. It can also effectively reduce the load of the server and extend the service life of the server.
[0130] It is obvious to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above, and that the present invention can be implemented in other specific forms without departing from the spirit or essential features of the present invention. Therefore, from any point of view, the embodiments should be regarded as exemplary and non-restrictive, and the scope of the present invention is defined by the appended claims rather than the above description, and it is intended that all changes falling within the meaning and scope of the equivalent elements of the claims are included in the present invention. Any figure mark in the claims should not be regarded as limiting the claims involved. In addition, it is obvious that the word "comprising" does not exclude other units or, and the singular does not exclude the plural. Multiple units or devices stated in the system claim may also be implemented by one unit or device through software or hardware. The words first, second, etc. are used to indicate names, and do not indicate any particular order.
[0131] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solution of the present invention can be modified or replaced by equivalents without departing from the spirit and scope of the technical solution of the present invention.
Claims
1. A SQL attack detection method, Features: The method comprises: When the server receives the HTTP request sent by the requester, it determines whether the number of accesses of the IP address of the HTTP request within the first access time is within the first preset number range, and if so, the request is approved; If not, determine whether the IP address of the HTTP request has continuously exceeded the second access time and exceeded the second preset number of times. If so, directly determine it as a SQL injection attack, otherwise perform HTTP request identification and judgment; The first access time refers to the reasonable access time to the server, and the first preset number refers to the reasonable number of accesses to the server within the reasonable access time; the second access time refers to the time required for attack adjustment, and the second preset number refers to the number of trial and error required for a general attack; The identification and judgment method of the HTTP request is as follows: Detect whether the HTTP request contains dangerous attack HTTP requests and safe attack HTTP requests; if it contains safe attack HTTP requests, send the safe attack HTTP requests to the server for processing; if it contains dangerous attack HTTP requests, intercept the detected dangerous attack HTTP requests and determine them as SQL injection attacks; if it does not contain dangerous attack HTTP requests and safe attack HTTP requests, pass safely; The server returns the corresponding HTTP response to the security attack HTTP request, and detects whether the SQL injection attack sample set contains the preset feature information of the HTTP response. If so, it is confirmed that there is a SQL injection vulnerability; The SQL injection attack sample set is data stored in a database; The preset characteristic information is information carried in the HTTP response, which includes attack type information, attack service type information and network address information for launching the attack.
2. A SQL attack detection method, Features: The method comprises: Step 1: For the Hypertext Transfer Protocol (HTTP) request sent by the requesting end to the server, detect whether the IP of the HTTP request is a new IP; if it is a new IP, identify and judge the HTTP request of the new IP. If it passes safely, it is regarded as a safe IP and stored in the safe IP set; if the IP of the HTTP request is not a new IP, execute step 2; Step 2: Determine whether the IP of the HTTP request belongs to the safe IP set or the dangerous IP set. When the IP of the HTTP request belongs to the safe IP set, execute step 3; when the IP of the HTTP request belongs to the dangerous IP set, identify and judge the HTTP request; Step 3: If the number of accesses of the IP address of the HTTP request within the first access time is within the first preset number range, the request is passed safely; Otherwise, determine whether the IP address of the HTTP request has continuously exceeded the second access time and exceeded the second preset number of times. If so, directly determine it as a SQL injection attack; otherwise, pass safely; The first access time refers to the reasonable access time to the server, and the first preset number refers to the reasonable number of accesses to the server within the reasonable access time; the second access time refers to the time required for attack adjustment, and the second preset number refers to the number of trial and error required for a general attack; The safe IP set and the dangerous IP set are stored in a database; The identification and judgment method of the HTTP request is as follows: Detect whether the HTTP request contains dangerous attack HTTP requests and safe attack HTTP requests; if it contains safe attack HTTP requests, send the safe attack HTTP requests to the server for processing; if it contains dangerous attack HTTP requests, intercept the detected dangerous attack HTTP requests and determine them as SQL injection attacks; if it does not contain dangerous attack HTTP requests and safe attack HTTP requests, pass safely; The server returns the corresponding HTTP response to the security attack HTTP request, and detects whether the SQL injection attack sample set contains the preset feature information of the HTTP response. If so, it is confirmed that there is a SQL injection vulnerability; The SQL injection attack sample set is data stored in a database; The preset characteristic information is information carried in the HTTP response, which includes attack type information, attack service type information and network address information for launching the attack.
3. A SQL attack detection method according to claim 2, Features: In step 3, after determining that it is a SQL injection attack, the IP address of the HTTP request is suspended from access, or transferred to manual processing; and / or When the system load is low, HTTP requests from secure IP addresses are randomly selected to identify and judge the HTTP requests.
4. A SQL attack detection system, Features: It includes data acquisition module, pre-judgment module and attack detection module; The data acquisition module is used to obtain the HTTP request sent by the request end; A pre-judgment module is used to determine whether the number of visits of the IP address of the HTTP request within the first access time is within a first preset number range. If yes, the request is approved; if not, it continues to determine whether the HTTP request has continuously exceeded the second access time and exceeded the second preset number. If yes, it is determined to be a SQL injection attack, otherwise the HTTP request is sent to the attack detection module; Attack detection module, used to identify HTTP requests and determine whether they are SQL injection attacks; The first access time refers to the reasonable access time to the server, and the first preset number refers to the reasonable number of accesses to the server within the reasonable access time; the second access time refers to the time required for attack adjustment, and the second preset number refers to the number of trial and error required for a general attack; The attack detection module identifies and judges HTTP requests as follows: Detect whether the HTTP request contains dangerous attack HTTP requests and safe attack HTTP requests; if so, send the safe attack HTTP request to the server, and intercept the detected dangerous attack HTTP request; The server returns the corresponding HTTP response to the security attack HTTP request, and detects whether the SQL injection attack sample set contains the preset feature information of the HTTP response. If so, it is confirmed that there is a SQL injection vulnerability; The SQL injection attack sample set is data stored in a database; The preset characteristic information is information carried in the HTTP response, which includes attack type information, attack service type information and network address information for launching the attack.
5. A SQL attack detection system, Features: It includes a database, a data acquisition module, an IP address judgment module, a pre-judgment module and an attack detection module; Database, used to store safe IP sets and dangerous IP sets; The data acquisition module is used to obtain the HTTP request sent by the request end; The IP address judgment module is used to judge whether the IP of the HTTP request is a new IP. If so, the HTTP request is sent to the attack detection module; Otherwise, determine whether the IP of the HTTP request is an IP in the safe IP set or an IP in the dangerous IP set. If it is an IP in the dangerous set, the HTTP request is sent to the attack detection module; if it is an IP in the safe set, the HTTP request is sent to the pre-judgment module; A pre-judgment module is used to determine whether the number of accesses to the HTTP address within the first access time is within a first preset number range. If yes, the request is passed; if not, it continues to determine whether the HTTP request is continuously longer than the second access time and longer than the second preset number. If yes, it is determined to be a SQL injection attack, otherwise, it is safely passed; Attack detection module, used to identify HTTP requests and determine whether they are SQL injection attacks; The first access time refers to the reasonable access time to the server, and the first preset number refers to the reasonable number of accesses to the server within the reasonable access time; the second access time refers to the time required for attack adjustment, and the second preset number refers to the number of trial and error required for a general attack; The attack detection module identifies and judges HTTP requests as follows: Detecting whether the HTTP request contains a dangerous attack HTTP request and a safe attack HTTP request; if a safe attack HTTP request is contained, sending the safe attack HTTP request to the server for processing; If a dangerous attack HTTP request is included, the detected dangerous attack HTTP request will be intercepted and determined to be a SQL injection attack; If it does not contain dangerous attack HTTP requests and safe attack HTTP requests, it passes safely; The server returns the corresponding HTTP response to the security attack HTTP request, and detects whether the SQL injection attack sample set contains the preset feature information of the HTTP response. If so, it is confirmed that there is a SQL injection vulnerability; The SQL injection attack sample set is data stored in a database; The preset characteristic information is information carried in the HTTP response, which includes attack type information, attack service type information and network address information for launching the attack.
6. A computer-readable storage medium, Features: The computer-readable storage medium stores instructions, and when the instructions are executed on a terminal device, the terminal device executes the SQL attack detection method according to any one of claims 1 to 3.
