Seed grouping method for network protocol fuzz testing
Through a two-stage seed grouping strategy, combining network protocol state transfer and message sequence, the problem of failure to effectively utilize protocol state information in the existing technology is solved, and more efficient network protocol fuzz testing is realized, which improves the test coverage and Adaptability.
Patent Information
- Application Number
- CN202411285407.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-13
- Publication Date
- 2024-11-01
AI Technical Summary
The existing network protocol fuzzy test seed packetization scheme fails to fully utilize protocol status information and message-driven characteristics, resulting in inaccurate packetization and affecting testing efficiency and effectiveness.
A two-stage seed grouping strategy is adopted. The first stage is coarse-grained classification through network protocol state transfer information, and the second stage is fine-grained semantic similarity measurements combined with protocol state machine and message sequence to improve the accuracy and coverage of packets.
It significantly improves the coverage and efficiency of fuzz testing, and can more accurately identify potential vulnerabilities and abnormal behaviors of network protocols, and adapt to the testing needs of complex network protocols.
Smart Images

Figure CN118890212A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of network protocol fuzzy testing, and relates to a seed grouping method for network protocol fuzzy testing. Background Art
[0002] Fuzz testing is an automated testing technique that detects the behavior of software when it handles abnormal or unexpected inputs by inputting a large amount of random or pseudo-random data (called "fuzzy data") into a software program. This technique aims to reveal potential defects or vulnerabilities in the program when it handles illegal, boundary or non-standard data. Fuzz testing can help discover security vulnerabilities, crash points and other abnormal situations, thereby improving the stability and security of the software.
[0003] Network protocol testing is a testing process for network protocols, which aims to ensure that network protocols correctly implement their functions according to design specifications and exhibit expected behaviors under various operating conditions. Network protocol testing helps developers and testers find and fix potential problems in protocol implementation by simulating real or expected network environments and using various testing tools and techniques such as protocol analyzers, load generators, and fault injection tools.
[0004] In the fuzz testing process, seeds refer to the basic inputs used to generate new inputs through mutation. These input seeds are usually valid, well-formed sample inputs that represent the normal or expected input forms that the program can handle. By mutating (i.e. modifying or extending) these input seeds to generate different fuzzy data, the stability and security of the program when processing various inputs can be tested.
[0005] In fuzz testing, seed grouping refers to classifying input seeds according to predetermined standards, characteristics, or attributes to facilitate the systematic generation and management of fuzzy data. By grouping seeds, fuzz testing tools can effectively organize test inputs, improve test efficiency, and optimize test coverage. Seed grouping helps identify and analyze the impact of different seed groups on program behavior and provide more targeted scheduling strategies.
[0006] Fuzz Testing is an automated software testing technology used to discover security vulnerabilities and stability issues in programs. Its basic principle is to test the behavior of a program when handling abnormal or unexpected inputs by inputting a large amount of random or pseudo-random data into the program. Compared with traditional software testing methods, it has the advantages of high efficiency (it can automatically discover potential defects in large-scale programs) and wide applicability (it can be used for various types of programs and systems, including network applications, operating systems and embedded systems).
[0007] Coverage Guided Greybox Fuzzing is an automated testing technology that combines fuzz testing and code coverage analysis. Through lightweight code instrumentation, coverage-guided greybox fuzzing can use the program's execution path information as feedback to optimize the generation of test inputs, thereby generating test inputs with high coverage in a targeted manner.
[0008] Network Protocol Fuzzing is an automated testing technology specifically for network protocols, used to discover defects, vulnerabilities, and abnormal behaviors in protocol implementations. It sends various abnormal or forged data packets to the network protocol to evaluate the stability and security of the protocol when processing these inputs.
[0009] By making full use of the state feedback information of network protocols (such as status codes) and the message-driven characteristics of network protocols, recently proposed network protocol fuzz testing schemes (such as AFLNet) can achieve better testing results. Specifically, the tool automatically generates and maintains a state machine model that reflects the protocol state by analyzing feedback information such as status codes returned by the network protocol server. On this basis, these schemes use the generated state machine to guide the mutation process of input data, thereby optimizing the coverage and depth of test inputs. Experiments show that fuzz testing schemes specially designed for network protocols can achieve broader and deeper code coverage on multiple widely used network protocols, thereby identifying more potential defects and security vulnerabilities.
[0010] The following uses the network protocol test AFLNET as an example to introduce the best technical solution for current network protocol fuzz testing.
[0011] AFLNET is the first stateful gray-box protocol fuzz testing tool based on AFL. It constructs a protocol state machine (IPSM) by extracting the state code in the response message and uses this state machine to guide the test. AFLNET includes modules such as state learner, target state selector, sequence selector and sequence mutator.
[0012] AFLNET implements network communication with the server through sockets and supports sending and receiving messages. The input is a pcap file containing network traffic, and a request sequence parser is used to generate a message sequence corpus. The state learner extends IPSM, the target state selector selects the test state according to IPSM, the sequence selector selects the message sequence from the corpus, and the sequence mutator mutates the message sequence.
[0013] The actual implementation process of AFLNET is as follows:
[0014] 1.AFLNET receives the pcap file and parses the message sequence.
[0015] 2. The state machine learner extracts the state code and builds the IPSM.
[0016] 3. Target state selector Select the test target state.
[0017] 4. The sequence selector selects the appropriate message sequence, and the sequence mutator mutates it.
[0018] 5. Update the corpus and IPSM, recording new states and state transitions.
[0019] Seed clustering is a new technology in the field of fuzz testing in recent years. The goal of seed clustering is to group similar seeds into one class based on grammatical and semantic similarity. The results of seed clustering can be used to learn different probability distributions for different classes to achieve more efficient fuzz testing. The following uses SeamFuzz as an example to introduce the general process of seed clustering technology.
[0020] SEAMFUZZ performs grey-box fuzz testing through a seed-adaptive mutation strategy. SEAMFUZZ first divides seed inputs into different groups according to their grammatical and semantic properties, and learns the probability distribution of mutation methods for each seed group through a variant of the Thompson sampling algorithm. The probability distribution learned for each group is used to select effective mutation methods when mutating seed inputs belonging to that group.
[0021] The execution flow of SEAMFUZZ during seed grouping is as follows:
[0022] 1. Given a seed input s and a set of seed groups G, the goal of seed grouping is to group the selected seed input s into appropriate seed groups with similar characteristics.
[0023] 2. To achieve this goal, it defines a similarity score, denoted by scoresim, and a CLUSTER function; the similarity score indicates how close the seed input s is to the seed group, and the CLUSTER function groups the seed inputs into corresponding seed groups based on this score.
[0024] 3. To calculate the similarity score, its definition explains two concepts of similarity: semantic similarity and grammatical similarity.
[0025] 4. The overall similarity score is intuitively the ratio of the number of path transitions covered by the seed input s and the seed input set S together to the total number of path transitions covered by the set S.
[0026] 5. The CLUSTER function calculates the similarity score between the seed input s and each seed group, and returns a seed group with an updated set of seed inputs when the highest similarity score dmax exceeds a threshold γ. If the seed input s is not related to any existing seed group (i.e., dmax is below the threshold γ), the CLUSTER function initializes a new seed group and starts with the representative seed input s. In this case, SEAMFUZZ initializes Pid to a uniform distribution (Pr) because the newly generated groups have not yet learned a valid probability distribution; the probability distribution Pid of all groups starts with a random probability and becomes smarter as the learning process progresses.
[0027] Although AFLNET has achieved good results in many protocols, it also has some shortcomings:
[0028] -AFLNET uses the coarse-grained response code in the response message as the status of the protocol program, but the response code cannot fully reflect the real status of the protocol, which affects the efficiency of fuzz testing.
[0029] -In order to test a specific state, AFLNET needs to send long prefix and suffix messages, resulting in a large amount of time spent sending unmutated messages. In contrast, the proportion of infix messages that are truly used to explore and trigger new states or branches in the test cases is very low, making the throughput of protocol fuzz testing extremely low.
[0030] - The low throughput of AFLNET leads to a tendency to choose short message sequences that can reach the target state faster when selecting seeds. However, this choice makes it difficult to cover deeper states or branches.
[0031] - In some protocols, there are some vulnerabilities that need to be triggered by multiple interrelated messages in a specific order. However, AFLNet only explores and tests specific target states in each round of testing, and cannot implement cross-state protocol testing.
[0032] - There is a lack of synchronization mechanism between AFLNET and System under Test (SUT), which makes it impossible for the fuzzer to accurately know whether the SUT has processed the test case. Therefore, AFLNET usually needs to set a time delay to wait for the response message from the SUT, which affects the efficiency and speed of the test.
[0033] The existing seed grouping scheme is designed for the fuzz testing process of general programs, and does not take into account the specific characteristics of network protocol programs and the information contained in the protocol state. Therefore, the existing seed grouping scheme has some defects when applied to fuzz testing of network protocols, as follows:
[0034] First, existing fuzz testing seed grouping schemes do not fully consider the state information of network protocols. The state of network protocols plays a key role in message processing and response, but existing schemes fail to effectively utilize this state information to optimize grouping effects. Ignoring the state characteristics of network protocols may lead to inaccurate grouping, thus affecting the effectiveness and effect of the test.
[0035] Secondly, the existing fuzz testing seed grouping schemes are too dependent on the code coverage in program execution for semantic similarity measurement design. However, the behavior of network protocols has characteristics such as state transfer and message-driven, rather than simple code path coverage. These characteristics are crucial for message processing, but the existing schemes fail to effectively reflect the behavioral characteristics of these network protocols. Therefore, the current semantic similarity measurement design is not enough to achieve the purpose of optimizing network protocol fuzz testing grouping. Summary of the invention
[0036] In view of the problems existing in the prior art, the purpose of the present invention is to provide a seed grouping method for network protocol fuzzy testing, and the key technical issues involved include:
[0037] First, how to combine the state information of the network protocol in the seed grouping scheme to obtain a better grouping effect. The state of the network protocol plays a vital role in processing and responding to messages, but existing seed grouping schemes often ignore this state information, resulting in the inability to fully utilize the semantic characteristics of the protocol. This may lead to inaccurate grouping, thus affecting the effectiveness of fuzz testing. Therefore, designing a grouping scheme that can effectively utilize the state information of the network protocol is a key issue.
[0038] Secondly, how to combine the state machine and message-driven characteristics of network protocols to design a semantic similarity measurement scheme that can better reflect the behavior of the protocol. Existing semantic similarity measurement designs usually rely on code coverage during program execution, while ignoring the state transition and message-driven characteristics of network protocol programs. However, these characteristics are crucial to the processing and behavioral impact of protocol messages. In order to optimize the grouping effect of network protocol fuzz testing, it is necessary to develop a new semantic similarity measurement scheme that can better reflect the complex behavioral characteristics of network protocols.
[0039] By solving the above two key technical problems, more effective seed grouping can be achieved in network protocol fuzz testing, thereby improving the coverage and efficiency of fuzz testing.
[0040] In order to better implement seed grouping in the process of network protocol fuzz testing, the present invention proposes a two-stage seed grouping strategy. In the first stage, the scheme uses the state transition information of the network protocol state transition to divide the seeds into coarse-grained types. In the second stage, the scheme designs a fine-grained semantic similarity that combines the protocol state transition and the message sequence to measure the relationship between seeds, and divides the seeds of the same type into more fine-grained groups. The key points of the present invention are as follows:
[0041] In order to better realize seed grouping in the process of network protocol fuzz testing, the present invention proposes an innovative two-stage seed grouping strategy, which aims to make full use of the statefulness and message-driven characteristics of network protocols and improve the efficiency and effect of fuzz testing.
[0042] In the first stage, the present invention innovatively uses protocol state transition information to classify seeds. Unlike traditional solutions that only group based on a single state information, the present invention classifies seeds with the same or similar state transitions into the same type by analyzing the state transition of the seed input in the protocol. This method not only captures the dynamic changes of the protocol state, but also effectively improves the semantic richness and accuracy of the grouping. By introducing the concept of state transition, the granularity of seed classification is optimized, avoiding the redundancy caused by overly detailed classification, thereby improving the overall efficiency of fuzz testing.
[0043] In the second stage, the present invention further proposes a fine-grained semantic similarity measurement scheme that combines the protocol state machine and the message sequence. Traditional seed grouping schemes usually rely only on the control flow information in program execution, while the present invention breaks through the combination of protocol state transfer, message sequence and general program semantic similarity to construct a more comprehensive and accurate similarity measurement model. This model can not only more accurately reflect the relationship between seed inputs, but also more effectively explore and discover potential vulnerabilities and abnormal behaviors in complex scenarios of network protocols.
[0044] Through the innovation of these two stages, the seed grouping strategy of the present invention can capture the characteristics of network protocols in a more refined manner, greatly improve the coverage and test effect of fuzz testing, and provide strong technical support for network protocol security testing.
[0045] The technical solution of the present invention is:
[0046] A seed grouping method for network protocol fuzz testing, the steps comprising:
[0047] 1) Obtaining state transition information of a seed in a network protocol, a message sequence triggered by the seed in the network protocol, and the code covered by the seed in the network protocol for network protocol fuzz testing;
[0048] 2) grouping the seeds according to the state transition information, and grouping the seeds with the same or similar state transition paths into the same coarse-grained seed group;
[0049] 3) For any two seeds in the same coarse-grained seed group, the similarity between the two seeds is calculated based on the network protocol state transition, message sequence and covered code corresponding to the seeds; the seeds in the same coarse-grained seed group are divided into several fine-grained seed groups according to the similarity.
[0050] Furthermore, the method for obtaining the state transition information is: first, according to the state machine of the network protocol, obtain the state of the network protocol and the transition relationship between them, and construct a state transition diagram of the network protocol; record the state transition path of each seed in the fuzzy test of the network protocol.
[0051] Furthermore, the path similarity between seeds is measured using a complete matching or partial matching method, and seeds with the same or similar state transition paths are grouped into the same coarse-grained seed group.
[0052] Furthermore, the code covered by the seed in the network protocol is obtained through the stub technology.
[0053] Furthermore, the protocol state machine similarity between any two seeds is calculated based on the network protocol state transition corresponding to the seeds, the message sequence similarity between any two seeds is calculated based on the message sequence corresponding to the seeds, and the general semantic similarity between any two seeds is calculated based on the codes covered by the seeds; the similarity between any two seeds is obtained by weighted calculation of the protocol state machine similarity, message sequence similarity, and general semantic similarity between any two seeds.
[0054] Furthermore, the similarity of the protocol state machines between the two seeds is determined based on the path intersection or the longest common subsequence of the network protocol state transitions corresponding to the two seeds; the similarity of the message sequences between the two seeds is determined based on the similarity of the message contents and the similarity of the message orders in the message sequences corresponding to the two seeds.
[0055] Further, the general semantic similarity between the two seeds is determined based on the intersection of code blocks between the covered codes corresponding to the two seeds; or the general semantic similarity between the two seeds is determined based on whether the covered codes corresponding to the two seeds cover the same function or code path; or the general semantic similarity between the two seeds is determined based on the similarity of control flow graphs between the covered codes corresponding to the two seeds.
[0056] A network protocol fuzz testing method, characterized in that fuzz testing data is generated using the seed grouping generated by the above method to test the target network protocol.
[0057] A server, characterized in that it comprises a memory and a processor, wherein the memory stores a computer program, the computer program is configured to be executed by the processor, and the computer program comprises instructions for executing the above method.
[0058] A computer-readable storage medium stores a computer program, wherein the computer program implements the above method when executed by a processor.
[0059] The advantages of the present invention are as follows:
[0060] 1. Improve the accuracy of fuzz testing: By combining the state information of the network protocol, message sequence similarity and general semantic similarity, the present invention can more accurately identify and group seed inputs with similar behaviors, avoiding the problem of inaccurate grouping caused by ignoring the protocol state in traditional methods, thereby improving the accuracy of fuzz testing.
[0061] 2. Optimize test coverage: The two-stage grouping strategy adopted by the present invention can comprehensively cover various behavior patterns of network protocols through coarse-grained state classification and fine-grained semantic similarity measurement. This helps to discover more potential vulnerabilities and improve the coverage and comprehensiveness of the test. Experiments on multiple common network protocols have confirmed that this solution can achieve significant coverage improvement.
[0062] 3. Enhanced test efficiency: Due to more accurate grouping and selection of seed inputs during the test process, the present invention reduces unnecessary redundant test operations and improves the efficiency of fuzz testing. More reasonable seed grouping also optimizes resource utilization, helping to cover more test scenarios within a limited time.
[0063] 4. Adaptability to complex network protocols: This invention specifically designs a special similarity measurement method for the statefulness and message-driven characteristics of network protocols, which can better adapt to the testing requirements of complex network protocols. Compared with traditional fuzz testing methods, this invention shows stronger adaptability and flexibility when dealing with complex protocols. Experiments on multiple common network protocols have confirmed the adaptability of this solution. BRIEF DESCRIPTION OF THE DRAWINGS
[0064] Figure 1 It is a two-stage seed grouping scheme.
[0065] Figure 2 Schematic diagram of seed type derivation combined with network protocol state transition information in phase one.
[0066] Figure 3 This is the flowchart of the multi-dimensional semantic similarity measurement in phase 2 that comprehensively uses the protocol state machine, message sequence similarity, and general semantic similarity. DETAILED DESCRIPTION
[0067] The present invention is further described in detail below in conjunction with the accompanying drawings. The examples given are only used to explain the present invention but not to limit the scope of the present invention.
[0068] In order to more effectively perform seed grouping in network protocol fuzz testing, this paper proposes an innovative two-stage seed grouping strategy. This strategy aims to make full use of the state transition information and message-driven characteristics of the network protocol to improve the accuracy of grouping and the test effect. The process is summarized as follows: Figure 1 shown.
[0069] In the first stage, the present invention introduces the network protocol state transition information and classifies the seeds in a coarse-grained manner according to the changes in the protocol state. This method classifies seeds with the same or similar state transition paths into the same type by identifying and utilizing the characteristics of state transitions during protocol execution. This process ensures that the grouping can capture the core semantic information in the protocol execution, making the grouping results more consistent with the operating logic and behavior patterns of the actual protocol.
[0070] In the second stage, the present invention further refines the grouping strategy by designing a fine-grained semantic similarity measurement method that combines protocol state transitions with message sequences to deeply analyze the relationship between seeds of the same type. This method not only considers the similarity of seeds in state transitions, but also combines the characteristics of message sequences to evaluate the semantic similarity between seeds. Through this multi-dimensional similarity measurement, the present invention can make a more refined division of seeds of the same type, ensuring that the grouping can more accurately reflect the complex behavior and potential vulnerabilities of the network protocol.
[0071] Below we will introduce in detail the specific implementation methods of seed grouping in these two stages.
[0072] Phase 1: Seed type derivation combined with network protocol state transition information
[0073] The detailed implementation of the first phase mainly includes the following steps:
[0074] 1. Construction of network protocol state transfer model
[0075] First, the state machine of the target network protocol needs to be modeled. Network protocols usually contain multiple states, each of which corresponds to the behavior of the protocol at different stages. The transition between states is driven by received messages or events. By analyzing the protocol documents or source code, the states of the protocol and the transition rules between them are extracted, and the state transition diagram of the protocol is constructed.
[0076] Implementation steps:
[0077] State identification: Determine the various states in the protocol, usually extracted from the protocol description, specification document or source code.
[0078] State transition rule definition: Define the transition rules between states, that is, when receiving what kind of message or event, the protocol will transition from one state to another.
[0079] State transition graph construction: Based on the identified states and transition rules, a state transition graph is constructed. The nodes of the graph represent states, and the edges represent transitions between states.
[0080] 2. Record the state transition path of the seed
[0081] During the fuzz testing process, each seed input triggers the execution of the protocol program and causes the program to perform a series of state jumps on the state transition graph. In order to combine the state transition information to group the seeds, it is necessary to record the state transition path of each seed.
[0082] Implementation steps:
[0083] Execution trace collection: When running the seed input, the state transition path experienced by the protocol program is recorded in real time. Monitoring points can be inserted into the protocol code through instrumentation technology to collect state changes during program execution.
[0084] Path representation: The state transition path of each seed is represented as a series of state sequences. For example, the path of seed s1 may be represented as: `S1→S2→S3`, where S1, S2, and S3 are different states of the protocol.
[0085] 3. Seed type derivation based on state transition information
[0086] Once the state transition paths of all seeds are obtained, the seeds can be classified according to the path information. Seeds with the same or similar state transition paths can be classified into the same type. This classification method ensures that the seed type not only reflects the surface characteristics of the input data, but also captures the deep information of the internal state changes of the protocol.
[0087] Implementation steps:
[0088] Path similarity measurement: Define the path similarity measurement method to determine the similarity of state transition paths between different seeds. Commonly used measurement methods include:
[0089] Exact match: Two seeds are classified as the same type only if their state transition paths are exactly the same.
[0090] Partial matching: allows differences in some states or transitions in the path, but requires that most paths have a high degree of similarity in order to be classified as the same type.
[0091] Seed grouping: seeds are divided into several types according to path similarity. For complete matches, you can directly group them according to whether the paths are the same or not; for partial matches, you can set a similarity threshold. When the similarity of two paths exceeds the threshold, they are classified as the same type.
[0092] 4. Dynamic adjustment and optimization
[0093] In the actual fuzz testing process, with the introduction of new seeds and the increase of state transition paths, it may be necessary to dynamically adjust the type of seed grouping. For example, when the path of the new seed does not match any existing type, a new type can be created; or when the similarity between multiple types is very high, the types may need to be merged.
[0094] Implementation steps:
[0095] New seed processing: For each new seed, check whether its state transition path matches the existing type. If it matches, it is classified into the corresponding type; if it does not match, a new type is created.
[0096] Type merging: Regularly check the similarity between existing types. If the similarity between two types is higher than a predetermined threshold, consider merging them into one type.
[0097] Phase 2: A multi-dimensional semantic similarity measurement scheme that uses protocol state machines, message sequence similarity, and general semantic similarity
[0098] The detailed implementation of the second stage mainly involves how to evaluate the semantic similarity between seeds from multiple dimensions and group seeds of the same type in a more fine-grained manner based on this. It includes the following steps:
[0099] 1. Protocol state machine similarity measurement
[0100] Protocol state machine similarity refers to measuring the similarity of two seed inputs in the protocol state machine based on the state transition diagram of the network protocol. This similarity measurement method mainly considers the degree of overlap between the two in the state transition path.
[0101] Implementation steps:
[0102] State transition path comparison: Compare the execution paths of the two seeds in the protocol state machine and calculate the similarity of the paths. The similarity can be calculated by a variety of methods, such as:
[0103] Path intersection: Calculate the ratio of the intersection of two seed paths to the total path length, that is, `similarity = intersection length / total length`.
[0104] Longest Common Subsequence (LCS): Calculate the longest common subsequence of two paths. The longer the LCS, the higher the similarity.
[0105] Similarity score: Convert the path comparison result into a similarity score. A higher score indicates that the seeds behave more similarly on the protocol state machine.
[0106] 2. Message sequence similarity measurement
[0107] Message sequence similarity measures the similarity of message sequences triggered by two seed inputs in a network protocol. This similarity measure considers message content, order, and its impact on the protocol state.
[0108] Implementation steps:
[0109] Message content similarity: First, the message content similarity is calculated. This can be achieved in a variety of ways:
[0110] Message structure comparison: If the message structures are the same or similar (such as the number of fields, field types), they are considered similar.
[0111] Message content difference: Use methods such as edit distance and Jaccard similarity coefficient to measure the difference in message text or binary content.
[0112] Message sequence similarity: Calculate the order similarity of message sequences, which can be achieved by comparing whether the order of message sequences triggered by two seeds is consistent. For example, a sequence matching algorithm (such as LCS) is used to evaluate the consistency of message sequences.
[0113] Similarity comprehensive score: The similarity of message content and message sequence is weighted and combined to obtain the final message sequence similarity score.
[0114] 3. General semantic similarity measurement
[0115] Generally, semantic similarity refers to the similarity measurement method based on program execution path and code coverage commonly used in traditional fuzz testing. It mainly considers the similarity of the execution paths of two seed inputs in the program code.
[0116] Implementation steps:
[0117] General semantic similarity: Through the instrumentation technology, the code coverage of the seed input in the protocol program is recorded. Then the similarity of the code blocks (basic blocks or functions) covered by the two seeds is compared. Common methods include:
[0118] Coverage block intersection: Calculate the ratio of the intersection of code blocks covered by two seeds to the total coverage blocks.
[0119] Function level comparison: compares whether two seeds cover the same functions or code paths.
[0120] Control flow similarity: Compare the control flow graphs of two seeds to determine the similarity of their execution paths. Usage methods include comparing the structure of the control flow graph, path similarity, etc.
[0121] 4. Multi-dimensional Similarity Fusion
[0122] After obtaining the similarity scores of the above three dimensions, the next step is to fuse these scores to form a comprehensive semantic similarity measure for refined grouping of seeds.
[0123] Implementation steps:
[0124] Weighted combination of similarities: Assign a weight to the similarity score of each dimension, and determine the weight of each dimension based on actual needs and importance. For example, the weights of protocol state machine similarity, message sequence similarity, and general semantic similarity can be set to `w1`, `w2`, and `w3` respectively, and the final comprehensive similarity is:
[0125] Comprehensive similarity = w1×protocol state machine similarity + w2×message sequence similarity + w3×general semantic similarity
[0126] Similarity threshold determination: Set a similarity threshold to decide whether to group two seeds into the same fine-grained group. Seeds with similarity higher than the threshold are grouped into the same group, otherwise they are grouped into different groups.
[0127] 5. Fine-grained seed grouping
[0128] Based on the comprehensive semantic similarity, seeds of the same type are further grouped. Seeds with high similarity are grouped into the same fine-grained group, thus achieving more refined management and test coverage of seeds.
[0129] Implementation steps:
[0130] Application of grouping algorithm: Use clustering algorithms such as hierarchical clustering or K-means to automatically group seeds with high similarity into the same fine-grained group.
[0131] Grouping optimization: Regularly check the grouping situation and dynamically adjust the grouping strategy based on the actual test results to ensure the effectiveness and rationality of the grouping.
[0132] The technical implementation of this solution may have the following potential variations:
[0133] Multi-stage classification scheme:
[0134] Extension phase: An intermediate phase is added between the first and second phases to further refine the classification. For example, after the initial classification, more features (such as message sequence, protocol anomaly patterns) are introduced for grouping.
[0135] Dynamic adjustment: Dynamically adjust the seed classification strategy based on the real-time results of fuzz testing. For example, dynamically update the grouping information based on new states or message sequences discovered during the test.
[0136] Refinement of the state machine model:
[0137] Hierarchical state machine: Model the state machine of the network protocol in a hierarchical manner, subdivide the states at different levels, and perform seed classification based on these hierarchical states.
[0138] Fine-grained state representation: Introduce more state variables or context information to refine the modeling accuracy of the state machine and improve the resolution of state transitions.
[0139] Improvements in semantic similarity metrics:
[0140] Integrate other metrics: Based on the existing semantic similarity metrics, integrate additional metrics such as context information and protocol specifications to improve the accuracy of grouping.
[0141] Dynamic similarity adjustment: Dynamically adjust the weights or parameters of the semantic similarity measurement based on feedback during the test process to better adapt to the actual situation of the network protocol.
[0142] Data-driven optimization:
[0143] Automated data analysis: Use data mining or automated analysis tools to conduct in-depth analysis of seed behavior and state transitions to automatically optimize grouping strategies.
[0144] Large-scale data processing: Use an efficient data processing platform to process large amounts of seed data to improve the efficiency and accuracy of grouping.
[0145] Although the specific embodiments of the present invention are disclosed for the purpose of illustration, the purpose is to help understand the content of the present invention and implement it accordingly, those skilled in the art will understand that various substitutions, changes and modifications are possible without departing from the spirit and scope of the present invention and the appended claims. Therefore, the present invention should not be limited to the content disclosed in the best embodiment, and the scope of the present invention is subject to the scope defined in the claims.
Claims
1. A seed grouping method for network protocol fuzz testing, the steps of which are include: 1) Obtaining state transition information of a seed in a network protocol, a message sequence triggered by the seed in the network protocol, and the code covered by the seed in the network protocol for network protocol fuzz testing; 2) grouping the seeds according to the state transition information, and grouping the seeds with the same or similar state transition paths into the same coarse-grained seed group; 3) For any two seeds in the same coarse-grained seed group, the similarity between the two seeds is calculated based on the network protocol state transition, message sequence and covered code corresponding to the seeds; the seeds in the same coarse-grained seed group are divided into several fine-grained seed groups according to the similarity.
2. The method according to claim 1, It is characterized in that The method for obtaining the state transition information is: first, according to the state machine of the network protocol, obtain the state of the network protocol and the transition relationship between them, and construct a state transition diagram of the network protocol; record the state transition path of each seed in the fuzzy test for the network protocol.
3. The method according to claim 1 or 2, It is characterized in that The path similarity between seeds is measured using the complete matching or partial matching method, and seeds with the same or similar state transition paths are grouped into the same coarse-grained seed group.
4. The method according to claim 1, It is characterized in that The code covered by the seed in the network protocol is obtained through the instrumentation technology.
5. The method according to claim 1, It is characterized in that The protocol state machine similarity between any two seeds is calculated based on the network protocol state transition corresponding to the seeds, the message sequence similarity between any two seeds is calculated based on the message sequence corresponding to the seeds, and the general semantic similarity between any two seeds is calculated based on the covered codes corresponding to the seeds; the similarity between any two seeds is obtained by weighted calculation of the protocol state machine similarity, message sequence similarity, and general semantic similarity between any two seeds.
6. The method according to claim 5, It is characterized in that The similarity of the protocol state machines between the two seeds is determined based on the path intersection or the longest common subsequence of the network protocol state transitions corresponding to the two seeds; the similarity of the message sequences between the two seeds is determined based on the similarity of the message content and the similarity of the message order in the message sequences corresponding to the two seeds.
7. The method according to claim 5, It is characterized in that The general semantic similarity between two seeds is determined based on the code block intersection between the codes covered by the two seeds; or the general semantic similarity between two seeds is determined based on whether the codes covered by the two seeds cover the same function or code path; or the general semantic similarity between two seeds is determined based on the control flow graph similarity between the codes covered by the two seeds.
8. A network protocol fuzz testing method, It is characterized in that The seed grouping generated by the method described in claim 1 is used to generate fuzzy test data to test the target network protocol.
9. A server, It is characterized in that The invention comprises a memory and a processor, wherein the memory stores a computer program, the computer program is configured to be executed by the processor, and the computer program comprises instructions for executing the method according to any one of claims 1 to 8.
10. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.
