Vulnerability hot repair method and device, equipment and storage medium
Patent Information
- Application Number
- CN202411634620.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-15
- Publication Date
- 2026-05-15
AI Technical Summary
[0005]本发明提供一种热修复漏洞的方法、装置、设备及存储介质,用以解决现有技术中采用脚本框架将热修复漏洞脚本转化为终端可执行的语言,以使终端进行热修复漏洞的方式存在可能会被禁用的缺陷,实现通过终端和服务器进行交互,终端通过runtime机制执行热修复漏洞的方法属性相关操作,服务器执行热修复漏洞的逻辑步骤,从而保证修复漏洞的逻辑代码的完整执行的目的
[0017]第七方面,本发明还提供一种计算机可读存储介质,其上存储有计算机程序,该计算机程序被处理器执行时实现如上述第一方面和/或第二方面的热修复漏洞的方法。
Smart Images

Figure CN122046351A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and in particular to a method, apparatus, device, and storage medium for hot-patching vulnerabilities. Background Technology
[0002] Hotfixing refers to methods for quickly resolving issues or defects found in an application's software without re-releasing the entire software package or application. Hotfixing is crucial for rapidly resolving defects / anomalies in mobile applications / products (such as IT products), therefore, designing a good hotfixing method is essential for fixing application / product defects / anomalies.
[0003] In related technologies, when problems occur in a released application / product, code to fix the problem is usually set up first. Then, the code to fix the problem is converted into a scripting language and deployed on a server. After the application / product on the mobile terminal starts, it can download the corresponding scripting language from the server. Then, the corresponding scripting framework and syntax parser are used to convert the scripting language into a language that can be executed on the mobile terminal. Finally, the executable language is executed on the mobile terminal to achieve hotfix of the application / product.
[0004] However, the above-mentioned technologies pose security risks and may be disabled, thus necessitating a new application hotfix method. Summary of the Invention
[0005] This invention provides a method, apparatus, device, and storage medium for hot-patching vulnerabilities, which addresses the shortcomings of existing technologies that use script frameworks to convert hot-patching vulnerability scripts into terminal-executable languages, potentially leading to the disabling of hot-patching methods on terminals. The invention achieves this by enabling interaction between the terminal and server, with the terminal executing method attribute-related operations for hot-patching vulnerabilities through a runtime mechanism, and the server executing the logical steps for hot-patching vulnerabilities, thereby ensuring the complete execution of the vulnerability-patching logic code.
[0006] In a first aspect, the present invention provides a method for hot-patching vulnerabilities, applied to a server, the method comprising: Based on the vulnerability information of the application, determine the first method to identify the vulnerability in the application, as well as the target class to be replaced and the second method to be replaced; After the application is launched on the terminal, the target class and the second method are sent to the terminal; the target class and the second method are used to instruct the terminal to replace the first method in the target class of the application with the second method. The receiving terminal sends a first execution request when it executes the second method, and sends a first operation instruction to the terminal according to the first execution request; the first operation instruction includes a first target operation that the terminal needs to execute through the runtime mechanism; After the receiving terminal completes the first target operation, it returns the target execution result and executes the corresponding logical steps of the second method according to the target execution result until the second method is completed.
[0007] According to a method for hot-patching vulnerabilities provided by the present invention, the first method for determining the existence of vulnerabilities in an application based on vulnerability information, and the second method for determining the target class to be replaced and the class to be replaced, include: Obtain vulnerability information of the input application, and extract the first vulnerable method and the target class to be replaced from the vulnerability information; the vulnerability information includes the first method, the target class, and the target input / output parameter configuration status corresponding to the first method; Based on the target input / output parameter configuration state, the target method format corresponding to the target input / output parameter configuration state is determined in the preset first correspondence relationship; the first correspondence relationship includes multiple different input / output parameter configuration states and the method format corresponding to each input / output parameter configuration state. Configure the second method corresponding to the target method format according to the target method format.
[0008] According to a method for hot-patching vulnerabilities provided by the present invention, the above-mentioned sending a first operation instruction to the terminal according to a first execution request includes: The second method is obtained according to the first execution request, and the first target operation that needs to be executed by the terminal through the runtime mechanism and the name of the target object for executing the first target operation are determined according to the logical steps of the second method. A first operation instruction is determined based on the first target operation, and the first operation instruction is sent to the terminal corresponding to the name of the target object; the first target operation includes one or a combination of an object attribute acquisition operation, an object attribute modification operation, and a second method execution operation of the target class; Accordingly, the aforementioned target execution result includes one or a combination of the attribute values accessed by the terminal from a preset dictionary based on the name of the target object, the attribute values obtained after modifying the attribute values of the target object, and the execution result obtained after executing the second method of the target class.
[0009] According to a method for hot-patching vulnerabilities provided by the present invention, the target execution result includes the target attribute value corresponding to the target object, and the logical steps of executing the second method according to the target execution result include: Based on the target attribute value, a second operation instruction corresponding to the target attribute value is determined from a preset instruction library; the instruction library includes a second correspondence between different attribute values and the operation instruction corresponding to each attribute value. Send a second operation instruction to the terminal; the second operation instruction includes a second target operation that the terminal needs to execute through the runtim mechanism, and the second target operation is different from the first target operation.
[0010] According to a method for hot-patching vulnerabilities provided by the present invention, the target execution result includes the attribute values of all objects involved in the second method, and the logical steps of executing the second method according to the target execution result include: Based on the logical steps of the second method, determine the attribute value of the target object that needs to be updated from the attribute values of all objects involved in the second method; Based on the target attribute value, a second operation instruction corresponding to the target attribute value is determined from a preset instruction library; the instruction library includes a second correspondence between different attribute values and the operation instruction corresponding to each attribute value. Send a second operation instruction to the terminal; the second operation instruction includes a second target operation that the terminal needs to execute through the runtim mechanism, and the second target operation is different from the first target operation.
[0011] Secondly, the present invention also provides a method for hot-patching vulnerabilities, applied to a terminal, the method comprising: After the application is started, the first method in the application that has a vulnerability is obtained from the server, as well as the target class and the second method that need to be replaced are determined, and the second method is used to replace the first method in the target class of the application. If the second method is executed, a first execution request is sent to the server, and a first operation instruction is received from the server based on the first execution request; the first operation instruction includes a first target operation that the terminal needs to execute through the runtime mechanism. Execute the first target operation, obtain the target execution result, and send the target execution result to the server; the above target execution result is used to instruct the server to execute the logical steps corresponding to the second method according to the target execution result, until the second method is completed.
[0012] According to a method for hot-patching vulnerabilities provided by the present invention, the first target operation includes the name of the target object to which the first target operation is performed, and the first target operation includes an object attribute retrieval operation. The method further includes: Based on the name of the target object, the target memory address corresponding to the name of the target object is determined in a preset dictionary, and the target attribute value corresponding to the target object is obtained from the target memory address; the dictionary includes a third correspondence between the names of different objects and their corresponding memory addresses, and the memory address stores the attribute value corresponding to the object.
[0013] Thirdly, the present invention also provides a device for hot-patching vulnerabilities, applied to a server, the device comprising: The first determination module is used to determine the first method in the application that has a vulnerability, as well as the target class and the second method that need to be replaced, based on the vulnerability information of the application. The first transceiver module is used to send a target class and a second method to the terminal after the application is launched on the terminal; the target class and the second method are used to instruct the terminal to replace the first method in the target class of the application with the second method. The second transceiver module is used to receive a first execution request sent by the terminal when the second method is executed, and to send a first operation instruction to the terminal according to the first execution request; the first operation instruction includes a first target operation that the terminal needs to execute through the runtime mechanism. The first execution module is used to receive the target execution result returned by the terminal after the first target operation is completed, and to execute the logical steps corresponding to the second method according to the target execution result until the second method is completed.
[0014] Fourthly, the present invention also provides a device for hot-patching vulnerabilities, applied to a terminal, the device comprising: The acquisition and replacement module is used to acquire the first method in the application that has a vulnerability from the server after the application starts, as well as to determine the target class to be replaced and the second method to be replaced, and to replace the first method in the target class of the application with the second method. The third transceiver module is used to send a first execution request to the server when the second method is executed, and to receive a first operation instruction sent by the server based on the first execution request; the first operation instruction includes a first target operation that needs to be executed by the terminal through the runtime mechanism. The second execution module is used to execute the first target operation, obtain the target execution result, and send the target execution result to the server. The target execution result is used to instruct the server to execute the logical steps corresponding to the second method according to the target execution result until the second method is completed.
[0015] Fifthly, the present invention also provides a server, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the hot-fix vulnerability described in the first aspect.
[0016] In a sixth aspect, the present invention also provides a terminal, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the hot-fix vulnerability described in the second aspect.
[0017] In a seventh aspect, the present invention also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the hot-fix vulnerability method as described in the first and / or second aspects above.
[0018] Eighthly, the present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the method for hot-fixing vulnerabilities as described in the first and / or second aspects above.
[0019] The present invention provides a method, apparatus, device, and storage medium for hot-patching vulnerabilities. The server determines a first method with a vulnerability in an application based on vulnerability information, as well as a target class and a second method to be replaced. After the application is launched on the terminal, the server sends the target class and the second method to the terminal, instructing the terminal to replace the first method in the target class with the second method. Then, the server receives a first execution request from the terminal when the second method is executed, and sends a first operation instruction to the terminal based on the first execution request, including a first target operation that the terminal needs to execute via a runtime mechanism. The server then receives the target execution result returned by the terminal after executing the first target operation, and executes the logical steps corresponding to the second method based on the target execution result until the second method is completed. In this method, because the terminal and server can interact, allowing the terminal to execute operations related to the hot-patching vulnerability method attributes via a runtime mechanism, while the server executes the logical steps for hot-patching the vulnerability, the complete execution of the vulnerability-patching logic code can be guaranteed. This method also ensures the security of the logic code execution and reduces the risk of disabling. Attached Figure Description
[0020] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0021] Figure 1 This is one of the flowcharts illustrating the hot patching method for vulnerabilities provided by the present invention.
[0022] Figure 2This is the second flowchart of the hot patching vulnerability method provided by the present invention.
[0023] Figure 3 This is a schematic diagram of the timing flow of the interaction between the App and the server on the terminal provided by the present invention.
[0024] Figure 4 This is one of the structural schematic diagrams of the device for hot patching vulnerabilities provided by the present invention.
[0025] Figure 5 This is the second schematic diagram of the device for hot-fixing vulnerabilities provided by the present invention.
[0026] Figure 6 This is a schematic diagram of the server structure provided by the present invention.
[0027] Figure 7 This is a schematic diagram of the terminal provided by the present invention. Detailed Implementation
[0028] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0029] Hotfixing is crucial for quickly resolving defects / anomalies in IT products such as mobile applications, especially on the iOS platform. The review process for hotfix solutions for iOS apps (applications) is time-consuming, and relying on new version releases to fix issues can lead to prolonged unresolved problems, impacting application functionality and potentially damaging the product's reputation and user experience, resulting in user churn. Currently, various open-source hotfix technologies exist on the iOS platform, such as JSPatch, Lua, and Wax. However, some of these technologies may utilize the JavaScriptCore framework and can arbitrarily call any native method using the iOS runtime mechanism, leading to security vulnerabilities when using related apps. Furthermore, these technologies may be disabled. Therefore, this invention provides a novel method, apparatus, device, and storage medium for hotfixing vulnerabilities to address this technical problem.
[0030] The following is combined Figures 1-3 The method for hot-fixing vulnerabilities described in this invention.
[0031] It should be noted that the technical solutions of the embodiments of the present invention can be applied to communication systems, which include servers and terminals communicating with each other. The server can be implemented through a standalone server or a server cluster, and the terminal can include, but is not limited to, mobile phones, tablets, personal laptops, wearable devices, smart home devices, etc. The following embodiments describe methods for hot-patching vulnerabilities on the server side and the terminal side, respectively.
[0032] First, let's explain the method for hot-patching vulnerabilities on the server side.
[0033] Figure 1 This is one of the flowcharts illustrating the hotfix vulnerability method provided by the present invention, such as... Figure 1 As shown, the method includes the following steps: S102, based on the vulnerability information of the application, determine the first method for identifying the vulnerability in the application, and determine the target class to be replaced and the second method to be replaced.
[0034] Here, "application" refers to the application installed on the terminal. This application can be an application corresponding to any operating system, such as an app under the iOS operating system or an app under the Android operating system.
[0035] During the operation of an application on a terminal, the application may encounter bugs, i.e., vulnerabilities. The terminal can collect information on these vulnerabilities and transmit it to the backend server. Alternatively, the terminal can manually collect information on vulnerabilities during application operation and input it into the server so that the server can obtain information on the vulnerabilities in the application. Other methods can also be used, as long as the server can obtain information on vulnerabilities in the application during operation.
[0036] The vulnerability information mentioned above can include vulnerable classes and / or vulnerable methods. The vulnerable method can be referred to as the first method, and the vulnerable class as the target class. Based on this vulnerable first method, programmers can programmatically obtain a second method to fix it in the server, i.e., replace the first method with the second method. Since the same first method may exist in different classes, it is possible to specify which class's first method the second method specifically fixes / replaces, to accurately and meticulously fix / replace the specific vulnerable first method. The class specifically fixed / replaced here can also be referred to as the target class.
[0037] S104, after the terminal starts the application, the target class and the second method are sent to the terminal; the target class and the second method are used to instruct the terminal to replace the first method in the target class of the application with the second method.
[0038] In this step, after the terminal launches the application with the aforementioned vulnerability information, it can interact with the server to inform the server that the terminal has launched the application. Then, the server can send the target class to be replaced and the second method to be replaced to the terminal.
[0039] The target class and the second method can be sent as strings, that is, both the target class and the second method are converted into strings and sent to the terminal. In this way, the terminal can directly obtain the target class and the second method through the strings without parsing and processing, which simplifies the complexity of the terminal performing the repair operation.
[0040] After receiving the target class and the second method sent by the server, the terminal can first find the target class and then replace the first method in the target class with the second method.
[0041] For example, using pseudocode of a vulnerability / error in an application, we can illustrate the process of the terminal replacing the first method with the second method.
[0042] / / Online error codes; (void)logoHight_replace: (UVDeviceInfo *)device { if (device.DVRType == 1) { device.logoHight = 15; } else { device.logoHight = 30; [device doSomething]; } } / / Prepare the correct code for hotfixing vulnerabilities; (void)logoHight_replace: (UVDeviceInfo *)device { if (device.DVRType == 1 || device.DVRType == 2) { device.logoHight = 15; } else { device.logoHight = 30; [device doSomething]; } }
[0043] In the second code snippet above, the bolded part "device.DVRType == 2" represents the second method of the example, while "device.DVRType == 1" in both the first and second code snippets represents the first method of the example. The logical OR symbol "||" is used in the second code snippet to indicate that the correct second method is replaced with the vulnerable first method.
[0044] S106, receive a first execution request sent by the terminal when executing the second method, and send a first operation instruction to the terminal according to the first execution request; the first operation instruction includes a first target operation that the terminal needs to execute through the runtime mechanism.
[0045] In this step, after the terminal replaces the first method in the target class with the second method, it can execute the relevant code or methods of the application. Here, "relevant code or methods" refers to the code or methods executed before the second method. When executing the code at the location of the second method, since the terminal lacks compilation and linking capabilities, it cannot directly execute the relevant logical steps of that second method. At this point, the terminal can send a first execution request to the server and wait for the server's operation instructions. This first execution request informs the server that the terminal has reached the location of the second method and needs the server to determine the operations performed by the terminal within the second method through the runtime mechanism.
[0046] In other words, after receiving the first execution request from the terminal, the server can determine the operations in the second method's related code that need to be executed by the terminal through the runtime mechanism, denoted as the first target operation, and send the first target operation to the terminal through the first operation instruction. This is mainly because object attributes and object methods cannot be executed on the server side. Therefore, when the server parses the object attributes and object methods in the second method of the hot-fix vulnerability, it needs to send this content to the terminal so that the terminal can execute it through the runtime mechanism; while the server can execute some logical steps between methods, compilation and linking operations, etc.
[0047] After receiving the first operation instruction from the server, the terminal can parse the instruction to obtain the first target operation. It can then execute the first target operation and obtain the execution result, denoted as the target execution result. For example, the first target operation might be an operation that requires the terminal to retrieve object attribute values through a runtime mechanism, and the corresponding target execution result could be the retrieved object attribute values.
[0048] It is understandable that the operations that require execution by the terminal can actually be performed by the aforementioned application (App) on the terminal.
[0049] S108, receive the target execution result returned by the receiving terminal after the first target operation is completed, and execute the logical steps corresponding to the second method according to the target execution result until the second method is completed.
[0050] In this step, after the terminal completes the first target operation, it can obtain the target execution result and then send the target execution result to the server. The server can then continue to execute the logical steps of the second method based on the target execution result, such as executing if judgment logic steps, for loop logic steps, switch transition logic steps, addition, subtraction, multiplication, division, and other logical steps.
[0051] During the execution of the logical steps corresponding to the second method by the server, the server can directly execute the logical steps corresponding to the second method until all logical steps and related code of the second method are executed; or, during the execution of the logical steps of the second method, if the terminal needs to continue to perform certain operations through the runtime mechanism, the server can continue to interact with the terminal to complete the execution of the logical steps and related code of the second method. In short, the logical steps and related code of the second method can be completely executed through the interaction between the server and the terminal.
[0052] In this embodiment, the server determines a vulnerable first method in the application based on vulnerability information, as well as a target class and a second method to be replaced. After the terminal starts the application, the server sends the target class and the second method to the terminal, instructing the terminal to replace the first method in the target class with the second method. Then, the server receives a first execution request from the terminal when it reaches the second method, and sends a first operation instruction to the terminal based on the first execution request, including a first target operation that the terminal needs to execute via the runtime mechanism. The server then receives the target execution result returned by the terminal after executing the first target operation, and executes the logical steps corresponding to the second method based on the target execution result until the second method is completed. In this method, because the terminal and server can interact, allowing the terminal to execute operations related to the hot-fix vulnerability method attributes via the runtime mechanism, while the server executes the logical steps for hot-fixing the vulnerability, the complete execution of the vulnerability-fixing logic code can be guaranteed. This method also ensures the security of the logic code execution and reduces the risk of disabling.
[0053] Considering that there may be various input and output parameter scenarios in the replacement method, this embodiment proposes multiple replacement method formats to meet the needs of various input and output parameter scenarios. The process is described below.
[0054] In some embodiments, the step S102 above, "determining a first method for identifying vulnerabilities in the application based on vulnerability information and determining a target class to be replaced and a second method to be replaced," may include the following steps: Step A1: Obtain vulnerability information of the input application, and obtain the first vulnerable method and the target class to be replaced from the vulnerability information; the vulnerability information includes the first method, the target class, and the target input / output parameter configuration status corresponding to the first method.
[0055] Step A2: Based on the target input / output parameter configuration state, determine the target method format corresponding to the target input / output parameter configuration state in the preset first correspondence relationship; the first correspondence relationship includes multiple different input / output parameter configuration states and the method format corresponding to each input / output parameter configuration state.
[0056] Step A3: Configure the second method corresponding to the target method format according to the target method format.
[0057] During the historical execution of applications on the terminal, vulnerability information or error information can be manually collected. This vulnerability information can then be parsed or analyzed to obtain the vulnerable target class, the vulnerable first method within that target class, and the input / output parameter configuration of that first method (i.e., the target input / output parameter configuration state of the first method). Here, the target input / output parameter configuration state of the first method refers to whether the first method has input parameters (also simply called input parameters) and output parameters (also simply called output parameters). For example, the target input / output parameter configuration state can be no input parameters and have output parameters.
[0058] For different input / output parameter configurations or different input / output parameter configuration states, different replacement method formats can be pre-set, and a binding relationship can be established between each input / output parameter configuration state and its corresponding set replacement method format to obtain the aforementioned first correspondence. For example, taking the replacement method format `replaceForBugfix` (replace bug method) as an example, the following are 5 common replacement method formats: (void)replaceForBugfix1; / / No input parameters, no output parameters; (int)replaceForBugfix2; / / No input parameters, output parameter is int (integer type); (id*)replaceForBugfix3; / / No input parameters, output parameter is an object; (void)replaceForBugfix4:(id*)para; / / Input parameter is an object, no output parameter; (id*)replaceForBugfix5: (id*)para; / / Input parameter is an object, output parameter is also an object.
[0059] It should be noted that the above replacement method formats are only examples and are not exhaustive. In other words, the replacement method formats include, but are not limited to, the above replacement method formats.
[0060] Specifically, after obtaining the target input / output parameter configuration status corresponding to the first method in the application that contains the vulnerability, a search can be performed in the pre-established first correspondence. First, the target input / output parameter configuration status is found, and then the replacement method format corresponding to the target input / output parameter configuration status is found and denoted as the target method format. The server can then configure the second method according to the target method format, for example, the configured second method may also be in a format with no input parameters and output parameters.
[0061] In this embodiment, by pre-setting corresponding replacement method formats for different input / output parameter scenarios, and determining the corresponding replacement method format and setting a second method of the corresponding format after obtaining the first method according to its input / output parameter configuration state, errors can be avoided when replacing the first method with the second method in the future, thus improving the accuracy of subsequent method execution. Simultaneously, by pre-setting multiple universal replacement method formats corresponding to different input / output parameter scenarios, it is easy to quickly obtain the replacement method format corresponding to any input / output parameter scenario, improving the efficiency of configuring the second method of the corresponding format.
[0062] The following embodiments illustrate the process by which a server sends a first operation instruction to a terminal based on a first execution request.
[0063] In some embodiments, the step of "sending a first operation instruction to the terminal according to the first execution request" in S106 above may include the following steps: Step B1: Obtain the second method according to the first execution request, and determine the first target operation that the terminal needs to execute through the runtime mechanism and the name of the target object for executing the first target operation according to the logical steps of the second method.
[0064] Step B2: Determine the first operation instruction based on the first target operation, and send the first operation instruction to the terminal corresponding to the name of the target object; the first target operation includes one or a combination of object attribute acquisition operation, object attribute modification operation, and second method execution operation of the target class.
[0065] After receiving the first execution request from the terminal, the server can first obtain the relevant logical steps of the second method, and then determine the first target operation that needs to be executed by the terminal through the runtime mechanism in that logical step, such as object attribute retrieval operation, object attribute modification operation, execution of the second method of the target class, termination operation, etc. It can also obtain the name of the object to be operated on, denoted as the target object name (the target object here could be the terminal or an application on the terminal). When the first target operation is an object attribute modification operation, it can also include the modified attribute values of the object.
[0066] After determining the first target operation, the server can encapsulate the first target operation in a first operation instruction and send it to the terminal corresponding to the name of the aforementioned target object, so that the terminal can execute the first target operation and obtain the target execution result.
[0067] Optionally, the aforementioned target execution result includes one or a combination of the following: the attribute value accessed by the terminal from a preset dictionary based on the name of the target object; the attribute value obtained after modifying the attribute value of the target object; and the execution result obtained after executing the second method of the target class. The dictionary includes a third correspondence between the names of different objects and their corresponding memory addresses, with the memory address storing the attribute value corresponding to the object.
[0068] To facilitate the terminal's quick retrieval of required object attribute values from a string, the input object can be stored in a pre-defined dictionary. This dictionary stores a third-party correspondence between the object's name and the memory address allocated to it. Each memory address can store information such as the object's attribute values and execution results during application runtime. The object's name (e.g., the object's key value) can be obtained from the server. The string here can be a string sent from the server to the terminal, which may include the name of the object the server needs to retrieve. For example, if the server needs to retrieve the attribute value of an object during logical steps, it can encapsulate the object's name in a string and send it to the terminal.
[0069] For example, the following is a pseudocode example of a replacement method with an object as the input parameter and no output parameter. This replacement method format with an object as the input parameter and no output parameter can be written as replaceForBugfix4, and its pseudocode example is as follows: (void)replaceForBugfix4:(id*)para { / / Step 1: To facilitate retrieving the object value from the string later, a general method can be added here, which is to keep the input object in a dictionary, and the key value of this field is obtained from the server side; NSString *strClassName = @"device"; NSDictionary *objectDictionary = @{strClassName: para}; / / Step 2: Enter the while loop and exit the method only when the end command is received; While (1) { / / Step 3: Request instructions from the server and parse the server instructions; switch(instruction type) { Case A1: / / Access the property and return its value; / / Step 4: Parse the attribute value "string" returned by the server, then retrieve the object from the dictionary and return the object's attribute value; Break Case A2: / / Modify attributes; / / Step 5: Referring to Step 4, update the property values returned by the server to the object's properties; Break Case A3: / / Execute a method of a certain class and return the execution result; / / Step 6: Refer to Step 4 to send the method returned by the server to the object for execution; Break Default: Break } If (server termination command) Break; / / If a termination command is received, exit the loop; } }
[0070] After the terminal executes the first target operation and obtains the target execution result, it can return the target execution result to the server. The server can then continue executing the logical steps of the second method based on this result, such as executing if statement logic, for loop logic, switch statement logic, and addition, subtraction, multiplication, and division logic. In other words, the terminal only executes fixed operations such as accessing attributes, modifying attributes, and executing methods of a certain class, while the server executes the code that flexibly executes business logic such as if / for / switch / addition, subtraction, multiplication, and division according to business needs. This collaboration between the server and the terminal enables hot-patching of vulnerabilities on the terminal.
[0071] In summary, after the application (App) on the terminal starts, it obtains information from the server regarding whether hotfix cooperation is needed, and dynamically replaces methods through runtime. For example, based on the server configuration, the terminal / App replaces the first method of the vulnerable target class with a non-vulnerable second method. Therefore, when the application executes the first method of the target class, it automatically replaces it with the second method. Then, in the second method, the terminal communicates with the server in real time to obtain the runtime method to be executed and returns the execution result to the server. After receiving the corresponding execution result, the server can execute the logic class code; at the same time, the server can further confirm the instructions that need to be executed by the terminal / App and send them to the terminal / App. Through this network interaction, the hotfix method is executed until it is completely completed.
[0072] In this embodiment, after the server determines the first target operation that the terminal needs to execute through the runtime mechanism according to the logical steps of the second method, it sends the first target operation to the corresponding terminal through the first operation command. The first target operation may include a variety of attribute and method operations. This refinement of the first target operation can enable the terminal to accurately execute the first target operation, thereby ensuring the accurate and complete execution of the second method.
[0073] The above embodiments mention that the first target operation can have multiple operations, and the corresponding target execution result can include the execution result of one operation or the execution result of multiple operations. During the interaction between the server and the terminal, the terminal can send the execution results of all operations to the server at once, or it can obtain the corresponding execution result according to each operation sent by the server and send it to the server. The following embodiments will describe these two situations respectively.
[0074] In one possible implementation, the target execution result includes the target attribute value corresponding to the target object, and the "execute the logical steps corresponding to the second method according to the target execution result" in S108 may include the following steps: Based on the target attribute value, a second operation instruction corresponding to the target attribute value is determined from a preset instruction library; the instruction library includes a second correspondence between different attribute values and the operation instruction corresponding to each attribute value. Send a second operation instruction to the terminal; the second operation instruction includes a second target operation that the terminal needs to execute through the runtim mechanism, and the second target operation is different from the first target operation.
[0075] In this embodiment, the server can pre-collect different operation instructions and set corresponding attribute values for each different operation instruction. Then, it binds the operation instructions with the set attribute values to obtain a second correspondence. Generally, the attribute values set for different operation instructions are different.
[0076] The target execution result sent by the terminal to the server may include, for example, the target attribute value corresponding to the target object, that is, the target attribute value of a specific target object. After receiving the target attribute value of the target object, the server can directly look up the operation instruction corresponding to the target attribute value in the instruction library, which is recorded as the second operation instruction.
[0077] The second operation instruction can then be sent to the terminal. This second operation instruction typically instructs the terminal to execute a second target operation via the runtime mechanism. This second target operation includes one or a combination of operations such as object attribute retrieval, object attribute modification, execution of a second method of the target class, and termination. The second target operation may also include the name of the object being operated on, denoted as the target object name. If the second target operation is an object attribute modification operation, it may also include the modified attribute values. Furthermore, the second target operation may be the same as or different from the first target operation described above. For example, if the first target operation is an object attribute retrieval operation, the second target operation could be an object attribute modification operation.
[0078] In another possible implementation, the target execution result includes the attribute values of all objects involved in the second method, and the step of "executing the logical steps corresponding to the second method according to the target execution result" in S108 may include the following steps: Based on the logical steps of the second method, determine the attribute value of the target object that needs to be updated from the attribute values of all objects involved in the second method; Based on the target attribute value, a second operation instruction corresponding to the target attribute value is determined from a preset instruction library; the instruction library includes a second correspondence between different attribute values and the operation instruction corresponding to each attribute value. Send a second operation instruction to the terminal; the second operation instruction includes a second target operation that the terminal needs to execute through the runtim mechanism, and the second target operation is different from the first target operation.
[0079] In this embodiment, the server can also pre-collect different operation instructions, set corresponding attribute values for each different operation instruction, and then bind the operation instructions and the set attribute values to obtain a second correspondence. Here, the attribute values set for different operation instructions are generally different.
[0080] If the target execution result sent by the terminal to the server includes, for example, the attribute values of all objects involved in the second method, then after receiving the attribute values of all objects, the server can detect the currently executed logical step according to the logical steps of the second method, determine the target object whose attributes need to be updated in the currently executed logical step, and then find the target object in the attribute values of all objects by the name of the target attribute, and obtain the target attribute value corresponding to the target object. After that, the server can directly look up the operation instruction corresponding to this target attribute value in the instruction library, which is recorded as the second operation instruction.
[0081] The second operation instruction can then be sent to the terminal. This second operation instruction typically instructs the terminal to execute a second target operation via the runtime mechanism. This second target operation includes one or a combination of operations such as object attribute retrieval, object attribute modification, execution of a second method of the target class, and termination. The second target operation may also include the name of the object being operated on, denoted as the target object name. If the second target operation is an object attribute modification operation, it may also include the modified attribute values. Furthermore, the second target operation may be the same as or different from the first target operation described above. For example, if the first target operation is an object attribute retrieval operation, the second target operation could be an object attribute modification operation.
[0082] In addition, in this embodiment, when the terminal sends the attribute values of all objects involved in the second method to the server, it may convert all objects involved in the second method and their attribute values into strings and then send them to the server together. The server updates the target attribute values that need to be updated in the string and then returns the string to the terminal (specifically, it may return it to the application with the vulnerability on the terminal), and the terminal (specifically, it may be the application with the vulnerability on the terminal) completes the attribute update.
[0083] It is understandable that the above-mentioned operations, such as determining the target attribute value of the target object, determining the second operation instruction corresponding to the target attribute value, and sending the second operation instruction to the terminal, can all be considered as the logical steps of the server executing the second method.
[0084] In this embodiment, during the interaction between the server and the terminal, the terminal can obtain the corresponding execution results based on each operation sent by the server and send them back to the server. This allows the methods of the object to be executed in a logical order, enabling hot-fix vulnerability processing for any function. Alternatively, during the interaction between the server and the terminal, the terminal can also send the execution results of all operations to the server at once for the server's use. This reduces the frequency of interaction between the terminal and the server, saving power for both the terminal and the server.
[0085] The following describes the method for hot-patching vulnerabilities on the terminal side.
[0086] Figure 2 This is the second flowchart illustrating the hotfix vulnerability method provided by the present invention, as shown below. Figure 2 As shown, the method includes the following steps: S202, after starting the application, obtain the first method in the application that has a vulnerability from the server, as well as determine the target class to be replaced and the second method to be replaced, and replace the first method in the target class of the application with the second method.
[0087] In this step, as explained on the server side above, after the terminal launches the vulnerable application, the terminal can interact with the server to inform it that the application has been launched. The server can then send the identified target class to be replaced and the second method to be replaced to the terminal, along with the vulnerable first method. The terminal can then use the second method to replace the first method in the application's target class.
[0088] For explanations of the first method, target class, and second method involved, please refer to the explanations of the above server-side embodiments, which will not be repeated here.
[0089] S204, if the second method is executed, a first execution request is sent to the server, and a first operation instruction is received from the server based on the first execution request; the first operation instruction includes a first target operation that needs to be executed by the terminal through the runtime mechanism.
[0090] In this step, when the terminal executes the second method, it can interact with the server to determine the operation it needs to perform. For the specific content of the interaction and the related explanations of the operation, please refer to the explanations of the above server-side embodiments, which will not be repeated here.
[0091] S206, Execute the first target operation, obtain the target execution result, and send the target execution result to the server; the above target execution result is used to instruct the server to execute the logical steps corresponding to the second method according to the target execution result, until the second method is completed.
[0092] In this step, after receiving the first operation instruction sent by the server, the terminal can parse it to obtain the first target operation included therein, and execute the first target operation to obtain the target execution result. After that, the target execution result can be fed back to the server.
[0093] For explanations regarding the terminal's execution of the first target operation and related procedures, as well as the logical steps of the server's execution of the second method after obtaining the target execution result, please refer to the explanations of the above server-side embodiments; they will not be repeated here.
[0094] In this embodiment, after launching the application, the terminal can obtain the vulnerable first method, the target class to be replaced, and the second method to be replaced from the server. The terminal then replaces the first method in the target class with the second method. Upon reaching the second method, the terminal sends a first execution request to the server and receives a first operation instruction from the server, including a first target operation that the terminal needs to execute via a runtime mechanism. The terminal then executes the first target operation and returns the target execution result to the server, enabling the server to execute the logical steps corresponding to the second method based on the target execution result, until the second method is completed. In this method, because the terminal and server can interact, allowing the terminal to execute operations related to the method attributes for hot-fixing vulnerabilities via a runtime mechanism, while the server executes the logical steps for hot-fixing vulnerabilities, the complete execution of the vulnerability-fixing logic code can be guaranteed. This method also ensures the security of the logic code execution and reduces the risk of disabling the vulnerability.
[0095] In some embodiments, the first target operation includes the name of the target object to which the first target operation is performed, and the first target operation includes an object attribute retrieval operation. The method further includes the following steps: Based on the name of the target object, the target memory address corresponding to the name of the target object is determined in a preset dictionary, and the target attribute value corresponding to the target object is obtained from the target memory address; the dictionary includes a third correspondence between the names of different objects and their corresponding memory addresses, and the memory address stores the attribute value corresponding to the object.
[0096] In this step, after the terminal obtains the first target operation, if the first target operation requires the terminal to obtain object attributes, it can simultaneously obtain the name of the target object that performs the first target operation. It can be understood that the name of the target object here can be obtained by the server side in the form of a string.
[0097] Then the terminal can find the corresponding target memory address in the preset dictionary by the name of the target object, and obtain the attribute value stored in the target memory address. This attribute value is the attribute value of the target object, and is denoted as the target attribute value.
[0098] For a detailed explanation of the dictionary, please refer to the explanation of the above server-side implementation, which will not be repeated here.
[0099] In this embodiment, when obtaining object attributes, the corresponding memory address is found in a preset dictionary by the object's name to obtain the attribute value stored therein. This allows the terminal to quickly obtain the attribute value of the required object based on the string.
[0100] The following is an overall embodiment, see [link to embodiment]. Figure 3 The diagram shown illustrates the timing flow of the interaction between the App on the terminal and the server. It should be noted that the interaction here only uses the App on the terminal as an example, but it is not limited to the App.
[0101] During the interaction, the server first configures or deploys the class (target class) and method name (name of the second method) that need hotfixing based on the hotfix requirements, obtaining the Objective-C code for hotfixing. Then, the server converts the Objective-C code for hotfixing into a server-executable scripting language (such as Python). For Objective-C object properties and methods that cannot be converted to Python, they are converted into strings. When that line of code is executed, the string content is sent to the App, which then executes the object method and retrieves the object property.
[0102] Since object properties and methods cannot be executed on the server side, when the server parses code containing hotfix vulnerabilities that includes object properties and methods, it needs to send them line by line to the App through the runtime mechanism. For example, here we need to first send the instruction type "get property" and the specific property name "device.DVRType" to the App.
[0103] When the app returns a specific value to the server, the server uses this value to determine the logic to be executed next. For example, if the value of device.DVRType is 5, then the server will prepare to execute the code branch corresponding to "device.logoHight = 15", which means sending one or a combination of the following to the app: the instruction to "modify attribute", the specific attribute name, the value to be modified, and the operation instruction to end.
[0104] When the App receives this instruction, it first performs the attribute modification operation, and then checks whether it has received an end operation instruction. If it has received an end operation instruction, it exits the entire method.
[0105] As described above, in the embodiments of the present invention, the code for hot-fixing vulnerabilities is implemented through network interaction between the App and the server. The terminal / App executes the logic steps of obtaining, modifying, and modifying attributes and object methods, while the server executes the repair method. This complements the shortcomings of the App runtime mechanism in being unable to implement logical code and the server in being unable to execute App class methods / attributes. It ensures the complete execution of the code for hot-fixing vulnerabilities, realizes a hot-update mechanism for fixing program errors / vulnerabilities, can quickly close online problems, and avoids the risk of disabling as much as possible.
[0106] The apparatus for hot patching vulnerabilities provided by the present invention will be described below. The apparatus for hot patching vulnerabilities described below can be referred to in correspondence with the method for hot patching vulnerabilities described above.
[0107] First, let me explain the device for hot-patching vulnerabilities on the server side.
[0108] Figure 4 This is one of the structural schematic diagrams of the device for hot-fixing vulnerabilities provided by the present invention. See also... Figure 4 As shown, the device may include: The first determining module 410 is used to determine the first method in the application that has a vulnerability, as well as the target class to be replaced and the second method to be replaced, based on the vulnerability information of the application. The first transceiver module 420 is used to send a target class and a second method to the terminal after the application is launched on the terminal; the target class and the second method are used to instruct the terminal to replace the first method in the target class of the application with the second method; The second transceiver module 430 is used to receive a first execution request sent by the terminal when the second method is executed, and to send a first operation instruction to the terminal according to the first execution request; the first operation instruction includes a first target operation that the terminal needs to execute through the runtime mechanism. The first execution module 440 is used to receive the target execution result returned by the terminal after the first target operation is completed, and execute the logical steps corresponding to the second method according to the target execution result until the second method is completed.
[0109] In some embodiments, the first determining module 410 described above is specifically used for Obtain vulnerability information of the input application, and extract the first vulnerable method and the target class to be replaced from the vulnerability information; the vulnerability information includes the first method, the target class, and the target input / output parameter configuration status corresponding to the first method; Based on the target input / output parameter configuration state, the target method format corresponding to the target input / output parameter configuration state is determined in the preset first correspondence relationship; the first correspondence relationship includes multiple different input / output parameter configuration states and the method format corresponding to each input / output parameter configuration state. Configure the second method corresponding to the target method format according to the target method format.
[0110] In some embodiments, the second transceiver module 430 described above is specifically used for The second method is obtained according to the first execution request, and the first target operation that needs to be executed by the terminal through the runtime mechanism and the name of the target object for executing the first target operation are determined according to the logical steps of the second method. A first operation instruction is determined based on the first target operation, and the first operation instruction is sent to the terminal corresponding to the name of the target object; the first target operation includes one or a combination of an object attribute acquisition operation, an object attribute modification operation, and a second method execution operation of the target class; Accordingly, the aforementioned target execution result includes one or a combination of the attribute values accessed by the terminal from a preset dictionary based on the name of the target object, the attribute values obtained after modifying the attribute values of the target object, and the execution result obtained after executing the second method of the target class.
[0111] In some embodiments, the target execution result includes the target attribute value corresponding to the target object, and the first execution module 440 is specifically used for Based on the target attribute value, a second operation instruction corresponding to the target attribute value is determined from a preset instruction library; the instruction library includes a second correspondence between different attribute values and the operation instruction corresponding to each attribute value. Send a second operation instruction to the terminal; the second operation instruction includes a second target operation that the terminal needs to execute through the runtim mechanism, and the second target operation is different from the first target operation.
[0112] Optionally, the target execution result mentioned above includes the attribute values of all objects involved in the second method, and the first execution module 440 is specifically used for... Based on the logical steps of the second method, determine the attribute value of the target object that needs to be updated from the attribute values of all objects involved in the second method; Based on the target attribute value, a second operation instruction corresponding to the target attribute value is determined from a preset instruction library; the instruction library includes a second correspondence between different attribute values and the operation instruction corresponding to each attribute value. Send a second operation instruction to the terminal; the second operation instruction includes a second target operation that the terminal needs to execute through the runtim mechanism, and the second target operation is different from the first target operation.
[0113] The following describes the device for hot-patching vulnerabilities on the terminal side.
[0114] Figure 5 This is the second schematic diagram of the device for hot-fixing vulnerabilities provided by the present invention. See also... Figure 5 As shown, the above-mentioned device may include: The acquisition and replacement module 510 is used to acquire, after the application starts, a first method in the application that has a vulnerability, as well as a target class to be replaced and a second method to be replaced, from the server, and replace the first method in the target class of the application with the second method. The third transceiver module 520 is used to send a first execution request to the server when the second method is executed, and to receive a first operation instruction sent by the server based on the first execution request; the first operation instruction includes a first target operation that needs to be executed by the terminal through the runtime mechanism. The second execution module 530 is used to execute the first target operation, obtain the target execution result, and send the target execution result to the server; the target execution result is used to instruct the server to execute the logical steps corresponding to the second method according to the target execution result until the second method is completed.
[0115] In some embodiments, the first target operation includes the name of the target object to which the first target operation is performed, and the first target operation includes an object attribute retrieval operation. The apparatus further includes: The attribute determination module is used to determine the target memory address corresponding to the name of the target object in a preset dictionary based on the name of the target object, and to obtain the target attribute value corresponding to the target object in the target memory address; the dictionary includes a third correspondence between the names of different objects and their corresponding memory addresses, and the memory address stores the attribute value corresponding to the object.
[0116] It should be noted that the apparatus provided in this embodiment of the invention can implement all the method steps implemented in the corresponding method embodiments and achieve the same technical effect. Therefore, the parts and beneficial effects that are the same as those in the method embodiments will not be described in detail here.
[0117] Figure 6 An example is a schematic diagram of the physical structure of a server, such as... Figure 6As shown, the server may include a processor 610, a communications interface 620, a memory 630, and a communication bus 640, wherein the processor 610, communications interface 620, and memory 630 communicate with each other via the communication bus 640. The processor 610 can call logical instructions in the memory 630 to execute a method for hot-fixing vulnerabilities. This method includes: determining a first method in the application containing vulnerabilities, and determining a target class and a second method to be replaced, based on vulnerability information in the application; sending the target class and the second method to the terminal after the application is launched; the target class and the second method instructing the terminal to replace the first method in the target class of the application with the second method; receiving a first execution request sent by the terminal when the second method is executed, and sending a first operation instruction to the terminal according to the first execution request; the first operation instruction includes a first target operation that the terminal needs to execute through a runtime mechanism; receiving the target execution result returned by the terminal after executing the first target operation, and executing the logical steps corresponding to the second method according to the target execution result until the second method is completed.
[0118] Furthermore, the logical instructions in the aforementioned memory 630 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0119] Figure 7 An example is a schematic diagram of the physical structure of a terminal, such as... Figure 7As shown, the terminal may include a processor 710, a communications interface 720, a memory 730, and a communication bus 740, wherein the processor 710, communications interface 720, and memory 730 communicate with each other via the communication bus 740. The processor 710 can call logical instructions in the memory 730 to execute a method for hot-fixing vulnerabilities. This method includes: after starting the application, obtaining a first method containing a vulnerability in the application from the server, determining the target class to be replaced and the second method to be replaced, and replacing the first method in the target class of the application with the second method; if the second method is executed, sending a first execution request to the server and receiving a first operation instruction sent by the server based on the first execution request; the first operation instruction includes a first target operation that the terminal needs to execute through a runtime mechanism; executing the first target operation, obtaining a target execution result, and sending the target execution result to the server; the target execution result is used to instruct the server to execute the logical steps corresponding to the second method according to the target execution result, until the second method is completed.
[0120] Furthermore, the logical instructions in the aforementioned memory 730 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, essentially, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0121] On the other hand, the present invention also provides a computer program product, the computer program product comprising a computer program that can be stored on a computer-readable storage medium, wherein when the computer program is executed by a processor, the computer is capable of performing the hot-fix vulnerability method provided by the above methods, the method comprising: Based on the vulnerability information of the application, the system identifies a first method with a vulnerability in the application, as well as a target class and a second method to be replaced. After the application is launched on the terminal, the system sends the target class and the second method to the terminal. The target class and the second method are used to instruct the terminal to replace the first method in the target class of the application with the second method. The system receives a first execution request sent by the terminal when the second method is executed, and sends a first operation instruction to the terminal according to the first execution request. The first operation instruction includes a first target operation that the terminal needs to execute through the runtime mechanism. The system receives the target execution result returned by the terminal after executing the first target operation, and executes the logical steps corresponding to the second method according to the target execution result until the second method is completed.
[0122] Alternatively, after starting the application, the system retrieves the vulnerable first method from the server, as well as the target class and the second method to be replaced, and replaces the first method in the target class with the second method. If the second method is executed, the system sends a first execution request to the server and receives a first operation instruction from the server based on the first execution request. The first operation instruction includes a first target operation that the terminal needs to execute through the runtime mechanism. The system executes the first target operation, obtains the target execution result, and sends the target execution result to the server. The target execution result is used to instruct the server to execute the logical steps corresponding to the second method according to the target execution result until the second method is completed.
[0123] In another aspect, the present invention also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to perform a method for hot-fixing vulnerabilities provided by the methods described above, the method comprising: Based on the vulnerability information of the application, the system identifies a first method with a vulnerability in the application, as well as a target class and a second method to be replaced. After the application is launched on the terminal, the system sends the target class and the second method to the terminal. The target class and the second method are used to instruct the terminal to replace the first method in the target class of the application with the second method. The system receives a first execution request sent by the terminal when the second method is executed, and sends a first operation instruction to the terminal according to the first execution request. The first operation instruction includes a first target operation that the terminal needs to execute through the runtime mechanism. The system receives the target execution result returned by the terminal after executing the first target operation, and executes the logical steps corresponding to the second method according to the target execution result until the second method is completed.
[0124] Alternatively, after starting the application, the system retrieves the vulnerable first method from the server, as well as the target class and the second method to be replaced, and replaces the first method in the target class with the second method. If the second method is executed, the system sends a first execution request to the server and receives a first operation instruction from the server based on the first execution request. The first operation instruction includes a first target operation that the terminal needs to execute through the runtime mechanism. The system executes the first target operation, obtains the target execution result, and sends the target execution result to the server. The target execution result is used to instruct the server to execute the logical steps corresponding to the second method according to the target execution result until the second method is completed.
[0125] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0126] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0127] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for hot-patching vulnerabilities, characterized in that, Applied to a server, the method includes: Based on the vulnerability information of the application, a first method for identifying the vulnerability in the application and a second method for identifying the target class to be replaced and the replacement method to be replaced are determined. After the application is launched on the terminal, the target class and the second method are sent to the terminal; the target class and the second method are used to instruct the terminal to replace the first method in the target class of the application with the second method; The system receives a first execution request sent by the terminal when it executes the second method, and sends a first operation instruction to the terminal according to the first execution request; the first operation instruction includes a first target operation that the terminal needs to execute through the runtime mechanism. The system receives the target execution result returned by the terminal after completing the first target operation, and executes the logical steps corresponding to the second method according to the target execution result until the second method is completed.
2. The method for hot-fixing vulnerabilities according to claim 1, characterized in that, The first method for determining vulnerabilities in an application based on vulnerability information, and the second method for determining the target class to be replaced and the class to be replaced, include: Obtain the vulnerability information of the input application, and obtain the first method with the vulnerability and the target class to be replaced from the vulnerability information; the vulnerability information includes the first method, the target class, and the target input / output parameter configuration status corresponding to the first method; Based on the target input / output parameter configuration state, the target method format corresponding to the target input / output parameter configuration state is determined in a preset first correspondence relationship; the first correspondence relationship includes multiple different input / output parameter configuration states and the method format corresponding to each input / output parameter configuration state. Configure the second method corresponding to the target method format according to the target method format.
3. The method for hot-fixing vulnerabilities according to claim 1, characterized in that, Sending the first operation instruction to the terminal according to the first execution request includes: The second method is obtained according to the first execution request, and the first target operation that the terminal needs to execute through the runtime mechanism and the name of the target object for executing the first target operation are determined according to the logical steps of the second method. A first operation instruction is determined based on the first target operation, and the first operation instruction is sent to the terminal corresponding to the name of the target object; the first target operation includes one or a combination of an object attribute acquisition operation, an object attribute modification operation, and a second method execution operation of the target class; Accordingly, the target execution result includes one or a combination of the attribute values accessed by the terminal from a preset dictionary based on the name of the target object, the attribute values obtained after modifying the attribute values of the target object, and the execution result obtained after executing the second method of the target class.
4. The method for hot-fixing vulnerabilities according to any one of claims 1 to 3, characterized in that, The target execution result includes the target attribute value corresponding to the target object. The logical steps of executing the second method according to the target execution result include: Based on the target attribute value, a second operation instruction corresponding to the target attribute value is determined from a preset instruction library; the instruction library includes a second correspondence between different attribute values and the operation instruction corresponding to each attribute value. The second operation instruction is sent to the terminal; the second operation instruction includes a second target operation that the terminal needs to execute through the runtim mechanism.
5. The method for hot-fixing vulnerabilities according to any one of claims 1 to 3, characterized in that, The target execution result includes the attribute values of all objects involved in the second method. The step of executing the logical steps corresponding to the second method based on the target execution result includes: According to the logical steps of the second method, the attribute value of the target object to be updated is determined from the attribute values of all objects involved in the second method; Based on the target attribute value, a second operation instruction corresponding to the target attribute value is determined from a preset instruction library; the instruction library includes a second correspondence between different attribute values and the operation instruction corresponding to each attribute value. The second operation instruction is sent to the terminal; the second operation instruction includes a second target operation that the terminal needs to execute through the Runtime mechanism, and the second target operation is different from the first target operation.
6. A method for hot-patching vulnerabilities, characterized in that, Applied to a terminal, the method includes: After the application is launched, a first method containing a vulnerability in the application is obtained from the server, as well as a target class to be replaced and a second method to be replaced, and the second method is used to replace the first method in the target class of the application. If the second method is executed, a first execution request is sent to the server, and a first operation instruction is received from the server based on the first execution request; the first operation instruction includes a first target operation that the terminal needs to execute through the runtime mechanism; The first target operation is executed to obtain the target execution result, and the target execution result is sent to the server. The target execution result is used to instruct the server to execute the logical steps corresponding to the second method according to the target execution result until the second method is completed.
7. The method for hot-fixing vulnerabilities according to claim 6, characterized in that, The first target operation includes the name of the target object from which the first target operation is performed, and the first target operation includes an object attribute retrieval operation. The method further includes: Based on the name of the target object, the target memory address corresponding to the name of the target object is determined in a preset dictionary, and the target attribute value corresponding to the target object is obtained from the target memory address; the dictionary includes a third correspondence between the names of different objects and their corresponding memory addresses, and the memory address stores the attribute value corresponding to the object.
8. An apparatus for hot-fixing vulnerabilities, characterized in that, Applied to a server, the device includes: The first determining module is used to determine a first method for identifying vulnerabilities in the application based on vulnerability information, and to determine the target class to be replaced and the second method to be replaced. A first transceiver module is configured to send the target class and the second method to the terminal after the application is launched on the terminal; the target class and the second method are configured to instruct the terminal to replace the first method in the target class of the application with the second method; The second transceiver module is configured to receive a first execution request sent by the terminal when executing the second method, and send a first operation instruction to the terminal according to the first execution request; the first operation instruction includes a first target operation that the terminal needs to execute through the runtime mechanism; The first execution module is used to receive the target execution result returned by the terminal after the first target operation is completed, and to execute the logical steps corresponding to the second method according to the target execution result until the second method is completed.
9. A server, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the method for hot-fixing vulnerabilities as described in any one of claims 1 to 5.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method for hot-fixing vulnerabilities as described in any one of claims 1 to 5, or the method for hot-fixing vulnerabilities as described in any one of claims 6 to 7.
