Network protocol fuzzy test method based on Seq2Seq model, medium and product

The Seq2Seq model generates interactive data and the protocol discrimination module optimizes the test logic, solving the problem of insufficient seed quality and diversity, and significantly improving the efficiency of fuzz testing, especially the testing efficiency of stateless protocols.

CN118540255APending Publication Date: 2024-08-23ARMY ENG UNIV OF PLA
View PDF 0 Cites 4 Cited by

Patent Information

Application Number
CN202410784947.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-18
Publication Date
2024-08-23

AI Technical Summary

Technical Problem

Existing protocol fuzz testing methods have deficiencies in seed quality and diversity capture, resulting in low testing efficiency, especially for stateless protocols.

Method used

Use the Seq2Seq model to simulate the interaction between the real server and the client, generate interaction data as the seed for fuzz testing, and determine the protocol type through the protocol identification module. Test stateful and stateless protocols separately, and use state machines and local socket optimization Test logic.

Benefits of technology

The quality and diversity of seeds are improved, and the automation level and efficiency of fuzz testing are improved. In particular, the testing efficiency of stateless protocols is significantly improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118540255A
    Figure CN118540255A
Patent Text Reader

Abstract

The invention discloses a network protocol fuzz testing method based on a Seq2Seq model, a medium and a product, and belongs to the field of network protocol fuzz testing. The method comprises the steps of performing instrumentation on a test target source code to generate a test target; constructing a server robot and a client robot based on a Seq2Seq model, generating interaction data as a seed of a fuzzy test, and outputting a test case; judging whether a network communication protocol used by the test target belongs to a stateful protocol or not, and obtaining a judgment result; if the network communication protocol belongs to a stateful protocol, synchronizing state information between a test target and a fuzzer in a fuzzing test process, and then performing fuzzing test by using a test case; and if the network communication protocol belongs to the stateless protocol, redirecting the test case to a local socket for fuzzy testing. According to the invention, the problems in the prior art that the seed quality is difficult to guarantee and abundant and diversified message types are usually difficult to capture are solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a network protocol fuzzy testing method, medium and product based on a Seq2Seq model, belonging to the technical field of network protocol fuzzy testing. Background Art

[0002] Fuzz testing is a testing technique that discovers security vulnerabilities in a test target by providing it with a large amount of malformed inputs and monitoring its performance. Protocol fuzz testing is mainly divided into black-box fuzz testing and gray-box fuzz testing, depending on the degree of understanding of the internal structure and behavior of the test target during runtime.

[0003] Black-box fuzz testing often only considers the input and output of the target program, and does not monitor memory changes during program execution. It has a high execution speed, is simple and easy to use, and is widely used in the field of protocol fuzz testing. However, due to the lack of status monitoring during program execution, black-box fuzz testing cannot be guided by indicators such as code coverage to prompt the tool to comprehensively test the program path.

[0004] Gray-box fuzz testing is often guided by code coverage. The higher the coverage, the more comprehensive the program coverage is, and the more likely it is to discover security vulnerabilities in the program. Protocol gray-box fuzz testing generally adopts the method of stub insertion during compilation. When the program is running, the stub code is used to obtain the memory changes during the program runtime, and the implementation of the test is guided according to the changes in indicators such as code coverage. The existing mainstream gray-box methods are often based on mutation, that is, before the fuzz test begins, the tester needs to provide the initial input as a "seed", and the fuzzer mutates the "seed" in order to generate diversified test cases. In the process of protocol fuzz testing, the "seed" is often obtained by capturing the interaction data of the target program. Before the test begins, the target program needs to be deployed, and the real interaction data obtained by interacting with the target program is used as the input of the fuzzer. This method does not require the tester to perform a fine-grained analysis of the protocol before the test begins, but there are still the following problems.

[0005] Existing protocol fuzz testing methods face two major challenges. First, the configuration and deployment of protocol entity programs are complex, and the selection and screening of test seeds, i.e., legitimate messages, rely on expert experience and traffic capture, which often contains redundancy and insufficient types, affecting test efficiency. Second, the current method is tightly coupled to stateful protocols, guiding the test through a state machine, and for stateless protocols, there are redundant processing flows and limited use case sending methods, resulting in low test efficiency.

[0006] Specifically, test seeds need to fully cover all types of legitimate messages to explore more program branches, but existing methods have difficulty in ensuring seed quality and often have difficulty capturing sufficiently rich and diverse message types. In addition, the state machine guidance mechanism and standard network socket method in stateful protocol testing appear redundant and inefficient when dealing with stateless protocols, because stateless protocols do not need to retain historical session information, and fuzzers can continue to send test cases at high speed to improve test efficiency.

[0007] The information disclosed in this background technology section is only intended to enhance the understanding of the overall background of the invention and should not be regarded as an acknowledgement or any form of suggestion that the information constitutes the prior art already known to ordinary technicians in this field. Summary of the invention

[0008] The present invention proposes a network protocol fuzz testing method based on the Seq2Seq model, which uses the Seq2Seq model to learn and simulate the interaction data of the protocol entity program, which can not only cover the typical behavior patterns of most entity programs, but also effectively generate behavior messages that are difficult to directly obtain in the actual environment. The above processing method has outstanding advantages when applied to protocol fuzz testing. First, the interaction data sequence generated by the Seq2Seq model can not only strictly follow the format specification of the target protocol, but also contains rich message types, which is conducive to the exploration of the protocol state space in the subsequent mutation process and covers more state branches. Secondly, the above method autonomously generates seeds based on the Seq2Seq model, which reduces the seed collection work before implementing the test and improves the automation level of the fuzzy test. For stateless protocols, the method of the present invention also simplifies the working logic of the fuzzy test and sends test cases based on the local communication pipeline, effectively improving the test efficiency of the stateless protocol.

[0009] The technical problem to be solved by the present invention is: how to ensure the quality of seeds, capture sufficiently rich and diverse message types, and improve the efficiency of fuzzy testing.

[0010] In order to solve the above technical problems, the present invention is implemented by adopting the following technical solutions.

[0011] The present invention provides a network protocol fuzzy testing method based on a Seq2Seq model, comprising: Obtain the test target source code, and when compiling the test target source code, use the compile-time instrumentation technology to instrument the test target source code to generate a test target, and deploy the test target and the fuzzer on the same host; Using the built server robot and client robot, based on the Seq2Seq model, simulate the interaction between the real server and the real client to generate interaction data; Use the interaction data as the seed of fuzz testing, input it into the fuzz testing tool, and generate and output test cases; Determine whether the network communication protocol used by the test target is a stateful protocol and obtain a determination result; If the network communication protocol is a stateful protocol, after synchronizing the state information between the test target and the fuzzifier during the fuzz testing process, the fuzz testing is performed using the test case to obtain the fuzz testing result; if the network communication protocol is a stateless protocol, the test case is redirected to the local domain socket for fuzz testing to obtain the fuzz testing result.

[0012] Furthermore, the server robot and the client robot are constructed using the same architecture, and the server robot and the client robot include an encoder, a decoder and an attention layer; The encoder includes a five-layer bidirectional gated recurrent unit BiGRU, which is responsible for understanding the received message; the BiGRU is composed of a group of forward gated recurrent units GRU and a group of reverse gated recurrent units GRU; The attention layer is the next layer of the encoder and is responsible for taking the received message as the key content and focusing on learning; The decoder includes a three-layer gated recurrent unit GRU, which is responsible for generating a reply to the input message word by word using a beam search strategy based on the input message features extracted by the encoder.

[0013] Furthermore, the constructed server robot and client robot are used to simulate the interaction between the real server and the real client based on the Seq2Seq model, including: The captured traffic data is used as training data for preprocessing; Extract the destination IP, source IP, destination port, and source port information from the training data, divide the captured traffic data into different sessions, and construct question-answer pairs; Use the constructed question-answer pairs as training data, and train the server robot and client robot through the Seq2Seq model to simulate the interaction behavior between the real server and client.

[0014] Furthermore, the captured traffic data is used as training data and preprocessed, including: Clean the training data, remove unnecessary English symbols and noise data, and obtain the cleaned training data; Performing a lemma operation on the cleaned training data to divide the text data into independent lemmas to obtain lemma-based training data, wherein the lemma-based training data includes text protocol data and binary protocol data; Convert text protocol data into a numerical matrix.

[0015] Furthermore, the destination IP, source IP, destination port and source port information in the training data are extracted, the captured traffic data is divided into different sessions, and question-answer pairs are constructed, including: in the divided sessions, when the client robot interacts with the user, the message sent by the server robot is regarded as a "question", and the response message sent by the client robot is regarded as an "answer", and a question-answer pair is constructed; when the server robot interacts with the client robot, the message sent by the client robot is regarded as a "question", and the response message sent by the server robot is regarded as an "answer".

[0016] Further, determining whether the network communication protocol used by the test target is a stateful protocol includes: Connect to the target network service through a standard network socket, send each message in the seed in the standard order, and record the response received after each message is sent; After completing the standard sequence of message transmission, these messages are rearranged to interact with the test target and sent again to the target network service; Whether the protocol is a stateful protocol is determined based on whether the received response changes. If the return message received by the fuzzifier is the same as the response obtained by sending the message in sequence, it is a stateless protocol. If the return message received by the fuzzifier is different from the response obtained by sending the message in sequence or is within an acceptable range, it is a stateful protocol.

[0017] Furthermore, if the network communication protocol is a stateful protocol, after synchronizing the state information between the test target and the fuzzer during the fuzz test, the fuzz test is performed using the test case, and the step of obtaining the fuzz test result includes: (1) Initialization: create an empty seed pool and initialize an empty protocol state machine model; (2) Generate an initialization seed. Use the trained server robot and client robot to randomly generate a message sequence as the initial seed and add it to the seed pool. (3) Select a seed. If this is the first test, randomly select a seed from the seed pool. In subsequent tests, select a seed that can reach a specific state based on the current protocol state machine. (4) Determine the mutation target and take the nth message in the selected seed as the mutation target; (5) Send messages and gradually build the state machine, Send the first n-1 messages to guide the test target to a state where it can receive the nth message; Mutate the nth message and generate a test case; Send the mutated test case to the test target and send the remaining messages; Use standard socket to interact with the test target and receive response messages; Determine the change of state based on the content of the response message and extract keywords to identify the new state; Add the new state and its transition condition M' to the protocol state machine model; (6) Fuzz testing: repeat steps (3) to (5), continue fuzz testing, and monitor protocol state changes and program coverage during the test process; (7) Update the seed pool. If the test case can cover the new protocol state or improve the program coverage, the test case will be added to the seed pool. (8) Synchronization and delay: using the delay waiting mechanism of the standard socket to synchronize the fuzzer with the test target state; (9) Iterative testing: repeat steps (3) to (8), iteratively perform fuzz testing, gradually build and improve the protocol state machine model, until the maximum number of iterations is reached, end the fuzz testing, and obtain the fuzz testing results.

[0018] Furthermore, if the network communication protocol is a stateless protocol, the test case is redirected to a local domain socket for fuzz testing, and the step of obtaining the fuzz testing result includes: (1) Use HOOK technology to intercept API calls related to data interaction in standard sockets; (2) When the API call of the socket() function is intercepted, it is redirected to the custom socket() function. The custom socket() function is responsible for creating and managing the local domain socket, replacing the original standard socket; (3) Create front-end and back-end sockets. In the custom socket() function, create the front-end socket front_socket() function and the back-end socket back_socket() function. The front-end socket front_socket() function is used for connection and data transmission between the client program and the server, simulating the behavior of the original client socket. The back-end socket back_socket() function is used to process the data received from the front-end socket front_socket() function and pass it to the back-end processing unit. (4) Create FRONT_TO_BACK_THREAD and BACK_TO_FRONT_THREAD threads; the FRONT_TO_BACK_THREAD thread is responsible for reading data from the front-end socket front_socket() function and passing it to the back-end socket back_socket() function; the BACK_TO_FRONT_THREAD thread is responsible for reading the data processed by the back-end processing unit from the back-end socket back_socket() function and returning it to the client through the front-end socket front_socket() function; (5) Allocate necessary memory space for the front-end socket front_socket() function to cache received data; manage the life cycle of the two threads FRONT_TO_BACK_THREAD and BACK_TO_FRONT_THREAD; (6) Use the fuzzer to establish a connection with the test target through the front-end socket front_socket() function, send test cases to the test target through the front_socket() function, perform fuzz testing, and obtain fuzz testing results.

[0019] The present invention also provides a computer-readable storage medium having a computer program / instruction stored thereon, wherein the computer program / instruction implements the steps of the above method when executed by a processor.

[0020] The present invention also provides a computer program product, comprising a computer program / instruction, characterized in that the computer program / instruction implements the steps of the above method when executed by a processor.

[0021] Compared with the prior art, the present invention has the following beneficial effects: The present invention uses a seed generation module based on a Seq2Seq model to obtain the message interaction between the client and the server to obtain high-quality seeds. At the same time, with the help of a protocol discrimination module and targeted applicable strategies, the efficiency of fuzzy testing of stateless protocols is improved. The problem that it is difficult to ensure seed quality and it is usually difficult to capture sufficiently rich and diverse message types in the prior art is solved. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] Figure 1 It is a flow chart of a network protocol fuzzy testing method based on a Seq2Seq model provided by an embodiment of the present invention; Figure 2 This is a client robot question-and-answer Q / A example provided by an embodiment of the present invention; Figure 3 This is a Q / A example of a server-side robot question and answer pair provided in an embodiment of the present invention; Figure 4 This is an example of text protocol message segmentation provided by an embodiment of the present invention; Figure 5 This is an example of binary protocol message segmentation provided by an embodiment of the present invention; Figure 6 It is a client / server robot structure provided by an embodiment of the present invention; Figure 7 The client / server robot encoder structure provided by the embodiment of the present invention; Figure 8 The structure of the client / server robot attention layer and decoder provided in the embodiment of the present invention; Fig. 9 It is a schematic diagram of the stateful protocol fuzzy testing workflow provided by an embodiment of the present invention; Fig.10 It is a schematic diagram of the stateless protocol fuzzy testing workflow provided by an embodiment of the present invention; Fig.11 is a schematic diagram of constructing a state machine provided by an embodiment of the present invention; Fig.12 It is a schematic diagram of the interaction strategy of the state protocol fuzzy testing module provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0023] The technical solution of the present invention is described in detail below through the accompanying drawings and specific embodiments. It should be understood that the embodiments of the present invention and the specific features in the embodiments are detailed descriptions of the technical solution of the present invention, rather than limitations on the technical solution of the present invention. The embodiments of the present invention and the technical features in the embodiments may be combined with each other unless there is a conflict.

[0024] Example 1 This embodiment introduces a network protocol fuzz testing method based on a Seq2Seq model, including the following steps:

[0025] Step 1: Obtain the test target source code. When compiling the test target source code, use the compile-time instrumentation technology to instrument the test target source code to generate a test target, and deploy the test target and the fuzzer on the same host. Stub insertion is to insert additional code into the source code or intermediate code to generate a test target with stub code. The program can collect the required information, such as function calls, variable values, execution paths, etc., when running for subsequent testing and analysis. A fuzzer is an automated or semi-automated testing tool that generates random or pseudo-random input data to find errors or vulnerabilities in a program. Deploying the test target and fuzzer on the same host can simplify the configuration of the test environment and improve test efficiency.

[0026] Step 2: Use the built server robot and client robot to simulate the interaction between the real server and the real client based on the Seq2Seq model to generate interaction data; The Seq2Seq model is a deep learning model. The present invention uses the Seq2Seq model to simulate the interaction between a real server and a client, generating a large amount of interaction data as a seed for fuzz testing, and helping to discover possible problems in the program when processing actual communications.

[0027] Step 3: Use the interaction data as the seed of fuzz testing, input it into the fuzz testing tool, and generate and output test cases; The interaction data generated by simulation is used as the starting point of fuzz testing, and a large number of meaningful test cases are generated through the fuzzer. These test cases can cover multiple execution paths and states of the program, thereby increasing the possibility of discovering program errors or vulnerabilities.

[0028] Step 4: Determine whether the network communication protocol used by the test target is a stateful protocol and obtain a determination result; Stateful and stateless protocols have different behavioral characteristics during the communication process. According to the state of the protocol, the strategy and configuration of the subsequent fuzz test are determined.

[0029] Step 5: If the network communication protocol is a stateful protocol, after synchronizing the state information between the test target and the fuzzer during the fuzz testing process, the test case is used to perform fuzz testing to obtain the fuzz testing result; if the network communication protocol is a stateless protocol, the test case is redirected to the local domain socket for fuzz testing to obtain the fuzz testing result.

[0030] For stateful protocols, maintaining state synchronization between the test target and the fuzzer is key to ensuring test accuracy. Synchronizing state information ensures that the test cases generated by the fuzzer can be sent to the test target in the expected order and conditions, thereby more accurately detecting errors or vulnerabilities in the program when processing stateful communications.

[0031] For stateless protocols, since there is no need to keep state synchronized, the test cases can be redirected to the local domain socket for testing to improve the test efficiency. By redirecting the test cases to the local domain socket, the network communication overhead and delay are reduced, the test speed is accelerated, and the dependence on the external environment is reduced.

[0032] Example 2 like Figure 1 As shown, this embodiment introduces a network protocol fuzz testing method based on a Seq2Seq model, including:

[0033] Step 1: Obtain the test target source code. When compiling the test target source code, use the compile-time instrumentation technology to instrument the test target source code to generate a test target, and deploy the test target and the fuzzer on the same host.

[0034] Step 2: Use the built server robot and client robot to simulate the interaction between the real server and the real client based on the Seq2Seq model to generate interaction data.

[0035] Before training the server robot and the client robot and simulating the interaction between the real server and the real client, the training data input to the server robot and the client needs to be processed.

[0036] The traffic data captured through the network is used as the training data of this embodiment, and the five-tuple information {source IP address, destination IP address, source port, destination port, application layer load} in the training data is extracted. When the server robot and the client robot communicate, one party initiates a request, the other party responds, and the two parties exchange data until the communication ends. This complete process can be regarded as a session. In this process, the two parties may have multiple requests and responses.

[0037] When preprocessing the training data, the sessions are divided according to the destination IP, source IP, destination port, and source port information. Then, based on the divided sessions, the application layer load is associated in the form of question-answer pairs (Q / A).

[0038] From the perspective of the client robot, the message sent by the server is regarded as a question, and the message of its response is regarded as an answer. The question and the answer are associated together in the form of a question-answer pair Q / A, reflecting the relationship between the server and the client.

[0039] From the perspective of the server robot, the message sent by the client is regarded as a question, and the message it responds to is regarded as an answer. Figure 2 This is an example of a client robot question-and-answer pair Q / A provided by an embodiment of the present invention. Figure 3 This is an example of a Q / A session between a server-side robot provided by an embodiment of the present invention; messages are continuously sent in the same direction, and the embodiment of the present invention combines these messages into one record. For example, Figure 2 The fourth message "150 Here comes the directory listing." and "226 Directory send OK." are messages sent continuously by the server to the client, which are merged into one record.

[0040] When preprocessing the training data, you also need to ensure that the training data meets the input format requirements of the Seq2Seq model and perform cleansing and Tokenization operations on the training data.

[0041] First, remove unnecessary symbols such as Chinese encoding and garbled characters that may have an adverse effect on robot training. In view of the fact that special symbols in protocol interaction messages may carry specific semantic information, the embodiment of the present invention only removes non-English characters and retains the remaining special symbols. In order to prevent escape characters such as line breaks from affecting subsequent data, escape characters such as line breaks are replaced with text symbols, for example, [r][n] is used to replace "\r\n".

[0042] Then, word segmentation is performed. Figure 4 The text protocol data shown in FIG. 1 includes the Hypertext Transfer Protocol HTTP, the Real-time Streaming Transfer Protocol RTSP, and the Text Transfer Protocol FTP, etc., and uses special symbols such as spaces as boundaries for word segmentation. Figure 5 The binary protocol data shown, including serial communication protocols such as Modbus, is divided into fixed lengths, and the default data division is 2 bytes. For each message after word segmentation, add the end character " <eos>", add the start character at the beginning of the message <sos>", aims to provide a clear boundary mark for each message, that is, to indicate the end and start of the message. Before the generated text test case is used as the initial input of the fuzz test, the adjustments made to the message to ensure the training data specification will be reversed to ensure the legality and validity of the input message.

[0043] After performing word segmentation on the message data, in order to meet the input requirements of the Seq2Seq model, the text data is converted into a numerical matrix, and the word unit Token obtained by the word segmentation is mapped to a numerical index to achieve vectorized expression of the message data to meet the input requirements of the neural network. Figure 4 As shown, "GET", " / ", "HTTP", "00" and "0b" obtained by the word segmentation operation are all word units.

[0044] The steps to convert text data into a numerical matrix include: First, the data after word segmentation is traversed to extract word units from it to form a non-repeating word unit set.

[0045] Next, the word set is sorted to construct an ordered word list, which is convenient for subsequently establishing numerical indexes for the elements in the word list. Considering that data that has not been encountered in the training phase may appear in actual applications, the embodiment of the present invention introduces the unknown tag " <unk>”, placed at the end of an ordered vocabulary to indicate data instances that do not appear in the vocabulary.

[0046] Finally, a number is assigned to each word in the ordered vocabulary to construct a correspondence between the number index and the word, forming a mapping structure that is easy to query and convert. In the subsequent model processing stage, the text vocabulary can be converted into the corresponding index, thereby converting the message into a numerical vector.

[0047] like Figure 6 As shown, the server robot and the client robot are constructed using the same architecture, and the server robot and the client robot include an encoder, a decoder, and an attention layer; Because GRU is concise, computationally efficient, and consumes low resources during training and use, it is beneficial to improve the performance and applicability of the overall system. In this embodiment, the encoder is constructed using a variant of the standard GRU, BiGRU. The BiGRU structure allows information to propagate bidirectionally in the time dimension, not only considering the influence of the preceding word element, but also taking into account the subsequent word elements, so that the robot can fully learn the received message.

[0048] like Figure 7 As shown in the figure, the encoder includes five layers of bidirectional gated recurrent units BiGRU, which are responsible for understanding the received message; the BiGRU is composed of a group of forward gated recurrent units GRU and a group of reverse gated recurrent units GRU. Since this structure pays attention to the sequential transmission and pre-order association of information at the same time, the hidden state of each time step contains not only the information of the previous unit in the message sequence, but also the information of all subsequent units. Ensure that the robot can fully understand the content of the received message.

[0049] The decoder includes a three-layer gated recurrent unit GRU, which is responsible for generating a reply to the input message word by word based on the input message features extracted by the encoder and using a beam search strategy. It follows the autoregressive generation criterion for text generation, that is, when generating words at time t, it only relies on the generated words and does not involve information about future words to be generated; the one-way transmission structure of GRU allows the decoder to consider all generated outputs when predicting the next output, which is more suitable for simulating the interaction between the real server and the real client in this embodiment.

[0050] exist Figure 6 In the figure, the forward information transfer of GRU is represented by a solid line, and the reverse information transfer is represented by a dotted line. For the forward GRU, the input of the encoder is the vector , is a random initialization vector, and the vector The amount in Participate in the forward propagation calculation together. For each forward GRU unit, the output of the current unit The output of the previous unit Closely related.

[0051] The output of the current unit The calculation formula is: (1); In the formula, Represents the output of the current unit; GRU represents the forward GRU unit, represents the output of the previous unit, x t Represents the input of the current forward GRU unit, which is the vector of the current step Corresponding weight .

[0052] Thus, the output set of the forward unit is obtained , expressed as: (2); In the formula, represents the output set of the forward unit, where Represents the output from the first forward GRU unit to the nth GRU unit; The calculation of the reverse GRU unit is similar to that of the forward GRU unit. The difference is that for the input vector The reverse GRU unit performs reverse calculations, and the reverse unit outputs a set It is expressed as: (3); In the formula, represents the output set of the reverse unit, where Indicates n The output of the first reverse GRU unit to the first reverse GRU unit; The output of each BiGRU unit is obtained by concatenating the forward unit and the reverse unit. The output set of the BiGRU unit can be expressed as: (4); In the formula, Y represents the set of representations of the BiGRU unit, concat () represents concatenation operation, where The output set of the forward unit and the reverse unit output set The output obtained by concatenating the corresponding elements in is Represents the output of the first forward GRU unit and the output of the nth reverse GRU unit The output obtained by splicing is Represents the output of the second forward GRU unit and the output of the n-1th reverse GRU unit The output obtained by splicing is Represents the output of the nth forward GRU unit and the output of the first reverse GRU unit The output obtained by splicing.

[0053] like Figure 8 As shown, the next layer of the encoder is the attention layer, and the input of the attention layer The last time step of the encoder The output of the attention layer contains both the information of the forward GRU and the information of the reverse GRU. It is expressed as: (5); In the formula, represents the input of the attention layer, concat () represents concatenation operation, where For the last time step t The output of the forward GRU unit, is the output of the first reverse GRU unit.

[0054] exist Figure 8 middle, is the output of the adjacent decoder unit, is the output of the encoder, and m is the length of the output sequence. In the attention layer, the robot calculates the weight vector according to the output of the decoder at the current time step and the message vector , focusing on learning a certain segment of message information according to the weight, rather than processing all fields in the message completely and evenly, helps the robot understand the input message and then accurately generate feedback messages based on the input message. To get the weight vector , you need to The output vector of the encoder Perform alignment operation, weight vector Each weight component of is expressed as , n is the length of the decoder input sequence, and the weight vector The calculation formula is: (6); In the formula, represents the weight vector, w 1, w 2, w 3, w 4, w n They represent the first component of the weight vector, the second component of the weight vector, the third component of the weight vector, the fourth component of the weight vector, and the nth component of the weight vector, respectively. n represents the length of the decoder input sequence. w 1, w 2, w 3,..., w 4, w n ∈ , represents the weight component; represents the output of the adjacent decoder unit, where i ∈[0, m ]; m represents the decoder output sequence length, y 1, y 2, y n Respectively represent the first, second, and nth output vectors, y 1, y 2,..., y n ∈ , represents the output vector; align () indicates alignment operation.

[0055] Weight Component The calculation is expressed as: (7); In the formula, represents the weight component, represents the matching score, and the subscript t represents the time step t. represents the fully connected operation function, Y represents the output set of the BiGRU unit, represents the output of the adjacent decoder unit, the subscript i represents the i-th decoder unit, It is a one-dimensional array, which is used to perform dot product operation with the matching score to achieve dimension compression to solve the dimension matching problem in actual calculation. tanh() represents the hyperbolic tangent function, and softmax() represents the normalized exponential function. The calculation process of the attention mechanism includes: (1) Using the fully connected operation function Perform association calculations, calculate the matching degree of all neurons between the encoder output and the decoder output, quantify the attention degree between neurons, and obtain quantified attention information; (2) Use the hyperbolic tangent function tanh to perform nonlinear transformation on the quantified attention information to obtain the matching score ; The purpose is to smooth the quantified attention information and limit its value to a dynamic range; (3) By converting the matching score With one-dimensional array Dot product operation is performed to achieve dimensionality compression, and each weight value is further normalized through the softmax function to obtain the weight component; (4) According to the weight component and the output of the corresponding encoder Perform weighted sum operation to generate context vector , expressed as: (8); In the formula, represents the weight component, Represents the output of the corresponding encoder, is the corresponding generated context vector, subscript is the number of the encoder output unit; the context vector The input weight information is included in the data. The elements with high weight will be taken as key content and focused on learning. (5) The context vector Current decoder hidden state They serve together as the input of the decoder, so that the decoder can focus on the key content of the message when generating the target sequence, improving the robot's ability to understand and generate messages. The calculation process is the same as the forward propagation layer of the encoder and will not be repeated here.

[0056] This embodiment uses beam search as the basic sampling strategy. Beam search can control the diversity of text by controlling the beam width parameter. When the beam width parameter is small, the generated message is relatively fixed, which can be applied to the construction of server-side robots. When the beam width parameter is large, the generated message diversity is strong, which can be used to build client-side robots.

[0057] The working principle of beam search is as follows, assuming that the vocabulary is , the beam width parameter is , Represents the context variable obtained by encoding the input message, which needs to be Predictions for time steps.

[0058] The first time step takes the conditional probability value Top The word As the candidate word for the current step. Among them, represents the probability distribution of word units predicted based on the encoder's understanding of the received message, Therefore, according to Candidate word generation branches, of which , representing the generation The second time step is branches, based on the calculation results of the first time step Make predictions, where , the calculation can be expressed as: (9); In the formula, Indicates the candidate word in the first time step of the target word predicted in this step The probability of the first word in , Represents the candidate word in the first time step The first word in ; Indicates the candidate word in the first time step of the target word predicted in this step The probability of the kth word in , Represents the candidate word in the first time step The kth word in , Represents the context variable obtained by encoding the input message, Predict the target word for this step, .

[0059] From the vocabulary Choose the one with the largest conditional probability in the above formula word The calculation of the third time step can be expressed as: (10); In the formula, Represents the candidate word in the first time step The first word in Represents the candidate word in the first time step The kth word in , Represents the candidate word in the second time step The first word in Represents the candidate word in the second time step The mth word in Represents the context variable obtained by encoding the input message, Predict the target word for this step, .

[0060] In each round, the conditional probability generated is based on the current conditional probability. Finally, according to the output of each time step, the product of conditional probabilities is calculated, and the sequence with the highest product of conditional probabilities is taken as the final output, as shown in the formula: (11); In the formula, Represents the penalty value, used to eliminate The impact of text length on calculation when it is too large, represents the time step, Indicates the first step of predicting the target word. Indicates the second step of predicting the target word, Indicates the target word predicted at step t, subscript Used in accumulation to indicate the growth of the accumulated item. Represents the context variable obtained by encoding the input message, represents the conditional probability of the predicted text sequence, Represents the conditional probability of predicting a word at each time step.

[0061] For the server robot, the beam width parameter Set to a smaller value. The default value in this embodiment is 1. When the value is 1, only one branch with the highest probability is generated in each time step. Messages are generated only within a small branch range, so that relatively fixed messages are generated as interaction data.

[0062] For client robots, the beam width parameter Set to a larger value. In this embodiment, the default value is 5. Finally, the candidate queue for the client robot to generate the message will also exist. Candidate results, The larger it is, the more diverse the messages it may generate. Based on this, it controls the generation of various request messages as interaction data to simulate the diverse request behaviors of the client.

[0063] The fuzz testing method in this embodiment pays special attention to the quality of the seed. The object of the protocol fuzz test is the protocol entity program, so the fuzz test seed needs to be able to fully cover and test various possible situations of the protocol. In the above case, the message sequence is a very suitable form for constructing fuzz test seeds. By designing different message sequences, various possible protocol interaction scenarios can be simulated, thereby comprehensively evaluating the performance and security of the protocol entity program.

[0064] The seeds constructed by the message sequence need to be diverse, which is conducive to covering different execution paths of the protocol entity program. This embodiment builds a server robot and a client robot based on the Seq2Seq model, simulating the interaction between the real server and the real client to grasp the association relationship between the messages.

[0065] The present invention organizes the request and response of the protocol entity program in the form of question-answer pairs Q / A. According to the different roles of the server and the client, the organization method of the question-answer pairs Q / A is different.

[0066] For the server, Q is the request message of the client program, and A is the response message of the service program. The question and answer pair Q / A can reflect the response of the server after receiving the request.

[0067] On the client side, Q is the message sent by the server program, and A is the response of the client program after receiving Q. The question-and-answer pair Q / A can reflect the behavior of the client program after receiving the server message.

[0068] The client robot learns the behavior of the client program, masters the client's request mode, and can generate various forms of legal requests. The server robot learns the response mode of the server program and has the ability to generate response messages based on the client's request information.

[0069] Step 3: Use the interaction data as the seed of fuzz testing, input it into the fuzz testing tool, and generate and output test cases.

[0070] To perform fuzz testing on the client, it is necessary to extract the message interaction data generated by the server robot as the seed of the fuzz testing. To perform fuzz testing on the server, it is necessary to extract the message interaction data generated by the client robot as the seed of the fuzz testing. The method of this embodiment focuses on the server fuzz testing, constructs the seed of the fuzz testing with the request message sent by the client robot, inputs it into the fuzz testing tool, and generates and outputs the test case.

[0071] A seed consists of a group of ordered messages, and each seed contains all request messages of an interactive session.

[0072] For example, for a session of a stateful protocol such as the File Transfer Protocol (FTP), the seed includes the login request and password verification initiated by the client, as well as various subsequent file operations, until the disconnection request and confirmation message at the end of the session; for a session of a stateless protocol such as the Hypertext Transfer Protocol (HTTP), the seed includes a series of resource request messages from the client until the client no longer makes any request operations.

[0073] Step 4: Determine whether the network communication protocol used by the test target is a stateful protocol and obtain a determination result; The identification module is used to determine whether the network communication protocol used by the test target is a stateful protocol, including: Connect to the target network service program through a standard network socket, send each message in the seed in the standard order to complete the standard order of message sending, and record the response received after each message is sent; After completing the standard sequence of message transmission, these messages are rearranged to interact with the test target and sent again to the target network service program; Whether the protocol is a stateful protocol is determined based on whether the received response changes. If the return message received by the fuzzifier is the same as the response obtained by sending the message in sequence, it is a stateless protocol. If the return message received by the fuzzifier is different from the response obtained by sending the message in sequence or is within an acceptable range, it is a stateful protocol.

[0074] The request messages of stateful protocols often rely on historical information. If the message order is rearranged, the request will be considered illegal, and the server will often refuse the connection or enter the exception handling process and return a status code indicating an error. The server of the stateless protocol does not record historical interactions, but processes each request independently. Therefore, after the message sequence is disrupted and sent to the test target, the return message received by the fuzzer will be consistent with the response obtained by sending the message in order.

[0075] Step 5: If the network communication protocol is a stateful protocol, the state information between the test target and the fuzzer is synchronized during the fuzz testing process; if the network communication protocol is a stateless protocol, the test case is redirected to the local domain socket for fuzz testing to obtain the fuzz testing results.

[0076] If the network communication protocol is a stateful protocol, a state machine is used for state guidance, and test cases are sent through a standard Socket. Reasonable delay waiting is used to ensure synchronization of state information between the test target and the fuzzer during the fuzz testing process.

[0077] like Fig. 9 As shown, if the network communication protocol is a stateful protocol, after synchronizing the state information between the test target and the fuzzer during the fuzz test, the fuzz test is performed using the test case, and the steps of obtaining the fuzz test result include: (1) Initialization: create an empty seed pool and initialize an empty protocol state machine model; (2) Generate an initialization seed. Use the trained server robot and client robot to randomly generate a message sequence as the initial seed and add it to the seed pool. (3) Select a seed. If this is the first test, randomly select a seed from the seed pool. In subsequent tests, select a seed that can reach a specific state based on the current protocol state machine. (4) Determine the mutation target and take the nth message in the selected seed as the mutation target; (5) Send a message and build a state machine, such as Fig.11 As shown: Send the first n-1 messages to guide the test target to a state where it can receive the nth message; Mutate the nth message and generate a test case; Send the mutated test case to the test target and send the remaining messages; Use standard socket to interact with the test target and receive response messages; Determine the change of state based on the content of the response message and extract keywords to identify the new state; Add the new state and its transition condition M' to the protocol state machine model; (6) Fuzz testing: repeat steps (3) to (5), continue fuzz testing, and monitor protocol state changes and program coverage during the test process; (7) Update the seed pool. If the test case can cover the new protocol state or improve the program coverage, the test case will be added to the seed pool. (8) Synchronization and delay: using the delay waiting mechanism of the standard socket to synchronize the fuzzer with the test target state; (9) Iterative testing: Repeat steps (3) to (8), iteratively perform fuzz testing, gradually build and improve the protocol state machine model, until the maximum number of iterations is reached, end the fuzz testing, obtain the fuzz testing results, and analyze the abnormal information to further guide the reinforcement of the protocol program.

[0078] The specific process of sending messages and building a state machine is as follows Fig.10 As shown, during the test, a state machine model from state S1 to state S6 is established based on sending the initial seed. When the fuzzer sends M' in state S2 and obtains a message that does not appear in the current state machine, a keyword is extracted from it to identify state S7, and the S7 state is expanded into the state machine. This state can be reached from state S2, and the migration condition is to send M'. The protocol state machine and the program coverage index jointly guide the fuzz test. The delay waiting mechanism of the standard socket gives the fuzzer sufficient time to establish synchronization with the test target to build a relatively accurate state machine model. In subsequent tests, if the test case can cover the new protocol state or improve the program coverage, the test case will be added to the seed pool for subsequent testing.

[0079] If the network communication protocol is a stateless protocol, this embodiment performs optimization processing, bypasses the state learning process, redirects the test case to the local domain socket and sends the test case based on the local communication pipeline, avoids the layer-by-layer encapsulation and parsing process required to send the test case in the form of data packets, and improves the fuzz testing efficiency of the stateless protocol.

[0080] For stateless protocols, the server no longer retains historical session information at the application layer as it does for stateful protocols. The server processes all requests independently, and the fuzzer does not need to learn the target state machine. The fuzzer only needs to collect changes in program coverage and error triggering during the test, and update the seed pool based on these standards. During the fuzz testing of stateful protocols, the standard Socket delay waiting mechanism is used to give the fuzzer sufficient time to gradually learn the state machine. However, this waiting is unnecessary for stateless protocols, and a more efficient test case sending method should be used.

[0081] like Fig.10 As shown, if the network communication protocol is a stateless protocol, the test case is redirected to the local domain socket for fuzz testing, and the steps of obtaining the fuzz testing results include: (1) Intercept Socket API calls and use HOOK technology to intercept API calls related to data interaction in standard sockets; (2) Redirect to the local domain socket. When the socket() function call is intercepted, it is redirected to the custom socket() function. The custom socket() function is responsible for creating and managing the local domain socket, replacing the original standard socket. (3) Create front-end and back-end sockets. In the custom socket() function, create the front-end socket front_socket() function and the back-end socket back_socket() function. The front-end socket front_socket() function is used for connection and data transmission between the client program and the server, simulating the behavior of the original client socket. The back-end socket back_socket() function is used to process the data received from the front-end socket front_socket() function and pass it to the back-end processing unit. (4) Create synchronization threads, FRONT_TO_BACK_THREAD thread and BACK_TO_FRONT_THREAD thread; FRONT_TO_BACK_THREAD thread is responsible for reading data from the front-end socket front_socket() function and passing it to the back-end socket back_socket() function; BACK_TO_FRONT_THREAD thread is responsible for reading the data processed by the back-end processing unit from the back-end socket back_socket() function and returning it to the client through the front-end socket front_socket() function; (5) Allocate memory and thread management, allocate necessary memory space for the front-end socket front_socket() function, cache received data; manage the life cycle of the two threads FRONT_TO_BACK_THREAD and BACK_TO_FRONT_THREAD; (6) Establishing a connection and sending test cases. The fuzzer establishes a connection with the test target through the front-end socket front_socket() function, sends test cases to the test target through the front_socket() function, performs fuzz testing, obtains fuzz testing results, and analyzes the abnormal information to further guide the reinforcement of the protocol program.

[0082] like Fig.12 As shown, the present invention adopts HOOK technology to intercept API calls related to data interaction in the standard socket Socket, and redirect them to the local high-speed communication pipeline to achieve high-speed delivery of use cases. The local inter-process communication mechanism avoids the performance loss of data packet encapsulation, decapsulation and other processes. The present invention redirects communication messages to local domain sockets. Local domain sockets are generally used in scenarios where efficient communication is required between processes, such as internal communication in containers, authentication and key exchange based on file systems, and communication between Web servers and local application servers. Compared with message queues that require more system resources to maintain data and pipeline mechanisms that are difficult to handle complex communication modes, the creation and management of local domain sockets are flexible and lightweight. Compared with the method of using shared memory, local domain sockets are more suitable for protocol fuzz testing scenarios because they support advanced features such as multiplexing and non-blocking.

[0083] Example 3 A computer-readable storage medium having computer instructions stored thereon, characterized in that when the computer instructions are executed by a processor, the steps of the method of embodiment 1 or 2 above are implemented.

[0084] Example 4 The present invention also provides a computer program product, including computer instructions, characterized in that when the computer instructions are executed by a processor, the steps of the method in the above-mentioned embodiment 1 or 2 are implemented.

[0085] In summary, the present invention designs a client robot and a server robot to simulate the interaction process of real messages to assist in the acquisition of high-quality seeds. On the basis of obtaining the seeds, the present invention uses a discrimination module to determine whether the protocol belongs to a stateful protocol. First, each message in the seed is sent in sequence through a standard network socket, and the response of each message is recorded. Then the message is disrupted to interact with the test target, and whether the target protocol is a stateful protocol is determined according to whether the received response changes. Further, after determining whether the protocol belongs to a stateful protocol or a stateless protocol, the present invention adopts a targeted strategy to guide fuzz testing for stateful protocols through a protocol state machine and program coverage, and sends test cases through a standard network socket. In order to solve the problem that the existing method is tightly coupled to the stateful protocol, a concise fuzzy test logic is adopted for the stateless protocol, the state machine construction process is avoided, and the data is redirected to the local domain socket to achieve efficient sending of test cases, which effectively improves the fuzzy test efficiency of the stateless protocol. It solves the problem that it is difficult to ensure the quality of seeds in the prior art, and it is usually difficult to capture sufficiently rich and diverse message types.

[0086] It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0087] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0088] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0089] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0090] The embodiments of the present invention are described above in conjunction with the accompanying drawings, but the present invention is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the enlightenment of the present invention, ordinary technicians in this field can also make many forms without departing from the scope of protection of the purpose of the present invention and the claims, which all fall within the protection of the present invention.< / unk> < / sos> < / eos>

Claims

1. A network protocol fuzz testing method based on Seq2Seq model, characterized in that: include: Obtain the test target source code, and when compiling the test target source code, use the compile-time instrumentation technology to instrument the test target source code to generate a test target, and deploy the test target and the fuzzer on the same host; Using the built server robot and client robot, based on the Seq2Seq model, simulate the interaction between the real server and the real client to generate interaction data; Use the interaction data as the seed of fuzz testing, input it into the fuzz testing tool, and generate and output test cases; Determine whether the network communication protocol used by the test target is a stateful protocol and obtain a determination result; If the network communication protocol is a stateful protocol, after synchronizing the state information between the test target and the fuzzer during the fuzz test, the fuzz test is performed using the test case to obtain the fuzz test result; If the network communication protocol is a stateless protocol, the test case is redirected to the local domain socket for fuzz testing to obtain the fuzz testing result.

2. The network protocol fuzz testing method based on Seq2Seq model according to claim 1 is characterized in that: The server robot and the client robot are constructed using the same architecture, and the server robot and the client robot include an encoder, a decoder, and an attention layer; The encoder includes a five-layer bidirectional gated recurrent unit BiGRU, which is responsible for understanding the received message; the BiGRU is composed of a group of forward gated recurrent units GRU and a group of reverse gated recurrent units GRU; The attention layer is the next layer of the encoder and is responsible for taking the received message as the key content and focusing on learning; The decoder includes a three-layer gated recurrent unit GRU, which is responsible for generating a reply to the input message word by word using a beam search strategy based on the input message features extracted by the encoder.

3. The network protocol fuzz testing method based on Seq2Seq model according to claim 1 is characterized in that: Using the built server robot and client robot, based on the Seq2Seq model, simulate the interaction between the real server and the real client, including: The captured traffic data is used as training data for preprocessing; Extract the destination IP, source IP, destination port, and source port information from the training data, divide the captured traffic data into different sessions, and construct question-answer pairs; Use the constructed question-answer pairs as training data, and train the server robot and client robot through the Seq2Seq model to simulate the interaction behavior between the real server and client.

4. The network protocol fuzz testing method based on Seq2Seq model according to claim 3 is characterized in that: The captured traffic data is used as training data and preprocessed, including: Clean the training data, remove unnecessary English symbols and noise data, and obtain the cleaned training data; Performing a lemma operation on the cleaned training data to divide the text data into independent lemmas to obtain lemma-based training data, wherein the lemma-based training data includes text protocol data and binary protocol data; Convert text protocol data into a numerical matrix.

5. The network protocol fuzz testing method based on Seq2Seq model according to claim 3 is characterized in that: Extract the destination IP, source IP, destination port, and source port information from the training data, divide the captured traffic data into different sessions, and construct question-answer pairs, including: In the divided conversation, when the client robot interacts with the user, the message sent by the server robot is regarded as a "question", and the response message sent by the client robot is regarded as an "answer", to construct a question-answer pair; when the server robot interacts with the client robot, the message sent by the client robot is regarded as a "question", and the response message sent by the server robot is regarded as an "answer".

6. The network protocol fuzz testing method based on Seq2Seq model according to claim 1 is characterized in that: Determine whether the network communication protocol used by the test target is a stateful protocol, including: Connect to the target network service through a standard network socket, send each message in the seed in the standard order, and record the response received after each message is sent; After completing the standard sequence of message transmission, these messages are rearranged to interact with the test target and sent again to the target network service; Whether the protocol is a stateful protocol is determined based on whether the received response changes. If the return message received by the fuzzifier is the same as the response obtained by sending the message in sequence, it is a stateless protocol. If the return message received by the fuzzifier is different from the response obtained by sending the message in sequence or is within an acceptable range, it is a stateful protocol.

7. The network protocol fuzz testing method based on Seq2Seq model according to claim 1 is characterized in that: If the network communication protocol is a stateful protocol, after synchronizing the state information between the test target and the fuzzer during the fuzz test, the fuzz test is performed using the test case, and the steps of obtaining the fuzz test result include: (1) Initialization: create an empty seed pool and initialize an empty protocol state machine model; (2) Generate an initialization seed. Use the trained server robot and client robot to randomly generate a message sequence as the initial seed and add it to the seed pool. (3) Select a seed. If this is the first test, randomly select a seed from the seed pool. In subsequent tests, select a seed that can reach a specific state based on the current protocol state machine. (4) Determine the mutation target and take the nth message in the selected seed as the mutation target; (5) Send messages and gradually build the state machine; Send the first n-1 messages to guide the test target to a state where it can receive the nth message; Mutate the nth message and generate a test case; Send the mutated test case to the test target and send the remaining messages; Use standard socket to interact with the test target and receive response messages; Determine the change of state based on the content of the response message and extract keywords to identify the new state; Add the new state and its transition condition M' to the protocol state machine model; (6) Fuzz testing: repeat steps (3) to (5), continue fuzz testing, and monitor protocol state changes and program coverage during the test process; (7) Update the seed pool. If the test case can cover the new protocol state or improve the program coverage, the test case will be added to the seed pool. (8) Synchronization and delay: using the delay waiting mechanism of the standard socket to synchronize the fuzzer with the test target state; (9) Iterative testing: repeat steps (3) to (8), iteratively perform fuzz testing, gradually build and improve the protocol state machine model, until the maximum number of iterations is reached, end the fuzz testing, and obtain the fuzz testing results.

8. The network protocol fuzz testing method based on Seq2Seq model according to claim 1 is characterized in that: If the network communication protocol is a stateless protocol, the test case is redirected to a local domain socket for fuzz testing, and the steps of obtaining the fuzz testing result include: (1) Use HOOK technology to intercept API calls related to data interaction in standard sockets; (2) When the API call of the socket() function is intercepted, it is redirected to the custom socket() function. The custom socket() function is responsible for creating and managing the local domain socket, replacing the original standard socket; (3) Create front-end and back-end sockets. In the custom socket() function, create the front-end socket front_socket() function and the back-end socket back_socket() function. The front-end socket front_socket() function is used for connection and data transmission between the client program and the server, simulating the behavior of the original client socket. The back-end socket back_socket() function is used to process the data received from the front-end socket front_socket() function and pass it to the back-end processing unit. (4) Create FRONT_TO_BACK_THREAD and BACK_TO_FRONT_THREAD threads; the FRONT_TO_BACK_THREAD thread is responsible for reading data from the front-end socket front_socket() function and passing it to the back-end socket back_socket() function; the BACK_TO_FRONT_THREAD thread is responsible for reading the data processed by the back-end processing unit from the back-end socket back_socket() function and returning it to the client through the front-end socket front_socket() function; (5) Allocate necessary memory space for the front-end socket front_socket() function to cache received data; manage the life cycle of the two threads FRONT_TO_BACK_THREAD and BACK_TO_FRONT_THREAD; (6) Use the fuzzer to establish a connection with the test target through the front-end socket front_socket() function, send test cases to the test target through the front_socket() function, perform fuzz testing, and obtain fuzz testing results.

9. A computer-readable storage medium having a computer program / instruction stored thereon, characterized in that: When the computer program / instructions are executed by a processor, the steps of the method according to claim 1 are implemented.

10. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the steps of the method according to claim 1 are implemented.

Citation Information

Cited By

  • State protocol fuzzy testing method based on reinforcement learning, medium and product

    CN119299195A

  • A stateful protocol fuzz testing method, medium, and product based on reinforcement learning

    CN119299195B

  • Vulnerability detection method and device, equipment, medium and product

    CN119995954A

  • Vulnerability detection method, device, equipment, medium and product

    CN119995954B