Request message generation method and device and site security test method and device

By parsing the YAML template to generate the target request message, the problem of low efficiency in manually constructing HTTP data packets is solved, and efficient site security testing and evaluation is achieved.

CN120658445AActive Publication Date: 2025-09-16BEIJING ZHIQIAN TECH CO LTD
View PDF 9 Cites 0 Cited by

Patent Information

Application Number
CN202510765380.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-10
Publication Date
2025-09-16
Estimated Expiration
2045-06-10

Smart Images

  • Figure CN120658445A_ABST
    Figure CN120658445A_ABST
Patent Text Reader

Abstract

The invention discloses a request message generation method, and relates to the technical field of computers, and the specific implementation scheme is as follows: obtaining a request message template, the request message template being a template of a request message, and the request message being communication data sent by a client to a server; analyzing the request message template to obtain template analysis data including a specified field representing at least one type of site information; acquiring specified data of the specified field so as to determine site information of the target site through the specified data; and the target request message which can be sent to the target site is generated based on the template analysis data and the specified data, so that the flexibility of request message generation is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of computer technology, in particular to the technical fields of network security, security operation, security testing, etc., and more particularly relates to a request message generation method and device, a site security testing method and device, an electronic device, and a computer-readable storage medium. Background Art

[0002] A Web Application Firewall (WAF) is a product that provides protection for Web application servers by implementing a series of HTTP / HTTPS security policies.

[0003] When testing a WAF, a large number of HTTP (Hypertext Transfer Protocol) packets must be sent, and each HTTP packet must have a unique identifier for identification. Traditional techniques typically rely on manually constructing HTTP packets, but this is inefficient and significantly impacts WAF testing efficiency.

[0004] The information disclosed in this background section is only intended to enhance understanding of the overall background of the invention and should not be considered as an admission or any form of suggestion that the information constitutes the prior art already known to a person skilled in the art. Summary of the Invention

[0005] The purpose of the present disclosure is to solve the technical problem of low efficiency when manually constructing request messages or testing target sites, and provides a request message generation method and device, a site security testing method and device, an electronic device, and a non-transitory computer-readable storage medium storing computer instructions.

[0006] The first aspect of the present disclosure provides a request message generation method, which includes: obtaining a request message template, which is a template of a request message, and the request message is communication data sent by a client to a server; parsing the request message template to obtain template parsing data including a specified field representing at least one site information; obtaining specified data of the specified field to determine the site information of the target site through the specified data; and generating a target request message that can be sent to the target site based on the template parsing data and the specified data.

[0007] The second aspect of the present disclosure provides a site security testing method, which includes: obtaining a target request message related to a target site, the target request message being generated using a request message generation method as described in any implementation of the first aspect; establishing a connection with the target site; sending the target request message to the target site; obtaining response information fed back by the target site; and generating a security assessment result for the target site based on the response information.

[0008] The third aspect of the present disclosure provides a request message generating device, which includes: a template acquiring unit, configured to acquire a request message template, where the request message template is a template of a request message, and the request message is communication data sent by a client to a server; a parsing unit, configured to parse the request message template to obtain template parsed data including a specified field representing at least one site information; a data acquiring unit, configured to acquire specified data of a specified field to determine the site information of a target site through the specified data; and a message generating unit, configured to generate a target request message that can be sent to a target site based on the template parsed data and the specified data.

[0009] The fourth aspect of the present disclosure provides a site security testing device, which includes: a message acquisition unit, configured to acquire a target request message related to a target site, where the target request message is generated using the request message generation method described in any implementation of the third aspect; a connection unit, configured to establish a connection with the target site; a sending unit, configured to send the target request message to the target site; a response acquisition unit, configured to acquire response information fed back by the target site; and a result generation unit, configured to generate a security assessment result of the target site based on the response information.

[0010] According to the fifth aspect, an electronic device is provided, which includes: at least one processor; and a memory communicatively connected to the at least one processor, wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the method described in any implementation of the first aspect or the second aspect.

[0011] According to a sixth aspect, a non-transitory computer-readable storage medium storing computer instructions is provided, where the computer instructions are used to cause a computer to execute the method described in any implementation of the first aspect or the second aspect.

[0012] The request message generation method and device provided by the embodiments of the present disclosure first obtain a request message template, which is a template of a request message, and a request message is communication data sent by a client to a server; secondly, the request message template is parsed to obtain template parsing data including a specified field representing at least one site information; thirdly, the specified data of the specified field is obtained to determine the site information of the target site through the specified data; finally, based on the template parsing data and the specified data, a target request message that can be sent to the target site is generated. Thus, by filling in the specified data in the template parsing data of the parsed request message template, the target request message is automatically generated without manual intervention, thereby improving the efficiency of generating the target request message; the present disclosure can generate target request messages in batches, saving the cost of generating target request messages. BRIEF DESCRIPTION OF THE DRAWINGS

[0013] Figure 1 is a flowchart of an embodiment of a method for generating a request message according to the present disclosure;

[0014] Figure 2 This is a schematic diagram of the structure of the public request message template;

[0015] Figure 3 is a flow chart of an embodiment of a site security testing method according to the present disclosure;

[0016] Figure 4 is a structural diagram of an embodiment of a request message generating device according to the present disclosure;

[0017] Figure 5 is a structural diagram of an embodiment of a site security testing device according to the present disclosure;

[0018] Figure 6 It is a block diagram of an electronic device used to implement the request message generation method or the site security testing method according to the embodiment of the present disclosure. DETAILED DESCRIPTION

[0019] Unless expressly stated otherwise, throughout the specification and claims, the term "comprise" or variations such as "include" or "comprising", etc., will be understood to include the stated elements or components but not to exclude other elements or other components.

[0020] The technical solutions of the present invention are described below by means of specific embodiments. It should be understood that one or more steps mentioned in the present invention do not exclude the presence of other methods and steps before and after the combination step, or other methods and steps may be inserted between these explicitly mentioned steps. It should also be understood that these examples are only used to illustrate the present invention and are not used to limit the scope of the present invention. Unless otherwise specified, the numbering of each method step is only for the purpose of identifying each method step, and does not limit the order of arrangement of each method or the scope of implementation of the present invention. Changes or adjustments in their relative relationships can also be regarded as the scope of implementation of the present invention without substantial changes in the technical content.

[0021] The sources of the raw materials and instruments used in the examples are not particularly limited and can be purchased from the market or prepared according to conventional methods known to those skilled in the art.

[0022] BAS (Breach and Attack Simulation) is an automated security testing technology used to simulate real-world network attacks and assess the strength and effectiveness of enterprise defense systems. By simulating various attack scenarios, BAS helps identify security vulnerabilities, configuration errors, and defensive weaknesses, ensuring that security measures are effective against real-world threats. When testing target sites, BAS requires constructing a large number of request message packets, such as HTTP (Hypertext Transfer Protocol) packets. Constructing these packets presents the following challenges:

[0023] The cost and speed of constructing a large number of data packets, due to the diversity of malicious data packets, will greatly reduce efficiency if the template cannot be configured to be simple, intuitive or scalable.

[0024] The ability to dynamically generate different data packets is required because each data packet contains a unique identifier for the test and also has fields that change dynamically based on each different target site (such as the Host header).

[0025] The data packet sending process must be controllable to the target. Since the target site's system mostly gives the form of a domain name, such as https: / / www.zhiqiansec.com, such a target site may get multiple IP addresses A, B, and C after domain name resolution. If it is required to use the B address to test https: / / www.zhiqiansec.com during the entire packet sending test process, then the overall connection process needs to be fixed.

[0026] The above problems are all unresolved problems in traditional technologies and need to be solved in a reasonable way.

[0027] In view of the defects in the prior art, the present invention provides a method for generating a request message. Figure 1 A process 100 of an embodiment of a method for generating a request message is shown. The method for generating a request message includes the following steps:

[0028] Step 101: Obtain a request message template.

[0029] In this embodiment, a request message is communication data sent by a client to a server to request specific resources or trigger the server to perform specific operations. In computer networks, particularly under the HTTP protocol, request messages are a core component of client-server interaction. Request messages are typically sent to the server in the form of data packets. The target request message is a request message that meets business or development requirements.

[0030] In this embodiment, the request message template is a template of the above-mentioned request message. The request message template is a template for defining the structure and content of the request message. According to the content of the request message, the request message template can be divided into multiple areas, and each area can represent different contents of the request message. Specifically, the request message template can adopt a YAML template. The YAML format is easy to read and write, and is suitable for configuring complex HTTP request messages. The YAML template is a template that defines the structure and content of the request message implemented in the YAML (abbreviation of YAML Ain'tMarkup Language) language, which can be used in scenarios such as configuration files, data exchange, and object persistence. Among them, the YAML language is a text-based markup language for data serialization.

[0031] In this embodiment, the request message template records the common structure and content of various types of request messages. For example, the request message template is divided into four areas: request line, request header, space, and request body. Each area can record different structures and contents of the request message. For example, the request line area records the request method, URL (Uniform Resource Locator) field and the placeholder corresponding to the URL field and the protocol version; the request header area records useful information about the client environment and the request body; the space area is simply a blank line, used to indicate the end of the request header, and the request body area can record content or not. When no content is recorded, it is determined that the request message has no request body. Among them, the URL (Uniform Resource Locator) field is a designated field, and the placeholder corresponding to the URL field and the protocol version are the site information of the site to be filled.

[0032] Step 102: Parse the request message template to obtain template parsing data including a designated field representing at least one site information.

[0033] In this embodiment, the request message template records the structure and content of the request message. By parsing the content in the request message template, such as determining which content represents the request method in the request line of the request message, general information of the request message can be determined.

[0034] In this embodiment, the designated field can be a field in the request message protocol that can be flexibly changed according to business needs or specifically designated as a site, such as a URL field. Since the actual content of the designated field needs to be specified, the designated field is recorded in the request message template and a corresponding location for the actual content of the designated field can be provided. After parsing the request message template, the designated field and the location of the actual content corresponding to the designated field can be obtained. The template parsed data is data obtained after interpreting the request message format and content of the information recorded in the request message template. The template parsed data includes a designated field, and the location of the actual content corresponding to the designated field can be determined through the designated field.

[0035] The above-mentioned step 102 includes: determining the request protocol of the target request message, identifying the information in the request message template according to the request protocol; detecting whether the specified field in the request message template is identified, and in response to identifying the specified field of the request message template, placing a corresponding space in the specified field, and continuing to identify the information in the request message template until all the information in the request message template is identified, thereby obtaining template parsing data including the specified field.

[0036] Step 103: Acquire designated data of a designated field to determine site information of the target site through the designated data.

[0037] In this embodiment, the specified data is the data that actually needs to be filled in the specified field, that is, the site information corresponding to the specified field. The specified data can be directly specified by the R&D personnel, or it can be the data automatically generated according to the target request message generation requirements when the target request messages are generated in batches. For example, when generating target request messages in batches, it is necessary to generate target request messages for the target site, then the URL of the target site is directly determined, and the URL is used as the specified data of the URL field. The URL is the site information of the target site.

[0038] Step 104: generating a target request message that can be sent to the target site based on the template parsing data and the specified data.

[0039] In this embodiment, the specified data is filled into the position corresponding to the specified field in the template parsed data to obtain the filled data, and the filled data is packaged according to the preset message protocol to generate a target request message that can be sent to the target site. The target request message is parsed by a specific data parser to determine the site information of the target site, and the target request message is sent to the target site based on the site information.

[0040] The request message generation method provided by the embodiment of the present disclosure first obtains a request message template, which is a template of a request message, and the request message is the communication data sent by the client to the server; secondly, the request message template is parsed to obtain template parsing data including a specified field representing at least one site information; thirdly, the specified data of the specified field is obtained to determine the site information of the target site through the specified data; finally, based on the template parsing data and the specified data, a target request message that can be sent to the target site is generated. Thus, by filling in the specified data in the template parsing data of the parsed request message template, the target request message is automatically generated without manual intervention, thereby improving the efficiency of generating the target request message; the present disclosure can generate target request messages in batches, saving the cost of generating target request messages.

[0041] In some optional implementations of the present disclosure, the above-mentioned parsing of the request message template to obtain template parsing data including specified fields representing at least one site information includes: determining the message structure data and body content data in the request message template; sorting the data in the message structure data according to a preset message protocol to obtain protocol parsing data including specified fields representing at least one site information and specified placeholders; and using the protocol parsing data and body content data as template parsing data.

[0042] In this optional implementation, the message structure data is data that represents the structure of different types of request messages. The message structure data may include multiple fields corresponding to the protocols of different request messages, such as POST, HOST, etc. The message structure data may also include: the content corresponding to each field, such as HTTP / 1.1; the body content data is data that represents the request body of the request message, such as u0000.

[0043] In this optional implementation, the message structure data corresponds to the part of the request message other than the request body. By parsing the message structure data, the part of the request message other than the request body can be obtained; the body content data corresponds to the request body in the request message. The positions of the message structure data and body content data in the message template can be mapped to the request message format accordingly. Figure 2As shown, it is a request message template related to the HTTP protocol, which includes: a variable definition area, a first area where the message structure data is located, and a body content area. Among them, the variable definition area and the body content area are both areas where the body content data is located. The variable definition area is an area for defining the information corresponding to the variables of the body content data, and the body content area is the area where the request body in the message request is located.

[0044] In this optional implementation, the data in the message structure data is sorted according to the preset message protocol to obtain protocol parsing data including specified fields and specified placeholders, including: matching the data in the message structure data in sequence according to the fields in the preset message protocol, in response to the fact that the fields corresponding to the message protocol are all in the message structure data, taking the fields with placeholders in the information content as designated fields, and taking all successfully matched fields and the information content of the fields as protocol parsing data.

[0045] like Figure 2 As shown, variables define some variables in the body content data that need to be dynamically rendered, such as null_hex, null_b64, and null_raw. This variable can identify, for example, read files or binary byte information that is difficult to identify with text.

[0046] The information of http:attack:raw is posted with the HTTP text markup. The part that needs to be rendered can be marked with "{{", "}}" and variables defined in variables, such as "null_raw". The final result is "{{null_raw}}". The rendered part refers to the part that needs to be filled with the parsed data in the parsed request message template.

[0047] Figure 2 The request message template shown is a YAML template. The execution entity on which the request message generation method runs parses the YAML template and extracts various fields in the HTTP protocol, such as the HTTP method (POST in the figure), the HTTP relative URL (such as / upload.jsp), the HTTP protocol version (such as HTTP / 1.1), and HTTP headers (such as User-Agent, etc.) and other protocol parsing data as well as body content data (such as null_hex:{{null_hex}}null_b64:{{null_b64}}null_raw:{{null_raw}}), to obtain template parsed data.

[0048] This optional implementation provides a method for obtaining template parsing data, determining the message structure data and body content data in the request message template; sorting the data in the message structure data according to a preset message protocol to obtain protocol parsing data including specified fields and specified placeholders representing at least one site information; using the protocol parsing data and body content data as template parsing data, providing a reliable implementation method for the division of template parsing data.

[0049] In some optional implementations of the present disclosure, the above-mentioned generation of a target request message that can be sent to a target site based on template parsing data and specified data includes: identifying a specified placeholder from protocol parsing data; replacing the specified placeholder with specified data to obtain protocol message data; processing the body content data to obtain body key-value pairs; obtaining body extraction data based on the body key-value pairs; combining the protocol message data and the body extraction data in sequence according to the format of the message protocol to obtain a request message to be processed; performing binary data conversion on the request message to be processed to obtain a target request message that can be sent to the target site.

[0050] In this embodiment, the processing of the text content data to obtain the text key-value pairs includes: identifying a variable in the text content area and a variable value of the variable, and using the variable and the variable value as the text key-value pair. The obtaining of the text extracted data based on the text key-value pair includes: using the variable value in the text key-value pair as the text extracted data.

[0051] In this embodiment, the designated placeholder is a symbol pre-defined in the request message template, and different designated fields correspond to different designated placeholders; the text key-value pair consists of a key and a value, wherein the key can be a variable pre-defined in the request message template, the value can be the above-mentioned variable value, the variable value can be a value pre-set in the request message template, or a value obtained based on a pre-set rule.

[0052] like Figure 2 As shown in Host:{{Hostname}}, Host is the specified field and Hostname is the specified placeholder. The target request message can be obtained by replacing the specified placeholder with the specified data.

[0053] In this optional implementation, the request message to be processed is a data packet in the form of a string. In order to meet the preset message protocol requirements, the request message to be processed has multiple characters, such as carriage returns, space characters, etc., and the target request message is a data packet after the request message to be processed is converted into binary data. When the request message is actually sent, a binary data packet needs to be sent.

[0054] In this optional implementation, based on the variables or rules in the template and the unique identifier in the sent data packet, a target request message with a unique identifier, target site, dynamic variables defined in variables, and request message template data is generated to render the target request message.

[0055] The request message generation method provided by this optional implementation method divides the content in the request message template into message structure data and body content data when parsing the request message template, fills in the specified data after parsing the message structure data, and extracts the body content data after processing, thereby improving the accuracy of obtaining the target request message.

[0056] In some optional implementations of the present disclosure, the above-mentioned text content data includes: defining area variable key-value pairs and variable placeholders of different variables in the text area; processing the text content data to obtain text key-value pairs including at least one of the following: in response to the value of the variable in the variable key-value pair being an environment function in which the independent variable changes with the environment, calculating the value of the environment function, and replacing the variable placeholder of the variable with the value of the environment function to obtain the text key-value pair; in response to the value of the variable in the variable key-value pair being a fixed function in which the independent variable is a preset fixed value, calculating the value of the fixed function, and replacing the variable placeholder of the variable with the value of the fixed function to obtain the text key-value pair; in response to the value of the variable in the variable key-value pair being a preset fixed value, replacing the variable placeholder of the variable with the preset fixed value to obtain the text key-value pair.

[0057] exist Figure 2 In the example, hex_decode('00') is a fixed function whose independent variable is a fixed value of '00', base64_decode('AA==') is a fixed function whose independent variable is a fixed value of 'AA==', and \u0000 is a preset fixed value.

[0058] The method for processing text content data provided by this optional implementation performs respective processing according to different situations of the text content data to obtain corresponding text key-value pairs, provides multiple optional implementation methods for processing the text content data, and improves the comprehensiveness of the text content data processing.

[0059] For some types of request messages, the body request is empty or has a fixed value. There is no need to set variables specifically for the body in the request message template. Instead, the template can be parsed directly and the data can be parsed using the template that parses the request message template to generate a target request message that can be sent to the target site.

[0060] In some optional implementations of the present disclosure, the above-mentioned generation of a target request message that can be sent to a target site based on template parsed data and specified data includes: identifying a specified placeholder corresponding to a specified field from the template parsed data; replacing the specified placeholder with the specified data to obtain a request message to be processed; and performing binary data conversion on the request message to be processed to obtain a target request message that can be sent to the target site.

[0061] In this optional implementation, the part related to the body in the template parsing data is empty or a fixed value. Since the request message template is parsed based on a preset protocol when parsing the request message template, the template parsing data is data sorted according to the preset protocol.

[0062] In this optional implementation, the above-mentioned use of specified data to replace the specified placeholder to obtain the request message to be processed includes: using specified data to replace the specified placeholder to obtain template processing data; adding a character string related to the protocol in the template processing data according to the protocol of the target request message (such as the HTTP protocol) to obtain the request message to be processed.

[0063] In this optional implementation, the request message to be processed is a data packet in the form of a string. In order to meet the preset message protocol requirements, the request message to be processed contains multiple characters, such as carriage returns, space characters, etc., and the target request message is a data packet after the request message to be processed is converted into binary data. When the request message is actually sent, a binary data packet needs to be sent.

[0064] The method for generating a target request message provided by this optional implementation directly replaces the designated placeholder with designated data after determining the designated placeholder, thereby providing a reliable implementation method for obtaining the target request message.

[0065] In view of the defects in the prior art, this invention provides a site security testing method. Figure 3 A process 300 of an embodiment of a site security testing method is shown. The site security testing method includes the following steps:

[0066] Step 301: Acquire a target request message related to a target site.

[0067] In this embodiment, the target request message is generated by the request message generation method provided in any of the above embodiments. The target request is a request simulated by a request message template. Based on the differences in the content filled in the request message template, the target request message generated by the request message generation method can be a legitimate request message or an illegitimate request message, such as a malicious request.

[0068] Step 302: Establish a connection with the target site.

[0069] In this embodiment, the core means of establishing a connection with the target site can be divided into three categories: transport layer protocol control, application layer protocol implementation, and encrypted tunnel technology. When the message protocol of the target request message is different, the method of establishing a connection with the target site may be different. The method of establishing a connection with the target site is a conventional method and will not be repeated here.

[0070] Step 303: Send the target request message to the target site.

[0071] In this embodiment, the target request message is a data packet encapsulated in the format of a message protocol (such as the HTTP protocol). Sending the data packet to the target site can simulate a real protocol request and trigger the detection and response mechanism of a WAF or other security device.

[0072] Step 304: Obtain response information fed back by the target site.

[0073] In this embodiment, after sending the target request message, the execution entity on which the site security testing method is running will wait for the target site's response information and record the response information, which includes the status code, response headers, and response body. After receiving the target request message, the target site encapsulates the status line, response headers, and response body (e.g., HTML content or JSON data) into a response message in the format of a message protocol (e.g., HTTP protocol) and transmits it back to the execution entity via the established connection.

[0074] Step 305: Generate a security assessment result of the target site based on the response information.

[0075] In this embodiment, the security assessment result is the result of evaluating the security protection performance of the target site. The execution entity (such as the client) on which the site security testing method runs evaluates the security protection capability of the target site (such as whether the WAF successfully intercepts malicious requests) by analyzing the response information and gives a security assessment result, wherein the security assessment result may include: normal protection, abnormal protection, etc.

[0076] The site security testing method disclosed in the present invention performs security assessment on the target site by generating a target request message, and can support the generation of simulated attack means on a fast BAS and perform simulation and testing of real hacker intrusions.

[0077] The site security testing method provided in this embodiment first obtains a target request message related to the target site, generated using a request message generation method; secondly, establishes a connection with the target site; thirdly, sends the target request message to the target site; thirdly, obtains response information fed back by the target site; and finally, generates a security assessment result for the target site based on the response information. Thus, by using the request message generation method to generate a target request and perform a security assessment on the target site, the convenience of target site assessment is improved.

[0078] Generally, when connecting to a target site, the target site's system will only provide a domain name, which corresponds to multiple IP addresses. If the site security test requires the use of a specified IP address for testing, traditional security testing through domain names cannot control the communication path with the target site.

[0079] In some optional implementations of the present disclosure, the establishing of a connection with the target site includes: obtaining an IP address associated with the target site; and recommending a connection to the target site based on the IP address.

[0080] In this optional implementation, the IP address associated with the target site may be a fixed IP address specified by a developer as required by the site security testing method. Acquiring the IP address associated with the target site includes acquiring a fixed IP address corresponding to the target site specified by the developer. Proposing a connection to the target site based on the IP address includes establishing a TCP (Transmission Control Protocol, a connection-oriented, reliable, byte-stream-based transport layer communication protocol) connection with the target site before sending a target request message, and connecting based on the fixed IP address.

[0081] This optional implementation provides a method for establishing a connection with the target site, obtaining the IP address related to the target site; based on the IP address, a connection is recommended to the target site, and only a fixed IP address can be used to test the target site. The overall connection process of the fixed target site ensures the stability and controllability of the site security test of the target site, and avoids connection problems caused by DNS (Domain Name System) resolution or network fluctuations.

[0082] In some optional implementations of the present disclosure, before sending the target request message to the target site, the request message generation method further includes: in response to detecting that the message protocol of the target request message is Hypertext Transfer Protocol, performing legal verification avoidance processing on the target request message.

[0083] In this optional implementation, circumventing legal verification processing is a process that avoids legal verification of the HTTP protocol before sending. Because the HTTP data in the simulated security test often contains some data and configurations that violate the HTTP protocol itself, the verification of these target request messages before sending needs to be bypassed.

[0084] In this optional implementation, the aforementioned circumvention of legal verification processing for the target request message includes: verifying the target request message using a verification method in a third-party verification method library; collecting the verification results of the verification method in real time; obtaining a pass result based on the verification result, and sending the target request message with the pass result. Obtaining a pass result based on the verification result includes: in response to the target request message failing in the verification result, directly modifying the verification result to pass. It should be noted that the verification method in the third-party verification method library is a conventional verification method for verifying whether a request is qualified, and will not be repeated here.

[0085] The request message generation method provided by this optional implementation method, in response to detecting that the message protocol of the target request message is the Hypertext Transfer Protocol, performs a legal verification avoidance process on the target request message. When the target request message is a Hypertext Parameter Protocol message, the target request message is processed by avoiding legal verification process, so that both simulated normal request messages and abnormal request messages can be sent to the target site, effectively realizing the security test of the target site and improving the comprehensiveness of the security test of the target site.

[0086] Further references Figure 4 As an implementation of the methods shown in the above figures, the present disclosure provides an embodiment of a request message generating device, which is similar to Figure 1 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.

[0087] like Figure 4 As shown, the request message generating device 400 provided in this embodiment includes: a template acquiring unit 401, a parsing unit 402, a data acquiring unit 403, and a message generating unit 404. The template acquiring unit 401 is configured to acquire a request message template, which is a template of a request message, and the request message is communication data sent by the client to the server. The parsing unit 402 can be configured to parse the request message template to obtain template parsing data including a specified field representing at least one site information. The data acquiring unit 403 can be configured to acquire specified data of a specified field to determine the site information of the target site through the specified data. The message generating unit 404 can be configured to generate a target request message that can be sent to the target site based on the template parsing data and the specified data.

[0088] In this embodiment, the specific processing of the template acquisition unit 401, the parsing unit 402, the data acquisition unit 403, and the message generation unit 404 and the technical effects thereof can be referred to in the respective Figure 1The relevant descriptions of step 101, step 102, step 103, and step 104 in the corresponding embodiment are not repeated here.

[0089] In one embodiment of the present disclosure, the above-mentioned parsing unit 402 is configured to: determine the message structure data and body content data in the request message template; sort the data in the message structure data according to the preset message protocol to obtain protocol parsing data including specified fields and specified placeholders representing at least one site information; and use the protocol parsing data and body content data as template parsing data.

[0090] In one embodiment of the present disclosure, the above-mentioned message generation unit 404 is configured to: identify a specified placeholder from the protocol parsing data; replace the specified placeholder with specified data to obtain protocol message data; process the body content data to obtain a body key-value pair; obtain body extraction data based on the body key-value pair; combine the protocol message data and the body extraction data in sequence according to the format of the message protocol to obtain a request message to be processed; perform binary data conversion on the request message to be processed to obtain a target request message that can be sent to the target site.

[0091] In one embodiment of the present disclosure, the above-mentioned text content data includes: definition area variable key-value pairs and variable placeholders of different variables in the text area; the above-mentioned parsing unit 402 is configured to at least one of the following: in response to the value of the variable in the variable key-value pair being an environment function in which the independent variable changes with the environment, calculating the value of the environment function, and replacing the variable placeholder of the variable with the value of the environment function to obtain the text key-value pair; in response to the value of the variable in the variable key-value pair being a fixed function in which the independent variable is a preset fixed value, calculating the value of the fixed function, and replacing the variable placeholder of the variable with the value of the fixed function to obtain the text key-value pair; in response to the value of the variable in the variable key-value pair being a preset fixed value, replacing the variable placeholder of the variable with the preset fixed value to obtain the text key-value pair.

[0092] In one embodiment of the present disclosure, the above-mentioned message generation unit 404 is configured to: identify the specified placeholder corresponding to the specified field from the template parsing data; replace the specified placeholder with the specified data to obtain a request message to be processed; perform binary data conversion on the request message to be processed to obtain a target request message that can be sent to the target site.

[0093] In the request message generation device provided by the embodiment of the present disclosure, first, the template acquisition unit 401 acquires the request message template; second, the parsing unit 402 parses the request message template to obtain template parsed data including a specified field representing at least one site information; third, the data acquisition unit 403 acquires the specified data of the specified field to determine the site information of the target site through the specified data; finally, the message generation unit 404 generates a target request message that can be sent to the target site based on the template parsed data and the specified data. Thus, by filling the specified data in the template parsed data of the parsed request message template, the target request message is automatically generated without manual intervention, thereby improving the efficiency of target request message generation; through the present disclosure, target request messages can be generated in batches, saving the cost of generating target request messages.

[0094] Further references Figure 5 As an implementation of the methods shown in the above figures, the present disclosure provides an embodiment of a site security testing device. Figure 3 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.

[0095] like Figure 5 As shown, the site security testing device 500 provided in this embodiment includes: a message acquisition unit 501, a connection unit 502, a sending unit 503, a response acquisition unit 504, and a result generation unit 505. The message acquisition unit 501 can be configured to acquire a target request message related to a target site, where the target request message is generated using the request message generation device of the above embodiment. The connection unit 502 can be configured to establish a connection with the target site. The sending unit 503 can be configured to send the target request message to the target site. The response acquisition unit 504 can be configured to acquire response information fed back by the target site. The result generation unit 505 can be configured to generate a security assessment result for the target site based on the response information.

[0096] In this embodiment, the specific processing of the request message generating device 500: the message obtaining unit 501, the connecting unit 502, the sending unit 503, the response obtaining unit 504, and the result generating unit 505 and the technical effects thereof can be referred to respectively. Figure 3 The relevant descriptions of step 301, step 302, step 303, step 304, and step 305 in the corresponding embodiment are not repeated here.

[0097] In some embodiments of the present disclosure, the connection unit 502 is further configured to: obtain an IP address associated with the target site; and recommend a connection to the target site based on the IP address.

[0098] In some embodiments of the present disclosure, the above-mentioned device 500 also includes: a verification unit (not shown in the figure), and the above-mentioned verification unit is configured to: in response to detecting that the message protocol of the target request message is the Hypertext Transfer Protocol, perform legal verification avoidance processing on the target request message.

[0099] The site security testing device provided in this embodiment firstly performs a message acquisition unit 501 to acquire a target request message related to a target site, using a request message generation method. Secondly, a connection unit 502 establishes a connection with the target site. Thirdly, a sending unit 503 sends the target request message to the target site. Finally, a response acquisition unit 504 acquires the response information fed back by the target site. Finally, a result generation unit 505 generates a security assessment result for the target site based on the response information. Thus, by using the request message generation method to generate a target request message to perform a security assessment on the target site, the convenience of target site assessment is improved.

[0100] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium, and a computer program product.

[0101] Figure 6 A schematic block diagram of an example electronic device 600 that can be used to implement embodiments of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their modes are provided for example only and are not intended to limit the implementation of the present disclosure described and / or claimed herein.

[0102] like Figure 6 As shown, the device 600 includes a computing unit 601, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 602 or a computer program loaded from a storage unit 608 into a random access memory (RAM) 603. Various programs and data required for the operation of the device 600 can also be stored in the RAM 603. The computing unit 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.

[0103] Various components in device 600 are connected to I / O interface 605, including an input unit 606, such as a keyboard, mouse, etc.; an output unit 607, such as various types of displays, speakers, etc.; a storage unit 608, such as a magnetic disk, optical disk, etc.; and a communication unit 609, such as a network card, modem, wireless communication transceiver, etc. The communication unit 609 allows device 600 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.

[0104] The computing unit 601 can be any general-purpose and / or specialized processing component with processing and computing capabilities. Some examples of the computing unit 601 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various specialized artificial intelligence (AI) computing chips, various computing units that run machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 601 performs the various methods and processes described above, such as the request message generation method or the site security testing method. For example, in some embodiments, the request message generation method or the site security testing method can be implemented as a computer software program tangibly embodied in a machine-readable medium, such as the storage unit 608. In some embodiments, part or all of the computer program can be loaded and / or installed onto the device 600 via the ROM 602 and / or the communication unit 609. When the computer program is loaded into the RAM 603 and executed by the computing unit 601, one or more steps of the request message generation method or the site security testing method described above can be performed. Alternatively, in other embodiments, the computing unit 601 may be configured to execute the request message generating method or the site security testing method in any other appropriate manner (for example, by means of firmware).

[0105] Various embodiments of the systems and techniques described herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), system-on-chip systems (SOCs), programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include being implemented in one or more computer programs that are executable and / or interpreted on a programmable system that includes at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0106] Program code for implementing the methods of the present disclosure can be written in any combination of one or more programming languages. Such program code can be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable request message generating device or a site security testing device, such that when the program code is executed by the processor or controller, the modes / operations specified in the flowcharts and / or block diagrams are implemented. The program code can be executed entirely on the machine, partially on the machine, as a stand-alone software package, partially on the machine and partially on a remote machine, or entirely on a remote machine or server.

[0107] In the context of the present disclosure, a machine-readable medium can be a tangible medium that can contain or store a program for use by or in conjunction with an instruction execution system, device or equipment. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium can include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0108] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).

[0109] The systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network (LAN), a wide area network (WAN), and the Internet.

[0110] It should be understood that the various forms of the processes shown above can be used to reorder, add, or delete steps. For example, the steps described in this disclosure can be performed in parallel, sequentially, or in a different order, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved. This is not limited herein.

[0111] The foregoing descriptions of specific exemplary embodiments of the present invention are for purposes of illustration and description. These descriptions are not intended to limit the invention to the precise forms disclosed, and it is apparent that many variations and modifications are possible in light of the foregoing teachings. The exemplary embodiments have been selected and described for the purpose of explaining the specific principles of the invention and their practical application, thereby enabling those skilled in the art to realize and utilize a variety of exemplary embodiments of the invention and various options and modifications. The scope of the invention is intended to be defined by the claims and their equivalents.

Claims

1. A method for generating a request message, characterized in that: The method comprises: Obtain a request message template, where the request message template is a template of a request message, and the request message is communication data sent by a client to a server; Parsing the request message template to obtain template parsed data including a designated field representing at least one site information; Acquire designated data of the designated field to determine site information of the target site through the designated data; Based on the template parsing data and the designated data, a target request message capable of being sent to the target site is generated.

2. The method according to claim 1, characterized in that The step of parsing the request message template to obtain template parsed data including a designated field representing at least one site information includes: Determining message structure data and body content data in the request message template; sorting the data in the message structure data according to a preset message protocol to obtain protocol parsing data including a designated field and a designated placeholder representing at least one site information; The protocol parsing data and the text content data are used as the template parsing data.

3. The method according to claim 2, characterized in that The generating, based on the template parsing data and the specified data, a target request message that can be sent to the target site includes: identifying the designated placeholder from the protocol parsed data; Replacing the designated placeholder with the designated data to obtain protocol message data; Processing the text content data to obtain text key-value pairs; Based on the text key-value pairs, obtaining text extraction data; Combining the protocol message data and the body extracted data in sequence according to the format of the message protocol to obtain a request message to be processed; Perform binary data conversion on the request message to be processed to obtain a target request message that can be sent to the target site.

4. The method according to claim 3, characterized in that The text content data includes: definition area variable key-value pairs and variable placeholders for different variables in the text area; the text content data is processed to obtain text key-value pairs including at least one of the following: In response to the value of a variable in the variable key-value pair being an environment function in which the independent variable changes with the environment, calculating the value of the environment function, replacing the variable placeholder of the variable with the value of the environment function, and obtaining a text key-value pair; In response to the value of a variable in the variable key-value pair being a fixed function whose independent variable is a preset fixed value, calculating the value of the fixed function, replacing a variable placeholder of the variable with the value of the fixed function, and obtaining a text key-value pair; In response to the value of the variable in the variable key-value pair being a preset fixed value, the variable placeholder of the variable is replaced with the preset fixed value to obtain a text key-value pair.

5. The method according to claim 1, characterized in that The generating, based on the template parsing data and the specified data, a target request message that can be sent to the target site includes: Identifying a designated placeholder corresponding to the designated field from the template parsed data; Replacing the specified placeholder with the specified data to obtain a request message to be processed; Perform binary data conversion on the request message to be processed to obtain a target request message that can be sent to the target site.

6. A site security testing method, characterized in that: The method comprises: Obtaining a target request message related to the target site, where the target request message is generated using the request message generation method according to any one of claims 1 to 5; Establishing a connection with the target site; Sending the target request message to the target site; Obtaining response information fed back by the target site; A security assessment result of the target site is generated based on the response information.

7. The method according to claim 6, characterized in that The establishing a connection with the target site includes: Obtaining an IP address associated with the target site; Based on the IP address, a connection is proposed to the target site.

8. The method according to claim 6, characterized in that Before sending the target request message to the target site, the method further includes: In response to detecting that the message protocol of the target request message is the Hypertext Transfer Protocol, a legality avoidance verification process is performed on the target request message.

9. A request message generating device, characterized in that: The device comprises: a template acquiring unit configured to acquire a request message template, wherein the request message template is a template of a request message, and the request message is communication data sent by a client to a server; a parsing unit configured to parse the request message template to obtain template parsed data including a designated field representing at least one site information; a data acquisition unit configured to acquire designated data of the designated field to determine site information of the target site through the designated data; The message generating unit is configured to generate a target request message that can be sent to the target site based on the template parsing data and the designated data.

10. A site security testing device, characterized in that: The device comprises: a message acquiring unit configured to acquire a target request message related to the target site, wherein the target request message is generated by the request message generating device according to claim 9; a connection unit, configured to establish a connection with the target site; a sending unit, configured to send the target request message to the target site; a response obtaining unit, configured to obtain response information fed back by the target site; The result generating unit is configured to generate a security assessment result of the target site based on the response information.

11. An electronic device, characterized in that: include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 8.

12. A non-transitory computer-readable storage medium storing computer instructions, characterized in that: The computer instructions are used to enable the computer to execute the method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Test system and test method oriented to next-generation firewall

    CN103746885A

  • Test method and device based on dynamic script template

    CN106649073A

  • Method and device for achieving data parameterization

    CN106681921A

  • Test frame generation method, device and equipment

    CN112565026A

  • Message generation method and device, equipment, storage medium and computer program product

    CN116167349A