Application program repairing method and device, electronic equipment and storage medium

By setting breakpoints in mobile applications and executing script code, real-time repair of emergency vulnerabilities is achieved without modifying the original code, solving the problems of long repair cycles and large downloads in the existing technology, and supporting multiple operating systems.

CN120386549APending Publication Date: 2025-07-29NETEASE (HANGZHOU) NETWORK CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510475202.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-15
Publication Date
2025-07-29

AI Technical Summary

Technical Problem

In the prior art, when mobile applications encounter urgent/important vulnerabilities, they cannot be repaired in time, resulting in a long review cycle and large number of parallel package downloads, making it difficult to deal with emergencies.

Method used

Set breakpoints in the target application in advance, execute the target script code in response to the breakpoint trigger, and repair the application according to the trigger type of the breakpoint to achieve rapid repair.

Benefits of technology

It realizes that emergency/important vulnerabilities are solved in real time without modifying the original code, preventing the spread of problems, and supports Android, Hongmeng and iOS, with extremely small downloads.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120386549A_ABST
    Figure CN120386549A_ABST
Patent Text Reader

Abstract

The invention provides an application program repairing method and device, electronic equipment and a storage medium, and relates to the technical field of data processing. The method comprises the steps that a target application program is run, the target application program comprises a plurality of to-be-repaired functions, and breakpoints are arranged in the to-be-repaired functions; in response to triggering of a breakpoint in the target to-be-repaired function, executing a target script code corresponding to the breakpoint in the target to-be-repaired function; when the target script code is executed, the target application program is repaired according to the trigger type of the breakpoint in the target to-be-repaired function, that is, the original execution logic is changed and influenced according to new requirements under the condition that the original code of the target application program is not modified, so that the purpose of solving the problem of online sudden emergency / important vulnerabilities in real time is achieved; the hot repair scheme provided by the invention not only supports the Android, the gap and the iOS at the same time, but also only needs an extremely small downloading amount, and can quickly cover all users.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data processing, and in particular, to a method, device, electronic device, and storage medium for repairing application programs. Background Art

[0002] The hot fix technology for mobile C++ code is a technology that directly updates the code of an application program during the running process of the application without stopping the program. This technology is particularly important in mobile application development because it allows developers to quickly fix discovered vulnerabilities without having to republish the entire application, thereby improving the stability and user experience of the application.

[0003] In the related art, when an emergency problem occurs in an already launched application program that needs to be addressed, such as a user being unable to log in / pay or an urgent public opinion issue, it is often only possible to submit a complete review process to the operator to release a new installation package (also known as a parallel package), and users can use the parallel package to repair the vulnerabilities of the application program.

[0004] However, adopting the above repair method has the problems of a long review cycle and a large download volume of the parallel package, making it difficult to handle sudden emergency / important vulnerabilities. Summary of the Invention

[0005] The purpose of the present invention is to provide a method, device, electronic device, and storage medium for repairing application programs to solve the problem in the prior art that sudden emergency / important vulnerabilities cannot be repaired in a timely manner, in view of the above deficiencies in the prior art.

[0006] To achieve the above purpose, the technical solutions adopted in the embodiments of the present application are as follows:

[0007] In a first aspect, an embodiment of the present application provides a method for repairing an application program, the method including:

[0008] Running a target application program, where the target application program includes a plurality of functions to be repaired, and breakpoints are set in each of the functions to be repaired;

[0009] Responding to the triggering of a breakpoint in a target function to be repaired, and executing target script code corresponding to the breakpoint in the target function to be repaired;

[0010] When the target script code is executed, repairing the target application program according to the triggering type of the breakpoint in the target function to be repaired.

[0011] In a second aspect, an embodiment of the present application further provides a device for repairing an application program, the device including:

[0012] A running module, configured to run a target application, where the target application includes multiple functions to be repaired, and breakpoints are set in each of the functions to be repaired;

[0013] An execution module, configured to execute target script code corresponding to a breakpoint in a target function to be repaired in response to the breakpoint in the target function to be repaired being triggered;

[0014] A repair module, configured to repair the target application according to the trigger type of the breakpoint in the target function to be repaired when the target script code is executed.

[0015] In a third aspect, an embodiment of the present application provides an electronic device, including: a processor, a storage medium, and a bus. The storage medium stores machine-readable instructions executable by the processor. When the electronic device runs, communication between the processor and the storage medium is carried out through the bus, and the processor executes the machine-readable instructions to execute the application repair method provided in the first aspect.

[0016] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer program is run by a processor, it executes the application repair method provided in the first aspect.

[0017] The beneficial effects of the present application are:

[0018] The present application provides a method, device, electronic device, and storage medium for repairing an application. In this solution, target script code for a target application is pre-written. During the running of the target application, when a breakpoint in a certain function to be repaired in the target application is triggered, the execution jumps from the function to be repaired to the target script code pointed to by the breakpoint in the target function to be repaired, and the arithmetic logic of the target script code is executed, that is, the execution process of the function to be repaired is paused, and the function call to be repaired is routed to the target script code; then, after the target script code is executed, the return value of the target function to be repaired is modified using the arithmetic result output by the target script code, solving the vulnerability problem existing in the target function to be repaired, that is, without modifying the original code of the target application, changing and affecting the original execution logic according to the new requirements pointed to by the breakpoint set in the target function to be repaired, achieving real-time solution of urgent / important vulnerability problems occurring online, preventing the spread of serious problems / public opinions. The hot repair solution provided by the present application not only supports Android, HarmonyOS, and iOS at the same time, but also only requires a very small download volume and can quickly cover all users. Description of the Drawings

[0019] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as limiting the scope. For those of ordinary skill in the art, without creative efforts, other related drawings can be obtained based on these drawings.

[0020] Figure 1 It is a schematic flowchart of a method for repairing an application program provided by an embodiment of the present application;

[0021] Figure 2 It is a schematic diagram of setting breakpoints in a function to be repaired provided by an embodiment of the present application;

[0022] Figure 3 It is an example of a function to be repaired in a method for repairing an application program provided by an embodiment of the present application;

[0023] Figure 4 It is a schematic flowchart of another method for repairing an application program provided by an embodiment of the present application;

[0024] Figure 5 It is a schematic flowchart of another method for repairing an application program provided by an embodiment of the present application;

[0025] Figure 6 It is a schematic structural diagram of a device for repairing an application program provided by an embodiment of the present application;

[0026] Figure 7 It is a schematic diagram of the structure of an electronic device provided by an embodiment of the present application. Detailed implementation manners

[0027] To make the objectives, technical solutions, and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. It should be understood that the accompanying drawings in the present application only serve the purpose of illustration and description and are not used to limit the protection scope of the present application. Additionally, it should be understood that the schematic drawings are not drawn to actual scale. The flowcharts used in the present application illustrate the operations implemented according to some embodiments of the present application. It should be understood that the operations in the flowchart may not be implemented in sequence, and steps without logical context relationships may be reversed or implemented simultaneously. In addition, those skilled in the art can add one or more other operations to the flowchart or remove one or more operations from the flowchart under the guidance of the content of the present application.

[0028] In addition, the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. The components of the embodiments of the present application generally described and shown in the drawings here can be arranged and designed in various configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the claimed application, but merely represents selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work are within the scope of protection of the present application.

[0029] In order to enable those skilled in the art to use the contents of this application, the following implementation method is provided in conjunction with the specific application scenario of "hot repair of mobile applications or game programs." For those skilled in the art, the general principles defined herein can be applied to other embodiments and application scenarios without departing from the spirit and scope of this application. Although this application mainly describes the hot repair of mobile applications, it should be understood that this is only an exemplary embodiment. This application can be applied to any other scenario.

[0030] It should be noted that the term "comprising" will be used in the embodiments of the present application to indicate the existence of the features declared thereafter, but does not exclude the addition of other features.

[0031] First, the prior art involved in this application is introduced.

[0032] Some mobile apps and games use C / C++ as their primary development language, such as games developed with the UE4 engine or third-party engines. However, hot-updating C / C++ code on mobile devices has long been a challenge. This is primarily due to channel or system limitations. For example, iOS cannot execute unsigned binary code, making it impossible for app developers to independently update C / C++ apps. These developers must submit their entire app or game for review, which requires a lengthy review cycle.

[0033] In related technologies, when an urgent problem occurs in an online application / game that needs to be handled, such as a user being unable to log in / pay or an urgent public opinion issue, it is often only possible to submit a complete review process to the operator to release a new installation package (also called a parallel package). Users can use the parallel package to fix vulnerabilities in the application or game.

[0034] However, the above repair method has the problem of a long period from review to online release and a large amount of parallel package downloads, which makes it difficult to deal with sudden urgent / important vulnerabilities online.

[0035] Based on the above problems, the present application proposes a repair solution for mobile applications or games developed in C / C++ language. When an online emergency vulnerability is encountered, breakpoints are set in multiple functions to be repaired included in the target application in advance. When the target application is running, when a breakpoint of a function to be repaired in the target application is triggered, it jumps to the target script code corresponding to the breakpoint in the function to be repaired, and executes the operation logic of the target script code, and uses the operation result output by the target script code to repair the target application. That is, without modifying the target application, according to the new requirements, it changes and affects the original execution logic of the target application, achieving real-time solution of online sudden emergency / important vulnerability problems and preventing the spread of serious problems / public opinions. The hot repair solution provided by the present application not only supports Android, HarmonyOS and iOS at the same time, but also only requires a very small download volume and can quickly cover all users.

[0036] The repair method of the application provided by the present application will be described through the following embodiments.

[0037] Figure 1 It is a schematic flowchart of the repair method of the application provided by the embodiment of the present application; optionally, the execution subject of this method can be an electronic device with data processing functions. It should be noted that the repair method of the application provided by the present application does not depend on Figure 1 and the specific order described below is limited.

[0038] It should be understood that in other embodiments, the order of some steps of the repair method of the application provided by the present application can be interchanged according to actual needs, or some of the steps can also be omitted or deleted. Refer to Figure 1 , the method includes:

[0039] S101. Run the target application.

[0040] Among them, the target application includes multiple functions to be repaired, and breakpoints are set in each function to be repaired.

[0041] A breakpoint refers to a point used to trigger the application to execute some additional custom script logics during the normal execution of the application to achieve hot repair of the application; essentially, it is the script injection point of each function or function. The user first sets breakpoints in the C / C++ functions to be repaired where problems occur or are related to the problems. During the execution of the function to be repaired, some additional custom script logics can be triggered to execute, which are used to repair the problems existing in the function itself (or read data, such as viewing variables, memory, call stack, and can also modify data or call functions) to achieve the purpose of hot repairing the application.

[0042] The target application can be an APP or game on the mobile device that requires dynamic repair or function update, such as a social APP, a mobile game, or an enterprise-level tool.

[0043] For example, when a social APP on the mobile device cannot be logged in, this situation needs to be urgently repaired. Therefore, the login function in the social APP can be used as a function to be repaired, and breakpoints can be set in the login function.

[0044] Another example is that when there are multiple problems to be repaired in a social APP on the mobile device at the same time, the function functions corresponding to each problem to be repaired can be used as a function to be repaired, and breakpoints can be set in each function to be repaired.

[0045] Another example is that when a social APP on the mobile device needs to update a certain function, the function corresponding to this function can be used as a function to be repaired, and breakpoints can be set in the function to be repaired.

[0046] S102. In response to the breakpoint in the target function to be repaired being triggered, execute the target script code corresponding to the breakpoint in the target function to be repaired.

[0047] Exemplarily, the target script code is pre-written in the programming languages of Lua / Python, but is not limited to these two.

[0048] Among them, before the target application runs, the script code can be downloaded from the server to the client so that when the target application runs, the script code can be used to repair the sudden problems existing in the target application. Among them, the download volume of the script code is extremely small, generally less than <0.01M, and it can achieve rapid repair of online emergency problems.

[0049] In this embodiment, during the running process of the target application, when the breakpoint of a function to be repaired in the target application is triggered, it jumps from the function to be repaired to the target script code corresponding to the breakpoint in the target function to be repaired, and executes the operation logic of the target script code, that is, pauses the execution process of the function to be repaired and routes the function call of the function to be repaired to the target script code.

[0050] S103. When the target script code is executed, repair the target application according to the trigger type of the breakpoint in the target function to be repaired.

[0051] Among them, in order to achieve rapid repair of the function to be repaired, it is proposed that when setting breakpoints in the target function to be repaired, the trigger type of the breakpoint is defined at the same time, such as the trigger type includes: repair type and information acquisition type.

[0052] In an implementable manner, if the trigger type of the breakpoint in the target function to be repaired is a repair type, when the target script code is executed, the return value of the target function to be repaired is modified using the operation result output by the target script code, solving the vulnerability problem existing in the target function to be repaired. That is, without modifying the original code of the target application, the original execution logic is changed and affected according to the new requirements pointed to by the breakpoint set in the target function to be repaired, achieving a quick hot fix for the target application.

[0053] In summary, the embodiment of the present application provides a method for repairing an application. In this solution, the target script code for the target application is pre-written, and during the running of the target application, when a breakpoint of a function to be repaired in the target application is triggered, the execution jumps from the function to be repaired to the target script code pointed to by the breakpoint in the target function to be repaired, and the operation logic of the target script code is executed. That is, the execution process of the function to be repaired is paused, and the function call of the function to be repaired is routed to the target script code. Then, after the target script code is executed, the return value of the target function to be repaired is modified using the operation result output by the target script code, solving the vulnerability problem existing in the target function to be repaired. That is, without modifying the original code of the target application, the original execution logic is changed and affected according to the new requirements pointed to by the breakpoint set in the target function to be repaired, achieving the real-time solution of urgent / important vulnerability problems occurring online and preventing the spread of serious problems / public opinions. The hot fix solution provided by the present application not only supports Android, HarmonyOS, and iOS at the same time, but also only requires a very small download volume and can quickly cover all users.

[0054] Optionally, the functions to be repaired include: all functions in the target application or specified functions at specific positions.

[0055] In an implementable manner, referring to Figure 2 As shown, in order to achieve a quick hot fix for the target application, breakpoints can be set in important functions at specific positions, such as C++ macros / template classes, special functions / templates, functions / modules. That is, breakpoints are set manually in advance at specific code positions. Or, breakpoints can also be set in each function, that is, it is implemented by automatically instrumenting at the beginning of each C / C++ function (batch, large quantity), and the automatic instrumentation occurs during compilation.

[0056] Among them, when a breakpoint is set in the function to be repaired in the target application, when the breakpoint is triggered, the function call of the function to be repaired can be routed to the script code pointed to by the breakpoint, and the operation logic of the script code is executed to achieve the purpose of repairing the vulnerability.

[0057] For example, referring to Figure 3As shown, for example, func_hello() is a function. Breakpoints can be set in func_hello(). Breakpoints can also be set within the sub-functions do_something1() and do_something2() in func_hello(). The sub-functions internally call sub-sub-functions. Therefore, it is equivalent to setting breakpoints at multiple positions in the func_hello() function (i.e., the breakpoint positions can be arbitrarily customized). In this way, there are a large number of opportunities to repair abnormal data.

[0058] Optionally, the following two methods can be used to optimize the performance of breakpoints:

[0059] (1) Use unlikely optimization so that the CPU can accurately predict when executing a new if judgment. It can also be used in loops or high-frequency functions.

[0060] (2) No additional memory access is required during if judgment, that is, map the bitwise judgment of all breakpoints to the same cache line (64B, global). This cache line is frequently used and will always be in the L1 Cache, which makes the entire process without reading memory.

[0061] Each breakpoint set in the function to be repaired used in this application corresponds to two bits. When the cache line contains these two bits, it is initially judged that the breakpoint may be hit. Among them, using two bits (or more) instead of one can effectively reduce the conflict probability (that is, when different breakpoints are mapped to the same bit, it is considered a "conflict").

[0062] Optionally, since the address of a virtual function can only be determined at runtime, setting breakpoints in virtual functions in the target application is different from ordinary functions. Therefore, the functions actually executed by different objects may be different. In addition, there may be a large number of objects of the same parent class. The specific implementation process includes: (1) Modify the virtual table pointer of the object to a new virtual table; (2) Objects of the same subclass share a new virtual table; This method can hook functions without source code.

[0063] The following embodiments will specifically explain how to perform hot repair on an application.

[0064] Optionally, when performing hot repair on the target application, there are the following situations:

[0065] Situation 1: Replace the implementation of the function to be repaired, that is, execute according to the processing logic of the target script code pointed to by the breakpoint in the function to be repaired, and use the operation result output by the target script code to replace the return value of the function to be repaired;

[0066] Case 2: Re - call the function to be repaired. When re - calling the function to be repaired at the breakpoint, all or some of the original input parameters can be fully maintained or modified, and the return value of the function to be repaired can be obtained / modified. That is, after re - calling the function to be repaired at the breakpoint, some custom processing is performed.

[0067] Case 3: Obtain the input parameters or return value of the function to be repaired.

[0068] Case 4: Read and write operations on memory data.

[0069] Among them, the above - mentioned Case 1 and Case 2 can be called repair types, and Case 3 and Case 4 can be called information - acquisition types. The following will specifically explain how to implement the above processes.

[0070] Optionally, the above - mentioned step S103 includes:

[0071] If the trigger type is a repair type, then perform online repair on the target application according to the trigger subtype of the breakpoint in the target function to be repaired.

[0072] In an implementable manner, if the trigger type of the breakpoint in the function A to be repaired is a repair type, then perform online repair on the target application according to the trigger subtype of the breakpoint in the function A to be repaired. For example, replace the return value of the function A to be repaired with the operation result of the target script code pointed to by the breakpoint in the function A to be repaired, quickly complete the emergency repair, and achieve the quick repair of the emergency or important vulnerabilities of the target application.

[0073] Optionally, as shown in Figure 4 The above step of performing online repair on the target application according to the trigger subtype of the breakpoint in the target function to be repaired includes:

[0074] S401: If the trigger subtype is to replace the function to be repaired, then obtain the parameters of the target function to be repaired and the called object.

[0075] Among them, the trigger subtype being to replace the function to be repaired means that instead of executing the code of the original C++ function, execute the custom Lua code pointed to by the breakpoint, and the custom new return value, and use the new return value to replace the return value of the original C++ function to repair the vulnerability existing in the original C++ function.

[0076] S402: Determine whether to meet the preset condition takeover according to the parameters of the function to be repaired.

[0077] Among them, takeover supports custom condition triggering, that is, conditional takeover and unconditional takeover. Conditional takeover means takeover only under specific conditions (such as the existence of vulnerabilities to be repaired).

[0078] S403. If the takeover condition is met, use the parameters of the target function to be repaired as the input parameters of the target function in the target script code, run the target function, obtain the execution result output by the target function, and use the execution result of the target function to modify the return value of the target function to be repaired.

[0079] In an implementable manner, for example, the following function to be repaired is:

[0080]

[0081] Among them, since the developer did not consider that when the leader in the DoSth() function is a null pointer, it will cause the application to crash. Therefore, there are two repair methods as follows:

[0082] Method 1: Set a breakpoint at XXXClass::DoSth and obtain the parameter m_leaderId. When m_leaderId is found to be -1, it is determined that the preset takeover condition is met, and the takeover is an empty implementation (conditional takeover);

[0083] Method 2: Set a breakpoint at ForceDetach. When obtaining the parameter of the pointer this, when the value of the pointer this is nullptr, it is determined that the preset takeover condition is met, and the takeover is an empty implementation (conditional takeover).

[0084] Among them, the code of the target function is as follows:

[0085]

[0086]

[0087] When the target function is executed, if the return value is nil, it means takeover, and this value is used to replace the return value of the original function, that is, hot fix the online problems existing in the application without reinstalling the application.

[0088] Optionally, as shown in Figure 5 it also includes:

[0089] S501. If the takeover condition is not met, determine whether the target function to be repaired meets the preset local takeover according to the called object of the target function to be repaired.

[0090] Among them, "partial takeover" means that a breakpoint is triggered only when it comes from a specific caller. For example, it is specified that the current function F triggers the behavior of the custom modification function F only when it is called from a specific function A; when the function F is called by other functions, no operation is triggered. In this way, it is possible to modify the behavior of a specific function F in a small range in function A without having to re-implement the entire function A, providing a stronger ability to modify code.

[0091] S502. If partial takeover is satisfied, use the parameters of the target function to be repaired as the input parameters of the target function in the target script code, run the target function, obtain the execution result output by the target function, and use the execution result of the target function to modify the return value of the target function to be repaired.

[0092] Exemplarily, the function to be repaired is function F. The return address returnAddr of function F and the currently executing code address hitAddr can be obtained, and it can be determined whether the partial takeover condition is triggered by judging whether the following conditions are met according to different situations:

[0093] Normal situation: returnAddr ∈ [callerStart, callerEnd]

[0094] Inline function: hitAddr ∈ [callerStart, callerEnd]

[0095] Tail call: returnAddr == callerReturnAddr

[0096] Among them, callerStart is the starting address of function A, callerEnd is the ending address of function A, and callerReturnAddr is the return address when function A is executed.

[0097] Therefore, the called object of the target function to be repaired can be determined according to the return address of the target function to be repaired, and it can be determined whether the target function to be repaired meets the preset partial takeover condition according to the called object of the target function to be repaired. If the partial takeover condition is met, use the parameters of the target function to be repaired as the input parameters of the target function in the target script code, run the target function, obtain the execution result output by the target function, and use the execution result of the target function to modify the return value of the target function to be repaired, realizing the rapid repair of emergency or important vulnerabilities of the target application.

[0098] Optionally, online repair of the target application is performed according to the trigger subtype of the breakpoint in the target function to be repaired, including:

[0099] If the trigger subtype is to re - call the function to be repaired, obtain the function address of the target function to be repaired, replace the original parameters of the target function to be repaired with the new parameters pre - generated for the target function to be repaired in the target script code, re - call the target function to be repaired, and obtain the new return value output by the target function to be repaired.

[0100] Among them, the trigger subtype being to re - call the function to be repaired means not executing according to the old input parameters of the original C++ function, but modifying the original input parameters according to the custom Lua code pointed to by the breakpoint, and using the modified input parameters to re - call the original C++ function to obtain the new return value after re - execution, so as to update the function of the original C++ function.

[0101] In an implementable way, if the trigger subtype of the breakpoint in the function to be repaired is to re - call the function to be repaired, read the register or stack area of the target function to be repaired, obtain the function address of the target function to be repaired from the register or stack area, replace the original parameters of the target function to be repaired with the new parameters pre - generated for the target function to be repaired in the target script code pointed to by the breakpoint, re - call the target function to be repaired with the new parameters, obtain the new return value output by the target function to be repaired, and use the new return value to replace the original return value, thus realizing the hot - fix of the target function to be repaired.

[0102] Optionally, repair the target application according to the trigger type of the breakpoint in the target function to be repaired, including:

[0103] If the trigger type is information - acquisition type, obtain the function information of the target function to be repaired from the target script code corresponding to the breakpoint in the target function to be repaired, and output the function information of the target function to be repaired, so that the user can perform repair operations according to the function information of the target function to be repaired.

[0104] In another implementable way, if the trigger type of the breakpoint in function B to be repaired is information - acquisition type, obtain the function information of the target function to be repaired, such as input parameters, return value, function address, called functions, etc., from the target script code pointed to by the breakpoint in function B to be repaired, and output the function information of the target function to be repaired, so that the user can perform repair operations according to the function information of the target function to be repaired.

[0105] For example, if the trigger type of the breakpoint in the function B to be repaired is information acquisition type, the target script code pointed to by the breakpoint reads the input parameters or return values of the function B to be repaired through AAPSC64; for another example, the target function in the target script code pointed to by the breakpoint can analyze the binary code of the currently executing C / C++ function to obtain the current function address, other functions called, local variables, global variables, etc.; then, the function information of the target function to be repaired is output so that the user can perform repair operations according to the function information of the target function to be repaired, such as modifying the input parameters.

[0106] Optionally, obtaining the function information of the target function to be repaired includes:

[0107] According to the identifier of the target function to be repaired, read the function information of the target function to be repaired from the storage area, so that the function information pre-generated for the target function to be repaired modifies the function information of the target function to be repaired.

[0108] Exemplarily, the storage area includes: registers or stack areas.

[0109] Among them, according to the standard of AAPCS64, the parameters of the function are transmitted through registers, and the parameters of some functions can be transmitted through the stack; in the breakpoint, the local variables and temporary calculation results of the original function are stored on the stack. Therefore, in this embodiment, the target script code pointed to by the breakpoint can read the stack pointer SP, and then according to the identifier of the target function to be repaired and the stack pointer offset, read the function information of the target function to be repaired on the stack, that is, check the input parameters, return values, etc. of the target function to be repaired to determine whether a vulnerability problem has occurred. If so, the function information pre-generated for the target function to be repaired can be used to correct the function information of the target function to be repaired.

[0110] Among them, when parsing local variables, simple analysis of assembly is required, but not in other cases.

[0111] Optionally, obtaining the function information of the target function to be repaired includes:

[0112] Obtain the binary code of the target function to be repaired that is currently being executed in the target application; parse the binary code of the target function to be repaired to obtain the function information of the target function to be repaired.

[0113] In another implementable manner, the target script code pointed to by the breakpoint can obtain the binary code of the target function to be repaired that is currently being executed in the target application, and parse the binary code of the target function to be repaired to obtain the function address, other functions referenced, local variables, and global variables of the target function to be repaired, and perform subsequent calls or read / write operations.

[0114] Optionally, the function information includes: input parameter values, return values, memory data, global variables, local variables, function addresses, or referenced functions.

[0115] Optionally, read and write operations can also be performed on the memory data of the target function to be repaired. For example, the target script code pointed to by the breakpoint in the target function to be repaired performs read and write operations on the corresponding application memory data through multi-level pointers. For example, read / write, application / release of memory data in scripts such as Lua / Python:

[0116] (1) Basic memory library (malloc, free) basic operations (+, -, -> member access);

[0117] (2) Basic type operations, such as:

[0118] void*, int, long, float, double, char*, std::string, TgcString, Vector;

[0119] (3) Auxiliary libraries such as vector / matrix operations.

[0120] Based on the same inventive concept, embodiments of the present application also provide a repair device for an application program corresponding to the repair method of the application program. Since the principle of problem-solving of the device in the embodiments of the present application is similar to the above-mentioned repair method of the application program in the embodiments of the present application, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be elaborated.

[0121] Figure 6 It is a schematic structural diagram of the repair device for an application program provided by an embodiment of the present application. Refer to Figure 6 As shown, the device includes:

[0122] A running module 601, configured to run a target application program, where the target application program includes multiple functions to be repaired, and breakpoints are set in each of the functions to be repaired;

[0123] An execution module 602, configured to execute the target script code corresponding to the breakpoint in the target function to be repaired in response to the breakpoint in the target function to be repaired being triggered;

[0124] A repair module 603, configured to repair the target application program according to the trigger type of the breakpoint in the target function to be repaired when the target script code is executed.

[0125] Optionally, the function to be repaired includes: all functions in the target application program or specified functions at specific positions.

[0126] Optionally, the repair module 603 is specifically configured to:

[0127] If the trigger type is the repair type, online repair is performed on the target application according to the trigger subtype of the breakpoint in the target function to be repaired.

[0128] Optionally, the repair module 603 is specifically configured to:

[0129] If the trigger subtype is to replace the function to be repaired, obtain the parameters of the target function to be repaired and the called object;

[0130] Determine whether to meet the preset condition takeover according to the parameters of the function to be repaired;

[0131] If the condition takeover is met, use the parameters of the target function to be repaired as the input parameters of the target function in the target script code, run the target function, obtain the execution result output by the target function, and use the execution result of the target function to modify the return value of the target function to be repaired.

[0132] Optionally, the repair module 603 is specifically configured to:

[0133] If the condition takeover is not met, determine whether the target function to be repaired meets the preset local takeover according to the called object of the target function to be repaired;

[0134] If the local takeover is met, use the parameters of the target function to be repaired as the input parameters of the target function in the target script code, run the target function, obtain the execution result output by the target function, and use the execution result of the target function to modify the return value of the target function to be repaired.

[0135] Optionally, the repair module 603 is specifically configured to:

[0136] If the trigger subtype is to re - call the function to be repaired, obtain the function address of the target function to be repaired, replace the original parameters of the target function to be repaired with the new parameters pre - generated for the target function to be repaired in the target script code, re - call the target function to be repaired, and obtain the new return value output by the target function to be repaired.

[0137] Optionally, the repair module 603 is specifically configured to:

[0138] If the trigger type is the information - obtaining type, obtain the function information of the target function to be repaired from the target script code corresponding to the breakpoint in the target function to be repaired, and output the function information of the target function to be repaired, so that the user can perform repair operations according to the function information of the target function to be repaired.

[0139] Optionally, the repair module 603 is specifically configured to:

[0140] Read the function information of the target function to be repaired from the storage area according to the identifier of the target function to be repaired, so as to modify the function information of the target function to be repaired with the function information pre-generated for the target function to be repaired.

[0141] Optionally, the repair module 603 is specifically configured to:

[0142] Obtain the binary code of the target function to be repaired that is currently being executed in the target application;

[0143] Parse the binary code of the target function to be repaired to obtain the function information of the target function to be repaired.

[0144] Optionally, the function information includes: input parameter values, return values, memory data, global variables, local variables, function addresses, or referenced functions.

[0145] The above device is used to execute the method provided in the foregoing embodiment, and its implementation principle and technical effects are similar, and will not be described in detail here.

[0146] The above modules may be one or more integrated circuits configured to implement the above methods. For example: one or more application specific integrated circuits (ASICs), or, one or more digital signal processors (DSPs), or, one or more field programmable gate arrays (FPGAs), etc. Again, when the above certain module is implemented in the form of a processing element scheduling program code, the processing element may be a general-purpose processor, such as a central processing unit (CPU) or other processors that can call program code. Again, these modules may be integrated together and implemented in the form of a system-on-a-chip (SOC).

[0147] Figure 7 The figure is a schematic structural diagram of an electronic device provided in an embodiment of the present application. The electronic device includes: a processor 701, a storage medium 702, and a bus 703. The storage medium 702 stores machine-readable instructions executable by the processor 701. When the electronic device runs, the processor 701 communicates with the storage medium 702 through the bus 703, and the processor 701 executes the machine-readable instructions to perform the following steps:

[0148] Run the target application, where multiple functions to be repaired are included in the target application, and breakpoints are set in each of the functions to be repaired;

[0149] In response to the breakpoint in the target function to be repaired being triggered, execute the target script code corresponding to the breakpoint in the target function to be repaired;

[0150] When the target script code is executed, repair the target application according to the trigger type of the breakpoint in the target function to be repaired.

[0151] Optionally, the functions to be repaired include: all functions in the target application or specified functions at specific positions.

[0152] Optionally, when the processor 701 executes the repair of the target application according to the trigger type of the breakpoint in the target function to be repaired, it is specifically used for:

[0153] If the trigger type is a repair type, perform online repair on the target application according to the trigger subtype of the breakpoint in the target function to be repaired.

[0154] Optionally, when the processor 701 executes the online repair of the target application according to the trigger subtype of the breakpoint in the target function to be repaired, it is specifically used for:

[0155] If the trigger subtype is to replace the function to be repaired, obtain the parameters and called objects of the target function to be repaired;

[0156] Determine whether to meet the preset condition takeover according to the parameters of the function to be repaired;

[0157] If the condition takeover is met, use the parameters of the target function to be repaired as the input parameters of the target function in the target script code, run the target function, obtain the execution result output by the target function, and use the execution result of the target function to modify the return value of the target function to be repaired.

[0158] Optionally, the processor 701 is further used to execute:

[0159] If the condition takeover is not met, determine whether the target function to be repaired meets the preset local takeover according to the called object of the target function to be repaired;

[0160] If the local takeover is met, use the parameters of the target function to be repaired as the input parameters of the target function in the target script code, run the target function, obtain the execution result output by the target function, and use the execution result of the target function to modify the return value of the target function to be repaired.

[0161] Optionally, when the processor 701 performs online repair on the target application according to the trigger subtype of the breakpoint in the target function to be repaired, it specifically is used for:

[0162] If the trigger subtype is to recall the function to be repaired, obtain the function address of the target function to be repaired, replace the original parameters of the target function to be repaired with the new parameters pre-generated in the target script code for the target function to be repaired, recall the target function to be repaired, and obtain the new return value output by the target function to be repaired.

[0163] Optionally, when the processor 701 performs repair on the target application according to the trigger type of the breakpoint in the target function to be repaired, it specifically is used for:

[0164] If the trigger type is information acquisition type, obtain the function information of the target function to be repaired from the target script code corresponding to the breakpoint in the target function to be repaired, and output the function information of the target function to be repaired, so that the user can perform a repair operation according to the function information of the target function to be repaired.

[0165] Optionally, when the processor 701 performs the operation of obtaining the function information of the target function to be repaired, it specifically is used for:

[0166] Read the function information of the target function to be repaired from the storage area according to the identifier of the target function to be repaired, so that the function information pre-generated for the target function to be repaired modifies the function information of the target function to be repaired.

[0167] Optionally, when the processor 701 performs the operation of obtaining the function information of the target function to be repaired, it specifically is used for:

[0168] Obtain the binary code of the target function to be repaired that is currently being executed in the target application;

[0169] Parse the binary code of the target function to be repaired to obtain the function information of the target function to be repaired.

[0170] Optionally, the function information includes: input parameter values, return values, memory data, global variables, local variables, function addresses, or referenced functions.

[0171] Optionally, the present invention further provides a program product, such as a computer-readable storage medium, including a program, which when executed by a processor is used to perform the following steps when the processor executes:

[0172] Run a target application, where the target application includes multiple functions to be repaired, and breakpoints are set in each of the functions to be repaired;

[0173] When a breakpoint in the target function to be repaired is triggered, execute the target script code corresponding to the breakpoint in the target function to be repaired;

[0174] When the target script code is executed, repair the target application according to the trigger type of the breakpoint in the target function to be repaired.

[0175] Optionally, the function to be repaired includes: all functions in the target application or specified functions at specific positions.

[0176] Optionally, when the processor executes the repair of the target application according to the trigger type of the breakpoint in the target function to be repaired, it is specifically used for:

[0177] If the trigger type is a repair type, perform online repair on the target application according to the trigger subtype of the breakpoint in the target function to be repaired.

[0178] Optionally, when the processor executes the online repair of the target application according to the trigger subtype of the breakpoint in the target function to be repaired, it is specifically used for:

[0179] If the trigger subtype is to replace the function to be repaired, obtain the parameters and called objects of the target function to be repaired;

[0180] Determine whether to meet the preset condition takeover according to the parameters of the function to be repaired;

[0181] If the condition takeover is met, use the parameters of the target function to be repaired as the input parameters of the target function in the target script code, run the target function, obtain the execution result output by the target function, and use the execution result of the target function to modify the return value of the target function to be repaired.

[0182] Optionally, the processor is also used to execute:

[0183] If the condition takeover is not met, determine whether the target function to be repaired meets the preset local takeover according to the called object of the target function to be repaired;

[0184] If the local takeover is met, use the parameters of the target function to be repaired as the input parameters of the target function in the target script code, run the target function, obtain the execution result output by the target function, and use the execution result of the target function to modify the return value of the target function to be repaired.

[0185] Optionally, when the processor executes the online repair of the target application according to the trigger subtype of the breakpoint in the target function to be repaired, the specific operations are as follows:

[0186] If the trigger subtype is to re - call the function to be repaired, obtain the function address of the target function to be repaired, replace the original parameters of the target function to be repaired with the new parameters pre - generated in the target script code for the target function to be repaired, re - call the target function to be repaired, and obtain the new return value output by the target function to be repaired.

[0187] Optionally, when the processor executes the repair of the target application according to the trigger type of the breakpoint in the target function to be repaired, the specific operations are as follows:

[0188] If the trigger type is information - acquisition type, obtain the function information of the target function to be repaired from the target script code corresponding to the breakpoint in the target function to be repaired, and output the function information of the target function to be repaired, so that the user can perform repair operations according to the function information of the target function to be repaired.

[0189] Optionally, when the processor executes the operation of obtaining the function information of the target function to be repaired, the specific operations are as follows:

[0190] According to the identifier of the target function to be repaired, read the function information of the target function to be repaired from the storage area, so as to modify the function information of the target function to be repaired with the function information pre - generated for the target function to be repaired.

[0191] Optionally, when the processor executes the operation of obtaining the function information of the target function to be repaired, the specific operations are as follows:

[0192] Obtain the binary code of the target function to be repaired that is currently being executed in the target application;

[0193] Parse the binary code of the target function to be repaired to obtain the function information of the target function to be repaired.

[0194] Optionally, the function information includes: input parameter values, return values, memory data, global variables, local variables, function addresses, or referenced functions.

[0195] In several embodiments provided by the present invention, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed couplings or direct couplings or communication connections between each other can be through some interfaces. The indirect couplings or communication connections of the devices or units can be in electrical, mechanical or other forms.

[0196] The units described as separate components may or may not be physically separated. The components displayed as units may or may not be physical units, that is, they can be located in one place or distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0197] In addition, in each embodiment of the present invention, the functional units can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The above integrated units can be implemented in the form of hardware or in the form of hardware plus software functional units.

[0198] The above integrated units implemented in the form of software functional units can be stored in a computer-readable storage medium. The above software functional units are stored in a storage medium and include several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor (English: processor) to execute some steps of the methods described in each embodiment of the present invention. The foregoing storage medium includes: USB flash drives, mobile hard disks, read-only memories (English: Read-Only Memory, abbreviated as: ROM), random access memories (English: Random Access Memory, abbreviated as: RAM), magnetic disks or optical disks and other various media that can store program codes.

Claims

1. A repair method for an application program, characterized in that, The method includes: Running a target application, where the target application includes multiple functions to be repaired, and breakpoints are set in each function to be repaired; In response to the breakpoint in the target function to be repaired being triggered, executing target script code corresponding to the breakpoint in the target function to be repaired; When the target script code is executed, repairing the target application according to the trigger type of the breakpoint in the target function to be repaired.

2. The method according to claim 1, characterized in that The functions to be repaired include: all functions in the target application or specified functions at specific positions.

3. The method according to claim 1, wherein The repairing the target application according to the trigger type of the breakpoint in the target function to be repaired includes: If the trigger type is a repair type, online repairing the target application according to the trigger subtype of the breakpoint in the target function to be repaired.

4. The method according to claim 3, wherein The online repairing the target application according to the trigger subtype of the breakpoint in the target function to be repaired includes: If the trigger subtype is to replace the function to be repaired, obtaining the parameters and the called object of the target function to be repaired; Determining whether to meet a preset takeover condition according to the parameters of the function to be repaired; If the takeover condition is met, using the parameters of the target function to be repaired as the input parameters of the target function in the target script code, running the target function, obtaining the execution result output by the target function, and using the execution result of the target function to modify the return value of the target function to be repaired.

5. The method according to claim 4, wherein It further includes: If the takeover condition is not met, determining whether the target function to be repaired meets a preset local takeover according to the called object of the target function to be repaired; If the local takeover is met, using the parameters of the target function to be repaired as the input parameters of the target function in the target script code, running the target function, obtaining the execution result output by the target function, and using the execution result of the target function to modify the return value of the target function to be repaired.

6. The method according to claim 3, wherein The online repairing the target application according to the trigger subtype of the breakpoint in the target function to be repaired includes: If the trigger subtype is to re - call the function to be repaired, obtaining the function address of the target function to be repaired, replacing the original parameters of the target function to be repaired with new parameters pre - generated in the target script code for the target function to be repaired, re - calling the target function to be repaired, and obtaining a new return value output by the target function to be repaired.

7. The method according to claim 1, wherein The repairing the target application according to the trigger type of the breakpoint in the target function to be repaired includes: If the trigger type is an information - obtaining type, obtaining function information of the target function to be repaired by the target script code corresponding to the breakpoint in the target function to be repaired, and outputting the function information of the target function to be repaired, so that the user can perform a repair operation according to the function information of the target function to be repaired.

8. The method according to claim 7, wherein The obtaining the function information of the target function to be repaired includes: Read the function information of the target function to be repaired from the storage area according to the identifier of the target function to be repaired, so that the function information pre-generated for the target function to be repaired modifies the function information of the target function to be repaired.

9. The method according to claim 7, wherein The obtaining the function information of the target function to be repaired includes: Obtain the binary code of the target function to be repaired that is currently being executed in the target application; Parse the binary code of the target function to be repaired to obtain the function information of the target function to be repaired.

10. The method according to claim 7, characterized in that The function information includes: input parameter values, return values, memory data, global variables, local variables, function addresses, or referenced functions.

11. A repair device for an application program, characterized in that, The device includes: A running module for running a target application, where the target application includes multiple functions to be repaired, and breakpoints are set in each of the functions to be repaired; An execution module for, in response to a breakpoint in the target function to be repaired being triggered, executing the target script code corresponding to the breakpoint in the target function to be repaired; A repair module for, when the target script code is executed, repairing the target application according to the trigger type of the breakpoint in the target function to be repaired.

12. An electronic device, characterized in that, Includes: A processor, a storage medium, and a bus. The storage medium stores machine-readable instructions executable by the processor. When the electronic device runs, the processor communicates with the storage medium through the bus, and the processor executes the machine-readable instructions to perform the steps of the method according to any one of claims 1-10.

13. A computer-readable storage medium, characterized in that, A computer program is stored on the storage medium, and when the computer program is run by the processor, it executes the method according to any one of claims 1-10.

Citation Information

Cited By

  • Memory vulnerability repairing method, computer device and readable storage medium

    CN120910872A