Disclosure of Invention
In view of the above, the present invention provides an attack simulation method, system, storage medium and electronic device that overcome or at least partially address the above-mentioned problems.
In a first aspect, an attack simulation method is applied to an attack simulation system, where the attack simulation system includes: the system comprises a Web server, a CDN server, attack simulation equipment and access simulation equipment;
the Web server is connected with the CDN server, and both the attack simulation device and the access simulation device are connected with the CDN server;
the attack simulation method comprises the following steps:
the attack simulation equipment constructs an attack simulation request and sends the attack simulation request to the CDN server, wherein the attack simulation request is a request for a first resource which is stored in the Web server and is not stored in the CDN server, and the attack simulation request conforms to the request format requirement of the CDN server and does not conform to the request format requirement of the Web server;
the CDN server sends the attack simulation request to the Web server to request the first resource;
the Web server returns an error response aiming at the simulated attack request to the CDN server, wherein the error response is an error reporting response which represents that the Web server cannot normally process the simulated attack request;
caching, by the CDN server, the error response locally as a response to the first resource;
when the CDN server receives a first resource acquisition request sent by the access simulation device, the CDN server returns the error response of the local cache to the access simulation device, so that the access simulation device cannot acquire the first resource.
With reference to the first aspect, in some optional embodiments, when the CDN server receives the first resource obtaining request sent by the access simulation device, the returning, by the CDN server, the error response cached locally to the access simulation device includes:
when the CDN server receives a first resource obtaining request sent by the access simulation equipment, the CDN server analyzes the first resource obtaining request and sends the error response of the local cache to the access simulation equipment as the first resource, wherein the first resource obtaining request meets the request format requirement of the CDN server.
With reference to the first aspect, in some optional embodiments, the attack simulation request is an HTTP request;
the method further comprises the following steps:
the CDN server cannot verify the auxiliary header, and an HTTP method supported by the Web server is different from the HTTP method of the auxiliary header in the attack simulation request;
the attack simulation device constructs an attack simulation request and sends the attack simulation request to the CDN server, and the method specifically comprises the following steps:
the attack simulation device constructs an attack simulation request carrying the auxiliary header and sends the attack simulation request to the CDN server, wherein the auxiliary header guides the Web server to replace an HTTP method in the attack simulation request with an HTTP method supported by the Web server.
With reference to the first aspect, in some optional embodiments, the attack simulation request is an HTTP request;
the method further comprises the following steps:
the first length threshold of the HTTP request limited by the CDN server is larger than the second length threshold of the HTTP request limited by the Web server;
the attack simulation device constructs an attack simulation request and sends the attack simulation request to the CDN server, and the method specifically comprises the following steps:
the attack simulation device inserts at least one numerical value into an attack simulation request and sends the attack simulation request to the CDN server, wherein the length of the attack simulation request is not greater than the first length threshold, and the length of the attack simulation request is greater than the second length threshold.
With reference to the first aspect, in some optional embodiments, the attack simulation request is an HTTP request;
the method further comprises the following steps:
the CDN server allows the request for inserting the Unicode control characters to be received, and the Web server prevents the request for inserting the Unicode control characters from being received;
the method comprises the steps that the attack simulation equipment constructs an attack simulation request and sends the attack simulation request to the CDN server, and specifically comprises the following steps:
the attack simulation equipment inserts at least one Unicode control character into the attack simulation request, wherein the Unicode control character comprises: an enter symbol \ n and a line feed symbol \ r.
In a second aspect, an attack simulation system includes: the system comprises a Web server, a CDN server, attack simulation equipment and access simulation equipment;
the Web server is connected with the CDN server, and both the attack simulation device and the access simulation device are connected with the CDN server;
the CDN server includes: the device comprises a request forwarding unit, a response caching unit and a response sending unit;
the attack simulation device is configured to execute and construct an attack simulation request and send the attack simulation request to the CDN server, where the attack simulation request is a request for a first resource which is stored in the Web server and is not stored in the CDN server, and the attack simulation request conforms to a request format requirement of the CDN server and does not conform to a request format requirement of the Web server;
the request forwarding unit is configured to execute sending the attack simulation request to the Web server to request the first resource;
the Web server returns an error response aiming at the simulated attack request to the CDN server, wherein the error response is an error reporting response which represents that the Web server cannot normally process the simulated attack request;
the response caching unit is configured to perform caching of the error response locally as a response to the first resource;
the response sending unit is configured to execute that when the CDN server receives a first resource acquisition request sent by the access simulation device, the error response of the local cache is returned to the access simulation device, so that the access simulation device cannot acquire the first resource.
With reference to the second aspect, in some optional embodiments, the response sending unit is specifically configured to, when the CDN server receives a first resource obtaining request sent by the access simulation device, parse the first resource obtaining request, and send the locally cached error response as the first resource to the access simulation device, where the first resource obtaining request meets a request format requirement of the CDN server.
With reference to the second aspect, in some optional embodiments, the attack simulation device is specifically configured to perform: and constructing an attack simulation request carrying the auxiliary header and sending the attack simulation request to the CDN server, wherein the CDN server cannot verify the auxiliary header, an HTTP method supported by the Web server is different from the HTTP method of the auxiliary header in the attack simulation request, and the auxiliary header guides the Web server to replace the HTTP method in the attack simulation request with the HTTP method supported by the Web server.
In a third aspect, a storage medium has a program stored thereon, and the program realizes the attack simulation method according to any one of the above when executed by a processor.
In a fourth aspect, an electronic device includes at least one processor, and at least one memory, a bus, connected to the processor; the processor and the memory complete mutual communication through the bus; the processor is configured to call program instructions in the memory to perform any of the attack simulation methods described above.
By means of the technical scheme, the attack simulation method, the system, the storage medium and the electronic device provided by the invention can construct an attack simulation request through the attack simulation device and send the attack simulation request to the CDN server, wherein the attack simulation request is a request for a first resource which is stored in the Web server and is not stored in the CDN server, and the attack simulation request conforms to the request format requirement of the CDN server and does not conform to the request format requirement of the Web server; the CDN server sends the attack simulation request to the Web server to request the first resource; the Web server returns an error response aiming at the simulated attack request to the CDN server, wherein the error response is an error reporting response which represents that the Web server cannot normally process the simulated attack request; caching, by the CDN server, the error response locally as a response to the first resource; when the access simulation device requests the first resource to the CDN service, the CDN server returns the error response of the local cache to the access simulation device, so that the access simulation device cannot obtain the first resource. Therefore, the method and the system can simulate the attack on the CDN server so as to make the resources on the CDN server unavailable. The simulation attack of the invention is closer to the actual attack, and the simulation attack effect is better. And then, a corresponding active defense mechanism can be set for the CDN server subsequently according to the process and the result of the simulated attack.
The foregoing description is only an overview of the technical solutions of the present invention, and the embodiments of the present invention are described below in order to make the technical means of the present invention more clearly understood and to make the above and other objects, features, and advantages of the present invention more clearly understandable.
Detailed Description
Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
As shown in fig. 1, the present invention provides an attack simulation method applied to an attack simulation system, where the attack simulation system includes: the system comprises a Web server, a CDN server, attack simulation equipment and access simulation equipment;
the Web server is connected with the CDN server, and both the attack simulation device and the access simulation device are connected with the CDN server;
the attack simulation method comprises the following steps:
s100, the attack simulation device constructs an attack simulation request and sends the attack simulation request to the CDN server, wherein the attack simulation request is a request for a first resource which is stored in the Web server and is not stored in the CDN server, and the attack simulation request conforms to the request format requirement of the CDN server and does not conform to the request format requirement of the Web server;
optionally, the connection between the Web server and the CDN server may be understood as: the Web server and the CDN server may perform communication access with each other, and the connection between the attack simulation device and the access simulation device and the CDN server may also be understood as: the attack simulation device may perform communication access with the CDN server, and the access simulation device may perform communication access with the CDN server, which is not limited in the present invention.
Optionally, the attack simulation device in the present invention may be a computer, or other devices that can construct an attack simulation request, for example, a device that constructs an HTTP request, and the present invention is not limited thereto.
Optionally, the present invention simulates an attack on the CDN server by using the caching capabilities of the CDN servers distributed in different geographic locations, and sends an incorrect HTTP request (a correct HTTP request for the CDN server, but an incorrect HTTP request for the Web server). Incorrect fields may be included in the request, but these incorrect fields are ignored by the CDN server, and the CDN server does not have the resources involved in the HTTP request. The CDN server forwards the HTTP request to the Web server, and the Web server responds to the wrong HTTP request and returns a page of the wrong response to the CDN server. These pages of error responses may be cached by an intermediate CDN server and returned to the attack simulation device. Subsequently, if the CDN server receives a request for the corresponding resource from another device, the CDN server that has cached the corresponding error response may send the error response to the other device, thereby truly simulating a process in which the CDN server is attacked by a malicious HTTP request, resulting in a normal request of the other device failing to obtain the corresponding correct resource.
The attack simulation request conforms to the request format requirement of the CDN server and does not conform to the request format requirement of the Web server, which can be understood as: the attack simulation request includes incorrect fields, but based on an operation mechanism of the CDN server, the CDN server ignores the fields, so that the attack simulation request is considered to be a normal request, but an error is caused when the Web server processes the attack simulation request, and the attack simulation request may be lower than a detection threshold of a Web application firewall and a distributed denial of service attack (DDoS) protection means, which is not limited by the present invention.
S200, the CDN server sends the attack simulation request to the Web server to request the first resource;
optionally, the CDN server may not specifically analyze the attack simulation request, so that an incorrect field in the attack simulation request is not found, and a general CDN server does not determine whether a certain request meets the format requirement of the Web server.
Optionally, the CDN server forwards the attack simulation request that is not compliant with the format requirement for the Web server to the Web server, but for the CDN server, the CDN server considers that the attack simulation request is a normal request for the first resource, and when the subsequent CDN receives a response returned by the Web request, the Web server is also used as the "first resource", and the response returned by the Web server may be an erroneous response for the first resource, instead of the true first resource, which is not limited by the present invention.
S300, the Web server returns an error response aiming at the simulated attack request to the CDN server, wherein the error response is an error reporting response for representing that the Web server cannot normally process the simulated attack request;
optionally, the error response to the simulated attack request may be understood as: the Web server analyzes the attack simulation request according to the self format, and the request contains the content except the normal service of the Web server, so that an error response is generated, and the Web server returns the error response aiming at the first resource.
Alternatively, the error response may be a response like an error response, for example, a response of "web page lost" displayed by browsing the web page at ordinary times, which is not limited by the present invention.
S400, caching the error response as a response aiming at the first resource in a local place by the CDN server;
s500, when the CDN server receives a first resource obtaining request sent by the access simulation equipment, the CDN server returns the error response of the local cache to the access simulation equipment, so that the access simulation equipment cannot obtain the first resource.
Optionally, when seen by the CDN server, the CDN server sends a correct request to the Web server, a response returned by the Web server may be used as a correct response for the first resource, and when the subsequent other device requests the first resource from the CDN server, the CDN server sends the cached corresponding response to the devices, which is not limited in this embodiment of the present invention.
Optionally, the present invention may simulate an attack on the CDN server, so that resources on the CDN server are unavailable. The simulation attack of the invention is closer to the actual attack condition, and the simulation attack effect is better. And then, a corresponding active defense mechanism can be set for the CDN server subsequently according to the process and the result of the simulated attack, so that the attack on the CDN server can be actively defended, and the method is not limited.
In some optional embodiments, in combination with the embodiment shown in fig. 1, the S500 includes:
when the CDN server receives a first resource obtaining request sent by the access simulation equipment, the CDN server analyzes the first resource obtaining request and sends the error response of the local cache to the access simulation equipment as the first resource, wherein the first resource obtaining request meets the request format requirement of the CDN server.
Optionally, the first resource obtaining request may be understood as: the present invention is not limited in this respect to the request for acquiring the first resource.
In some optional embodiments, in combination with the embodiment shown in fig. 1, the attack simulation request is an HTTP request;
the method further comprises the following steps:
the CDN server cannot verify the auxiliary header, and an HTTP method supported by the Web server is different from the HTTP method of the auxiliary header in the attack simulation request;
the S100 specifically comprises the following steps:
the attack simulation device constructs an attack simulation request carrying the auxiliary header and sends the attack simulation request to the CDN server, wherein the auxiliary header guides the Web server to replace an HTTP method in the attack simulation request with an HTTP method supported by the Web server.
Alternatively, other HTTP methods described herein may include: GET, POST, DELATE, PUT, and PATCH, as the present invention is not limited in this respect.
For example, as shown in fig. 2, in step (r): the attack simulation device uses the auxiliary header X-HTTP-Method-Override in the attack simulation request.
Step two: the CDN server does not process, analyzes the attack simulation request into a normal GET request, and directly forwards the request to the Web server.
Step three: the X-HTTP-Method-Override guides the Web server to cover the GET Method in the attack simulation request by using the POST Method, so that the attack simulation request is analyzed into the POST request, however, the Web server does not respond to the POST request of index. Html can be understood as the first resource, and the invention is not limited.
Step IV: the CDN server returns an error response to the attack simulation equipment.
Step five: error responses are transmitted between CDN servers, and certainly, error responses are not transmitted between CDN servers, which is not limited in the present invention.
Step (c): html sends a normal request for index to the CDN server.
Step (c): and the CDN server directly multiplexes the cached error response and directly returns the cached error response aiming at the GET request of index.
In some optional embodiments, in combination with the embodiment shown in fig. 1, the attack simulation request is an HTTP request;
the method further comprises the following steps:
the first length threshold of the HTTP request limited by the CDN server is larger than the second length threshold of the HTTP request limited by the Web server;
the S100 specifically comprises the following steps:
the attack simulation device inserts at least one numerical value into an attack simulation request and sends the attack simulation request to the CDN server, wherein the length of the attack simulation request is not greater than the first length threshold, and the length of the attack simulation request is greater than the second length threshold.
Optionally, the HTTP standard does not define any size limit for the request header, so that there is a difference between the size limits of the request headers of the Web server and the CDN server, and a simulated attack can be implemented using the difference, which is not limited by the present invention.
Optionally, a larger length of content may be inserted in the auxiliary header of the attack simulation request, such that the length of the attack simulation request is not greater than the first length threshold but greater than the second length threshold. Of course, a value may be inserted into other parts of the attack simulation request, which is not limited by the present invention.
Optionally, the length of the attack simulation request is not greater than the first threshold, so that the CDN server may forward the attack simulation request to the Web server; the length of the attack simulation request is greater than the second threshold, so that the Web server blocks the attack simulation request and returns an error response, which is not limited by the present invention.
In some optional embodiments, in combination with the embodiment shown in fig. 1, the attack simulation request is an HTTP request;
the method further comprises the following steps:
the CDN server allows the request of inserting the Unicode control character to be received, and the Web server prevents the request of inserting the Unicode control character from being received;
the S100 specifically includes:
the attack simulation equipment inserts at least one Unicode control character into the attack simulation request, wherein the Unicode control character comprises: the carriage return symbol \ n and the line feed symbol \ r.
Optionally, at least one Unicode control character may be inserted into the auxiliary header of the attack simulation request, so that when the Web server parses the attack simulation request, the Web server parses the attack simulation request that the Unicode control character is inserted into the attack simulation request; the Web server discards the attack simulation request containing the Unicode control character and returns a corresponding error response, which is not limited by the invention.
Optionally, the Web server discards the request containing the Unicode control character when receiving the request, which is a protection mechanism of the Web server, and the present invention is not limited thereto.
Optionally, the invention can also be used for attacking some illegal devices. For example, the CDN server may be a device for storing illegal data, and for the illegal devices, the method of the present invention may be used to attack the illegal devices, so that the data on the illegal devices cannot be used by the suspicious part, which is not limited by the present invention.
As shown in fig. 3, an attack simulation system includes: a Web server 100, a CDN server 200, an attack simulation device 300, and an access simulation device 400;
the Web server 100 is connected to the CDN server 200, and both the attack simulation device 300 and the access simulation device 400 are connected to the CDN server 200;
the CDN server 200 includes: the device comprises a request forwarding unit, a response caching unit and a response sending unit;
the attack simulation device 300 is configured to execute building of an attack simulation request, and send the attack simulation request to the CDN server 200, where the attack simulation request is a request for a first resource stored in the Web server 100 and not stored in the CDN server 200, and the attack simulation request meets a request format requirement of the CDN server 200 and does not meet a request format requirement of the Web server 100;
the request forwarding unit is configured to execute sending the attack simulation request to the Web server 100 to request the first resource;
the Web server 100 returns an error response for the simulated attack request to the CDN server 200, where the error response is an error reporting response that indicates that the Web server 100 cannot normally process the simulated attack request;
the response caching unit is configured to perform caching of the error response locally as a response to the first resource;
the response sending unit is configured to execute, when the CDN server 200 receives the first resource obtaining request sent by the access simulation device 400, returning the error response of the local cache to the access simulation device 400, so that the access simulation device 400 cannot obtain the first resource.
With reference to the embodiment shown in fig. 3, in some optional embodiments, the response sending unit is specifically configured to perform: when the CDN server 200 receives a first resource acquisition request sent by the access simulation device 400, parse the first resource acquisition request, and send the error response cached locally to the access simulation device 400 as the first resource, where the first resource acquisition request meets a request format requirement of the CDN server 200.
In some optional embodiments, in combination with the embodiment shown in fig. 3, the attack simulation device 300 is specifically configured to perform: an attack simulation request carrying the auxiliary header is constructed and sent to the CDN server 200, wherein the CDN server 200 cannot verify the auxiliary header, and the HTTP method supported by the Web server 100 is different from the HTTP method of the auxiliary header in the attack simulation request, and the auxiliary header guides the Web server 100 to replace the HTTP method in the attack simulation request with the HTTP method supported by the Web server 100.
Optionally, in combination with the embodiment shown in fig. 3, in some optional embodiments, the attack simulation device 300 is specifically configured to perform:
inserting at least one numerical value into the attack simulation request, and sending the attack simulation request to the CDN server 200, wherein the length of the attack simulation request is not greater than the first length threshold, and the length of the attack simulation request is greater than the second length threshold, wherein the first length threshold of the HTTP request restricted by the CDN server 200 is greater than the second length threshold of the HTTP request restricted by the Web server 100, and the attack simulation request is an HTTP request.
Optionally, in combination with the embodiment shown in fig. 3, in some optional embodiments, the attack simulation device 300 is specifically configured to perform:
inserting at least one Unicode control character into the attack simulation request, wherein the Unicode control character comprises: an enter symbol \ n and a linefeed symbol \ r, wherein the attack simulation request is an HTTP request, the CDN server 20 allows receiving a request for inserting a Unicode control character, and the Web server 100 prevents receiving a request for inserting a Unicode control character.
The present invention provides a storage medium having stored thereon a program which, when executed by a processor, implements the attack simulation method of any one of the above.
As shown in fig. 4, the present invention provides an electronic device 70, where the electronic device 70 includes at least one processor 701, at least one memory 702 connected to the processor 701, and a bus 703; the processor 701 and the memory 702 complete communication with each other through the bus 703; the processor 701 is configured to call the program instructions in the memory 702 to execute any one of the attack simulation methods described above.
In this application, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
All the embodiments in the present specification are described in a related manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment focuses on differences from other embodiments. In particular, as for the system embodiment, since it is substantially similar to the method embodiment, the description is relatively simple, and reference may be made to the partial description of the method embodiment for relevant points.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
The above description is only for the preferred embodiment of the present invention, and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention shall fall within the protection scope of the present invention.