Method and apparatus for generating abnormal data

Optimizing grammar fuzzers to align with C-V2X syntax allows for effective generation of malformed data for C-V2X protocol testing, addressing the limitations of existing frameworks and improving vehicle communication security.

CN114296736BActive Publication Date: 2025-07-15QI AN XIN TECHNOLOGY GROUP INC +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111614818.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-27
Publication Date
2025-07-15
Estimated Expiration
2041-12-27

AI Technical Summary

Technical Problem

The existing fuzz testing framework cannot generate malformed data suitable for the C-V2X protocol because the C-V2X protocol is defined in bit units, while the existing framework is generated in byte units.

Method used

The original syntax fuzzer is processed through an optimization program, and an optimized syntax fuzzer is generated. Deformed data is generated based on the syntax template and target seed of the C-V2X protocol, including regular matching, syntax tree analysis and the use of syntax implementation functions.

Benefits of technology

It realizes the generation of malformed data suitable for the C-V2X protocol, meets the needs of fuzz testing, and improves the effectiveness and coverage of fuzz testing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114296736B_ABST
    Figure CN114296736B_ABST
Patent Text Reader

Abstract

The present application discloses a method and apparatus for generating abnormal data, relating to the technical field of fuzzy detection. The method of the present application includes: an optimization program optimizes an original syntax fuzzer according to a syntax template corresponding to each C-V2X sub-protocol included in the C-V2X protocol, so as to obtain an optimized syntax fuzzer; the optimized syntax fuzzer receives an abnormal data generation task, wherein the abnormal data generation task includes a unique identifier corresponding to a target C-V2X sub-protocol and a target seed; the optimized syntax fuzzer obtains a target syntax template corresponding to the target C-V2X sub-protocol according to the unique identifier; the optimized syntax fuzzer determines a fuzzy rule corresponding to the target syntax template according to the target seed; the optimized syntax fuzzer generates abnormal data corresponding to the target C-V2X sub-protocol according to the fuzzy rule and the target syntax template.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of fuzzy detection technology, and particularly to a method and device for generating abnormal data. Background Art

[0002] The C-V2X protocol is a general V2X protocol that realizes vehicle ad-hoc networking by reusing the current cellular network and infrastructure. To ensure the security of vehicle communication, it is necessary to mine vulnerabilities in the C-V2X protocol.

[0003] Currently, vulnerabilities in the C-V2X protocol are usually mined by means of fuzz testing the C-V2X protocol. Among them, during the process of fuzz testing the C-V2X protocol, abnormal data required for fuzz testing needs to be generated. However, existing fuzz testing frameworks can generate abnormal data required for protocols written in bytes, while the C-V2X protocol is a protocol defined and written in bits. Therefore, based on existing fuzz testing frameworks, abnormal data required for fuzz testing the C-V2X protocol cannot be generated. Thus, how to generate abnormal data required for fuzz testing the C-V2X protocol is an urgent problem to be solved currently. Summary of the Invention

[0004] Embodiments of this application provide a method and device for generating abnormal data, and the main purpose is to generate abnormal data required for fuzz testing the C-V2X protocol.

[0005] To solve the above technical problems, the embodiments of this application provide the following technical solutions:

[0006] In a first aspect, this application provides a method for generating abnormal data, including:

[0007] An optimization program optimizes an original syntax fuzzer according to a syntax template corresponding to each C-V2X sub-protocol included in the C-V2X protocol to obtain an optimized syntax fuzzer, where each of the syntax templates includes multiple syntaxes, the optimized syntax fuzzer includes a syntax implementation function corresponding to each syntax, and the syntax template corresponding to the C-V2X sub-protocol is written according to the C-V2X sub-protocol;

[0008] The optimized syntax fuzzer receives an abnormal data generation task, where the abnormal data generation task includes a unique identifier corresponding to a target C-V2X sub-protocol and a target seed;

[0009] The optimized syntax fuzzer obtains a target syntax template corresponding to the target C-V2X sub-protocol according to the unique identifier;

[0010] The optimized syntax fuzzer determines a fuzzing rule corresponding to the target syntax template according to the target seed;

[0011] The optimized grammar fuzzer generates malformed data corresponding to the target C-V2X sub-protocol according to the fuzzing rules and the target grammar template.

[0012] Optionally, the optimization program optimizes the original grammar fuzzer according to the grammar templates corresponding to each C-V2X sub-protocol included in the C-V2X protocol to obtain an optimized grammar fuzzer, including:

[0013] Performing regular matching processing on each of the grammar templates according to a preset regular expression to obtain a plurality of grammar tags included in each of the grammar templates;

[0014] Obtaining a grammar implementation function corresponding to each of the grammar tags according to the plurality of grammar tags;

[0015] Adding the plurality of grammar implementation functions to the code corresponding to the original grammar fuzzer to obtain the optimized grammar fuzzer.

[0016] Optionally, the optimized grammar fuzzer determines the fuzzing rules corresponding to the target grammar template according to the target seed, including:

[0017] Performing parsing processing on the target grammar template to obtain a grammar tree corresponding to the target grammar template, where the grammar tree includes a plurality of branches, and each branch includes a plurality of fields;

[0018] Generating a random number corresponding to the target seed according to the target seed, a first preset pseudo-random function, and the number of the plurality of branches;

[0019] Determining a target branch corresponding to the target seed according to the random number;

[0020] Determining the plurality of fields included in the target branch as fields to be fuzzed to obtain the fuzzing rules.

[0021] Optionally, the fields to be fuzzed are specifically simple fields to be fuzzed or complex fields to be fuzzed; the optimized grammar fuzzer generates malformed data corresponding to the target C-V2X sub-protocol according to the fuzzing rules and the target grammar template, including:

[0022] Generating a fuzzed field value corresponding to each of the simple fields to be fuzzed according to the target seed, a second preset pseudo-random function, and the original field value included in each of the simple fields to be fuzzed;

[0023] Respectively replacing the original field value included in each of the simple fields to be fuzzed with the fuzzed field value corresponding to each of the simple fields to be fuzzed to obtain a fuzzed field corresponding to each of the simple fields to be fuzzed;

[0024] Perform regular matching on the target grammar template according to the grammar tags included in each of the complex fields to be obfuscated, so as to obtain the parameters corresponding to each of the grammar tags;

[0025] Input the parameters corresponding to each of the grammar tags into the grammar implementation functions corresponding to each of the grammar tags respectively;

[0026] Call the grammar implementation functions respectively to obtain the obfuscated field values corresponding to each of the complex fields to be obfuscated;

[0027] Replace the original field values included in each of the complex fields to be obfuscated with the obfuscated field values corresponding to each of the complex fields to be obfuscated respectively, so as to obtain the obfuscated fields corresponding to each of the complex fields to be obfuscated;

[0028] Combine multiple of the obfuscated fields to obtain the malformed data.

[0029] Optionally, the original field values included in the simple fields to be obfuscated are composed of multiple bits; the generating the obfuscated field values corresponding to each of the simple fields to be obfuscated according to the target seed, the second preset pseudo-random function, and the original field values included in each of the simple fields to be obfuscated includes:

[0030] Determine the obfuscated value corresponding to each of the bits according to the target seed, the second preset pseudo-random function, and the number of multiple of the bits;

[0031] Determine the obfuscated field values corresponding to the simple fields to be obfuscated according to the obfuscated values corresponding to each of the bits.

[0032] Optionally, after the optimization program optimizes the original grammar obfuscator according to the grammar templates corresponding to each C-V2X sub-protocol included in the C-V2X protocol to obtain an optimized grammar obfuscator, the method further includes:

[0033] The optimization program adds a preset HOOK grammar implementation function to the code corresponding to the optimized grammar obfuscator.

[0034] Optionally, after the optimized grammar obfuscator generates the malformed data corresponding to the target C-V2X sub-protocol according to the obfuscation rules and the target grammar template, the method further includes:

[0035] The optimized grammar obfuscator inputs the malformed data into the preset HOOK grammar implementation function;

[0036] The optimized grammar fuzzer calls the preset HOOK grammar implementation function so that the preset HOOK grammar implementation function corrects the malformed data to obtain the corrected malformed data.

[0037] In a second aspect, the present application further provides a malformed data generation device, including:

[0038] An optimization unit, configured to optimize the original grammar fuzzer according to the grammar templates corresponding to each C-V2X sub-protocol included in the C-V2X protocol, so as to obtain a generation unit, where each of the grammar templates includes multiple grammars, and the generation unit includes grammar implementation functions corresponding to each grammar, and the grammar template corresponding to the C-V2X sub-protocol is written according to the C-V2X sub-protocol;

[0039] The generation unit is configured to receive a malformed data generation task, where the malformed data generation task includes a unique identifier corresponding to a target C-V2X sub-protocol and a target seed;

[0040] Obtain the target grammar template corresponding to the target C-V2X sub-protocol according to the unique identifier;

[0041] Determine the fuzzing rule corresponding to the target grammar template according to the target seed;

[0042] Generate the malformed data corresponding to the target C-V2X sub-protocol according to the fuzzing rule and the target grammar template.

[0043] Optionally, the optimization unit includes:

[0044] A first matching module, configured to perform regular matching processing on each of the grammar templates according to a preset regular expression, so as to obtain multiple grammar tags included in each of the grammar templates;

[0045] An acquisition module, configured to obtain the grammar implementation function corresponding to each grammar tag according to the multiple grammar tags;

[0046] An addition module, configured to add the multiple grammar implementation functions to the code corresponding to the original grammar fuzzer to obtain the optimized grammar fuzzer.

[0047] Optionally, the generation unit includes:

[0048] A parsing module, configured to perform parsing processing on the target grammar template to obtain a syntax tree corresponding to the target grammar template, where the syntax tree includes multiple branches, and each branch includes multiple fields;

[0049] A first generation module, configured to generate a random number corresponding to the target seed according to the target seed, a first preset pseudo-random function, and the number of the multiple branches;

[0050] A first determination module, configured to determine a target branch corresponding to the target seed according to the random number;

[0051] A second determination module, configured to determine multiple fields included in the target branch as fields to be blurred, so as to obtain the blurring rule.

[0052] Optionally, the fields to be blurred are specifically simple fields to be blurred or complex fields to be blurred; the generation unit further includes:

[0053] A second generation module, configured to generate a blurred field value corresponding to each simple field to be blurred according to the target seed, a second preset pseudo-random function, and the original field value included in each simple field to be blurred;

[0054] A first replacement module, configured to respectively replace the original field value included in each simple field to be blurred with the blurred field value corresponding to each simple field to be blurred, so as to obtain a blurred field corresponding to each simple field to be blurred;

[0055] A second matching module, configured to perform regular matching on the target syntax template according to the syntax tags included in each complex field to be blurred, so as to obtain parameters corresponding to each syntax tag;

[0056] An input module, configured to respectively input the parameters corresponding to each syntax tag into the syntax implementation function corresponding to each syntax tag;

[0057] A call module, configured to respectively call each syntax implementation function, so as to obtain a blurred field value corresponding to each complex field to be blurred;

[0058] A second replacement module, configured to respectively replace the original field value included in each complex field to be blurred with the blurred field value corresponding to each complex field to be blurred, so as to obtain a blurred field corresponding to each complex field to be blurred;

[0059] A combination module, configured to combine the multiple blurred fields, so as to obtain the deformed data.

[0060] Optionally, the original field value included in the simple field to be blurred consists of multiple bits;

[0061] The second generation module is specifically configured to determine a blurred value corresponding to each bit according to the target seed, the second preset pseudo-random function, and the number of the multiple bits;

[0062] Determine the fuzzy field value corresponding to the simple to-be-fuzzed field according to the fuzzy value corresponding to each bit.

[0063] Optionally, the optimization unit is further configured to add a preset HOOK syntax implementation function to the code corresponding to the optimized syntax fuzzer.

[0064] Optionally, the generating unit is further configured to input the malformed data into the preset HOOK syntax implementation function;

[0065] Call the preset HOOK syntax implementation function so that the preset HOOK syntax implementation function corrects the malformed data to obtain the corrected malformed data.

[0066] In a third aspect, an embodiment of the present application provides a storage medium, where the storage medium includes a stored program, and when the program runs, it controls the device where the storage medium is located to execute the method for generating malformed data described in the first aspect.

[0067] In a fourth aspect, an embodiment of the present application provides a device for generating malformed data, the device includes a storage medium; and one or more processors, the storage medium is coupled to the processors, and the processors are configured to execute program instructions stored in the storage medium; when the program instructions run, they execute the method for generating malformed data described in the first aspect.

[0068] By means of the above technical solutions, the technical solutions provided by the present application have at least the following advantages:

[0069] The present application provides a method and device for generating abnormal data. After the optimization program optimizes the original syntax fuzzer to obtain an optimized syntax fuzzer, the optimized syntax fuzzer can obtain a target syntax template corresponding to the target C-V2X sub-protocol according to the unique identifier carried in the abnormal data generation task, and determine the fuzzy rules corresponding to the target syntax template according to the target seed carried in the abnormal data generation task. Finally, according to the fuzzy rules corresponding to the target syntax template and the target syntax template, abnormal data corresponding to the target C-V2X sub-protocol is generated, that is, first determine which fields in the target syntax template need to be fuzzed according to the fuzzy rules, and then perform fuzzing on these fields based on the syntax implementation functions included in itself to obtain multiple fuzzed fields, and the abnormal data corresponding to the target C-V2X sub-protocol is composed of multiple fuzzed fields. Since the optimized syntax fuzzer is obtained by the optimization program optimizing the original syntax fuzzer according to the syntax templates corresponding to each C-V2X sub-protocol included in the C-V2X protocol, the optimized syntax fuzzer can implement various syntaxes in the syntax templates corresponding to each C-V2X sub-protocol, so that the optimized syntax fuzzer has the ability to generate abnormal data required for fuzz testing the C-V2X protocol. Therefore, based on the optimized syntax fuzzer, abnormal data required for fuzz testing the C-V2X protocol can be generated.

[0070] The above description is only an overview of the technical solution of the present application. In order to be able to understand the technical means of the present application more clearly, it can be implemented according to the content of the specification. And in order to make the above and other purposes, features and advantages of the present application more obvious and understandable, the specific embodiments of the present application are specifically exemplified below. Brief Description of the Drawings

[0071] By referring to the accompanying drawings and reading the following detailed description, the above and other purposes, features and advantages of the exemplary embodiments of the present application will become easy to understand. In the drawings, several embodiments of the present application are shown in an exemplary rather than restrictive manner, and the same or corresponding reference numerals represent the same or corresponding parts, wherein:

[0072] Figure 1 Shows a flowchart of a method for generating abnormal data provided by an embodiment of the present application;

[0073] Figure 2 Shows a flowchart of another method for generating abnormal data provided by an embodiment of the present application;

[0074] Figure 3 Shows a block diagram of the composition of a device for generating abnormal data provided by an embodiment of the present application;

[0075] Figure 4 Shows a block diagram of the composition of another device for generating abnormal data provided by an embodiment of the present application. Detailed implementation manners

[0076] Exemplary implementation manners of the present application will be described in more detail with reference to the accompanying drawings. Although the exemplary implementation manners of the present application are shown in the drawings, it should be understood that the present application can be implemented in various forms and should not be limited by the implementation manners set forth herein. On the contrary, these implementation manners are provided so that the present application can be more thoroughly understood and the scope of the present application can be completely conveyed to those skilled in the art.

[0077] It should be noted that, unless otherwise specified, the technical terms or scientific terms used in the present application should have the ordinary meanings understood by those skilled in the art to which the present application belongs.

[0078] The embodiment of the present application provides a method for generating abnormal data, specifically as Figure 1 shown. The method includes:

[0079] 101. The optimization program optimizes the original syntax fuzzer according to the syntax templates corresponding to each C-V2X sub-protocol included in the C-V2X protocol to obtain an optimized syntax fuzzer.

[0080] Among them, the original syntax fuzzer can be, but is not limited to, a Dharma syntax fuzzer; among the multiple C-V2X sub-protocols included in the C-V2X protocol, for any C-V2X sub-protocol, the syntax template corresponding to the C-V2X sub-protocol is written by the staff in advance according to the C-V2X sub-protocol, and various fields, various data structures, and the association relationships between various fields included in the C-V2X sub-protocol are defined in the syntax template corresponding to the C-V2X sub-protocol; among them, each syntax template contains multiple syntaxes, and the optimized syntax fuzzer contains the syntax implementation functions corresponding to each syntax, so that the optimized syntax fuzzer can implement various syntaxes in each syntax template, so that the optimized syntax fuzzer has the ability to generate abnormal data required for fuzz testing the C-V2X protocol.

[0081] In the embodiment of the present application, since the original syntax fuzzer does not have the ability to generate abnormal data required for fuzz testing the C-V2X protocol, the optimization program needs to optimize the original syntax fuzzer according to the syntax templates corresponding to each C-V2X sub-protocol included in the C-V2X protocol, so as to obtain the syntax fuzzer after optimization processing (i.e., the optimized syntax fuzzer), where the optimized syntax fuzzer has the ability to generate abnormal data required for fuzz testing the C-V2X protocol.

[0082] 102. The optimized syntax fuzzer receives an abnormal data generation task.

[0083] Among them, the malformed data generation task includes the unique identifier corresponding to the target C-V2X sub-protocol and the target seed.

[0084] In the embodiment of the present application, after the optimization program optimizes the original syntax fuzzer to obtain an optimized syntax fuzzer, when it is desired to use the optimized syntax fuzzer to generate malformed data required for fuzz testing a certain C-V2X sub-protocol (i.e., the target C-V2X sub-protocol), a malformed data generation task carrying the unique identifier corresponding to the target C-V2X sub-protocol and the target seed can be input to the optimized syntax fuzzer. At this time, the optimized syntax fuzzer can receive the malformed data generation task.

[0085] 103. The optimized syntax fuzzer obtains the target syntax template corresponding to the target C-V2X sub-protocol according to the unique identifier, and determines the fuzzing rules corresponding to the target syntax template according to the target seed.

[0086] Among them, the fuzzing rules are used to indicate which fields in the target syntax template need to be fuzzed.

[0087] In the embodiment of the present application, after receiving the malformed data generation task, the optimized syntax fuzzer can obtain the target syntax template corresponding to the target C-V2X sub-protocol according to the unique identifier carried in the malformed data generation task, and determine the fuzzing rules corresponding to the target syntax template according to the target seed carried in the malformed data generation task, that is, determine which fields in the target syntax template need to be fuzzed according to the target seed.

[0088] 104. The optimized syntax fuzzer generates malformed data corresponding to the target C-V2X sub-protocol according to the fuzzing rules and the target syntax template.

[0089] In the embodiment of the present application, after obtaining the target syntax template corresponding to the target C-V2X sub-protocol and determining the fuzzing rules corresponding to the target syntax template, the optimized syntax fuzzer can generate malformed data corresponding to the target C-V2X sub-protocol according to the fuzzing rules corresponding to the target syntax template and the target syntax template, that is, first determine which fields in the target syntax template need to be fuzzed according to the fuzzing rules, and then perform fuzzing on these fields based on the syntax implementation functions included in itself to obtain multiple fuzzed fields, and the multiple fuzzed fields form the malformed data corresponding to the target C-V2X sub-protocol.

[0090] An embodiment of the present application provides a method for generating abnormal data. After the optimization program optimizes the original syntax fuzzer to obtain an optimized syntax fuzzer, the optimized syntax fuzzer can obtain a target syntax template corresponding to the target C-V2X sub-protocol according to the unique identifier carried in the abnormal data generation task received, and determine the fuzzing rules corresponding to the target syntax template according to the target seed carried in the abnormal data generation task. Finally, according to the fuzzing rules corresponding to the target syntax template and the target syntax template, abnormal data corresponding to the target C-V2X sub-protocol is generated, that is, first determine which fields in the target syntax template need to be fuzzed according to the fuzzing rules, and then perform fuzzing processing on these fields based on the syntax implementation functions included in itself to obtain multiple fuzzed fields, and the multiple fuzzed fields form the abnormal data corresponding to the target C-V2X sub-protocol. Since the optimized syntax fuzzer is obtained by the optimization program optimizing the original syntax fuzzer according to the syntax template corresponding to each C-V2X sub-protocol included in the C-V2X protocol, the optimized syntax fuzzer can implement various syntaxes in the syntax templates corresponding to each C-V2X sub-protocol, so that the optimized syntax fuzzer has the ability to generate the abnormal data required for fuzz testing the C-V2X protocol. Therefore, based on the optimized syntax fuzzer, the abnormal data required for fuzz testing the C-V2X protocol can be generated.

[0091] For more detailed description, another method for generating abnormal data is provided in the embodiment of the present application, specifically as Figure 2 shown, and the method includes:

[0092] 201. The optimization program optimizes the original syntax fuzzer according to the syntax template corresponding to each C-V2X sub-protocol included in the C-V2X protocol to obtain an optimized syntax fuzzer.

[0093] In the embodiment of the present application, since the original syntax fuzzer does not have the ability to generate the abnormal data required for fuzz testing the C-V2X protocol, the optimization program needs to optimize the original syntax fuzzer according to the syntax template corresponding to each C-V2X sub-protocol included in the C-V2X protocol, so as to obtain the syntax fuzzer after optimization processing (that is, the optimized syntax fuzzer).

[0094] Specifically, in this step, the optimization program can optimize the original syntax fuzzer according to the syntax template corresponding to each C-V2X sub-protocol included in the C-V2X protocol in the following manner to obtain an optimized syntax fuzzer:

[0095] Among them, for any C-V2X sub-protocol, when the staff writes the grammar template corresponding to the C-V2X sub-protocol according to the C-V2X sub-protocol, the grammar tags corresponding to each grammar used in the grammar template will be set, the parameters corresponding to each grammar will be set, and the grammar tags corresponding to the grammar used will be added to the fields representing the field values using a certain grammar; after writing the grammar template, the staff needs to write the grammar implementation function corresponding to each grammar and write the regular expression corresponding to each grammar tag.

[0096] First, perform regular matching processing on each grammar template according to the preset regular expression to obtain multiple grammar tags included in each grammar template; second, obtain the grammar implementation function corresponding to each grammar tag according to the obtained multiple grammar tags; finally, add the obtained multiple grammar implementation functions to the code corresponding to the original grammar fuzzer to obtain an optimized grammar fuzzer.

[0097] 202. The optimized grammar fuzzer receives a malformed data generation task.

[0098] Among them, regarding step 202, where the optimized grammar fuzzer receives a malformed data generation task, reference can be made to Figure 1 the corresponding part of the description, which will not be elaborated here in the embodiments of the present application.

[0099] 203. The optimized grammar fuzzer obtains the target grammar template corresponding to the target C-V2X sub-protocol according to the unique identifier.

[0100] Among them, regarding step 203, where the optimized grammar fuzzer obtains the target grammar template corresponding to the target C-V2X sub-protocol according to the unique identifier, reference can be made to Figure 1 the corresponding part of the description, which will not be elaborated here in the embodiments of the present application.

[0101] 204. The optimized grammar fuzzer determines the fuzzing rule corresponding to the target grammar template according to the target seed.

[0102] In the embodiments of the present application, after the optimized grammar fuzzer obtains the target grammar template corresponding to the target C-V2X sub-protocol, it is necessary to determine the fuzzing rule corresponding to the target grammar template according to the target seed carried in the malformed data generation task, that is, to determine which fields in the target grammar template are to be fuzzed according to the target seed.

[0103] Specifically, in this step, the optimized grammar fuzzer can determine the fuzzing rule corresponding to the target grammar template according to the target seed in the following manner:

[0104] First, parse the target grammar template to obtain the syntax tree corresponding to the target grammar template. The syntax tree contains multiple branches, and each branch contains multiple fields. During the generation of the syntax tree, numbers are also assigned to each branch contained in the syntax tree starting from 1. Second, generate a random number corresponding to the target seed according to the target seed, the first preset pseudo-random function, and the number of multiple branches, that is, input the target seed and the number of multiple branches into the first preset pseudo-random function, and the first preset pseudo-random function outputs the random number corresponding to the target seed. The value range of the random number is greater than 0 and less than or equal to the number of multiple branches. Third, determine the target branch corresponding to the target seed according to the random number corresponding to the target seed, that is, determine the branch with the number equal to the random number corresponding to the target seed as the target branch corresponding to the target seed. Finally, determine the multiple fields contained in the target branch as the fields to be fuzzed, thereby obtaining the fuzzing rule, that is, the fuzzing rule is specifically to perform fuzzing processing on the multiple fields (i.e., the fields to be fuzzed) contained in the target branch.

[0105] 205. The optimized syntax fuzzer generates malformed data corresponding to the target C-V2X sub-protocol according to the fuzzing rule and the target grammar template.

[0106] In the embodiment of the present application, after determining the fuzzing rule corresponding to the target grammar template, the optimized syntax fuzzer can generate malformed data corresponding to the target C-V2X sub-protocol according to the fuzzing rule corresponding to the target grammar template and the target grammar template.

[0107] Specifically, in this step, the optimized syntax fuzzer can generate malformed data corresponding to the target C-V2X sub-protocol according to the fuzzing rule corresponding to the target grammar template and the target grammar template in the following manner:

[0108] Among them, the fuzzing rule is specifically to perform fuzzing processing on the multiple fields to be fuzzed contained in the target branch. Among them, the fields to be fuzzed are specifically divided into simple fields to be fuzzed and complex fields to be fuzzed. The original field value contained in the simple field to be fuzzed consists of multiple bits. The field value contained in the complex field to be fuzzed is represented by a certain syntax, and the complex field to be fuzzed contains the syntax label corresponding to the syntax it uses.

[0109] (1) Generate the blurred field value corresponding to each simple field to be blurred according to the target seed, the second preset pseudo-random function, and the original field value included in each simple field to be blurred. For any one simple field to be blurred, the specific process of generating the blurred field value corresponding to this simple field to be blurred is as follows: First, determine the blurred value corresponding to each bit included in the original field value of this simple field to be blurred according to the target seed, the second preset pseudo-random function, and the number of bits included in the original field value of this simple field to be blurred, that is, input the target seed and the number of bits into the second preset pseudo-random function, and the second preset pseudo-random function outputs the blurred value corresponding to each bit; then determine the blurred field value corresponding to this simple field to be blurred according to the blurred value corresponding to each bit, that is, perform a combination process on the blurred values corresponding to each bit in the order of each bit in the original field value, so as to obtain the blurred field value corresponding to this simple field to be blurred;

[0110] (2) Replace the original field value included in each simple field to be blurred with the blurred field value corresponding to each simple field to be blurred respectively, so as to obtain the blurred field corresponding to each simple field to be blurred, that is, first use the blurred field value corresponding to the first simple field to be blurred to replace the original field value included in the first simple field to be blurred, so as to obtain the blurred field corresponding to the first simple field to be blurred, and then use the blurred field value corresponding to the second simple field to be blurred to replace the original field value included in the second simple field to be blurred, so as to obtain the blurred field corresponding to the second simple field to be blurred...;

[0111] (3) Perform regular matching on the target grammar template according to the grammar tags included in each complex field to be blurred, so as to obtain the parameters corresponding to each grammar tag, and input the parameters corresponding to each grammar tag into the grammar implementation function corresponding to each grammar tag respectively, that is, first input the parameters corresponding to the first grammar tag into the grammar implementation function corresponding to the first grammar tag, and then input the parameters corresponding to the second grammar tag into the grammar implementation function corresponding to the second grammar tag...;

[0112] (4) Call each grammar implementation function respectively to obtain the blurred field value corresponding to each complex field to be blurred, that is, first call the grammar implementation function corresponding to the first complex field to be blurred, and the grammar implementation function corresponding to the first complex field to be blurred will output the blurred field value corresponding to the first complex field to be blurred, and then call the grammar implementation function corresponding to the second complex field to be blurred, and the grammar implementation function corresponding to the second complex field to be blurred will output the blurred field value corresponding to the second complex field to be blurred...;

[0113] (5) Replace the original field values included in each complex field to be obfuscated with the corresponding obfuscated field values of each complex field to be obfuscated, so as to obtain the obfuscated field corresponding to each complex field to be obfuscated. That is, first replace the original field values included in the first complex field to be obfuscated with the corresponding obfuscated field values of the first complex field to be obfuscated, so as to obtain the obfuscated field corresponding to the first complex field to be obfuscated. Then, first replace the original field values included in the second complex field to be obfuscated with the corresponding obfuscated field values of the second complex field to be obfuscated, so as to obtain the obfuscated field corresponding to the second complex field to be obfuscated...;

[0114] (6) Perform a combination process on the obtained multiple obfuscated fields, so as to obtain the malformed data corresponding to the target C-V2X sub-protocol.

[0115] Further, in the embodiment of the present application, after the optimization program optimizes the original syntax fuzzer according to the syntax template corresponding to each C-V2X sub-protocol included in the C-V2X protocol to obtain an optimized syntax fuzzer, a preset HOOK syntax implementation function can also be added to the code corresponding to the optimized syntax fuzzer. The preset HOOK syntax implementation function is pre-written by the staff according to the target HOOK syntax. The target HOOK syntax may include, but is not limited to, any one of function functions such as encryption function functions, logic processing function functions, etc. After the optimized syntax fuzzer generates the malformed data corresponding to the target C-V2X sub-protocol according to the obfuscation rules and the target syntax template corresponding to the target syntax template, the generated malformed data can also be input into the preset HOOK syntax implementation function, and the preset HOOK syntax implementation function is called, so that the preset HOOK syntax implementation function performs correction processing on the malformed data to obtain the corrected malformed data.

[0116] Specifically, in this step, when the target HOOK syntax specifically includes an encryption function function, the correction processing performed by the preset HOOK syntax implementation function on the malformed data is specifically encryption processing. When the target HOOK syntax specifically includes a logic processing function function, the correction processing performed by the preset HOOK syntax implementation function on the malformed data is specifically logic processing...

[0117] To achieve the above object, according to another aspect of the present application, the embodiment of the present application also provides a storage medium. The storage medium includes a stored program. When the program runs, it controls the device where the storage medium is located to execute the above-mentioned method for generating malformed data.

[0118] To achieve the above object, according to another aspect of the present application, an embodiment of the present application further provides a device for generating malformed data. The device includes a storage medium; and one or more processors. The storage medium is coupled to the processors, and the processors are configured to execute program instructions stored in the storage medium; when the program instructions run, they execute the method for generating malformed data described above.

[0119] Further, for the implementation of the method described above Figure 1 and Figure 2 shown, another embodiment of the present application further provides a device for generating malformed data. The device embodiment corresponds to the foregoing method embodiment. For the convenience of reading, the details in the foregoing method embodiment will not be described one by one in this device embodiment, but it should be clear that the device in this embodiment can correspondingly implement all the contents in the foregoing method embodiment. This device is applied to generate malformed data required for fuzz testing the C-V2X protocol, specifically as Figure 3 shown, the device includes:

[0120] An optimization unit 31, configured to optimize the original grammar fuzzer according to the grammar template corresponding to each C-V2X sub-protocol included in the C-V2X protocol, so as to obtain a generation unit 32. Each of the grammar templates includes multiple grammars, and the generation unit 32 includes grammar implementation functions corresponding to each grammar. The grammar template corresponding to the C-V2X sub-protocol is written according to the C-V2X sub-protocol;

[0121] A generation unit 32, configured to receive a malformed data generation task, where the malformed data generation task includes a unique identifier corresponding to a target C-V2X sub-protocol and a target seed;

[0122] Obtain the target grammar template corresponding to the target C-V2X sub-protocol according to the unique identifier;

[0123] Determine the fuzzing rules corresponding to the target grammar template according to the target seed;

[0124] Generate malformed data corresponding to the target C-V2X sub-protocol according to the fuzzing rules and the target grammar template.

[0125] Further, as Figure 4 shown, the optimization unit 31 includes:

[0126] A first matching module 3101, configured to perform regular matching processing on each grammar template according to a preset regular expression, so as to obtain multiple grammar tags included in each grammar template;

[0127] An acquisition module 3102, configured to obtain a syntax implementation function corresponding to each of the plurality of syntax tags according to the plurality of syntax tags;

[0128] An addition module 3103, configured to add the plurality of syntax implementation functions to the code corresponding to the original syntax fuzzer, so as to obtain the optimized syntax fuzzer.

[0129] Further, as Figure 4 shown, the generation unit 32 includes:

[0130] A parsing module 3201, configured to perform parsing processing on the target syntax template to obtain a syntax tree corresponding to the target syntax template, where the syntax tree includes a plurality of branches, and each branch includes a plurality of fields;

[0131] A first generation module 3202, configured to generate a random number corresponding to the target seed according to the target seed, a first preset pseudo-random function, and the number of the plurality of branches;

[0132] A first determination module 3203, configured to determine a target branch corresponding to the target seed according to the random number;

[0133] A second determination module 3204, configured to determine the plurality of fields included in the target branch as fields to be fuzzed, so as to obtain the fuzzing rule.

[0134] Further, as Figure 4 shown, the fields to be fuzzed are specifically simple fields to be fuzzed or complex fields to be fuzzed; the generation unit 32 further includes:

[0135] A second generation module 3205, configured to generate a fuzzed field value corresponding to each simple field to be fuzzed according to the target seed, a second preset pseudo-random function, and the original field value included in each simple field to be fuzzed;

[0136] A first replacement module 3206, configured to replace the original field value included in each simple field to be fuzzed with the fuzzed field value corresponding to each simple field to be fuzzed, so as to obtain a fuzzed field corresponding to each simple field to be fuzzed;

[0137] A second matching module 3207, configured to perform regular matching on the target syntax template according to the syntax tags included in each complex field to be fuzzed, so as to obtain a parameter corresponding to each syntax tag;

[0138] An input module 3208, configured to input the parameter corresponding to each syntax tag into the syntax implementation function corresponding to each syntax tag;

[0139] The calling module 3209 is used to call each of the syntax implementation functions respectively to obtain the fuzzed field values corresponding to each of the complex fields to be fuzzed;

[0140] The second replacement module 3210 is used to replace the original field values included in each of the complex fields to be fuzzed with the fuzzed field values corresponding to each of the complex fields to be fuzzed respectively, so as to obtain the fuzzed fields corresponding to each of the complex fields to be fuzzed;

[0141] The combination module 3211 is used to combine a plurality of the fuzzed fields to obtain the malformed data.

[0142] Further, as Figure 4 shown, the original field values included in the simple fields to be fuzzed are composed of a plurality of bits;

[0143] The second generation module 3205 is specifically used to determine the fuzzed values corresponding to each of the bits according to the target seed, the second preset pseudo-random function, and the number of the plurality of bits;

[0144] Determine the fuzzed field values corresponding to the simple fields to be fuzzed according to the fuzzed values corresponding to each of the bits.

[0145] Further, as Figure 4 shown, the optimization unit 31 is further used to add a preset HOOK syntax implementation function to the code corresponding to the optimized syntax fuzzer.

[0146] Further, as Figure 4 shown, the generation unit 32 is further used to input the malformed data into the preset HOOK syntax implementation function;

[0147] Call the preset HOOK syntax implementation function so that the preset HOOK syntax implementation function performs correction processing on the malformed data to obtain the corrected malformed data.

[0148] The embodiments of the present application provide a method and device for generating abnormal data. After the optimization program optimizes the original syntax fuzzer to obtain an optimized syntax fuzzer, the optimized syntax fuzzer can obtain the target syntax template corresponding to the target C-V2X sub-protocol according to the unique identifier carried in the received abnormal data generation task, and determine the fuzzing rules corresponding to the target syntax template according to the target seed carried in the abnormal data generation task. Finally, according to the fuzzing rules corresponding to the target syntax template and the target syntax template, abnormal data corresponding to the target C-V2X sub-protocol is generated, that is, first determine which fields in the target syntax template need to be fuzzed according to the fuzzing rules, and then perform fuzzing on these fields based on the syntax implementation functions included in itself to obtain multiple fuzzed fields, and the multiple fuzzed fields form the abnormal data corresponding to the target C-V2X sub-protocol. Since the optimized syntax fuzzer is obtained by the optimization program optimizing the original syntax fuzzer according to the syntax template corresponding to each C-V2X sub-protocol included in the C-V2X protocol, the optimized syntax fuzzer can implement various syntaxes in the syntax templates corresponding to each C-V2X sub-protocol, so that the optimized syntax fuzzer has the ability to generate abnormal data required for fuzz testing the C-V2X protocol. Therefore, based on the optimized syntax fuzzer, abnormal data required for fuzz testing the C-V2X protocol can be generated.

[0149] The device for generating abnormal data includes a processor and a memory. The above-mentioned optimization unit, generation unit, etc. are all stored in the memory as program units, and the corresponding functions are implemented by the processor executing the above program units stored in the memory.

[0150] The processor includes a kernel, and the kernel retrieves the corresponding program unit from the memory. One or more kernels can be set, and the abnormal data required for fuzz testing the C-V2X protocol can be generated by adjusting the kernel parameters.

[0151] The embodiments of the present application provide a storage medium, and the storage medium includes a stored program. When the program runs, it controls the device where the storage medium is located to execute the method for generating abnormal data described above.

[0152] The storage medium may include non-permanent memory in computer-readable media, forms such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash memory (flash RAM), and the memory includes at least one storage chip.

[0153] An embodiment of the present application further provides a device for generating abnormal data. The device includes a storage medium; and one or more processors. The storage medium is coupled to the processors, and the processors are configured to execute program instructions stored in the storage medium. When the program instructions run, they execute the method for generating abnormal data described above.

[0154] An embodiment of the present application provides a device. The device includes a processor, a memory, and a program stored on the memory and executable on the processor. When the processor executes the program, the following steps are implemented:

[0155] The optimization program optimizes the original syntax fuzzer according to the syntax templates corresponding to each C-V2X sub-protocol included in the C-V2X protocol to obtain an optimized syntax fuzzer. Each of the syntax templates includes multiple syntaxes, and the optimized syntax fuzzer includes syntax implementation functions corresponding to each syntax. The syntax template corresponding to the C-V2X sub-protocol is written according to the C-V2X sub-protocol;

[0156] The optimized syntax fuzzer receives an abnormal data generation task, where the abnormal data generation task includes a unique identifier corresponding to a target C-V2X sub-protocol and a target seed;

[0157] The optimized syntax fuzzer obtains the target syntax template corresponding to the target C-V2X sub-protocol according to the unique identifier;

[0158] The optimized syntax fuzzer determines the fuzzing rules corresponding to the target syntax template according to the target seed;

[0159] The optimized syntax fuzzer generates abnormal data corresponding to the target C-V2X sub-protocol according to the fuzzing rules and the target syntax template.

[0160] Further, the optimization program optimizes the original syntax fuzzer according to the syntax templates corresponding to each C-V2X sub-protocol included in the C-V2X protocol to obtain an optimized syntax fuzzer, including:

[0161] Performing regular matching processing on each of the syntax templates according to a preset regular expression to obtain multiple syntax tags included in each of the syntax templates;

[0162] Obtaining syntax implementation functions corresponding to each of the syntax tags according to the multiple syntax tags;

[0163] Adding the multiple syntax implementation functions to the code corresponding to the original syntax fuzzer to obtain the optimized syntax fuzzer.

[0164] Further, the optimized syntax fuzzer determines the fuzzing rules corresponding to the target grammar template according to the target seed, including:

[0165] Parse the target grammar template to obtain the syntax tree corresponding to the target grammar template, where the syntax tree contains multiple branches, and each branch contains multiple fields;

[0166] Generate a random number corresponding to the target seed according to the target seed, the first preset pseudo-random function, and the number of multiple branches;

[0167] Determine the target branch corresponding to the target seed according to the random number;

[0168] Determine the multiple fields included in the target branch as the fields to be fuzzed to obtain the fuzzing rules.

[0169] Further, the fields to be fuzzed are specifically simple fields to be fuzzed or complex fields to be fuzzed; the optimized syntax fuzzer generates malformed data corresponding to the target C-V2X sub-protocol according to the fuzzing rules and the target grammar template, including:

[0170] Generate a fuzzed field value corresponding to each simple field to be fuzzed according to the target seed, the second preset pseudo-random function, and the original field value included in each simple field to be fuzzed;

[0171] Replace the original field value included in each simple field to be fuzzed with the fuzzed field value corresponding to each simple field to be fuzzed to obtain a fuzzed field corresponding to each simple field to be fuzzed;

[0172] Perform regular matching on the target grammar template according to the syntax tags included in each complex field to be fuzzed to obtain the parameters corresponding to each syntax tag;

[0173] Input the parameters corresponding to each syntax tag into the syntax implementation function corresponding to each syntax tag respectively;

[0174] Call each syntax implementation function respectively to obtain the fuzzed field value corresponding to each complex field to be fuzzed;

[0175] Replace the original field value included in each complex field to be fuzzed with the fuzzed field value corresponding to each complex field to be fuzzed to obtain a fuzzed field corresponding to each complex field to be fuzzed;

[0176] Combine multiple fuzzed fields to obtain the malformed data.

[0177] Further, the original field value included in the simple field to be obfuscated consists of multiple bits; generating a corresponding obfuscated field value for each simple field to be obfuscated according to the target seed, the second preset pseudo-random function, and the original field value included in each simple field to be obfuscated includes:

[0178] Determining a corresponding obfuscated value for each bit according to the target seed, the second preset pseudo-random function, and the number of multiple bits;

[0179] Determining the obfuscated field value corresponding to the simple field to be obfuscated according to the obfuscated value corresponding to each bit.

[0180] Further, after the optimization program optimizes the original syntax obfuscator according to the syntax template corresponding to each C-V2X sub-protocol included in the C-V2X protocol to obtain an optimized syntax obfuscator, the method further includes:

[0181] The optimization program adds a preset HOOK syntax implementation function to the code corresponding to the optimized syntax obfuscator.

[0182] Further, after the optimized syntax obfuscator generates malformed data corresponding to the target C-V2X sub-protocol according to the obfuscation rule and the target syntax template, the method further includes:

[0183] The optimized syntax obfuscator inputs the malformed data into the preset HOOK syntax implementation function;

[0184] The optimized syntax obfuscator calls the preset HOOK syntax implementation function so that the preset HOOK syntax implementation function corrects the malformed data to obtain the corrected malformed data.

[0185] The present application also provides a computer program product, which, when executed on a data processing device, is adapted to execute program code initialized with the following method steps: The optimization program optimizes the original syntax fuzzer according to the syntax templates corresponding to each C-V2X sub-protocol included in the C-V2X protocol to obtain an optimized syntax fuzzer, wherein each of the syntax templates contains multiple syntaxes, the optimized syntax fuzzer contains syntax implementation functions corresponding to each syntax, and the syntax template corresponding to the C-V2X sub-protocol is written according to the C-V2X sub-protocol; The optimized syntax fuzzer receives a malformed data generation task, wherein the malformed data generation task includes a unique identifier corresponding to the target C-V2X sub-protocol and a target seed; The optimized syntax fuzzer obtains the target syntax template corresponding to the target C-V2X sub-protocol according to the unique identifier; The optimized syntax fuzzer determines the fuzzing rules corresponding to the target syntax template according to the target seed; The optimized syntax fuzzer generates malformed data corresponding to the target C-V2X sub-protocol according to the fuzzing rules and the target syntax template.

[0186] Those skilled in the art should understand that the embodiments of the present application may be provided as a method, a system, or a computer program product. Therefore, the present application may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk memory, CD-ROM, optical memory, etc.) containing computer-usable program code.

[0187] The present application is described with reference to the flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each flow and / or block in the flowchart and / or block diagram, and the combination of flows 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 the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing devices generate a device for realizing the functions specified in Figure 1 one or more of the flows Figure 1 or multiple flows and / or blocks

[0188] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory generate a manufactured article including an instruction device, and the instruction device realizes the functions specified in Figure 1 one or more of the flows Figure 1The functions specified in one or more boxes.

[0189] These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operation steps are executed on the computer or other programmable device to generate a computer-implemented process. Thus, the instructions executed on the computer or other programmable device provide for implementing the steps of the functions specified in one Figure 1 one process or multiple processes and / or boxes Figure 1 step of the functions specified in one or more boxes.

[0190] In a typical configuration, a computing device includes one or more processors (CPUs), an input / output interface, a network interface, and memory.

[0191] The memory may include non-permanent memory in the computer-readable medium, in the form of random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash memory (flash RAM). The memory is an example of a computer-readable medium.

[0192] Computer-readable media includes permanent and non-permanent, removable and non-removable media and can be implemented by any method or technology for information storage. The information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassette tapes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include transitory computer-readable media, such as modulated data signals and carrier waves.

[0193] It should also be noted that the term "comprises", "comprising" or any other variation thereof is intended to cover non-exclusive inclusion, so that a process, method, commodity or device comprising a series of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, commodity or device. Without further limitation, an element defined by the statement "comprising one..." does not exclude the presence of additional identical elements in the process, method, commodity or device comprising the element.

[0194] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can 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.) that contain computer-usable program code.

[0195] The above are only the embodiments of the present application and are not intended to limit the present application. For those skilled in the art, various changes and modifications can be made to the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included within the scope of the claims of the present application.

Claims

1. A method for generating abnormal data, characterized in that, Including: The optimization program optimizes the original syntax fuzzer according to the syntax templates corresponding to each C-V2X sub-protocol included in the C-V2X protocol to obtain an optimized syntax fuzzer. Each of the syntax templates contains multiple syntaxes, and the optimized syntax fuzzer contains syntax implementation functions corresponding to each syntax. The syntax template corresponding to the C-V2X sub-protocol is written according to the C-V2X sub-protocol; The optimized syntax fuzzer receives a malformed data generation task, where the malformed data generation task includes a unique identifier corresponding to the target C-V2X sub-protocol and a target seed; The optimized syntax fuzzer obtains the target syntax template corresponding to the target C-V2X sub-protocol according to the unique identifier; The optimized syntax fuzzer determines the fuzzing rules corresponding to the target syntax template according to the target seed; The optimized syntax fuzzer generates malformed data corresponding to the target C-V2X sub-protocol according to the fuzzing rules and the target syntax template; The optimized syntax fuzzer determines the fuzzing rules corresponding to the target syntax template according to the target seed, including: Performing a parsing process on the target syntax template to obtain a syntax tree corresponding to the target syntax template, where the syntax tree contains multiple branches, and each branch contains multiple fields; Generating a random number corresponding to the target seed according to the target seed, a first preset pseudo-random function, and the number of multiple branches; Determining a target branch corresponding to the target seed according to the random number; Determining the multiple fields included in the target branch as fields to be fuzzed to obtain the fuzzing rules; The fields to be fuzzed are specifically simple fields to be fuzzed or complex fields to be fuzzed; the optimized syntax fuzzer generates malformed data corresponding to the target C-V2X sub-protocol according to the fuzzing rules and the target syntax template, including: Generating a fuzzed field value corresponding to each simple field to be fuzzed according to the target seed, a second preset pseudo-random function, and the original field value included in each simple field to be fuzzed; Respectively replacing the original field value included in each simple field to be fuzzed with the fuzzed field value corresponding to each simple field to be fuzzed to obtain a fuzzed field corresponding to each simple field to be fuzzed; Performing regular matching on the target syntax template according to the syntax tags included in each complex field to be fuzzed to obtain parameters corresponding to each syntax tag; Respectively inputting the parameters corresponding to each syntax tag into the syntax implementation function corresponding to each syntax tag; Respectively calling each syntax implementation function to obtain a fuzzed field value corresponding to each complex field to be fuzzed; Respectively replacing the original field value included in each complex field to be fuzzed with the fuzzed field value corresponding to each complex field to be fuzzed to obtain a fuzzed field corresponding to each complex field to be fuzzed; Combining multiple fuzzed fields to obtain the malformed data.

2. The method according to claim 1, characterized in that, The optimization program optimizes the original syntax fuzzer according to the syntax templates corresponding to each C-V2X sub-protocol included in the C-V2X protocol to obtain an optimized syntax fuzzer, including: Performing regular matching processing on each of the syntax templates according to a preset regular expression to obtain a plurality of syntax tags included in each of the syntax templates; Obtaining a syntax implementation function corresponding to each of the syntax tags according to the plurality of syntax tags; Adding the plurality of syntax implementation functions to the code corresponding to the original syntax fuzzer to obtain the optimized syntax fuzzer.

3. The method according to claim 1, wherein The original field value included in the simple field to be fuzzed consists of a plurality of bits; generating a fuzzed field value corresponding to each simple field to be fuzzed according to the target seed, the second preset pseudo-random function, and the original field value included in each simple field to be fuzzed, including: Determining a fuzzed value corresponding to each of the bits according to the target seed, the second preset pseudo-random function, and the number of the plurality of bits; Determining the fuzzed field value corresponding to the simple field to be fuzzed according to the fuzzed value corresponding to each of the bits.

4. The method according to any one of claims 1 to 3, characterized in that, After the optimization program optimizes the original syntax fuzzer according to the syntax templates corresponding to each C-V2X sub-protocol included in the C-V2X protocol to obtain an optimized syntax fuzzer, the method further includes: The optimization program adds a preset HOOK syntax implementation function to the code corresponding to the optimized syntax fuzzer.

5. The method according to claim 4, wherein After the optimized syntax fuzzer generates malformed data corresponding to the target C-V2X sub-protocol according to the fuzzing rule and the target syntax template, the method further includes: The optimized syntax fuzzer inputs the malformed data into the preset HOOK syntax implementation function; The optimized syntax fuzzer calls the preset HOOK syntax implementation function so that the preset HOOK syntax implementation function performs correction processing on the malformed data to obtain the corrected malformed data.

6. A device for generating abnormal data, characterized in that, Including: An optimization unit for optimizing the original syntax fuzzer according to the syntax templates corresponding to each C-V2X sub-protocol included in the C-V2X protocol to obtain a generation unit, wherein each of the syntax templates includes multiple syntaxes, the generation unit includes a syntax implementation function corresponding to each syntax, and the syntax template corresponding to the C-V2X sub-protocol is written according to the C-V2X sub-protocol; The generation unit for receiving a malformed data generation task, wherein the malformed data generation task includes a unique identifier corresponding to the target C-V2X sub-protocol and a target seed; Obtaining a target syntax template corresponding to the target C-V2X sub-protocol according to the unique identifier; Determining a fuzzing rule corresponding to the target syntax template according to the target seed; Generating malformed data corresponding to the target C-V2X sub-protocol according to the fuzzing rule and the target syntax template; The generation unit includes: A parsing module, configured to parse the target grammar template to obtain a syntax tree corresponding to the target grammar template, where the syntax tree includes multiple branches, and each branch includes multiple fields; A first generation module, configured to generate a random number corresponding to the target seed according to the target seed, a first preset pseudo-random function, and the number of the multiple branches; A first determination module, configured to determine a target branch corresponding to the target seed according to the random number; A second determination module, configured to determine multiple fields included in the target branch as fields to be blurred to obtain the blurring rule; The fields to be blurred are specifically simple fields to be blurred or complex fields to be blurred; the generation unit further includes: A second generation module, configured to generate a blurred field value corresponding to each simple field to be blurred according to the target seed, a second preset pseudo-random function, and an original field value included in each simple field to be blurred; A first replacement module, configured to respectively replace the original field value included in each simple field to be blurred with the blurred field value corresponding to each simple field to be blurred to obtain a blurred field corresponding to each simple field to be blurred; A second matching module, configured to perform regular matching on the target grammar template according to a syntax label included in each complex field to be blurred to obtain a parameter corresponding to each syntax label; An input module, configured to respectively input the parameter corresponding to each syntax label into a syntax implementation function corresponding to each syntax label; A call module, configured to respectively call each syntax implementation function to obtain a blurred field value corresponding to each complex field to be blurred; A second replacement module, configured to respectively replace the original field value included in each complex field to be blurred with the blurred field value corresponding to each complex field to be blurred to obtain a blurred field corresponding to each complex field to be blurred; A combination module, configured to combine the multiple blurred fields to obtain the deformed data.

7. A storage medium, characterized in that, The storage medium includes a stored program, where, when the program runs, it controls the device where the storage medium is located to execute the deformed data generation method according to any one of claims 1 to 5.

8. A device for generating abnormal data, characterized in that, The device includes a storage medium; and one or more processors, the storage medium is coupled to the processor, and the processor is configured to execute program instructions stored in the storage medium; when the program instructions run, they execute the deformed data generation method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Fuzzy test method and device of industrial control protocol, storage medium and processor

    CN113328914A

  • Fuzzy test method and system and storage medium

    CN113434386A