Dynamic injection-based operating system privacy protection method, device and equipment

Monitoring and controlling calls to sensitive APIs by dynamically injecting into the operating system solves the problem of low privacy security of mobile devices, achieves real-time privacy protection for the Android operating system, and improves the privacy protection capabilities and flexibility of mobile devices.

CN118536152APending Publication Date: 2024-08-23CHINA FINANCIAL CERTIFICATION AUTHORITY
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202410549294.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-06
Publication Date
2024-08-23

AI Technical Summary

Technical Problem

Existing methods require modification or recompilation of the operating system or applications, which limits the privacy security and flexibility of mobile devices, and cannot effectively monitor and prevent unauthorized data access and leakage.

Method used

Adopt an operating system privacy protection method based on dynamic injection, generate a dynamic link library by obtaining the source code files of sensitive APIs, dynamically inject into the operating system, monitor the calls of sensitive APIs, record and analyze the call stack, and implement privacy protection policies based on the analysis results to achieve Real-time monitoring and control of sensitive APIs.

Benefits of technology

There is no need to modify the operating system or applications, which improves the flexibility and applicability of privacy protection of mobile devices. It can accurately identify applications or system components that access sensitive data, effectively prevent unauthorized data access and leakage, and improve the accuracy of privacy protection. performance and reliability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118536152A
    Figure CN118536152A
Patent Text Reader

Abstract

The invention relates to the field of privacy security, and discloses a dynamic injection-based operating system privacy protection method, device and equipment, and the method comprises the steps: obtaining a source code file for monitoring a sensitive API (Application Program Interface), generating a dynamic link library according to the source code file, and dynamically injecting the dynamic link library into an operating system; monitoring calling of all sensitive APIs based on the dynamic link library; when a sensitive API calling event is captured, recording a calling stack, and analyzing the calling stack to obtain an analysis result; and according to the analysis result, determining whether to execute a privacy protection strategy on the calling of the sensitive API. According to the invention, the problems that the privacy security of mobile equipment is low and unauthorized data is accessed and leaked are solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of security protection technology, and in particular to a method, device and equipment for protecting privacy of an operating system based on dynamic injection. Background Art

[0002] With the widespread use of mobile devices, the security of the Android operating system has received increasing attention. Monitoring the calls of sensitive Application Programming Interfaces (APIs) is one of the key issues in the field of mobile security, which helps identify potential privacy leaks and malicious behaviors.

[0003] However, existing methods often require modification or recompilation of the operating system or application, limiting their practicality and flexibility. Summary of the invention

[0004] The present invention provides a method, device and equipment for protecting privacy of an operating system based on dynamic injection, which solves the problem of low privacy security of mobile devices and unauthorized data access and leakage.

[0005] A privacy protection method for an operating system based on dynamic injection, comprising:

[0006] Obtaining source code files of the monitored sensitive API, generating a dynamic link library according to the source code files, and dynamically injecting the dynamic link library into the operating system;

[0007] Monitoring all sensitive API calls based on the dynamic link library;

[0008] When a sensitive API call event is captured, the call stack is recorded, and the call stack is analyzed to obtain an analysis result;

[0009] Based on the analysis result, determine whether to execute a privacy protection policy on the call of the sensitive API.

[0010] In one embodiment of the present invention, generating a dynamic link library according to the source code file and dynamically injecting the dynamic link library into the operating system specifically includes: compiling and linking the source code file to generate an executable file, wherein the executable file is a binary form of the dynamic link library; storing the dynamic link library in a specific directory; based on a modified operating system core file, loading the dynamic link library by calling a dynamic loading library extension function and returning a handle; and searching and calling functions in the dynamic link library according to the handle.

[0011] In one embodiment of the present invention, the monitoring of calls of all sensitive APIs based on the dynamic link library specifically includes: in the Hook callback function, obtaining the method name of the called Java method, and determining the number of times the Java method is called; if the number of times the Java method is called is lower than a preset number, then: according to a preset filtering condition, determining whether it is necessary to record the calling information of the Java method; if the filtering condition is met, recording the calling information of the Java method.

[0012] In one embodiment of the present invention, when a sensitive API call event is captured, the call stack is recorded, and the call stack is analyzed to obtain an analysis result, which specifically includes: when a sensitive API call event is captured, the call stack of the current thread is obtained through the debugging API of the operating system; the call stack is traversed to record the information of each stack frame; the information of the stack frame is analyzed to obtain the call information of calling the sensitive API.

[0013] In one embodiment of the present invention, the method of loading the dynamic link library by calling a dynamic loading library extension function and returning a handle, and searching and calling a function in the dynamic link library according to the handle specifically includes: loading the dynamic link library by calling a dynamic loading library extension function, obtaining the handle of the dynamic link library and saving it in a first address variable; obtaining the handle according to the address in the first address variable, obtaining the address of the runtime method call function from the dynamic link library according to the handle, and saving it in a second address variable; registering a Hook callback function of the second address variable, and when the runtime method call function is called, intercepting and processing the runtime method call function through the Hook callback function.

[0014] In one embodiment of the present invention, judging whether it is necessary to record the calling information of the Java method according to preset filtering conditions specifically includes: obtaining a configuration file, the configuration file including the method name of the sensitive method; each time the Java method is called, executing the monitoring program in the dynamic link library to judge whether the called Java method is consistent with the method name in the configuration file; if the called Java method is consistent with the method name in the configuration file, determining that the called Java method is a sensitive API, and recording the calling information of the sensitive API.

[0015] In one embodiment of the present invention, all sensitive API calls are monitored based on the dynamic link library, specifically including: in the Hook callback function, judging the call count of the Java method called by the runtime method call function, if the call count exceeds the preset count, returning directly to end the execution of the current Hook callback function; if the call count does not exceed the preset count, then: traversing the first filter condition in the configuration file, if the method name of the Java method contains any one of the first filter condition strings, jumping to the first label to perform a logging operation; then, traversing the second filter condition in the configuration file, if the method name of the Java method contains any one of the second filter condition strings, jumping to the second label; if the method name of the Java method contains neither the first filter condition string nor the second filter condition string, executing the logging operation at the first label, then jumping to the second label, and calling the Hook manager source call function to execute the original runtime method call function.

[0016] An operating system privacy protection device based on dynamic injection, comprising:

[0017] A dynamic link library injection module is used to obtain the source code file of the monitored sensitive API, generate a dynamic link library according to the source code file, and dynamically inject the dynamic link library into the operating system;

[0018] A monitoring module, used to monitor the calls of all sensitive APIs based on the dynamic link library;

[0019] A recording and analysis module is used to record the call stack when a sensitive API call event is captured, analyze the call stack, and obtain an analysis result;

[0020] The privacy protection module is used to determine whether to execute a privacy protection policy on the call of the sensitive API according to the analysis result.

[0021] An operating system privacy protection device based on dynamic injection, comprising:

[0022] at least one processor; and,

[0023] A memory connected to the at least one processor via a bus; wherein,

[0024] The memory stores instructions executable by the at least one processor, and the instructions are executed to implement the method described in any one of the above embodiments.

[0025] A non-volatile storage medium stores computer executable instructions, wherein the computer executable instructions are executed by a processor to implement the method described in any one of the above embodiments.

[0026] The present invention provides a method, device and apparatus for protecting privacy of an operating system based on dynamic injection, which at least have the following beneficial effects:

[0027] 1. By generating and dynamically injecting specific dynamic link libraries (.so files), real-time monitoring and control of sensitive APIs in the Android operating system can be achieved without modifying the operating system or the application itself; this dynamic injection method improves the flexibility and applicability of system privacy protection, and can be quickly deployed and provide privacy protection for mobile devices.

[0028] 2. Through Hook technology, key sensitive APIs in the system are intercepted and monitored, calling events of sensitive APIs are captured, calling stack information is recorded, and calling relationships are deeply analyzed. This enables real-time monitoring and control of sensitive APIs in the Android operating system, and can accurately identify which applications or system components are accessing sensitive data, providing a basis for privacy protection decisions.

[0029] 3. Based on the monitoring and analysis results, various privacy protection strategies can be adopted, such as allowing, blocking or modifying sensitive API calls, to achieve real-time identification and dynamic protection of user privacy, and effectively prevent unauthorized data access and leakage.

[0030] 4. Compared with the privacy protection method based on modifying the operating system or application, the present invention does not require any changes to the source code of the system. Without modifying the application, it effectively improves the privacy protection capability of the mobile device, which is more flexible and lossless.

[0031] 5. Compared with the existing method based on modifying the system source code, the present invention can realize dynamic monitoring and real-time protection of sensitive APIs, and the privacy protection effect is more accurate and reliable. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:

[0033] Figure 1 A schematic diagram of the steps of a privacy protection method for an operating system based on dynamic injection provided by an embodiment of the present invention;

[0034] Figure 2 A schematic diagram of a process for dynamically injecting Hook code into an Android system provided by an embodiment of the present invention;

[0035] Figure 3 A flowchart of the application self-start detection provided by an embodiment of the present invention;

[0036] Figure 4 A schematic diagram of an operating system privacy protection device based on dynamic injection provided by an embodiment of the present invention;

[0037] Figure 5 A schematic diagram of an operating system privacy protection device based on dynamic injection provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0038] In order to make the purpose, technical scheme and advantages of the present invention clearer, the present invention will be described clearly and completely in conjunction with the specific embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0039] It should be noted that it is explicitly and implicitly understood by those of ordinary skill in the art that the embodiments described in the present invention can be combined with other embodiments without conflict. Unless otherwise defined, the technical terms or scientific terms involved in the present invention should be the usual meanings understood by people with ordinary skills in the technical field to which the present invention belongs. The words "one", "a", "a", "the" and the like involved in the present invention do not indicate a quantitative limitation and may represent the singular or plural. The terms "including", "comprising", "having" and any of their variations involved in the present invention are intended to cover non-exclusive inclusions; the terms "first", "second", "third", etc. involved in the present invention are merely to distinguish similar objects and do not represent a specific ordering of objects.

[0040] Some concepts involved in the present invention are described below.

[0041] Hook function refers to a function that is called when a specific event occurs, and is used to perform some specific operations before or after the event occurs. Usually, the Hook function is registered as a callback function in the event handler. When an event occurs, the event handler will automatically call the corresponding Hook function. It is usually used to achieve the extensibility and customizability of the program, allowing users to add custom operations or modify the behavior of the program while the program is running.

[0042] The ArtMethod_Invoke function is a key function in the Android ART (Android Runtime) virtual machine, which is used to call Java methods. The ART virtual machine is the runtime environment used by Android 5.0 (Lollipop) and later versions to execute the bytecode of the application.

[0043] Android NDK is a set of tools that allows developers to use native code languages ​​such as C and C++ to write some application components for the Android platform.

[0044] Based on the goal of improving the privacy security of mobile devices and preventing unauthorized data access and leakage, the present invention provides a dynamic injection privacy protection method. The basic idea of ​​the dynamic injection privacy protection method is to monitor and control the calls of sensitive APIs in real time in the Android operating system through dynamic injection and Hook technology. The system dynamically injects monitoring code and uses Hook technology to capture the call events of sensitive APIs. By recording call stack information and analyzing call relationships, the system can identify which applications or system components are accessing sensitive data. Based on the results of monitoring and analysis, the system can make privacy protection decisions, such as allowing or blocking the execution of sensitive APIs, or modifying the parameters of the call to protect the user's privacy.

[0045] The specific instructions are given below.

[0046] Figure 1 A schematic diagram of the steps of a privacy protection method for an operating system based on dynamic injection provided by an embodiment of the present invention, Figure 1 The operating system privacy protection method based on dynamic injection can be executed by an operating system privacy protection device based on dynamic injection, and the operating system privacy protection device based on dynamic injection can be set on a server. For example, the server can be a physical server including an independent host, a virtual server carried by a host cluster, a cloud server, etc., which is not limited in the embodiment of the present invention. The operating system privacy protection method based on dynamic injection can include the following steps:

[0047] S110: Obtain source code files of the monitored sensitive API, generate a dynamic link library according to the source code files, and dynamically inject the dynamic link library into the operating system.

[0048] In one embodiment of the present invention, a dynamic link library is generated according to a source code file, and the dynamic link library is dynamically injected into an operating system, specifically including: compiling and linking the source code file to generate an executable file, the executable file being a binary form of the dynamic link library; storing the dynamic link library in a specific directory; based on a modified operating system core file, loading the dynamic link library by calling a dynamic loading library extension function and returning a handle; searching and calling functions in the dynamic link library according to the handle.

[0049] Furthermore, first, the tester writes a monitoring code in C or C++ to form a source code file, which contains the code that needs to be executed in the Android system, which usually includes the Hook function for monitoring sensitive APIs. Then, use Android NDK (Native Development Kit) to compile this source code file. In this process, create an Android.mk file that describes how the source code is compiled and linked. Finally, use the ndk-build command to compile the source code and generate a dynamic link library (.so file). This .so file contains the code that needs to be executed in the Android system.

[0050] Once you have a .so file, you need to inject it into the Android system. This is usually done by using the dlopen() function, which loads the .so file and returns a handle that can be used to find and call functions in the .so file. In order to automatically load the .so file when the Android system starts, you need to put it in a specific directory (such as / system / lib or / system / lib64) and modify some system files (such as activitythread.java) to add the load command for the .so file.

[0051] In one embodiment of the present invention, a dynamic link library is loaded by calling a dynamic loading library extension function and a handle is returned, and a function in the dynamic link library is searched and called according to the handle, specifically including: loading the dynamic link library by calling a dynamic loading library extension function, obtaining the handle of the dynamic link library and saving it in a first address variable; obtaining the handle according to the address in the first address variable, obtaining the address of the runtime method call function from the dynamic link library according to the handle, and saving it in a second address variable; registering a Hook callback function of the second address variable, and when the runtime method call function is called, intercepting and processing the runtime method call function through the Hook callback function.

[0052] Specifically, generate a dynamic link library:

[0053] Use the ndk-build command to compile the source code written by the tester. The generated .so file contains the monitoring code that you want to execute in the Android system.

[0054] Dynamic injection:

[0055] 1. After injecting the executable file (.so file), the init_array function will automatically trigger the monitoring code logic, use the dlopen function to open the libart.so library, and save its handle in the variable handle.

[0056] 2. Use the dlsym function to get the address of the ArtMethod_Invoke function from the libart.so library and save it in the variable ArtMethod_Invoke_ptr.

[0057] 3. Check whether the function address is obtained successfully: Check whether ArtMethod_Invoke_ptr is nullptr. If it is, it means that the function address has failed to be obtained. The error log is recorded and returned.

[0058] 4. Register Hook function: Use HookManager::registerHook function to register the Hook callback function of ArtMethod_Invoke_ptr. The callback function intercepts and processes the ArtMethod_Invoke function.

[0059] The present invention uses dynamic injection technology to inject specific monitoring code into the Android system, so as to dynamically load and execute the monitoring code at runtime. This method avoids modifying or recompiling the operating system or application program, thereby improving practicality and flexibility.

[0060] S120: Monitor calls of all sensitive APIs based on dynamic link libraries.

[0061] In one embodiment of the present invention, the calls of all sensitive APIs are monitored based on a dynamic link library, specifically including: in the Hook callback function, obtaining the method name of the called Java method, and determining the number of times the Java method is called; if the number of calls is lower than a preset number, then: according to preset filtering conditions, determining whether it is necessary to record the calling information of the Java method; if the filtering conditions are met, recording the calling information of the Java method.

[0062] Specifically, sensitive API identification and Hook: In the Hook callback function, the call to the ArtMethod_Invoke function is monitored and analyzed. First, the called method name method_name is obtained, and the number of times the method is called is counted. Then, based on certain filtering conditions, it is determined whether the calling information of the method needs to be recorded. If the filtering conditions are met, the calling information of the method is recorded. The filtering conditions are from the document configured by the tester, and the filtered method name can be written in the document.

[0063] In one embodiment of the present invention, based on preset filtering conditions, it is determined whether it is necessary to record the calling information of the Java method, specifically including: obtaining a configuration file, the configuration file including the method name of the sensitive method; each time a Java method is called, executing a monitoring program in a dynamic link library to determine whether the called Java method is consistent with the method name in the configuration file; if the called Java method is consistent with the method name in the configuration file, it is determined that the called Java method is a sensitive API, and the calling information of the sensitive API is recorded.

[0064] Specifically, in the security detection method of the present invention, the call of Java methods is monitored and controlled through the Hook function. Specifically, through the implementation of the Hook function, each time a Java method is called, the written monitoring code will be executed first. The monitoring code can check the called Java method. If the called Java method is a sensitive API, the code can record the call, modify the parameters, or block the call to protect the user's privacy. For the key function _ZN3art9ArtMethod6InvokeEPNS_6ThreadEPjjPNS_6JValueEPKc, Hook is implemented and the configuration file is configured. The configuration file contains the method names of some sensitive methods, thereby monitoring the calls of all sensitive APIs.

[0065] By real-time monitoring and controlling the calls of sensitive APIs in the Android system, through Hook technology, the system can identify the calls of sensitive APIs and monitor and analyze them, thereby protecting the privacy of users.

[0066] In one embodiment of the present invention, all sensitive API calls are monitored based on a dynamic link library, specifically including: in a Hook callback function, determining the number of calls to a Java method called by a runtime method call function, if the number of calls exceeds a preset number, returning directly to terminate the execution of the current Hook callback function; if the number of calls does not exceed the preset number, then: traversing the first filter condition in the configuration file, if the method name of the Java method contains any of the first filter condition strings, jumping to the first label to perform a logging operation; then, traversing the second filter condition in the configuration file, if the method name of the Java method contains any of the second filter condition strings, jumping to the second label; if the method name of the Java method contains neither the first filter condition string nor the second filter condition string, executing the logging operation at the first label, then jumping to the second label, and calling the Hook manager source call function to execute the original runtime method call function.

[0067] Specifically, call monitoring and analysis: In the Hook callback function, first judge and process the method name. If the number of calls to a method (counted by countTimes) exceeds the predetermined number of times, skip the subsequent processing and return directly. Next, traverse the filter conditions in filterContainStr. If the method name contains any filter condition string, jump to the log label. Then, traverse the filter conditions in filterStr. If the method name contains any filter condition string, jump directly to the end label without logging. If none of the above conditions are met, execute the logging operation at the log label to record the method name of artMethod. Finally, jump to the end label and call the HookManager::srcCall function to execute the original ArtMethod_Invoke function.

[0068] S130: When a sensitive API call event is captured, the call stack is recorded, and the call stack is analyzed to obtain an analysis result.

[0069] In one embodiment of the present invention, when a sensitive API call event is captured, the call stack is recorded, and the call stack is analyzed to obtain analysis results, which specifically include: when a sensitive API call event is captured, the call stack of the current thread is obtained through the debugging API of the operating system; the call stack is traversed to record the information of each stack frame; the stack frame information is analyzed to obtain the call information of the sensitive API.

[0070] Specifically, through the Hook function, the call events of sensitive APIs are captured and the call stack is recorded. To record the call stack, Android's debugging API, such as Thread.currentThread().getStackTrace(), can be used to obtain the call stack of the current thread. This call stack is an array of StackTraceElement. Each StackTraceElement object represents a stack frame, including the class name, method name, file name, and line number. This array can be traversed to record the information of each stack frame. Analyze which applications or system components are accessing sensitive data. In order to analyze the call relationship, the monitoring code can analyze the recorded call stack to find the code path that calls the sensitive API. For example, the direct caller, indirect caller, etc. of the sensitive API can be found to find out possible privacy leaks.

[0071] By recording the stack information of sensitive API calls and analyzing which applications or system components are accessing sensitive data, potential privacy leaks and malicious behaviors can be identified.

[0072] S140: Determine whether to implement a privacy protection policy for calls to sensitive APIs based on the analysis results.

[0073] Furthermore, based on the results of monitoring and analysis, the system can make privacy protection decisions, such as allowing or blocking the execution of sensitive APIs, or modifying the parameters of calls and other privacy protection strategies to protect user privacy in real time.

[0074] Specifically, execute the recording function, jump to the log label, use Thread.currentThread().getStackTrace() to print out the call stack, and record the stack information of the triggered sensitive API, and whether the optional parameters and return values ​​are modified.

[0075] like Figure 2 The process of dynamically injecting Hook code into the Android system is demonstrated. The Hook key sensitive API logic source code is compiled into a binary executable file, injected into the Android system, and the startup behavior of the application to be detected is monitored based on the configuration file, and then the results are output.

[0076] like Figure 3 The figure shows the self-start detection flow chart of the application of the present invention. After the current application monitoring is started, the library function is opened to determine whether the ArtMethod_Invoke function address is found. If found, the Hook function is registered, and the call monitoring and analysis are performed through the Hook callback function, the relevant information is recorded, and then the result is output.

[0077] Through the above method, the present invention can realize real-time monitoring and control of sensitive API calls in the Android system without modifying the application or operating system, effectively improving the privacy protection capability of the Android operating system, preventing unauthorized data access and leakage, and improving the security of mobile devices.

[0078] The present invention is not only based on existing mobile security technology, but also introduces the technology of dynamic link library injection, which is a relatively new technical means in the field of mobile security protection. The implementation of the method of the present invention will effectively enhance the privacy protection capability of the Android operating system and bring new possibilities and opportunities to the field of mobile Internet security protection.

[0079] The above is a method for protecting privacy of an operating system based on dynamic injection provided by an embodiment of the present invention. Based on the same inventive idea, an embodiment of the present invention also provides a corresponding device for protecting privacy of an operating system based on dynamic injection, such as Figure 4 As shown, including:

[0080] A dynamic link library injection module 410 is used to obtain a source code file of a monitoring sensitive API, generate a dynamic link library according to the source code file, and dynamically inject the dynamic link library into the operating system;

[0081] A monitoring module 420, configured to monitor calls of all sensitive APIs based on the dynamic link library;

[0082] The recording and analysis module 430 is used to record the call stack and analyze the call stack to obtain the analysis result when a sensitive API call event is captured;

[0083] The privacy protection module 440 is used to determine whether to execute a privacy protection policy on the call of the sensitive API according to the analysis result.

[0084] The embodiment of the present invention also provides a corresponding operating system privacy protection device based on dynamic injection, such as Figure 5 As shown, including:

[0085] At least one processor 502 (processor), a communication interface 504 (Communications Interface), a memory 506 (memory) and a communication bus 508; wherein the processor 502, the communication interface 504, and the memory 506 communicate with each other via the communication bus 508; the processor 502 can call the logic instructions stored in the memory 506 to enable at least one processor 502 to execute the steps of the above-mentioned embodiments.

[0086] Based on the same idea, some embodiments of the present invention also provide a medium corresponding to the above method.

[0087] Some embodiments of the present invention provide a storage medium storing computer executable instructions, and the computer executable instructions are executed by a processor to implement the steps of the above embodiments.

[0088] On the other hand, an embodiment of the present application also provides a computer program product, which includes a computer program. The computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the steps of a dynamic injection-based operating system privacy protection method provided in the above-mentioned embodiments.

[0089] Each embodiment of the present invention is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device, medium and program product embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0090] The devices, media, and program products provided in the embodiments of the present invention correspond one-to-one to the methods. Therefore, the devices, media, and program products also have similar beneficial technical effects as the corresponding methods. Since the beneficial technical effects of the methods have been described in detail above, the beneficial technical effects of the devices, media, and program products will not be repeated here.

[0091] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or method including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or method. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or method including the elements.

[0092] The above are only embodiments of the present invention and are not intended to limit the present invention. Although the present invention has been described in detail above with general descriptions and specific embodiments, it is obvious to those skilled in the art that some modifications or improvements can be made on the basis of the present invention. Therefore, these modifications or improvements made on the basis of not departing from the spirit of the present invention all belong to the scope of protection claimed in the present invention.

Claims

1. A privacy protection method for an operating system based on dynamic injection, characterized in that: include: Obtaining a source code file of a monitoring sensitive application programming interface API, generating a dynamic link library according to the source code file, and dynamically injecting the dynamic link library into the operating system; Monitoring all sensitive API calls based on the dynamic link library; When a sensitive API call event is captured, the call stack is recorded, and the call stack is analyzed to obtain an analysis result; Based on the analysis result, determine whether to execute a privacy protection policy on the call of the sensitive API.

2. The method according to claim 1, characterized in that Generating a dynamic link library according to the source code file and dynamically injecting the dynamic link library into the operating system specifically includes: Compiling and linking the source code file to generate an executable file, wherein the executable file is in binary form of a dynamic link library; Storing the dynamic link library in a specific directory; Based on the modified operating system core file, the dynamic link library is loaded by calling a dynamic loading library extension function and a handle is returned; The function in the dynamic link library is searched and called according to the handle.

3. The method according to claim 1, characterized in that The monitoring of all sensitive API calls based on the dynamic link library specifically includes: In the Hook callback function, obtain the method name of the called Java method and determine the number of times the Java method is called; If the number of times the call is made is lower than the preset number, then: According to the preset filtering conditions, determine whether it is necessary to record the call information of the Java method; If the filtering condition is met, the calling information of the Java method is recorded.

4. The method according to claim 1, characterized in that When a sensitive API call event is captured, the call stack is recorded, and the call stack is analyzed to obtain analysis results, which specifically include: When a sensitive API call event is captured, the call stack of the current thread is obtained through the operating system's debugging API; Traversing the call stack and recording information of each stack frame; The information of the stack frame is analyzed to obtain the call information of calling the sensitive API.

5. The method according to claim 2, characterized in that: The method of loading the dynamic link library by calling a dynamic loading library extension function and returning a handle, and searching and calling a function in the dynamic link library according to the handle specifically includes: Load the dynamic link library by calling a dynamic loading library extension function, obtain a handle of the dynamic link library and save it to a first address variable; Obtaining a handle according to the address in the first address variable, obtaining the address of the runtime method call function from the dynamic link library according to the handle, and storing it in a second address variable; A Hook callback function is registered for the second address variable, and when the runtime method calling function is called, the runtime method calling function is intercepted and processed by the Hook callback function.

6. The method according to claim 3, characterized in that The determining whether it is necessary to record the call information of the Java method according to the preset filtering condition specifically includes: Obtain a configuration file, wherein the configuration file includes a method name of a sensitive method; Each time a Java method is called, a monitoring program in the dynamic link library is executed to determine whether the called Java method is consistent with the method name in the configuration file; If the called Java method is consistent with the method name in the configuration file, it is determined that the called Java method is a sensitive API, and the calling information of the sensitive API is recorded.

7. The method according to claim 1, characterized in that Based on the dynamic link library, all sensitive API calls are monitored, including: In the Hook callback function, determine the number of calls to the Java method called by the runtime method call function. If the number of calls exceeds the preset number, return directly to end the execution of the current Hook callback function. If the number of calls does not exceed the preset number, then: Traverse the first filter condition in the configuration file, and if the method name of the Java method contains any of the first filter condition strings, jump to the first label to perform a log recording operation; Then, traverse the second filter condition in the configuration file, and if the method name of the Java method contains any second filter condition string, jump to the second label; If the method name of the Java method contains neither the first filter condition string nor the second filter condition string, the logging operation at the first label is executed, and then the process jumps to the second label and calls the Hook manager source calling function to execute the original runtime method calling function.

8. An operating system privacy protection device based on dynamic injection, characterized in that: include: A dynamic link library injection module is used to obtain the source code file of the monitored sensitive API, generate a dynamic link library according to the source code file, and dynamically inject the dynamic link library into the operating system; A monitoring module, used to monitor the calls of all sensitive APIs based on the dynamic link library; A recording and analysis module is used to record the call stack when a sensitive API call event is captured, analyze the call stack, and obtain an analysis result; The privacy protection module is used to determine whether to execute a privacy protection policy on the call of the sensitive API according to the analysis result.

9. An operating system privacy protection device based on dynamic injection, characterized in that: include: at least one processor; as well as, A memory connected to the at least one processor via a bus; wherein, The memory stores instructions executable by the at least one processor, and the instructions are executed to implement the method according to any one of claims 1 to 7.

10. A non-volatile storage medium storing computer executable instructions, characterized in that: The computer executable instructions are executed by a processor to implement the method according to any one of claims 1 to 7.

Citation Information

Cited By

  • File outgoing management and control method and system, electronic equipment and storage medium

    CN118916921A