An optimization method and system for resisting SYN FLOOD attacks

By defining the attack defense data structure and session information table, the SYN COOKIE attack defense process is optimized, solving the problems of high resource consumption and low performance in traditional technology, and improving the efficiency and performance of resisting SYN FLOOD attacks.

CN118413356BActive Publication Date: 2024-10-18TMLAKE (BEIJING) TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202410477748.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-04-19
Publication Date
2024-10-18
Estimated Expiration
2044-04-19

AI Technical Summary

Technical Problem

When traditional SYN COOKIE technology resists SYN FLOOD attacks, it consumes large resources, has low performance, and frequently checks cookie values, affecting the performance and efficiency of real servers.

Method used

By defining the attack defense data structure, creating a session information table, using load balancing equipment to process client requests in real time, generating message reply sequence numbers, and performing blocking processing based on session comparison results, the defense process for SYN COOKIE attacks is optimized.

Benefits of technology

It improves the efficiency and performance of resisting SYN FLOOD attacks, reduces the resource consumption of real servers, speeds up the forwarding of normal traffic and blocks abnormal traffic.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118413356B_ABST
    Figure CN118413356B_ABST
Patent Text Reader

Abstract

This invention discloses an optimized method and system for resisting SYN FLOOD attacks. The method includes: defining an attack defense data structure according to a network request processing flow, and creating a session information table based on the attack defense data structure; receiving client requests in real time through a load balancer, obtaining the synchronization flag message, client address, and client port sent by the client according to the client request, and performing session comparison processing on the client request from the session information table; based on the result of the session comparison processing, the load balancer generates a message reply sequence number according to the synchronization flag message, and sends the message reply sequence number to the client; the load balancer receives and verifies the acknowledgment flag message returned by the client, and blocks the SYN FLOOD attack based on the verification result. By applying the technical solution provided by this invention, the efficiency and performance of resisting SYN COOKIE attacks are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the fields of Internet and artificial intelligence, and more specifically, to an optimization method and system for resisting SYN FLOOD attacks. Background Art

[0002] SYN FLOOD attack is a typical DDOS attack. The terminal sends a large number of SYN packets to fill up the semi-connected queue of the TCP real server, thereby exhausting the real server port resources. This makes it impossible to process real TCP requests normally, resulting in TCP service unavailability.

[0003] SYN COOKIE technology is a technology used to prevent SYN FLOOD attacks. The basic principle is to implement SYNPROXY proxy on the real server side, that is, to carry a special cookie value in the SYN response to the TCP connection. The cookie value is calculated by the real server based on the client's SYN message information. After the client receives the response from the real server, it will return the characteristic information carrying the cookie value to the real server. If the real server successfully verifies the cookie value, it will establish a TCP connection and create resources. If the verification fails, the data packet will be directly discarded.

[0004] Traditional SYN COOKIE technology is basically implemented on a real server. The real server will have a complete TCP protocol stack to facilitate the TCP state management of SYNPROXY, but a large amount of traffic entering the real server will consume the real server's CPU and other resources.

[0005] In traditional SYN COOKIE technology, whether it is a normal traffic request or an abnormal attack request, each time the SYN packet must be encrypted and decrypted and the ACK reply message sequence number seq must be verified. This actually occupies the resources of the real server and reduces performance.

[0006] To sum up, it is necessary to introduce a new method and system to load the real server traffic, isolate and protect the real server resources, and optimize the SYN COOKIE attack resistance technology by combining the SYN COOKIE technology with the session, so as to speed up the forwarding of normal traffic and the blocking of abnormal traffic, so as to solve the technical problems existing in the prior art such as frequent cookie value verification, high resource consumption and low performance, thereby improving the efficiency and performance of resisting SYN COOKIE attacks. Summary of the invention

[0007] In view of the technical problems mentioned above, the present invention provides an optimization method and system for resisting SYN FLOOD attacks, by defining an attack resistance data structure, creating a session information table based on the attack resistance data structure, and using the session information table and cookie values ​​to judge and process client requests in real time, thereby optimizing the SYN COOKIE attack resistance technology, accelerating the forwarding of normal traffic, accelerating the blocking of abnormal traffic, and solving the technical problems of frequent cookie value verification, large resource consumption, low performance, etc. in the prior art, thereby improving the efficiency and performance of resisting SYN COOKIE attacks.

[0008] The present invention provides an optimization method for resisting SYN FLOOD attacks, the method comprising:

[0009] S1, according to the network request processing flow, define the attack resistance data structure, and create a session information table based on the attack resistance data structure; S2, receive the client request in real time through the load balancing device, obtain the synchronization mark message, client address and client port sent by the client according to the client request, and perform session comparison processing on the client request from the session information table according to the client address and the client port based on the attack resistance data structure; S3, based on the result of the session comparison processing, the load balancing device generates a message reply sequence number according to the synchronization mark message, and sends the message reply sequence number to the client; S4, the load balancing device receives and verifies the confirmation mark message returned by the client, returns and blocks the SYN FLOOD attack according to the verification result, and updates the session information table at the same time; wherein, in the process of performing session comparison processing on the client request, the client request will be directly blocked according to the session data in the session information table, or a server access connection will be created for the client.

[0010] Preferably, the attack defense data structure includes: message encryption sequence data, session index and session data; wherein the session data includes 7 fields: session number, session type, quintuple data, timeout period, message outgoing interface, TCP access times and TCP blocking times; the session type includes 2 types, namely: blocking session and normal session; the quintuple data includes 5 fields, namely: client address, client port, server address, server port and network protocol number.

[0011] Preferably, in step S2, the step of performing session comparison processing on the client request from the session information table according to the client address and the client port based on the attack defense data structure further includes: S2-1, parsing the client request, and obtaining the synchronization mark message corresponding to the client request, as well as the client address and the client port according to the parsing result; S2-2, traversing the session information table according to the client address and the client port, if the client address and the client port exist in the session information table, jumping to step S2-3, if the client address and the client port do not exist in the session information table, jumping to step S2-4; S2-3, obtaining the session number and session type of the corresponding session according to the client address and the client port, and performing session processing on the client request based on the session type of the session; S2-4, generating message encryption sequence data according to the synchronization mark message corresponding to the client request, generating the message reply sequence number according to the message encryption sequence data, and sending a first reply message to the client based on the message reply sequence number.

[0012] Preferably, the message encryption sequence data includes three fields, namely time, maximum segmentation of the message encryption sequence data and hash function value; wherein the length of the message encryption sequence data is 32 bits, the length of the time is 5 bits, the length of the maximum segmentation of the message encryption sequence data is 3 bits, and the length of the hash function is 24 bits; the time is t, T is the current time in the process of processing the SYN FLOOD attack, % represents the remainder, and - represents the divisor; the hash function value is calculated based on the client address, client port, server address, server port, the time t and the maximum segmentation of the message encryption sequence data.

[0013] Preferably, in S2-3, the step of performing session processing on the client request according to the session type of the session includes: judging the session type of the session, and processing the client request according to the result of the judgment: 1) if the session type of the session corresponding to the client request is a blocking session, rejecting the client request, and increasing the TCP blocking times of the session corresponding to the client request by 1; 2) if the session type of the session corresponding to the client request is a normal session, obtaining the five-tuple data of the session corresponding to the client request, extracting and using the client address, client port, server address, server port and network protocol number in the five-tuple data, providing the client that sends the client request with a server access connection and access resources, and increasing the TCP access times of the session corresponding to the client request by 1.

[0014] Preferably, step S3 also includes a step of client confirming message processing, specifically: the client receives the first reply message, and extracts the message encryption sequence data from the first reply message according to the message reply sequence number, and adds 1 to the value of the message encryption sequence data to obtain new message encryption sequence data; the client generates and sends a confirmation mark message to the load balancing device based on the new message encryption sequence data.

[0015] Preferably, in step S4, the load balancing device receives and verifies the confirmation mark message returned by the client, and returns and blocks the SYN FLOOD attack according to the verification result, and the step further includes: S411, the load balancing device receives and generates new message encryption sequence data according to the confirmation mark message, and obtains the message encryption sequence data generated in step S2-4; S412, the load balancing device verifies the value of the new message encryption sequence data after subtracting 1 based on the message encryption sequence data, if the value of the new message encryption sequence data is equal to the value of the message encryption sequence data after subtracting 1, jump to step S414, otherwise, jump to step S413; S413, mark the client request as SYN FLOOD attack, and create a corresponding new blocking session, reject the client request, initialize the timeout time and TCP blocking times of the new blocking session, and update the session data of the new blocking session to the session information table, wherein the initial value of the TCP blocking times of the new blocking session is 1; S414, according to the client address and client port corresponding to the client request, create a corresponding new normal session, set the timeout time and access times of the new normal session, generate a session index according to the five-tuple data of the new normal session, and update the session data and session index of the new normal session to the session information table; wherein, the session data includes session number, session type, five-tuple data, timeout time, message outgoing interface, TCP access times and TCP blocking times; the session type includes blocking session and normal session; the five-tuple data includes client address, client port, server address, server port and network protocol number.

[0016] Preferably, in the step S414, after the value of the new message encryption sequence data is subtracted by 1 and verified, it also includes the step of establishing a three-way handshake connection, specifically: 1) the load balancing device sends a message of a three-way handshake connection request to the server based on the new message encryption sequence data; 2) after the server parses and processes the message of the access connection request, it returns a confirmation message to the load balancing device and provides resources for the three-way handshake connection, including server address, server port, network protocol number, access permission, storage space and computing resources; 3) the load balancing device receives the confirmation message returned by the server and sends a connection success message to the client; 4) the client sends a traffic access request based on the successful connection message and the resources of the three-way handshake connection.

[0017] Preferably, after the session is created, a session clearing step is also included, specifically: if the timeout period of the session is greater than the current time, the session is cleared, and the session index and session data of the session are deleted from the session information table; if the TCP access number of the session is greater than the preset access number, or the TCP blocking number of the session is greater than the preset blocking number, the session is cleared, and the session index and session data of the session are deleted from the session information table; wherein the preset access number and the preset blocking number are set according to actual needs.

[0018] Correspondingly, the present invention also provides an optimization system for resisting SYN FLOOD attacks, the system comprising an initialization processing module, a request preprocessing module, a message reply module and a message verification processing module; wherein the initialization processing module is used to define an attack resistance data structure according to a network request processing flow, and to create a session information table based on the attack resistance data structure; the request preprocessing module is used to receive a client request in real time through a load balancing device, obtain a synchronization mark message, a client address and a client port sent by the client according to the client request, and perform session comparison processing on the client request from the session information table according to the client address and the client port based on the attack resistance data structure; the message reply module is used to generate a message reply sequence number according to the synchronization mark message based on the result of the session comparison processing, and send the message reply sequence number to the client; the message verification processing module is used to receive and verify the confirmation mark message returned by the client, return and verify the SYN FLOOD message according to the verification result. FLOOD attack is blocked and the session information table is updated at the same time; in the process of performing session comparison processing on the client request, the client request is directly blocked according to the session data in the session information table, or a server access connection is created for the client.

[0019] The present invention, by applying the above technical scheme, realizes defining an attack resistance data structure, creating a session information table based on the attack resistance data structure, and using the session information table and cookie values ​​to judge and process client requests in real time, thereby optimizing the SYN COOKIE attack resistance technology, accelerating the forwarding of normal traffic, accelerating the blocking of abnormal traffic, and solving the technical problems of frequent cookie value verification, large resource consumption, low performance, etc. in the prior art, thereby improving the efficiency and performance of resisting SYN COOKIE attacks. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0021] Figure 1 A schematic flow chart of an optimization method for resisting SYN FLOOD attacks proposed in an embodiment of the present invention is shown;

[0022] Figure 2 A schematic diagram of a connection process of an optimization method for resisting SYN FLOOD attacks proposed in an embodiment of the present invention is shown;

[0023] Figure 3 A schematic structural diagram of an optimization system for resisting SYN FLOOD attacks proposed in an embodiment of the present invention is shown. DETAILED DESCRIPTION

[0024] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0025] The present invention provides an optimization method for resisting SYN FLOOD attacks, such as Figure 1 As shown, the method comprises the following steps:

[0026] S1, defining an attack defense data structure according to a network request processing flow, and creating a session information table based on the attack defense data structure.

[0027] In this embodiment, the attack defense data structure includes: message encryption sequence data, session index and session data;

[0028] in,

[0029] The session data includes 7 fields: session number, session type, five-tuple data, timeout, message outgoing interface, TCP access times and TCP blocking times;

[0030] The session types include two types: blocking session and normal session;

[0031] The five-tuple data includes five fields, namely: client address, client port, server address, server port and network protocol number.

[0032] S2, receiving the client request in real time through the load balancing device, obtaining the synchronization flag message, client address and client port sent by the client according to the client request, and based on the attack defense data structure, performing session comparison processing on the client request from the session information table according to the client address and the client port.

[0033] S3, based on the result of the session comparison processing, the load balancing device generates a message reply sequence number according to the synchronization mark message, and sends the message reply sequence number to the client.

[0034] In the process of performing session comparison processing on the client request, the client request will be directly blocked according to the session data in the session information table, or a server access connection will be created for the client.

[0035] In this embodiment, in step S2, the step of performing session comparison processing on the client request from the session information table according to the client address and the client port based on the attack defense data structure further includes:

[0036] S2-1, parsing the client request, and obtaining a synchronization flag message corresponding to the client request, as well as the client address and the client port according to the parsing result;

[0037] S2-2, traversing the session information table according to the client address and the client port, if the client address and the client port exist in the session information table, jumping to step S2-3, if the client address and the client port do not exist in the session information table, jumping to step S2-4;

[0038] S2-3, acquiring a session number and a session type of a corresponding session according to the client address and the client port, and performing session processing on the client request based on the session type of the session;

[0039] S2-4, generating message encryption sequence data according to the synchronization mark message corresponding to the client request, generating the message reply sequence number according to the message encryption sequence data, and sending the first reply message to the client based on the message reply sequence number.

[0040] In this embodiment, the message encryption sequence data includes three fields, namely time, maximum segmentation of the message encryption sequence data and hash function value;

[0041] in,

[0042] The length of the message encryption sequence data is 32 bits, the length of the time is 5 bits, the length of the maximum segment of the message encryption sequence data is 3 bits, and the length of the hash function is 24 bits;

[0043] The time is t, T is the current time during the SYN FLOOD attack process, % represents the remainder, and - represents the divisor;

[0044] The hash function value is obtained by calculating the maximum segment of the client address, the client port, the server address, the server port, the time t and the message encryption sequence data.

[0045] In this embodiment, in S2-3, the step of performing session processing on the client request by the session type of the session includes:

[0046] The session type of the session is determined, and the client request is processed according to the result of the determination:

[0047] 1) If the session type of the session corresponding to the client request is a blocking session, reject the client request and increase the TCP blocking count of the session corresponding to the client request by 1;

[0048] 2) If the session type of the session corresponding to the client request is a normal session, obtain the five-tuple data of the session corresponding to the client request, extract and use the client address, client port, server address, server port and network protocol number in the five-tuple data, provide the client that sends the client request with a server access connection and access resources, and increase the TCP access count of the session corresponding to the client request by 1.

[0049] In this embodiment, step S3 also includes a step of client confirming message processing, specifically:

[0050] The client receives the first reply message, extracts message encryption sequence data from the first reply message according to the message reply sequence number, and adds 1 to the value of the message encryption sequence data to obtain new message encryption sequence data;

[0051] The client generates a confirmation mark message based on the new message encryption sequence data and sends it to the load balancing device.

[0052] S4, the load balancing device receives and verifies the confirmation message returned by the client, returns and blocks the SYN FLOOD attack according to the verification result, and updates the session information table at the same time;

[0053] In this embodiment, in step S4, the load balancing device receives and verifies the confirmation message returned by the client, and returns and blocks the SYN FLOOD attack according to the verification result, further comprising:

[0054] S411, the load balancing device receives and generates new message encryption sequence data according to the confirmation mark message, and obtains the message encryption sequence data generated in step S2-4;

[0055] S412, the load balancing device verifies the value of the new message encryption sequence data after subtracting 1 based on the message encryption sequence data, if the value of the new message encryption sequence data after subtracting 1 is equal to the value of the message encryption sequence data, jump to step S414, otherwise, jump to step S413;

[0056] S413, marking the client request as a SYN FLOOD attack, creating a corresponding new blocking session, rejecting the client request, initializing the timeout time and TCP blocking times of the new blocking session, and updating the session data of the new blocking session into the session information table, wherein the initial value of the TCP blocking times of the new blocking session is 1;

[0057] S414, creating a corresponding new normal session according to the client address and the client port corresponding to the client request, setting a timeout time and access count for the new normal session, generating a session index according to the quintuple data of the new normal session, and updating the session data and session index of the new normal session into the session information table;

[0058] in,

[0059] The session data includes session number, session type, five-tuple data, timeout period, message outgoing interface, TCP access times and TCP blocking times;

[0060] The session types include blocking sessions and normal sessions;

[0061] The five-tuple data includes a client address, a client port, a server address, a server port and a network protocol number.

[0062] In this embodiment, in the step S414, after the value of the new message encryption sequence data is subtracted by 1 and verified, a three-way handshake connection establishment step is further included, specifically:

[0063] 1) The load balancing device sends a three-way handshake connection request message to the server based on the new message encryption sequence data;

[0064] 2) After parsing the access connection request message, the server returns confirmation information to the load balancing device and provides resources for the three-way handshake connection, including server address, server port, network protocol number, access rights, storage space and computing resources;

[0065] 3) The load balancing device receives the confirmation information returned by the server and sends a message of successful connection to the client;

[0066] 4) The client sends a traffic access request based on the successful connection message and the resources of the three-way handshake connection.

[0067] In this embodiment, after the session is created, a session clearing step is also included, specifically:

[0068] If the timeout time of the session is greater than the current time, clearing the session and deleting the session index and session data of the session from the session information table;

[0069] If the TCP access count of the session is greater than the preset access count, or the TCP blocking count of the session is greater than the preset blocking count, clearing the session and deleting the session index and session data of the session from the session information table;

[0070] The preset number of accesses and the preset number of blockings are both set according to actual needs.

[0071] By applying the above technical scheme, it is achieved by defining an attack defense data structure, creating a session information table based on the attack defense data structure, and using the session information table and cookie values ​​to judge and process client requests in real time, thereby completing the optimization of SYN COOKIE attack defense technology, accelerating the forwarding of normal traffic, accelerating the blocking of abnormal traffic, and solving the technical problems existing in the prior art such as frequent cookie value verification, high resource consumption, and low performance, thereby improving the efficiency and performance of defending against SYN COOKIE attacks.

[0072] In order to facilitate those skilled in the art to better understand the technical solution provided by the present invention, the technical solution provided by the present invention is supplemented by examples. Figure 2 shown.

[0073] In this embodiment, the synchronization mark message is a SYN message, the synchronization mark message is a SYN message, the confirmation mark message is an ACK message, the message encryption sequence data is a cookie value, SYN / ACK is the abbreviation of Synchronize Sequence Numbers, which means synchronization sequence number, and is a handshake signal used when TCP / IP establishes a connection.

[0074] The client address is the client ip, the client port is the client port, the server address is the server ip, and the server port is the server port.

[0075] In the first step, when the load balancer receives a SYN message from the client, it first searches for the session based on the client address and client port, and traverses the session information table.

[0076] If the client address and the client port exist in the session information table, obtaining a session number and a session type of the corresponding session according to the client address and the client port, and performing session processing on the client request based on the session type of the session;

[0077] If the session is a normal session, the five-tuple information is obtained and forwarded, and the corresponding TCP access count is increased by 1.

[0078] If the client address and the client port do not exist in the session information table, the message encryption sequence data (cookie value) is generated according to the synchronization mark message corresponding to the client request, the message reply sequence number is generated according to the message encryption sequence data (cookie value), and the first reply message is sent to the client based on the message reply sequence number. At this time, the load balancing will not create a session here, but will first generate a 32-bit encrypted cookie value according to the SYN message, and use the generated cookie value as the sequence number Seq of the TCP protocol three-way handshake SYN / ACK reply message as a reply.

[0079] The second step is, Figure 2 In step ②, the load balancer replies to the client message, using the generated cookie value as the sequence number Seq of the SYN / ACK reply message of the TCP protocol three-way handshake, and replies to the client. At this time, for the load balancer, no session is created and no resources are occupied.

[0080] Step 3: The client receives the SYN / ACK message. Figure 2 In ③, an ACK message will be sent to the load balancer immediately. According to the TCP protocol specification, the sequence number returned at this time must be the value of seq+1 received by SYN / ACK. Therefore, after the load balancer receives the ACK message, the cookie value will be obtained by subtracting the current seq-1.

[0081] Step 4: After Figure 2 After ③, for normal traffic, a normal session is created on the load balancer. Then the load balancer will first establish a connection with the server through a three-way handshake. The process of establishing a connection through a three-way handshake is shown in Figure ④⑤⑥. After the three-way handshake between the load balancer and the server is successfully established, as shown in Figure ⑦, it will actively send a message with a TCP window value of not 0 to the client. The purpose of this is to make the client start to actively request traffic. After that, the traffic between the client and the server through the load balancer will be quickly forwarded through the information in the session table.

[0082] It should be noted that the cookie value is actually a sequence number with characteristic significance, which is the Sequence Number field in the TCP protocol, including 3 fields, namely time, maximum segment of message encryption sequence data and hash function value; the length of the message encryption sequence data is 32 bits, that is, 4 bytes, the length of the time is 5 bits, the length of the maximum segment of the message encryption sequence data is 3 bits, and the length of the hash function is 24 bits;

[0083] The time is t, T is the current time during the SYN FLOOD attack processing, % is the remainder, and - is the divisor, that is, the value of t is the system time divided by 64 and then the remainder of 32 (time()>>6mod 32).

[0084] The maximum segment of the message encryption sequence data is 3 bits, which represents the maximum segment size in TCP. However, since this segment is only 3 bits, there are only eight ways to represent the maximum segment size. Therefore, the server can only send eight different values ​​when the SYN cookie value is enabled.

[0085] The hash function value is calculated based on the client address, client port, server address, server port, time t and the maximum segmentation of the message encryption sequence data, and its length is 24 bits. It is the value mac=MAC(A,k) calculated by the encrypted hash function, where MAC is a hash function with a key, A=source IP||source PORT||destination IP||destination PORT||t||MSSIND, where t is the time mentioned above, and MSSIND is the maximum segmentation size mentioned above. k is the key provided by the server.

[0086] The cookie value will be generated according to the above rules. Verifying the cookie value means that when the message is received again, the cookie value is generated again and compared with the original cookie value carried. If they are consistent, the verification passes. If they are inconsistent, the verification fails and it is determined that it may be an attack.

[0087] like Figure 2 ③, when the client receives the ACK message, it will create a blocking or normal session according to the result of the cookie value check. To create a session, the five-tuple is hashed to obtain a 32-bit index value, and the table content is associated with the index as the result information. The detailed session content can be found through the five-tuple. The five-tuple includes the client IP, client port, server IP, server port, and network protocol number. The session stores the type of the session in detail, whether it is blocking or normal; stores the timeout of the session. If it times out, the call will be cleared; stores the interface information for sending the message outward, identifying which specific interface the message is sent out from.

[0088] When traffic arrives, it will first use the five-tuple information in the message to find out whether there is a session. If it is found, it will be forwarded directly according to the session information. If it is not found, it needs to be forwarded again according to the session information. Figure 2 The process is carried out.

[0089] For normal sessions, even if the TCP connection between the client and the real server is disconnected, the session can remain in existence for a long time. For clients that have passed verification, when they receive a request again, they do not need to frequently generate and verify cookie values, which reduces the pressure on load balancing. At the same time, because the session retains previous information such as interface forwarding, it does not need to frequently find the interface, which speeds up the network transmission of the intermediate node and makes the communication between the client and the network smoother. For normal sessions, you can set the time and TCP access count statistics. When the access count reaches the threshold or times out, the session is automatically cleared to prevent attack messages from accessing the real server through normal session forwarding.

[0090] The blocking session created when an attack is identified can also be maintained for a long time. When a message with attack characteristics is received again, the session can be quickly found through the traffic quintuple, and the traffic can be blocked immediately, which also reduces the verification process. In addition, the timeout time and blocking count can be set. When the set time or number is reached, the session can be automatically cleared, so that the traffic can be automatically re-verified. This prevents the possibility of no more attacks in the future, but blocks normal messages.

[0091] Through the above technical solutions provided by the application, the implementation of SYNPROXY is placed on the load balancer of the intermediate device of the network, which not only loads the real server traffic, but also isolates and protects the real server resources. Through the session optimization of SYNCOOKIE, the forwarding of normal traffic is accelerated, and the blocking of abnormal traffic is accelerated. The detection frequency of traffic is controlled by means of session timeout and statistical threshold.

[0092] In addition, a private encryption method is used to encrypt the cookie value, which is more secure. In addition, the cookie value carries the intermediate information generated by the load balancing, which can be directly verified and used the next time it is received. The information of the outbound interface is stored in the session table, so there is no need to find the outbound interface for the traffic next time. There may be multiple outbound interfaces. When the next traffic arrives, it will be sent according to the previous outbound interface. The load scheduling is done in advance in the selection of the outbound interface to ensure the same outbound interface.

[0093] Corresponding to the optimization method for resisting SYN FLOOD attack in one embodiment of the present invention, the present invention also discloses an optimization system for resisting SYN FLOOD attack, such as Figure 3 As shown, the system includes an initialization processing module, a request pre-processing module, a message reply module and a message verification processing module;

[0094] in,

[0095] The initialization processing module is used to define an attack defense data structure according to a network request processing flow, and to create a session information table based on the attack defense data structure;

[0096] The request preprocessing module is used to receive the client request in real time through the load balancing device, obtain the synchronization mark message, the client address and the client port sent by the client according to the client request, and perform session comparison processing on the client request from the session information table according to the client address and the client port based on the attack defense data structure;

[0097] The message reply module is used to generate a message reply sequence number according to the synchronization mark message based on the result of the session comparison processing, and send the message reply sequence number to the client;

[0098] The message verification processing module is used to receive and verify the confirmation mark message returned by the client, return and block the SYN FLOOD attack according to the verification result, and update the session information table at the same time;

[0099] In the process of performing session comparison processing on the client request, the client request will be directly blocked according to the session data in the session information table, or a server access connection will be created for the client.

[0100] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referenced to each other, and each embodiment focuses on the differences from other embodiments.

[0101] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.

Claims

1. An optimization method for resisting SYN FLOOD attack, characterized in that: The method comprises: S1, defining an attack defense data structure according to a network request processing flow, and creating a session information table based on the attack defense data structure; S2, receiving the client request in real time through the load balancing device, obtaining the synchronization mark message, the client address and the client port sent by the client according to the client request, and performing session comparison processing on the client request from the session information table according to the client address and the client port based on the attack defense data structure; S3, based on the result of the session comparison processing, the load balancing device generates a message reply sequence number according to the synchronization mark message, and sends the message reply sequence number to the client; S4, the load balancing device receives and verifies the confirmation message returned by the client, returns and blocks the SYN FLOOD attack according to the verification result, and updates the session information table at the same time; in, In the process of performing session comparison processing on the client request, the client request will be directly blocked according to the session data in the session information table, or a server access connection will be created for the client; In step S2, the step of performing session comparison processing on the client request from the session information table according to the client address and the client port based on the attack defense data structure further includes: S2-1, parsing the client request, and obtaining a synchronization flag message corresponding to the client request, as well as the client address and the client port according to the parsing result; S2-2, traversing the session information table according to the client address and the client port, if the client address and the client port exist in the session information table, jumping to step S2-3, if the client address and the client port do not exist in the session information table, jumping to step S2-4; S2-3, acquiring a session number and a session type of a corresponding session according to the client address and the client port, and performing session processing on the client request based on the session type of the session; S2-4, generating message encryption sequence data according to the synchronization mark message corresponding to the client request, generating the message reply sequence number according to the message encryption sequence data, and sending the first reply message to the client based on the message reply sequence number.

2. The method according to claim 1, characterized in that The attack defense data structure includes: message encryption sequence data, session index and session data; in, The session data includes 7 fields: session number, session type, five-tuple data, timeout, message outgoing interface, TCP access times and TCP blocking times; The session types include two types: blocking session and normal session; The five-tuple data includes five fields, namely: client address, client port, server address, server port and network protocol number.

3. The method according to claim 1, characterized in that The message encryption sequence data includes three fields, namely time, maximum segmentation of the message encryption sequence data and hash function value; in, The length of the message encryption sequence data is 32 bits, the length of the time is 5 bits, the length of the maximum segment of the message encryption sequence data is 3 bits, and the length of the hash function is 24 bits; The time is t, T is the current time during the SYN FLOOD attack process, % represents the remainder, and - represents the divisor; The hash function value is obtained by calculating the maximum segment of the client address, the client port, the server address, the server port, the time t and the message encryption sequence data.

4. The method according to claim 1, characterized in that In S2-3, the step of performing session processing on the client request according to the session type of the session includes: The session type of the session is determined, and the client request is processed according to the result of the determination: 1) If the session type of the session corresponding to the client request is a blocking session, reject the client request and increase the TCP blocking count of the session corresponding to the client request by 1; 2) If the session type of the session corresponding to the client request is a normal session, obtain the five-tuple data of the session corresponding to the client request, extract and use the client address, client port, server address, server port and network protocol number in the five-tuple data, provide the client that sends the client request with a server access connection and access resources, and increase the TCP access count of the session corresponding to the client request by 1.

5. The method according to claim 1, characterized in that Step S3 also includes the step of client confirming message processing, specifically: The client receives the first reply message, extracts message encryption sequence data from the first reply message according to the message reply sequence number, and adds 1 to the value of the message encryption sequence data to obtain new message encryption sequence data; The client generates and sends a confirmation mark message to the load balancing device based on the new message encryption sequence data.

6. The method according to claim 1, characterized in that In step S4, the load balancing device receives and verifies the confirmation message returned by the client, and returns and blocks the SYN FLOOD attack according to the verification result, which further includes: S411, the load balancing device receives and generates new message encryption sequence data according to the confirmation mark message, and obtains the message encryption sequence data generated in step S2-4; S412, the load balancing device verifies the value of the new message encryption sequence data after subtracting 1 based on the message encryption sequence data, if the value of the new message encryption sequence data after subtracting 1 is equal to the value of the message encryption sequence data, jump to step S414, otherwise, jump to step S413; S413, marking the client request as a SYN FLOOD attack, creating a corresponding new blocking session, rejecting the client request, initializing the timeout time and TCP blocking times of the new blocking session, and updating the session data of the new blocking session into the session information table, wherein the initial value of the TCP blocking times of the new blocking session is 1; S414, creating a corresponding new normal session according to the client address and the client port corresponding to the client request, setting a timeout time and access count for the new normal session, generating a session index according to the quintuple data of the new normal session, and updating the session data and session index of the new normal session into the session information table; in, The session data includes session number, session type, five-tuple data, timeout period, message outgoing interface, TCP access times and TCP blocking times; The session types include blocking sessions and normal sessions; The five-tuple data includes a client address, a client port, a server address, a server port and a network protocol number.

7. The method according to claim 6, characterized in that In the step S414, after the value of the new message encryption sequence data is subtracted by 1 and verified, a three-way handshake connection establishment step is also included, specifically: 1) The load balancing device sends a three-way handshake connection request message to the server based on the new message encryption sequence data; 2) After parsing the access connection request message, the server returns confirmation information to the load balancing device and provides resources for the three-way handshake connection, including server address, server port, network protocol number, access rights, storage space and computing resources; 3) The load balancing device receives the confirmation information returned by the server and sends a message of successful connection to the client; 4) The client sends a traffic access request based on the successful connection message and the resources of the three-way handshake connection.

8. The method according to claim 6, characterized in that After creating a session, the following steps are also included to clear the session: If the timeout time of the session is greater than the current time, clearing the session and deleting the session index and session data of the session from the session information table; If the TCP access count of the session is greater than the preset access count, or the TCP blocking count of the session is greater than the preset blocking count, clearing the session and deleting the session index and session data of the session from the session information table; The preset number of accesses and the preset number of blockings are both set according to actual needs.

9. A system for implementing the optimization method for resisting SYN FLOOD attack according to claim 1, characterized in that: The system includes an initialization processing module, a request pre-processing module, a message reply module and a message verification processing module; in, The initialization processing module is used to define an attack defense data structure according to a network request processing flow, and to create a session information table based on the attack defense data structure; The request preprocessing module is used to receive the client request in real time through the load balancing device, obtain the synchronization mark message, the client address and the client port sent by the client according to the client request, and perform session comparison processing on the client request from the session information table according to the client address and the client port based on the attack defense data structure; The message reply module is used to generate a message reply sequence number according to the synchronization mark message based on the result of the session comparison processing, and send the message reply sequence number to the client; The message verification processing module is used to receive and verify the confirmation mark message returned by the client, return and block the SYN FLOOD attack according to the verification result, and update the session information table at the same time; In the process of performing session comparison processing on the client request, the client request will be directly blocked according to the session data in the session information table, or a server access connection will be created for the client; The step of performing session comparison processing on the client request from the session information table according to the client address and the client port based on the attack defense data structure further includes: S2-1, parsing the client request, and obtaining a synchronization flag message corresponding to the client request, as well as the client address and the client port according to the parsing result; S2-2, traversing the session information table according to the client address and the client port, if the client address and the client port exist in the session information table, jumping to step S2-3, if the client address and the client port do not exist in the session information table, jumping to step S2-4; S2-3, acquiring a session number and a session type of a corresponding session according to the client address and the client port, and performing session processing on the client request based on the session type of the session; S2-4, generating message encryption sequence data according to the synchronization mark message corresponding to the client request, generating the message reply sequence number according to the message encryption sequence data, and sending the first reply message to the client based on the message reply sequence number.

Citation Information

Patent Citations

  • Method and device for preventing attack under transmission control protocol (TCP)

    CN102780688A

  • Attack protection method and device for server, storage medium and electronic device

    CN110198293A

  • Thwarting SYN flood ddos attacks

    US20230048431A1