A binary multi-executable software plug-in method based on dynamic plug-in

Through dynamic instrumentation technology, probe code is inserted into the multi-execution software, the target executor is identified using the current on-site information and monitoring system calls, solving the problems of inaccurate information and large performance overhead in the existing technology, and realizing multi-execution The precise instrumentation and efficient execution path recording of the body software meet the needs of intelligent fuzz testing.

CN114860586BActive Publication Date: 2024-11-19NAT UNIV OF DEFENSE TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210428966.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-22
Publication Date
2024-11-19
Estimated Expiration
2042-04-22

AI Technical Summary

Technical Problem

The prior art instrumentation method in multi-execution software is not suitable for dynamic and multi-execution scenarios, resulting in inaccurate information and high performance overhead, which cannot meet the needs of intelligent fuzz testing.

Method used

Using a dynamic instrumentation method, binary software is loaded through the loader, symbol tables are parsed, software instructions are traversed, probe codes are inserted, target execution bodies are identified using the current on-site information, system calls are monitored, execution paths are recorded, and system state switching is avoided. Achieve quick identification and accurate recording.

Benefits of technology

It realizes precise instrumentation of multi-executive software, reduces performance overhead, provides accurate execution path feedback information, and meets the needs of intelligent fuzz testing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114860586B_ABST
    Figure CN114860586B_ABST
Patent Text Reader

Abstract

The present invention discloses a binary multi-executable software plugging method based on dynamic plugging, comprising: step S1: using a loader to load the binary multi-executable software to obtain a file format; step S2: parsing the symbol table from the file format information, traversing the function name in the symbol table; step S3: using a dynamic translator to traverse the software instructions and extract translation blocks one by one for processing; step S4: inserting probe code into each translation block; step S5: using a dynamic executor to execute the translation block code; step S6: using a dynamic executor to monitor system call information during the execution of the translation block code; step S7: until the multi-executable software is terminated or crashed, an execution track record file of the software running process is obtained. The present invention has the advantages of simple principle, simple operation, wide application range, high accuracy, etc.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention mainly relates to the technical field of software dynamic analysis, and in particular to a binary multi-executable software plugging method based on dynamic plugging. Background Art

[0002] Software instrumentation is a basic software dynamic analysis method that inserts functional codes (generally called probe codes) for extraction, judgment, and recording into the target software, thereby monitoring and recording the execution flow, data flow, and other information of the software runtime through the execution of the probe codes without affecting the normal operation of the target software. Software instrumentation is applied to scenarios such as software behavior function analysis and coverage-guided fuzz testing, and can provide feedback information for analyzing the functions of the target software and fuzz testing of the target software.

[0003] However, traditional software instrumentation technology has the following shortcomings:

[0004] First, they mainly rely on source code plug-in, and lack support for binary software;

[0005] Second, for multi-executable software running in multi-threaded and multi-process states, since there are multiple executors running at the same time, due to different thread scheduling strategies and timings, the workflows of different executors are intertwined, and the execution paths of multiple executors will intersect, resulting in inaccurate and uncertain information obtained by the instrumentation.

[0006] Regarding the first problem mentioned above, the source code instrumentation method requires mastering the source code of the software, cannot be applied to closed-source software, and its usage scenarios are limited.

[0007] In response to the second problem mentioned above, multi-executor software will create multiple executables during operation and provide the same execution code to each executable by sharing code segments. When multiple executables access the probe code in a random scheduling manner, the execution path will be confused, making it difficult to provide accurate and effective execution path feedback information for the scheduling process of fuzz testing. During the operation of multi-executor software, different executables complete different tasks and have independent workflows and trajectories. Instrumentation needs to identify different executables and take targeted measures.

[0008] In the prior art, for the plugging of binary multi-executable software, in terms of the selection of the plugging method, it is necessary to use a dynamic binary plugging method to inject probe code during the creation and execution of multiple executables; in terms of the working mechanism of the probe code, in the process of monitoring and recording the execution path feedback information of the multi-executable software, it is necessary to identify the target executable created by processing user requests during the software execution process, and only record the execution path information of the target executable to achieve accurate monitoring and recording functions; in terms of the performance overhead of the probe code, it is necessary to quickly identify whether the current executable is the target executable and record the execution trajectory. The use of methods such as getpid that identify the executable through system calls should be avoided, which will cause the system to switch from user mode to kernel mode, causing huge performance overhead. From the perspective of reducing overhead, a better method is to use only the current field information for distinction. The execution path feedback process for fuzz testing of binary multi-executable software needs to be applied to the dynamic injection process when the software is running, and it is also necessary to use only the current field information to quickly identify the target executable during the running stage, so as to accurately execute the monitoring and recording process of the probe code.

[0009] As can be seen from the above, various existing instrumentation methods are not suitable for dynamic, multi-executable scenarios with low performance overhead requirements, and cannot meet the requirements of coverage-guided intelligent fuzz testing. Summary of the invention

[0010] The technical problem to be solved by the present invention is: in view of the technical problems existing in the prior art, the present invention provides a binary multi-executable software plugging method based on dynamic plugging, which has simple principle, simple operation, wide application range and high accuracy.

[0011] In order to solve the above technical problems, the present invention adopts the following technical solutions:

[0012] A binary multi-executable software plugging method based on dynamic plugging, the steps of which include:

[0013] Step S1: Use a loader to load the binary multi-executable software to obtain its file format;

[0014] Step S2: parsing the symbol table from the file format information, traversing the function names in the symbol table, and matching the characteristic characters of each function name to determine the creation mode W of the multi-executable software;

[0015] Step S3: Use a dynamic translator to traverse the software instructions, record the code segment ending with the branch jump instruction as a translation block, and extract the translation blocks one by one for processing;

[0016] Step S4: before each translation block, insert a probe code that is selectively executed according to the current field information;

[0017] Step S5: Execute the translation block code using a dynamic executor, and when the translation block probe code is reached, determine whether the recognition code condition is met; if so, execute the function code to record the execution path, otherwise skip the function code and execute the instructions following the probe code;

[0018] Step S6: Use the dynamic executor to monitor the system call information during the execution of the translation block code; if the clone system call event is monitored to prepare to create a new executable body, the execution is interrupted, updated according to different creation methods W, and the dynamic executor is used to continue to execute the translation block code, and return to step S3 after completion; otherwise, return to step S3 after execution is completed;

[0019] Step S7: until the multi-executable software is terminated or crashes, an execution track record file of the software running process is obtained.

[0020] As a further improvement of the method of the present invention: in step S2, for the running state composed of multiple threads, set W=1, and read the system preset thread default stack space size S through the C library interface, set the new execution body stack base address identifier B=0, and B will be updated to its stack base address before the new thread is created.

[0021] As a further improvement of the method of the present invention: in step S2, for the running state composed of multiple processes, set W=2, and set the new executable global variable identifier F=0, F will be updated to 1 before the new process is created, and restored to 0 after the new process is created.

[0022] As a further improvement of the method of the present invention: in step S2, W=3 is set for other situations except the running state composed of multiple threads and the running state composed of multiple processes.

[0023] As a further improvement of the method of the present invention: in step S4, the identification code is judged according to different identification conditions according to W, specifically including:

[0024] When W=1, it means that the new execution body is in thread state. The method to determine and identify the target thread is that the current code is running on the stack space of the target thread. The required information is the default stack space size S of the thread preset by the system, the stack base address information B of the new thread after creation, and the current stack top information T. When T belongs to the interval (BS, B), it is determined that the probe code is running on the target thread and the function code is executed, otherwise the execution is skipped.

[0025] When W=2, it indicates that the new executable body is in process state. The method for determining whether the target process is identified is that the value of the current global variable is the copy value 1 when the new process is created, rather than the global variable value 0 subsequently restored by the parent process. The required information is the current global variable identifier F. When F=1, it is considered that the probe code is running on the target process and the function code is executed, otherwise the execution is skipped.

[0026] As a further improvement of the method of the present invention: in step S4, the probe code includes an identification code and a function code; the identification code is used to identify whether the current execution body is the target execution body, and if so, the function code is executed, otherwise the execution of the function code is skipped. The execution of the function code will be used to record the current execution path.

[0027] As a further improvement of the method of the present invention: in step S5, the step of monitoring and updating the system call information includes: using a dynamic executor to monitor the system call information during the execution of the translation block code; if a clone system call event is monitored to prepare to create a new executable body, the execution is interrupted, otherwise the execution is completed and then returns to step S3.

[0028] As a further improvement of the method of the present invention: in step S5, if W=1, it means that the newly created executable body will run in thread state, read the register to obtain the new executable body stack base address information C, and update the new thread stack base address identifier B=C; if W=2, it means that the newly created executable body will run in process state, modify the new process global variable identifier F=1, use the dynamic executor to execute the clone system call and interrupt the execution again, and modify F=0.

[0029] As a further improvement of the method of the present invention: in step S5, a dynamic executor is used to continue to execute the translation block code, and after completion, the method returns to step S3.

[0030] Compared with the prior art, the advantages of the present invention are:

[0031] 1. A binary multi-executable software plugging method based on dynamic plugging of the present invention utilizes dynamic plugging technology to insert different probe codes during the loading of multi-executable software, the creation of multi-executables, and the operation of multi-executables, thereby determining the specific creation method of multi-executables, identifying the target executable body, and recording the execution trajectory.

[0032] 2. The present invention is a binary multi-executable software plugging method based on dynamic plugging. During the loading process, the probe code mainly completes the identification of the multi-executable creation method; the probe code in the process of creating multi-executables monitors whether a new executable is created based on the identified creation method, and records the field information of the new executable for the identification of the target executable. During the operation of the present invention, the probe code determines whether to execute the recording code based on the current field information and the field information of the new executable, and completes the recording function.

[0033] 3. The binary multi-executable software plugging method based on dynamic plugging of the present invention can quickly identify the target executable body during the alternating operation of multiple executable bodies and record its corresponding execution trajectory data to meet the needs of multi-executable software analysis and the accuracy requirements of execution path feedback information in intelligent fuzzy testing.

[0034] 4. The present invention provides a binary multi-executable software plugging method based on dynamic plugging, which creates a new executable body for the multi-executable software to process the working scenario requested by the user, takes the new executable body as the target executable body to be plugged, plugs the binary multi-executable software based on dynamic plugging, and collects the execution path information of the target executable body. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] Figure 1 It is a schematic flow diagram of the method of the present invention.

[0036] Figure 2 It is a flow chart of monitoring and updating system call information in a specific application example of the present invention. DETAILED DESCRIPTION

[0037] The present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0038] like Figure 1 and Figure 2 As shown, a binary multi-executable software plugging method based on dynamic plugging of the present invention comprises the following steps:

[0039] Step S1: Use a loader to load the binary multi-executable software to obtain its file format;

[0040] Step S2: parsing the symbol table from the file format information, traversing the function names in the symbol table, and matching the characteristic characters of each function name to determine the creation mode W of the multi-executable software;

[0041] Step S3: Use a dynamic translator to traverse the software instructions, record the code segment ending with the branch jump instruction as a translation block, extract the translation blocks one by one for processing; for each translation block, execute step S4;

[0042] Step S4: before each translation block, insert a probe code that is selectively executed according to the current field information;

[0043] Step S5: Execute the translation block code using a dynamic executor, and when the translation block probe code is reached, determine whether the recognition code condition is met; if so, execute the function code to record the execution path, otherwise skip the function code and execute the instructions following the probe code;

[0044] Step S6: Use the dynamic executor to monitor the system call information during the execution of the translation block code; if the clone system call event is monitored to prepare to create a new executable body, the execution is interrupted, updated according to different creation methods W, and the dynamic executor is used to continue to execute the translation block code, and return to step S3 after completion; otherwise, return to step S3 after execution is completed;

[0045] Step S7: until the multi-executable software is terminated or crashes, an execution track record file of the software running process is obtained.

[0046] In a specific application example, in step S2, for the running state composed of multiple threads, set W=1, and read the system preset thread default stack space size S through the C library interface, set the new execution body stack base address identifier B=0, and B will be updated to its stack base address before the new thread is created.

[0047] In a specific application example, in step S2, for a running state consisting of multiple processes, W=2 is set, and a new executable global variable identifier F=0 is set. F will be updated to 1 before a new process is created, and restored to 0 after the new process is created.

[0048] In a specific application example, W=3 is set in other cases.

[0049] In a specific application example, in step S4, the probe code consists of an identification code and a function code. The identification code is used to identify whether the current execution body is the target execution body. If it is, the function code is executed, otherwise the execution of the function code is skipped. The execution of the function code will be used to record the current execution path.

[0050] In a specific application example, in step S4, the identification code performs different identification condition determinations according to W, specifically including:

[0051] When W=1, it means that the new execution body is in thread state. The method to determine and identify the target thread is that the current code is running on the stack space of the target thread. The required information is the default stack space size S of the thread preset by the system, the stack base address information B of the new thread after creation, and the current stack top information T. When T belongs to the interval (BS, B), it is determined that the probe code is running on the target thread and the function code is executed, otherwise the execution is skipped.

[0052] When W=2, it means that the new executable body is in process state. The method to determine and identify the target process is that the value of the current global variable is the copy value 1 when the new process is created, rather than the global variable value 0 subsequently restored by the parent process. The required information is the current global variable identifier F. When F=1, it is considered that the probe code is running on the target process and the function code is executed, otherwise the execution is skipped.

[0053] In a specific application example, in step S6, the step of monitoring and updating the system call information includes:

[0054] Step S601: Use the dynamic executor to monitor the system call information during the execution of the translation block code. If the clone system call event is monitored to prepare to create a new executable body, the execution is interrupted and the execution continues to step S602. Otherwise, the execution is completed and the process returns to step S3.

[0055] Step S602: If W=1, it means that the newly created executable body will run in thread state, read the register to obtain the new executable body stack base address information C, and update the new thread stack base address identifier B=C; if W=2, it means that the newly created executable body will run in process state, modify the new process global variable identifier F=1, use the dynamic executor to execute the clone system call and interrupt the execution again, modify F=0. Go to step S603;

[0056] Step S603: Use the dynamic executor to continue executing the translation block code, and return to step S3 after completion.

[0057] In a specific application example of the present invention, taking qemu, a popular computer simulator, as an example, the present invention illustrates how to record the precise execution trajectory of multi-executable software based on the proposed software instrumentation method. In this application example, the detailed steps of the present invention are as follows:

[0058] Step 1: Based on the open source qemu framework, use the loader to load the binary multi-executable software and obtain its file format;

[0059] Step 2: Based on step 1, parse the symbol table from the file format information, traverse the function names in the symbol table, and match the characteristic characters of each function name to determine the creation method W of the multi-executable software. If "pthread_create@@" is matched, it means that the running state is composed of multiple threads, set W=1, and read the system preset thread default stack space size S through the C library interface, set the new executable stack base address identifier B=0, B will be updated to its stack base address before the new thread is created; if "fork@@" is matched, it means that the running state is composed of multiple processes, set W=2, and set the new executable global variable identifier F=0, F will be updated to 1 before the new process is created, and restored to 0 after the new process is created; in other cases, set W=3

[0060] Step 3: Based on the dynamic translator of qemu, use the dynamic translator to traverse the software instructions, record the code segment ending with the branch jump instruction as the translation block, extract the translation blocks one by one for processing. For each translation block, execute step 4;

[0061] Step 4: Use the function interfaces tcg_gen_code() and cpu_tb_exec() provided by qemu to insert probe code that is selectively executed according to the current field information before each translation block. The probe code consists of identification code and function code. The identification code identifies whether the current execution body is the target execution body. If it is, the function code is executed. Otherwise, the execution of the function code is skipped. The execution of the function code will record the current execution path.

[0062] The identification code makes different identification condition judgments based on W. When W=1, it means that the new execution body is composed of thread state. The method for determining and identifying the target thread is that the current code is running on the stack space of the target thread. The required information is the default thread stack space size S preset by the system, the stack base address information B after the new thread is created, and the current stack top information T. When T belongs to the interval (BS, B), it is considered that the probe code is running on the target thread and the function code is executed, otherwise the execution is skipped. When W=2, it means that the new execution body is composed of process state. The method for determining and identifying the target process is that the value of the current global variable is the copy value 1 when the new process is created instead of the global variable value 0 subsequently restored by the parent process. The required information is the current global variable identifier F. When F=1, it is considered that the probe code is running on the target process and the function code is executed, otherwise the execution is skipped.

[0063] Step 5: Based on step 4, the qemu-based dynamic execution system executes the translation block code. When it runs to the probe code of the translation block, it determines whether the identification code condition is met. If it is met, the function code is executed to record the execution path. Otherwise, the function code is skipped and the instructions after the probe code are executed;

[0064] Step 6: Based on step 5, use qemu's system call monitoring function helper_syscall() to monitor system call information during the execution of the translation block code. If the clone system call event is detected to prepare to create a new executable body, the execution is interrupted and the process goes to step 7. Otherwise, the process goes back to step 3 after the execution is completed.

[0065] Step 7: Based on step 6, if W=1, it means that the newly created executable body will run in thread state, read the register to obtain the new executable body stack base address information C, and update the new thread stack base address identifier B=C; if W=2, it means that the newly created executable body will run in process state, modify the new process global variable identifier F=1, execute the clone system call based on the qemu dynamic execution system and interrupt the execution again, modify F=0. Go to step 8;

[0066] Step 8: Based on step 7, the qemu-based dynamic execution system continues to execute the translation block code, and returns to step 3 after completion;

[0067] Step 9: Repeat steps 3-8 until the multi-executable software is terminated or crashes, and obtain the execution track record file of the software running process.

[0068] The above are only preferred embodiments of the present invention, and the protection scope of the present invention is not limited to the above embodiments. All technical solutions under the concept of the present invention belong to the protection scope of the present invention. It should be pointed out that for ordinary technicians in this technical field, some improvements and modifications without departing from the principle of the present invention should be regarded as the protection scope of the present invention.

Claims

1. A binary multi-executable software instrumentation method based on dynamic instrumentation, characterized in that the steps include: Step S1: Use a loader to load the binary multi-executable software to obtain its file format; Step S2: parsing the symbol table from the file format information, traversing the function names in the symbol table, and matching the characteristic characters of each function name to determine the creation mode W of the multi-executable software; Step S3: Use a dynamic translator to traverse the software instructions, record the code segment ending with the branch jump instruction as a translation block, and extract the translation blocks one by one for processing; Step S4: before each translation block, insert a probe code that is selectively executed according to the current field information; Step S5: using a dynamic executor to execute the translation block code, and when running to the probe code of the translation block, determining whether the recognition code condition is met; If satisfied, the function code is executed to record the execution path, otherwise the function code is skipped and the instructions following the probe code are executed; Step S6: Use the dynamic executor to monitor the system call information during the execution of the translation block code; if the clone system call event is monitored to prepare to create a new executable body, the execution is interrupted, updated according to different creation methods W, and the dynamic executor is used to continue to execute the translation block code, and return to step S3 after completion; otherwise, return to step S3 after execution is completed; Step S7: until the multi-executable software is terminated or crashes, an execution track record file of the software running process is obtained; In step S4, the identification code is determined according to different identification conditions, including: When W=1, it means that the new execution body is in thread state. The method to determine and identify the target thread is that the current code is running on the stack space of the target thread. The required information is the default stack space size S of the thread preset by the system, the stack base address information B of the new thread after creation, and the current stack top information T. When T belongs to the interval (BS, B), it is determined that the probe code is running on the target thread and the function code is executed, otherwise the execution is skipped. When W=2, it indicates that the new executable body is in process state. The method for determining whether the target process is identified is that the value of the current global variable is the copy value 1 when the new process is created, rather than the global variable value 0 subsequently restored by the parent process. The required information is the current global variable identifier F. When F=1, it is considered that the probe code is running on the target process and the function code is executed, otherwise the execution is skipped.

2. The binary multi-executable software instrumentation method based on dynamic instrumentation according to claim 1, characterized in that: In step S2, for the running state composed of multiple threads, W=1 is set, and the system preset thread default stack space size S is read through the C library interface, and the new execution body stack base address identifier B=0 is set. B will be updated to its stack base address before the new thread is created.

3. The binary multi-executable software plugging method based on dynamic plugging according to claim 2, characterized in that: In step S2, for the running state consisting of multiple processes, W=2 is set, and the global variable identifier F of the new executable body is set=0. F will be updated to 1 before the new process is created, and restored to 0 after the new process is created.

4. The binary multi-executable software plugging method based on dynamic plugging according to claim 3, characterized in that: In step S2, W=3 is set for other cases except the operation state composed of multiple threads and the operation state composed of multiple processes.

5. The binary multi-executable software instrumentation method based on dynamic instrumentation according to any one of claims 1 to 4, characterized in that: In step S4, the probe code includes an identification code and a function code; the identification code is used to identify whether the current execution body is the target execution body, if so, the function code is executed, otherwise the execution of the function code is skipped; the execution of the function code will be used to record the current execution path.

6. The binary multi-executable software instrumentation method based on dynamic instrumentation according to claim 1, characterized in that: In step S5, the step of monitoring and updating the system call information includes: using a dynamic executor to monitor the system call information during the execution of the translation block code; if a clone system call event is monitored to prepare to create a new executable body, the execution is interrupted, otherwise the execution is completed and the process returns to step S3.

7. The binary multi-executable software instrumentation method based on dynamic instrumentation according to claim 6, characterized in that: In step S5, if W=1, it means that the newly created executable body will run in thread state, read the register to obtain the new executable body stack base address information C, and update the new thread stack base address identifier B=C; if W=2, it means that the newly created executable body will run in process state, modify the new process global variable identifier F=1, use the dynamic executor to execute the clone system call and interrupt the execution again, and modify F=0.

8. The binary multi-executable software instrumentation method based on dynamic instrumentation according to claim 7, characterized in that: In step S5, the dynamic executor is used to continue executing the translation block code, and after completion, the process returns to step S3.