Comparison function identification system and identification method based on data stream characteristics

Through the comparison function identification system based on data flow characteristics, the problem of high false positive and false negative rates of comparison function identification methods in embedded devices is solved, and accurate identification of comparison functions for multiple instruction set architectures is achieved, supporting automatic Define and implement the identification of functions to improve the identification effect.

CN114968324BActive Publication Date: 2024-09-10Chinese People's Liberation Army Cyberspace Force Information Engineering University
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210398639.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-15
Publication Date
2024-09-10
Estimated Expiration
2042-04-15

AI Technical Summary

Technical Problem

Existing comparison function identification methods have problems with high false positive and false negative rates in embedded devices, especially when it is difficult to identify custom implemented comparison functions in the absence of source code and function name information.

Method used

A comparison function identification system based on data flow characteristics is used to build a data flow feature matching model through CFG extraction and loop detection, loop instruction extraction, comparison operation branch, VEX IR instruction generation, data flow construction and data flow analysis modules to identify whether the function For comparison-like functions, multiple instruction set architectures are supported.

Benefits of technology

It achieves accurate identification of comparison functions implemented in any way, is almost not affected by the compilation environment, has good applicability and identification effects, and has significantly improved precision and recall rates compared with existing methods.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114968324B
    Figure CN114968324B
Patent Text Reader

Abstract

The present invention belongs to the technical field of comparison function recognition, and specifically relates to a comparison function recognition system and recognition method based on data flow features. The present invention analyzes the control flow of a function, extracts loop paths and branch paths therefrom, constructs a data flow and detects whether the data flow features match, and converts the instructions in the path into intermediate language VEX IR instructions. It supports ARM, MIPS, PPC and x86 instruction sets, does not rely on information such as source code, and is less affected by compiler options, compiler versions and optimization levels. It has a good recognition effect on comparison functions of glibc libraries and custom implementations. Experimental evaluation shows that when information such as source code and function name is missing, CMPSeek has higher precision and recall than FLIRT and SaTC.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of comparison function identification, and in particular relates to a comparison function identification system and identification method based on data stream characteristics. Background Art

[0002] With the rapid development of the Internet of Things, more and more embedded devices are entering our lives. They often appear in key locations in the security field and in private places close to terminals, such as routers, switches, printers and other devices. However, recent studies have shown that many embedded devices on the market have backdoors. Backdoors refer to a program method used to secretly bypass normal authentication processes such as software, computer systems, and password mechanisms to obtain access rights to computer systems or plain text encrypted by password systems. Among them, the most disclosed are hard-coded backdoors (i.e. password backdoors). For example, the password backdoor discovered in D-Link routers in 2013: after the browser User-Agent is set to "xmlset_roodkcableoj28840ybtide", the router can be remotely controlled; the SSH backdoor discovered in Fortinet's firewall in 2016, the hard-coded password is "FGTAbc11*xy+Qqz27"; in 2021, the administrator-level account {username:"zyfwp", password:"PrOw!aN_fXp"} was found in Zyxel's firewalls, VPN and other devices. This account can be used to access the device through the Web management panel.

[0003] Password backdoor is one of the most common backdoors, which has serious harm, far-reaching impact and inestimable losses. In the process of triggering password backdoor, comparison function is indispensable, so there are many methods to detect password backdoor with the help of comparison function.

[0004] There are many studies on vulnerability mining technology based on comparison functions in embedded devices. In 2015, Yan et al. proposed a binary analysis framework Firmice, which needs to use functions such as strcmp and strncmp to locate the critical path, slice the critical path, and use static symbolic execution to determine whether there are deterministic constraints. If so, there is a backdoor. In 2017, Thomas et al. proposed a backdoor identification method Stringer based on static data weight comparison. The principle is to locate functions such as strcmp, memcmp, and strstr to find and locate the strings involved in the comparison, and then calculate the weight of the string according to the proposed algorithm. According to the weight comparison, the password backdoor of the binary program is identified. In 2020, Redini et al. proposed a static taint analysis framework Karonte, which analyzes firmware by modeling and tracking the interaction of multiple binary files, and propagates taint information between binary files to identify unsafe interactions and identify vulnerabilities, but it still needs to use the information of functions such as strcmp and strncmp to statically track and propagate tainted data. In 2021, Chen et al. proposed a directed fuzz testing tool called SaTC, which matches front-end keywords and back-end input items, and performs taint analysis on sensitive inputs to identify vulnerabilities, but SaTC also requires functions such as strcmp and strncmp to locate sensitive inputs.

[0005] At present, the function identification technology for binary files that strip off information such as function names is mainly based on static analysis methods. For example, the Fast Library Identification and Recognition Technology (FLIRT) in IDA Pro first analyzes the binary program to find the library function name and version information used by the program, then downloads the source code from GitHub or other open source platforms, compiles the library function into the target program architecture, selects the first few bytes of the binary code of the function to make a function signature, and finally identifies the function in the program based on the signature matching method; however, the FLIRT method requires source code, and the function identification effect will be affected by the compiler type, compiler version, optimization level, optimization options, etc. Static function identification methods based on feature matching are proposed in Karonte and SaTC, but the features taken are relatively simple: 1) there is a loop structure; 2) there is a comparison instruction in the loop. However, functions that meet the above conditions do not necessarily have the function of comparing strings, and have a high false positive rate and false negative rate.

[0006] In fact, in embedded devices, due to commercial competition or software security needs, manufacturers often do not publish development documents or source codes, but release software in binary form, and even strip function names, symbol tables and other information in the program. In this case, comparison function identification is of great significance and value for the discovery and repair of password backdoors. However, the current function identification methods have the following problems: the FLIRT method requires source code to make function signatures, and the identification effect depends on the compilation environment. Binary programs often do not disclose source code, so FLIRT is difficult to identify comparison functions in the program, especially custom comparison functions; the function features used by the Karonte and SaTC methods are relatively simple, with high false positive and false negative rates. Summary of the invention

[0007] In view of the defects and problems of the current comparison function identification methods, such as high false alarm rate and high missed alarm rate, the present invention provides a comparison function identification method based on data stream characteristics.

[0008] The solution adopted by the present invention to solve its technical problem is: a comparison function recognition system based on data flow features, the system includes a CFG extraction and loop detection module, a loop instruction extraction module, a comparison operation branch module, a VEX IR instruction generation module, a data flow construction module, a data flow analysis module and a comparison function recognition module; the CFG extraction and loop detection module analyzes whether a function contains a loop path; the loop instruction extraction module and the comparison operation branch module are respectively used to extract instructions from comparison operation branches in loop blocks and loops to function returns; the VEX IR instruction generation module converts binary code into intermediate language VEX IR instructions with the help of an open source library pyvex, so that the system supports multiple instruction set architectures; the data flow construction and data flow analysis modules extract variable relationships in the data flow from VEX IR instructions, generate a data flow DFG and analyze it; the comparison function recognition module detects whether the loop path and the branch path match according to the data flow features, thereby judging whether the function is a comparison function.

[0009] The present invention also provides a comparison function identification method based on data stream characteristics, comprising the following steps:

[0010] Step 1: Extract the control flow CFG of the function, regard the basic block as the vertex v, and the jump relationship between the basic blocks as the directed edge e, and convert the function CFG into a directed topological graph G.

[0011] G={V,E}

[0012] Where: V = {v1, v2, …, v n}, E={e1,e2,…,e m},

[0013] e k =(v i ,v j )(1≤k≤m,1≤i,j≤n)

[0014] Step 2: Identify whether there is a cycle in the directed graph G;

[0015] (1) If there is no cyclic path in the directed graph G, it is directly considered to be a non-comparison function;

[0016] (2) If the directed graph G contains a loop path, extract the loop path and the branch path from the loop exit to the function return, convert the loop path and the branch path into intermediate language VEX IR instructions, and construct the data flow DFG; then, based on whether the data flow DFG features match, if they match, it is considered to be a comparison function identification, otherwise it is considered to be a non-comparison function.

[0017] In the above-mentioned comparison function identification method based on data flow features, in step 1, the FlowChart() class and self.succs() function of the IDA Python plug-in built into IDA Pro are called to obtain V and E.

[0018] In the above-mentioned comparison function identification method based on data flow characteristics, in step 2, the DiGraph() function of the open source library NetworkX is used to quickly construct a directed graph G, and simple_circles() is called to identify whether there is a cycle in the graph G.

[0019] In the above-mentioned comparison function identification method based on data flow characteristics, in step 2, if the data flow DFG satisfies the following characteristics at the same time, it is identified as a comparison function.

[0020] (1) There is a ring structure on the data stream, and there are comparison operations and arithmetic operations on the ring;

[0021] (2) There are Cz points and Cmp pairs in the data stream;

[0022] (3) There exists a path from point Cz to the Cmp pair, and point Cz appears before the Cmp pair;

[0023] (4) After the Cmp pair on the ring jumps out of the loop, it can reach the function point Rt.

[0024] The beneficial effects of the present invention are as follows: the present invention analyzes the source code of comparison functions, compiles it into different instruction set architectures, analyzes the characteristics of control flow and data flow, constructs a comparison function recognition model based on data flow feature matching, proposes and implements a comparison function recognition method CMPSeek, which does not rely on source code, function name, symbol table and other information, and the recognition effect is almost unaffected by the compilation environment. It can recognize comparison functions implemented in any way, supports ARM, MIPS, PowerPC (PPC) and x86 instruction sets, and has good applicability.

[0025] We collected comparable functions from platforms such as GitHub and Stack Overflow, and constructed open source library function dataset A and custom implementation function dataset B for testing. The experimental results show that when information such as source code and function name is missing, CMPSeek has better results in both precision and recall than FLIRT and SaTC. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] Figure 1 This is a flow chart of the identification system CMPSeek of the present invention.

[0027] Figure 2 Identify comparison functions in Karonte.

[0028] Figure 3 Identify comparison class functions in SaTC.

[0029] Figure 4 It is the source code of strcmp function in glibc library.

[0030] Figure 5 It is the strcmp function under ARM architecture.

[0031] Figure 6 This is the loop path in the strcmp function DFG. DETAILED DESCRIPTION

[0032] There are many studies on vulnerability mining technology based on comparison functions in embedded devices. In 2015, Yan et al. proposed a binary analysis framework Firmice, which needs to use functions such as strcmp and strncmp to locate the critical path, slice the critical path, and use static symbolic execution to determine whether there are deterministic constraints. If so, there is a backdoor.

[0033] In 2017, Thomas et al. proposed Stringer, a backdoor identification method based on static data weight comparison. The principle is to locate functions such as strcmp, memcmp and strstr to find and locate the strings involved in the comparison, and then calculate the weight of the string according to the proposed algorithm, and identify the password backdoor of the binary program based on the weight comparison.

[0034] In 2020, Redini et al. proposed a static taint analysis framework, Karonte (see Figure 2 )Analyze firmware by modeling and tracing multi-binary file interactions, propagate taint information between binaries to identify unsafe interactions and identify vulnerabilities. It can be seen that it is still necessary to statically track and propagate taint data with the help of information from functions such as strcmp and strncmp.

[0035] In 2021, Chen et al. proposed the targeted fuzz testing tool SaTC (see Figure 3 ) matches the front-end keywords and back-end input items, and performs taint analysis on sensitive inputs to identify vulnerabilities, but SaTC also needs functions such as strcmp and strncmp to locate sensitive inputs.

[0036] At present, the function identification technology for binary files that strip off information such as function names is mainly based on static analysis methods. For example, the Fast Library Identification and Recognition Technology (FLIRT) in IDA Pro first analyzes the binary program to find the library function name and version information used by the program, then downloads the source code from GitHub or other open source platforms, compiles the library function into the target program architecture, selects the first few bytes of the binary code of the function to make a function signature, and finally identifies the function in the program based on the signature matching method. However, the FLIRT method requires source code, and the function identification effect will be affected by the compiler type, compiler version, optimization level, optimization options, etc. Static function identification methods based on feature matching are proposed in Karonte and SaTC, but the features taken are relatively simple: 1) there is a loop structure; 2) there is a comparison instruction in the loop. However, functions that meet the above conditions do not necessarily have the function of comparing strings, and have a high false positive rate and false negative rate.

[0037] However, the current function recognition methods have the following problems: the FLIRT method requires source code to make function signatures, and the recognition effect depends on the compilation environment. Binary programs often do not disclose source code, so FLIRT is difficult to identify comparison functions in programs, especially custom-implemented comparison functions; the function features used by the Karonte and SaTC methods are relatively simple, with high false positive and false negative rates. In order to solve the problem of comparing function recognition, a function recognition system CMPSeek and recognition method based on feature matching are proposed. The present invention is further described below in conjunction with the accompanying drawings and embodiments.

[0038] Embodiment 1: This embodiment provides a comparison function recognition system CMPSeek based on data stream features, such as Figure 1 As shown, the system includes a CFG extraction and loop detection module, a loop instruction extraction module, a comparison operation branch module, a VEX IR instruction generation module, a data flow construction module, a data flow analysis module and a comparison class function identification module; wherein the CFG extraction and loop detection module analyzes whether the function contains a loop path; the loop instruction extraction module and the comparison operation branch module are used to extract instructions from the comparison operation branch in the loop block and the loop to the function return respectively; the VEX IR instruction generation module converts the binary code into the intermediate language VEX IR instruction with the help of the open source library pyvex, so that the system supports multiple instruction set architectures; the data flow construction and data flow analysis module extracts the variable relationship in the data flow from the VEX IR instruction, generates the data flow DFG and analyzes it; the comparison class function identification module detects whether the loop path and the branch path match according to the data flow characteristics, so as to determine whether the function is a comparison class function.

[0039] Embodiment 2: This embodiment provides a comparison function identification method based on data flow features. The method extracts the control flow CFG of the function, regards the basic block as the vertex v, and regards the jump relationship between the basic blocks as the directed edge e, and converts the function CFG into a directed topological graph G.

[0040] G={V,E}

[0041] Where: V = {v1, v2, …, v n}, E={e1,e2,…,e m},

[0042] e k =(v i ,v j )(1≤k≤m,1≤i,j≤n)

[0043] Since the IDAPython plug-in built into IDA Pro provides the FlowChart() class and the self.succs() function to obtain the relationship between function basic blocks and basic blocks, this embodiment directly calls FlowChart() and self.succs() to obtain V and E (lines 3-8 in Algorithm 1 below).

[0044] Then, the DiGraph() function of the open source library NetworkX is used to quickly construct the directed graph G (line 9 in Algorithm 1), and simple_circles() is called to identify whether there is a cycle in the graph G (line 10 in Algorithm 1).

[0045] (1) If there is no cyclic path in the directed graph G, it is directly considered to be a non-comparison function;

[0046] (2) If the directed graph G contains a loop path, extract the branch path, convert the loop path and branch path into intermediate language VEX IR instructions, and construct the data flow DFG; then, according to whether the data flow DFG features match, if they match, it is considered to be a comparison function identification, otherwise it is considered to be a non-comparison function. Considering that there may be multiple loop paths in the function CFG, as long as one of the paths meets the conditions, it is identified as a comparison function.

[0047] The specific recognition algorithm example is shown in Algorithm 1.

[0048] Algorithm 1:

[0049] Input: (ea) / *Function start address* /

[0050] Output: (0 / 1) / *Is it a comparison function?* /

[0051] 1 func←get_func(ea)

[0052] 2 V←[],E←[]

[0053] 3 for block in FlowChart(func)do

[0054] 4 V←V∪block / *Get the vertex* /

[0055] 5 for succor in block.succs()do

[0056] 6 E←E∪(block,succor) / *Get directed edges* /

[0057] 7 end for

[0058] 8 end for

[0059] 9 cfg←generate_cfg(V,E) / *Generate control flow graph* /

[0060] 10 loops←simple_cycles(cfg) / *Extract the cycle path* /

[0061] 11

[0062] 12 branches←get_branch(cfg) / *Extract branch path* /

[0063] 13 dfg←generate_dfg(loops,branchs) / *Generate data flow graph* /

[0064] 14 if is_cmp_func(dfg) / *Does the data stream feature match?* /

[0065] 15 return 1

[0066] 16 end if

[0067] 17 end if

[0068] 18 return 0

[0069] After extracting loop paths and branch paths through CFG, analyze the data flow in the path, regard the register or memory address as the vertex v, and convert the data transmission direction to the directed edge e. Construct DFG in the same way (line 13 in Algorithm 1). To better illustrate the characteristics of the data flow, the following Table 1 lists the relevant definitions and examples.

[0070] Table 1 Special values ​​in the data stream

[0071]

[0072] *Note: The registers where function return values ​​are stored are different in different architectures, such as r0 in ARM and ra in MIPS. Table 1 is for the ARM architecture.

[0073] If a function satisfies the following four characteristics, it is identified as a comparison function, otherwise it is not a comparison function.

[0074] (1) There is a ring structure on the data stream, and there are comparison operations and arithmetic operations on the ring;

[0075] (2) There are Cz points and Cmp pairs in the data stream;

[0076] (3) There exists a path from point Cz to the Cmp pair, and point Cz appears before the Cmp pair;

[0077] (4) After the Cmp pair on the ring jumps out of the loop, it can reach the function point Rt.

[0078] For details, see the source code of the strcmp function in the glibc library. Figure 4 , strcmp function under ARM architecture see Figure 5 .

[0079] extract Figure 5 The loop path and branch path in are converted into VEX IR instructions and then DFG is constructed. The loop path DFG is as follows Figure 6 As shown (the branch paths are relatively simple, namely (r2→ r1, r3→ r1) and (r2→ r1), and the DFG of the branch paths is not given due to space limitations). In the figure, Cz={t11}, Add={t10, t14}, Cmp={(r3, r2)}, Cr={t33}. There are comparison operation Cmp pairs {(r3, r2)} and arithmetic operation Add points {t10, t14} in the loop (feature a), and there are also Cz points t11 and the path from t11 to r3 (features b and c), and finally there are paths from Cmp pairs {(r3, r2)} to Rt point r0 in the branch paths (feature d), so CMPSeek identifies strcmp as a comparison function.

[0080] Experimental example: This embodiment evaluates the comparison function recognition effect of the method (CMPSeek) of the present invention from different angles, and compares it with the existing methods FLIRT, Karonte, and SaTC. Experiments are conducted on glibc library functions and custom comparison functions respectively, and the effects of compiler options, compiler versions, optimization levels, and different instruction set architectures on the three function recognition methods are compared.

[0081] Dataset: It is divided into dataset A and dataset B. A is the comparison function in the C language glibc library, as shown in Table 2, with a total of 25. B is a custom-implemented comparison function, which is collected from platforms such as Github (openwrt and Mirai source code) and StackOverflow, and integrated into a C program for compilation and testing.

[0082] Table 2 Comparison functions in the glibc library

[0083]

[0084] Comparison methods: FLIRT, Karonte and SaTC (such as Figure 2 and Figure 3As shown in the figure, Karonte and SaTC have exactly the same method for comparing functions, so SaTC can be selected. Considering that FLIRT needs source code to make function signatures, and the recognition effect is affected by the compilation environment, the signature used in FLIRT comes from the glibc library function, the compiler type and version is GCC 5.5.0, the optimization level is -O0, and the ARM architecture is selected as the target program.

[0085] Tool implementation: CMPSeek is implemented based on IDAPython and pyvex, and uses NetworkX to process CFG and DFG. Table 3 shows the tools and instruction set architectures that each method relies on.

[0086] Table 3 Comparison of three methods

[0087]

[0088] *Note: The function signatures used by FLIRT in the experiment correspond to the ARM architecture, so the dataset will be compiled to the ARM architecture in subsequent experiments.

[0089] Evaluation indicators: Use precision P and recall R to evaluate the effect of the proposed method. The higher the precision and recall, the better the effect.

[0090] P=TP / (TP+FP)

[0091] R=TP / (TP+FN)

[0092] Where TP is a true positive example, that is, a comparison function is identified as a comparison function; FP is a false positive example, that is, a non-comparison function is identified as a comparison function; FN is a false negative example, that is, a comparison function is identified as a non-comparison function.

[0093] Compiler and optimization level: Table 4 shows the compiler type, compiler version, and optimization level used in the experimental evaluation. Two compilers, GCC and Clang, were used for testing, and buildroot was used to build a cross-toolchain for different instruction sets to generate programs for different instruction architectures.

[0094] Table 4. Compilation environment options used in the experimental evaluation

[0095]

[0096] Effect of compiler options on function recognition

[0097] To compare the effect of compiler options on function recognition, GCC and Clang compilers are used with an optimization level of -O0 to compile data sets A and B into binary programs of the ARM instruction set architecture. The function recognition effects are shown in Tables 5 and 6.

[0098] Table 5 Comparison of recognition effects on dataset A under different compilers

[0099]

[0100] Table 6 Comparison of recognition effects on dataset B under different compilers

[0101]

[0102] As can be seen from Tables 5 and 6, for dataset A (comparison functions in the glibc library), FLIRT has the best function recognition effect, with P values ​​of 1.00 and 0.71 under the GCC and Clang compilers, respectively. However, it is greatly affected by the compiler options. The P values ​​of CMPSeek and SaTC are not much different, but the R value of CMPSeek can reach 0.80, while that of SaTC is only 0.16. For dataset B (comparison functions implemented by the user), both P and R of FLIRT are 0.00, and the comparison functions cannot be recognized at all. The P value of CMPSeek is above 0.56 and the R value is above 0.67. Both P and R are better than SaTC, and the overall performance is relatively stable. When there is function source code, FLIRT has the best function recognition effect, but it is greatly affected by the compiler selection. It has the best recognition effect in GCC-5.1.0, with P and R of 1.00 and 0.88 respectively. CMPSeek also has a relatively good recognition effect, and performs best in GCC-4.5.4, with P and R of 0.62 and 0.80 respectively. When there is no source code, CMPSeek function recognition effect is better than SaTC and FLIRT, and the recognition effect is basically the same under GCC and Clang compilers.

[0103] Effect of compiler version on function recognition

[0104] To further compare the impact of compiler versions on function recognition effects, the GCC compiler is selected. The version is shown in Table 4 above, the optimization level is -O0, and datasets A and B are compiled into binary files of the ARM architecture. The function recognition effects are shown in Tables 7 and 8.

[0105] Table 7 Comparison of recognition effects on dataset A under different versions

[0106]

[0107] Table 8 Comparison of recognition effects on dataset B under different versions

[0108]

[0109] As can be seen from Tables 7 and 8, for dataset A, FLIRT has the best recognition effect, with P of 1.00 and R above 0.80, followed by CMPSeek, with P and R above 0.52 and 0.72 respectively, and SaTC has the worst, with the highest recall rate R only 0.20. For dataset B, CMPSeek has the best recognition effect, with P and R above 0.58 and 0.68 respectively, while FLIRT's P and R are still 0.00.

[0110] The three methods are not greatly affected by the compiler version. For dataset A, FLIRT performs best in GCC-5.5.0, with P and R reaching 1.00, because the compilation environment of the function signature in FLIRT is also GCC-5.5.0-O0; SaTC and CMPSeek perform best under GCC-4.5.4; for dataset B, the three methods perform best in GCC-5.3.0 and above.

[0111] The influence of optimization level on function recognition effect

[0112] In order to compare the effects of different optimization levels on function recognition, the GCC-5.5.0 compiler is selected with optimization levels of -O0 to -O3. Data sets A and B are compiled into binary files of ARM architecture. The function recognition effects are shown in Tables 9 and 10.

[0113] Table 9 Comparison of recognition effects on dataset A at different optimization levels

[0114]

[0115] Table 10 Comparison of recognition effects on dataset B at different optimization levels

[0116]

[0117] As can be seen from Tables 9 and 10, FLIRT is greatly affected by the optimization level, and P and R continue to decrease with the increase of optimization level. Relatively speaking, CMPSeek and SaTC are basically not affected by the optimization level. For dataset A, even at the -O3 optimization level, FLIRT still has the best effect in terms of P and R, with P and R being 0.73 and 0.76 respectively; for dataset B, CMPSeek has the best recognition effect, with P and R both above 0.70. Whether it is dataset A or dataset B, CMPSeek's P and R are higher than SaTC.

[0118] The influence of instruction set on function recognition effect

[0119] This experiment only tests the recognition effect of CMPSeek for four instruction sets. Therefore, we will not test data sets A and B separately. We will integrate the source codes of A and B into one file and use the GCC 5.5.0 compiler with the optimization level of -O0~O3 to compile them into binary files of four different architectures. The experimental results are shown in Table 11.

[0120] Table 11 The impact of different instruction sets on function recognition

[0121]

[0122] As can be seen from Table 11, CMPSeek supports function recognition for multiple instruction set architectures, and the recognition effect of comparison functions in different architectures is not much different. It performs best in the MIPS architecture optimization level of -O0, with P and R of 0.67 and 0.80 respectively.

[0123] The above description is only a preferred embodiment of the present invention and does not limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims

1. A comparison function identification system based on data stream characteristics, characterized in that: The system includes a CFG extraction and loop detection module, a loop instruction extraction module, a comparison operation branch module, a VEX IR instruction generation module, a data flow construction module, a data flow analysis module and a comparison class function identification module; The CFG extraction and loop detection module analyzes whether a function contains a loop path; The loop instruction extraction module and the comparison operation branch module are used to extract instructions from comparison operation branches within loop blocks and loops to function returns, respectively; The VEX IR instruction generation module converts binary code into intermediate language VEX IR instructions with the help of the open source library pyvex, so that the system can support multiple instruction set architectures; The data flow construction and data flow analysis module extracts the variable relationship in the data flow from the VEX IR instruction, generates the data flow DFG and performs analysis; The comparison function identification module detects whether the loop path and the branch path match according to the data flow characteristics, thereby determining whether the function is a comparison function; comprising the following steps: Step 1: Extract the control flow CFG of the function, regard the basic block as the vertex v, and the jump relationship between the basic blocks as the directed edge e, and convert the function CFG into a directed topological graph G. G={V,E} Where: V = {v1, v2, …, v n }, E={e1,e2,…,e m }, yes k =(v i ,v j )(1≤k≤m,1≤i,j≤n) Step 2: Identify whether there is a cycle in the directed graph G; (1) If there is no cyclic path in the directed graph G, it is directly considered to be a non-comparison function; (2) If the directed graph G contains a loop path, extract the loop path and the branch path from the loop jump to the function return, convert the loop path and the branch path into the intermediate language VEXIR instructions, and build the data flow DFG; then determine whether the data flow DFG features match. If they match, it is considered to be a comparison function identification, otherwise it is considered to be a non-comparison function; in step 1, call the FlowChart() class and self.succs() function of the IDA Python plug-in built into IDA Pro to obtain V and E. In step 2, use the DiGraph() function of the open source library NetworkX to quickly build the directed graph G, and call simple_circles() to identify whether there is a loop in the graph G; In step 2, the DiGraph() function of the open source library NetworkX is used to quickly construct a directed graph G, and simple_circles() is called to identify whether there is a cycle in the graph G; In step 2, if the data flow DFG satisfies the following characteristics at the same time, it is identified as a comparison function. (1) There is a ring structure on the data stream, and there are comparison operations and arithmetic operations on the ring; (2) There are Cz points and Cmp pairs in the data stream; (3) There exists a path from point Cz to the Cmp pair, and point Cz appears before the Cmp pair; (4) After the Cmp pair on the ring jumps out of the loop, it can reach the function point Rt; the Cz point represents the value compared with zero in the data stream, and the Cmp pair represents the value involved in the comparison in the data stream. The Rt point represents the result returned by the function in the data flow.

2. A comparison function identification method based on data stream characteristics, applying the above claim 1 The comparison function identification system based on data stream features is characterized by: The following steps are involved: Step 1: Extract the control flow CFG of the function, regard the basic block as the vertex v, and the jump relationship between the basic blocks as the directed edge e, and convert the function CFG into a directed topological graph G. G={V,E} Where: V = {v1, v2, …, v n }, E={e1,e2,…,e m }, yes k =(v i ,v j )(1≤k≤m,1≤i,j≤n) Step 2: Identify whether there is a cycle in the directed graph G; (1) If there is no cyclic path in the directed graph G, it is directly considered to be a non-comparison function; (2) If the directed graph G contains a loop path, extract the loop path and the branch path from the loop exit to the function return, convert the loop path and the branch path into intermediate language VEXIR instructions, and construct the data flow DFG; then, based on whether the data flow DFG features match, if they match, it is considered to be a comparison function identification, otherwise it is considered to be a non-comparison function.