Method, device and electronic device for detecting hook framework
By detecting specific target features in electronic devices, the problem of low detection accuracy of hook frames in the existing technology is solved, accurate detection of multiple types of hook frames is achieved, and the security of electronic devices is enhanced.
Patent Information
- Application Number
- CN202110539434.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-05-18
- Publication Date
- 2024-10-25
- Estimated Expiration
- 2041-05-18
AI Technical Summary
The accuracy of detecting hook frames in the existing technology is low, resulting in security risks, and it is impossible to effectively detect hook frames modified according to existing methods.
By detecting the presence of target features in electronic devices, such as Xposed plug-ins, Xposed modules, directories associated with the Xposed framework, package names associated with variants of the Xposed framework, and port occupancy of the Frida framework, the system determines whether Whether there is a hook framework to improve the accuracy of detection.
It improves the accuracy of hook frame detection, enhances the security of electronic devices, can effectively detect variants of hook frames and multiple types of hook frames, and reduces security threats.
Smart Images

Figure CN113238946B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of information security, and in particular to a method, device and electronic device for detecting a hook framework. Background Art
[0002] With the rapid development of the Internet, more and more users access the Internet through electronic devices such as mobile phones, which have at least one Internet application installed on them. Network black and gray industries (hereinafter referred to as "black and gray industries") refer to illegal activities that use the Internet as a medium and network technology as the main means to bring potential threats (major security risks) to the security of computer information systems and the management order of cyberspace. Exemplarily, black and gray industries can reversely analyze the working logic of Internet applications, crack encryption and decryption algorithms, etc. through hook frameworks such as Xposed, Frida, and Cydia Substrate, so as to simulate the operation of real users offline to perform batch automatic wool plucking, etc. In the related art, electronic devices usually use the method of checking the installation list through the package manager, reading the stack matching keywords by making an exception, or detecting whether there are files such as XposedBridge.jar in the library loaded by themselves to detect the Xposed framework, or through dynamic loading detection or method feature code detection, etc., to detect the Cydia Substrate framework, determine whether there is a hook framework in the electronic device, and then determine whether there is a security threat in the electronic device. However, the features used for hook framework detection in the above detection method can be modified in a targeted manner, so that the accuracy of hook framework detection using the above related technologies is reduced, thereby causing security risks. Summary of the invention
[0003] The present disclosure provides a hook framework detection method, device and electronic device to at least solve the problem of low accuracy in determining whether a hook framework exists in an electronic device in the related art. The technical solution of the present disclosure is as follows:
[0004] According to the first aspect of the embodiments of the present disclosure, a method for detecting a hook framework is provided, comprising: detecting whether a target feature exists in an electronic device; wherein the target feature includes at least one of the following: an Xposed plug-in, an Xposed module, a directory associated with an Xposed framework, and a package name associated with a variant of the Xposed framework; if the target feature exists, it is determined that a hook framework exists in the electronic device. In this way, by detecting the hook framework in the electronic device through the target feature, it is possible to avoid the situation where the hook framework modified according to the existing detection method cannot be detected, thereby improving the accuracy of detecting the hook framework and improving the security of the electronic device. In addition, through the package name associated with the variant of the Xposed framework contained in the above-mentioned target feature, the variant of the Xposed framework can be detected, thereby further improving the accuracy of detecting the hook framework.
[0005] In a possible implementation, the directory associated with Xposed is a directory storing an installation package of the Xposed framework and / or a directory storing an installation package of an Xposed module. In this way, the content of the target feature is further clarified, and it is determined that the target feature is different from the feature disclosed in the above-mentioned related art, so that the occurrence of the situation where the hook framework is modified according to the target feature can be better avoided, and the accuracy of detecting the hook framework through the above-mentioned target feature is guaranteed.
[0006] In a possible implementation, the variants of the Xposed framework include VirtualXposed framework and / or EdXposed framework. In this way, the hook frameworks of various variants of the Xposed framework can be detected through target features, thereby ensuring the accuracy of determining whether the electronic device has the hook framework.
[0007] In a possible implementation, the target feature also includes a Cydia Substrate module. Thus, by detecting the Cydia Substrate module in the target feature, it is possible to detect whether a Cydia Substrate type hook framework exists in the electronic device, thereby realizing detection of multiple types of hook frameworks and improving the accuracy of determining whether a hook framework exists in the electronic device.
[0008] In a possible implementation, the target feature also includes that the port corresponding to the Frida framework is occupied. At this time, detecting whether the target feature exists in the electronic device includes: detecting whether there is an Xposed plug-in, an Xposed module, a directory associated with the Xposed framework, and at least one of the package names associated with the variant of the Xposed framework in the electronic device; detecting whether the port of the Frida framework in the electronic device is occupied. In this way, by detecting the occupancy of the port used by the Frida framework also included in the target feature, it can be detected whether there is a Frida type hook framework in the electronic device, thereby realizing the detection of multiple types of hook frameworks and improving the accuracy of determining whether there is a hook framework in the electronic device. In addition, when the Frida framework is detected, a separate thread needs to be opened. Therefore, the target feature is detected in the electronic device according to a certain preset order, that is, the Xposed plug-in, the Xposed module, the directory associated with the Xposed framework, and the package name associated with the variant of the Xposed framework are first detected, and then the Frida framework is detected. Whether it is occupied can be better improved. The efficiency of hook framework detection can be improved.
[0009] In a possible implementation, the target feature also includes establishing a connection between the electronic device and the port corresponding to the Frida framework. At this time, detecting whether the target feature exists in the electronic device includes: detecting whether there is an Xposed plug-in, an Xposed module, a directory associated with the Xposed framework, and at least one of the package names associated with a variant of the Xposed framework in the electronic device; detecting whether a connection is established between the electronic device and the port corresponding to the Frida framework. It should be noted that, compared with the target feature located in the Java layer, the target feature in this implementation is located in the native layer, that is, it is closer to the bottom layer of the system and has a stronger adversarial nature, that is, it can be better used to determine whether the Frida framework exists. In this way, through this target feature, it is possible to well detect whether the Frida framework exists in the electronic device, thereby ensuring the accuracy of determining whether the hook framework exists in the electronic device.
[0010] In a possible implementation, the target feature is the Xposed module; detecting whether the target feature exists in the electronic device includes: parsing at least one application installation package APK on the electronic device, determining whether there is a target file in the directory of the at least one APK, and the target file is a file in the Xposed module; if the target file exists in the directory of the at least one APK, determining that the Xposed module exists in the electronic device.
[0011] In a possible implementation, detecting whether a target feature exists in an electronic device includes: parsing at least one application installation package APK on the electronic device to obtain at least one string; if a target string exists in the at least one string, determining that a Cydia Substrate module exists in the electronic device, and the target string is a string in the Cydia Substrate framework.
[0012] In a possible implementation, the method further includes: determining the security level of the electronic device according to the number of hook frameworks present in the electronic device. In this way, compared with the detection result of whether there is a hook framework in the electronic device, the security level of the electronic device directly determined can more intuitively reflect the security status of the electronic device, making it easier for users to directly understand the security status of the electronic device and improve user experience.
[0013] According to a second aspect of an embodiment of the present disclosure, a device for detecting a hook framework is provided, comprising a detection unit and a determination unit: the detection unit is configured to execute detection of whether a target feature exists in an electronic device; wherein the target feature includes at least one of the following: an Xposed plug-in, an Xposed module, a directory associated with an Xposed framework, and a package name associated with a variant of the Xposed framework; the determination unit is configured to execute, if the target feature exists, determining that a hook framework exists in the electronic device.
[0014] In a possible implementation, the directory associated with Xposed is a directory storing an installation package of an Xposed framework and / or a directory storing an installation package of an Xposed module.
[0015] In a possible implementation, the variant of the Xposed framework includes a VirtualXposed framework and / or an EdXposed framework.
[0016] In a possible implementation, the target feature also includes a Cydia Substrate module.
[0017] In a possible implementation, the target feature also includes that the port corresponding to the Frida framework is occupied. At this time, the detection unit is specifically configured to perform a detection on whether there is an Xposed plug-in, an Xposed module, a directory associated with the Xposed framework, and at least one of a package name associated with a variant of the Xposed framework in the electronic device, and then detect whether the port of the Frida framework in the electronic device is occupied.
[0018] In a possible implementation, the target feature also includes establishing a connection between the electronic device and a port corresponding to the Frida framework. At this time, the detection unit is specifically configured to perform a detection on whether there is an Xposed plug-in, an Xposed module, a directory associated with the Xposed framework, and a package name associated with a variant of the Xposed framework in the electronic device, and then detect whether a connection is established between the electronic device and the port corresponding to the Frida framework.
[0019] In a possible implementation, the target feature is the Xposed module; the detection unit is specifically configured to perform parsing of at least one application installation package APK on the electronic device to determine whether a target file exists in a directory of the at least one APK, and the target file is a file in the Xposed module; the detection unit is further specifically configured to determine whether the Xposed module exists in the electronic device if the target file exists in the directory of the at least one APK.
[0020] In a possible implementation, the detection unit is specifically configured to parse at least one application installation package APK on the electronic device to obtain at least one string; the detection unit is also specifically configured to determine whether the CydiaSubstrate module exists in the electronic device if a target string exists in the at least one string, and the target string is a string in the Cydia Substrate framework.
[0021] In a possible implementation, the device further includes an evaluation unit: the evaluation unit is configured to determine the security level of the electronic device according to the number of hook frameworks existing in the electronic device.
[0022] According to a third aspect of an embodiment of the present disclosure, there is provided an electronic device, including: a processor;
[0023] a memory for storing instructions executable by the processor;
[0024] The processor is configured to execute the instructions to implement the method for detecting the hook framework shown in any possible implementation of the first aspect.
[0025] According to a fourth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided, on which instructions are stored. When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the method for detecting a hook framework shown in any possible implementation method of the first aspect above.
[0026] According to a fifth aspect of an embodiment of the present disclosure, a computer program product is provided, comprising instructions, which, when executed on a computer, enable the computer to execute a method for detecting a hook framework as shown in any possible implementation of the first aspect.
[0027] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] The drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the description are used to explain the principles of the present disclosure, and do not constitute improper limitations on the present disclosure.
[0029] Figure 1 The figure is a flowchart of a method for detecting a hook framework according to an exemplary embodiment.
[0030] Figure 2 The present invention is a flowchart showing a method of detecting a hook framework by using a detection APP according to an exemplary embodiment.
[0031] Figure 3 The invention is a block diagram showing a device for detecting a hook framework according to an exemplary embodiment.
[0032] Figure 4 It is a block diagram (general structure) of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION
[0033] In order to enable ordinary persons in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings.
[0034] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0035] Before introducing the method for detecting the hook framework provided by the embodiment of the present disclosure in detail, the application scenarios involved in the embodiment of the present disclosure are briefly introduced here. The method for detecting the hook framework provided by the embodiment of the present disclosure can be applied to security detection scenarios of various electronic devices, and can also be applied to other scenarios, such as security detection scenarios of application programs, and the present disclosure does not limit this.
[0036] The execution subject of the method for detecting the hook framework provided in the embodiment of the present disclosure may be a device for detecting the hook framework, or may be a functional module and / or functional entity in the device for detecting the hook framework that can implement the method for detecting the hook framework. The specific execution subject may be determined according to actual usage requirements, and the embodiment of the present disclosure is not limited thereto.
[0037] The device for detecting the hook framework in the embodiment of the present disclosure may be an electronic device, which may be a mobile terminal device or a non-mobile terminal device. For example, the mobile terminal device may be a mobile phone, a tablet computer, a laptop computer, a PDA, a vehicle-mounted terminal, a wearable device, an ultra-mobile personal computer (UMPC), a netbook or a personal digital assistant (PDA), etc., and the non-mobile terminal device may be a personal computer (PC), a television (TV), a teller machine or a self-service machine, etc., which is not specifically limited in the embodiment of the present disclosure.
[0038] The following will be combined with the drawings in the embodiments of the present disclosure to clearly and completely describe the technical solutions in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, not all of the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present disclosure.
[0039] Figure 1 is a flow chart of a method for detecting a hook framework according to an exemplary embodiment. Figure 1 As shown, the method is used in an electronic device and comprises the following steps:
[0040] S101, detecting whether a target feature exists in an electronic device.
[0041] Among them, the target feature includes at least one of the following: an Xposed plug-in, an Xposed module, a directory associated with the Xposed framework, and a package name associated with a variant of the Xposed framework. That is, the target feature is an Xposed plug-in, or the target feature is an Xposed module, or the target feature is a directory associated with the Xposed framework, or the target feature is a package name associated with a variant of the Xposed framework, or the target feature includes an Xposed plug-in and an Xposed module, or the target feature includes an Xposed plug-in and a directory associated with the Xposed framework, or the target feature includes an Xposed plug-in and a package name associated with a variant of the Xposed framework, or the target feature includes an Xposed module and a directory associated with the Xposed framework, or the target feature includes an Xposed module and a package name associated with a variant of the Xposed framework, or the target feature includes a directory associated with the Xposed framework with and package names associated with variants of the Xposed framework, or the target features include Xposed plug-ins, Xposed modules, and directories associated with the Xposed framework, or the target features include Xposed plug-ins, Xposed modules, and package names associated with variants of the Xposed framework, or the target features include Xposed plug-ins, directories associated with the Xposed framework, and package names associated with variants of the Xposed framework, or the target features include Xposed modules, directories associated with the Xposed framework, and package names associated with variants of the Xposed framework, or the target features include Xposed plug-ins, Xposed modules, directories associated with the Xposed framework, and package names associated with variants of the Xposed framework.
[0042] The at least one target feature is used to detect a hook framework. More specifically, the at least one target feature is used to detect an Xposed type hook framework.
[0043] The following is a brief introduction to the detection process of each of the above target features:
[0044] 1. Xposed plugin
[0045] Optionally, a list of apps installed on the electronic device is detected through a package manager at the Java layer, and an Xposed plug-in is detected (or matched) in the list of apps, i.e., it is determined whether an Xposed plug-in exists in the list of apps. If an Xposed plug-in is detected in the list of apps, i.e., it is determined that an Xposed plug-in exists in the list of apps, then it can be determined that an Xposed plug-in exists in the electronic device.
[0046] In a possible implementation, the Xposed plug-in may be a commonly used Xposed plug-in, or may be said to be a mainstream Xposed plug-in.
[0047] Exemplarily, the above-mentioned Xposed plug-in can be, for example, a red envelope grabbing plug-in (the package name of the red envelope grabbing plug-in is com.fkzhang.wechatxposed), or a plug-in JustTrustMe (the package name of the plug-in is just.trust.me) that turns off SSL (Secure Sockets Layer) certificate verification to facilitate packet capture, etc.
[0048] It should be noted that when conventional detection methods are used to determine whether a hook framework exists, for example, by detecting XposedInstaller (package name is de.robv.android.xposed.installer) to directly determine whether a hook framework exists, when gray and black industry personnel modify the package name in the source code (the modified package name can be any name other than the package name before the modification) and repackage it, there may be a risk of bypassing the XposedInstaller. In this example, because the Xposed plug-in requires the Xposed framework to work properly, the environment containing the Xposed plug-in usually has the Xposed framework installed. Therefore, the detection of the hook framework by detecting the Xposed plug-in has a higher accuracy.
[0049] 2. Xposed module
[0050] Optionally, the Xposed module is detected at the Java layer by detecting features of the Xposed module (eg, files that must exist in the Xposed module, etc.) If the features of the Xposed module are detected at the Java layer, it is determined that the Xposed module exists in the electronic device.
[0051] In a possible implementation, at least one application installation package APK on the electronic device is parsed to determine whether a target file exists in the directory of the at least one APK, that is, to determine whether a file in the Xposed module exists in the directory of the at least one APK. In other words, the target file is a file in the Xposed module. Subsequently, if the target file exists in the directory of the at least one APK, it is determined that the Xposed module exists in the electronic device.
[0052] In one possible implementation, by scanning the list of APKs that have been installed in the electronic device, and then collecting all the APKs, the code is used to parse whether the assets directory in the APK contains a file named xposed_init, that is, the target file. Since the file named xposed.ini belongs to the Xposed module, that is, the file xposed.ini is a file in the Xposed module, therefore, if the file is contained in the assets directory in the APK, it is determined that the Xposed module exists in the electronic device. In this example, the Xposed module must work with the help of the Xposed framework, and the Xposed framework is usually installed in the environment where the Xposed module exists. Therefore, the detection of the Xposed framework is indirectly achieved by detecting the features of the Xposed module with high accuracy.
[0053] 3. Directories associated with the Xposed framework
[0054] Optionally, at the Java layer, by detecting an application-specific directory, i.e., a file path related to the application, including a path where the source file of the application is located or a path where the library file of the application is located, it is determined whether there is a directory associated with Xposed in the electronic device.
[0055] In a possible implementation, if it is detected that an application-specific directory, i.e., / sdcard / Android / data / de.robv.android.xposed.installer, exists in the electronic device, it is determined that a directory associated with Xposed exists in the electronic device. If an application-specific directory, i.e., / sdcard / Android / data / de.robv.android.xposed.installer, is detected in the electronic device, it is determined that a directory associated with Xposed does not exist in the electronic device.
[0056] In a possible implementation, the directory associated with Xposed is a directory storing an installation package of an Xposed framework and / or a directory storing an installation package of an Xposed module.
[0057] It should be noted that if the Xposed framework exists in the electronic device, there will be a framework directory in the cache folder under this application-specific directory, i.e., / sdcard / Android / data / de.robv.android.xposed.installer, to save the installation package of the Xposed framework. If the electronic device downloads the corresponding Xposed module through the Xposed framework, there will be a modules directory in the cache folder under the application-specific directory to save the installation package of the Xposed module downloaded by the electronic device. Therefore, by detecting whether there is an application-specific directory, i.e., / sdcard / Android / data / de.robv.android.xposed.installer, in the electronic device, the directory storing the installation package of the Xposed framework and / or the directory storing the installation package of the Xposed module can be detected. In addition, by detecting whether there is an application-specific directory in the electronic device, i.e., detecting whether there is a directory associated with the Xposed framework in the electronic device, the detection of the Xposed framework in the electronic device is realized with high accuracy.
[0058] 4. Package names associated with variants of the Xposed framework
[0059] Optionally, at the Java layer, a list of installed APPs is traversed through a package manager to detect whether a package name of a variant of the Xposed framework exists in the list of the APPs to determine whether a variant of the Xposed framework exists in the electronic device.
[0060] In a possible implementation, variants of the Xposed framework include a VirtualXposed framework and / or an EdXposed framework.
[0061] In a possible implementation, the existence of the variant of the Xposed framework, VirtualXposed framework, is determined by detecting whether a package name, such as io.va.exposed, exists. If the package name io.va.exposed exists in the list of APPs of the electronic device, it is determined that the VirtualXposed framework exists in the electronic device.
[0062] In a possible implementation, the existence of the EdXposed framework, a variant of the Xposed framework, is determined by detecting a package name such as org.meowcat.edxposed.manager. If the package name org.meowcat.edxposed.manager exists in the list of APPs of the electronic device, it is determined that the EdXposed framework exists in the electronic device.
[0063] It should be noted that by detecting the target feature, i.e., the package name associated with the variant of the Xposed framework, the hook framework of various variants of the Xposed framework can be detected, thereby ensuring the accuracy of determining whether the hook framework exists in the electronic device. In addition, by using the above-mentioned target feature to detect the Xposed framework of the electronic device, it is possible to avoid modifying the target feature to avoid the detection of the Xposed framework, thereby improving the accuracy of detecting the Xposed framework and ensuring the safety of the electronic device.
[0064] In a possible implementation, the target feature also includes a feature for detecting the Cydia Substrate framework, namely the Cydia Substrate module. The following is a brief introduction to the detection process of the Cydia Substrate module:
[0065] Optionally, the CydiaSubstrate module is detected indirectly at the Java layer by detecting whether the CydiaSubstrate module exists.
[0066] In a possible implementation, the APK list installed by the system is scanned, and then all APKs are collected, and at least one collected APK is parsed to obtain at least one string. If the at least one string contains a target string, it is determined that the electronic device contains a Cydia Substrate module. The target string is a string in the CydiaSubstrate framework.
[0067] Specifically, the AndroidMainfest.xml file in at least one installation package APK on the electronic device is parsed to obtain at least one string. Then, the target string, such as the string for applying for permission, is found in the at least one string.<uses-permission android:name="cydia.permission.SUBSTRATE" / > , to determine whether the APK belongs to the module of the Cydia Substrate framework. If the target string exists, that is, the APK belongs to the module of the Cydia Substrate framework, it is determined that the Cydia Substrate module exists in the electronic device.
[0068] Of course, in a possible implementation, the target feature may include only the Cydia Substrate module, or may include the other target features mentioned above. If the target feature only includes the Cydia Substrate module, that is, the target feature is the Cydia Substrate module, then the method is only used to detect the Cydia Substrate type hook framework. If the target feature includes the other target features mentioned above, that is, at least one of the Xposed plug-in, the Xposed module, the directory associated with the Xposed framework, and the package name associated with the variant of the Xposed framework, the target feature also includes the Cydia Substrate module. At this time, the method can be used to detect the Xposed type hook framework and the Cydia Substrate type hook framework.
[0069] It should be noted that by detecting the Cydia Substrate module in the target feature, it is possible to detect whether a Cydia Substrate type hook framework exists in the electronic device, thereby realizing the detection of multiple types of hook frameworks and improving the accuracy of determining whether a hook framework exists in the electronic device.
[0070] In a possible implementation, the target feature also includes a feature for detecting the Frida framework, that is, the port corresponding to the Frida framework is occupied. The following is a brief introduction to the detection process of the port corresponding to the Frida framework being occupied:
[0071] For example, the java layer monitors port 27042 of the electronic device through new ServerSocket to determine whether the port corresponding to the Frida framework is occupied. Because the default port used by Frida is 27042, if this port is occupied, the Frida Server is running, and it can be determined that the electronic device has the target feature, that is, the port corresponding to the Frida framework is occupied. That is, it is determined that the Frida framework exists in the electronic device.
[0072] It should be noted that by detecting whether the port corresponding to the Frida framework in the target feature is occupied, that is, detecting whether the port corresponding to the Frida framework in the electronic device is occupied, it is possible to detect whether there is a Frida-type hook framework in the electronic device, thereby realizing the detection of multiple types of hook frameworks and improving the accuracy of determining whether there is a hook framework in the electronic device.
[0073] In another possible implementation, the target feature also includes a feature for detecting the Frida framework, that is, the electronic device is connected to the port corresponding to the Frida framework. The following is a brief introduction to the detection process of whether the electronic device is connected to the port corresponding to the Frida framework:
[0074] Specifically, after determining through the Java layer that there is a hook framework of the Frida type, the target feature can no longer be obtained through the native layer, that is, the electronic device establishes a connection with the port corresponding to the Frida framework. If it is determined through the Java layer that there is no hook framework of the Frida type, the target feature can be further obtained, that is, the electronic device establishes a connection with the port corresponding to the Frida framework. Among them, the electronic device can establish a connection with the port corresponding to the Frida framework through connect.
[0075] It should be noted that the Native layer can attempt to establish a connection with the port 27042 corresponding to the Frida framework through connect. If the connection is successfully established, the Frida Server exists and is in operation, and a Frida-type hook framework exists in the electronic device. Since the Native layer is closer to the bottom layer of the system and has stronger adversarial properties, the detection result obtained by detecting whether the Native layer successfully establishes a connection with the port corresponding to the Frida framework is more accurate and reliable. In other words, by detecting whether the electronic device has the target feature, it can be more accurately determined whether a Frida-type hook framework exists in the electronic device.
[0076] In addition, by detecting whether the electronic device in the target feature establishes a connection with the port corresponding to the Frida framework, that is, detecting whether the electronic device has established a connection with the port corresponding to the Frida framework, it is possible to detect whether a Frida-type hook framework exists in the electronic device, thereby realizing the detection of multiple types of hook frameworks and improving the accuracy of determining whether a hook framework exists in the electronic device.
[0077] In a possible implementation, the order of detecting hook frameworks according to different target features can be determined according to the level of obtaining target features, i.e., Java layer or native layer. Since the common features of Xposed framework and Cydia Substrate framework are that the package name of Hook framework exists in the system installation list, there are corresponding plug-ins, and there are similar detection methods, the features of these two hook frameworks can be extracted and summarized at the same time and then detected at the same time, which takes up less system resources.
[0078] The Frida framework needs to work with the help of the network and establish a network connection on the specified port. It needs to start a separate thread for detection, which will occupy some system resources, so the detection is performed last. In other words, in a possible implementation, the presence of target features in the electronic device can be detected in a preset order, that is, first, the presence of target features for detecting the Xposed framework or the Cydia Substrate framework in the electronic device is detected, and then the presence of target features for detecting the Frida framework in the electronic device is detected.
[0079] Specifically, the target features include target features for detecting the Xposed framework and target features for detecting the Frida framework. When checking whether there is a hook framework in an electronic device, firstly check whether there is a target feature for detecting the Xposed framework in the electronic device, that is, first check whether there is an Xposed framework in the electronic device, and then check whether there is a target feature for detecting the Frida framework in the electronic device, that is, check whether there is a Frida framework in the electronic device. According to the above content, it can be known that the target features for detecting the Xposed framework include at least one of an Xposed plug-in, an Xposed module, a directory associated with the Xposed framework, and a package name associated with a variant of the Xposed framework.
[0080] Exemplarily, taking the case where the target features include at least one of an Xposed plug-in, an Xposed module, a directory associated with the Xposed framework, a package name associated with a variant of the Xposed framework, and the port corresponding to the Frida framework being occupied, first, a detection is performed to determine whether an Xposed plug-in, an Xposed module, a directory associated with the Xposed framework, and at least one of a package name associated with a variant of the Xposed framework exists in the electronic device, and then a detection is performed to determine whether the port corresponding to the Frida framework in the electronic device is occupied.
[0081] Exemplarily, taking the example that the target features include an Xposed plug-in, an Xposed module, a directory associated with the Xposed framework, at least one of a package name associated with a variant of the Xposed framework, and the electronic device establishing a connection with a port corresponding to the Frida framework, first, it is detected whether the electronic device exists with an Xposed plug-in, an Xposed module, a directory associated with the Xposed framework, and at least one of a package name associated with a variant of the Xposed framework, and then it is detected whether the electronic device is connected to the port corresponding to the Frida framework.
[0082] For example, taking the case where the target features include an Xposed plug-in and an electronic device establishes a connection with a port corresponding to the Frida framework, firstly a detection is performed to determine whether an Xposed plug-in exists in the electronic device, and then a detection is performed to determine whether a connection is established between the electronic device and the port corresponding to the Frida framework.
[0083] Exemplarily, taking the case where the target features include at least one of an Xposed plug-in, an Xposed module, a directory associated with an Xposed framework, a package name associated with a variant of the Xposed framework, an occupied port of the Frida framework in an electronic device, and a connection between the electronic device and the port corresponding to the Frida framework, firstly detect whether there is an Xposed plug-in, an Xposed module, a directory associated with the Xposed framework, and at least one of the package names associated with a variant of the Xposed framework in the electronic device, and then detect whether the port of the Frida framework in the electronic device is occupied and whether the electronic device and the port corresponding to the Frida framework are connected. Among them, the process of detecting whether the port of the Frida framework in the electronic device is occupied and whether the port corresponding to the Frida framework is connected can be referred to the above content, which will not be repeated here.
[0084] Specifically, the target features include target features for detecting the Cydia Substrate framework and target features for detecting the Frida framework. When checking whether there is a hook framework in an electronic device, firstly check whether there is a target feature for detecting the Cydia Substrate framework in the electronic device, that is, first check whether there is a Cydia Substrate framework in the electronic device, and then check whether there is a target feature for detecting the Frida framework in the electronic device, that is, check whether there is a Frida framework in the electronic device.
[0085] For example, taking the case where the target features include the Cydia Substrate module and the port corresponding to the Frida framework being occupied, firstly, it is detected whether there is an Xposed plug-in in the electronic device, and then it is detected whether a connection is established at the port corresponding to the Frida framework in the electronic device.
[0086] Specifically, the target features include target features for detecting the Xposed framework, target features for detecting the CydiaSubstrate framework, and target features for detecting the Frida framework. When checking whether there is a hook framework in an electronic device, firstly check whether there are target features for detecting the Cydia Substrate framework and target features for detecting the Xposed framework in the electronic device, that is, first check whether there are the CydiaSubstrate framework and the Xposed framework in the electronic device, and then check whether there are target features for detecting the Frida framework in the electronic device, that is, check whether there is a Frida framework in the electronic device.
[0087] For example, taking the case where the target features include Xposed plug-ins, Cydia Substrate modules, and ports corresponding to the Frida framework being occupied, firstly, it is detected whether there are Xposed plug-ins and Cydia Substrate modules in the electronic device, and then it is detected whether a connection is established at the port corresponding to the Frida framework in the electronic device.
[0088] Of course, in a possible implementation, the target feature may include only the target feature for detecting the Frida framework, or may include the other target features mentioned above. If the target feature only includes the target feature for detecting the Frida framework, for example, the target feature is that the port corresponding to the Frida framework is occupied, then the method is only used to detect the Frida type hook framework. If the target feature includes the other target features mentioned above, such as at least one of the Xposed plug-in, the Xposed module, the directory associated with the Xposed framework, and the package name associated with the variant of the Xposed framework, the target feature also includes that the CydiaSubstrate module and the port corresponding to the Frida framework are occupied, then the method can be used to detect the Xposed type hook framework, the Frida type hook framework, and the Cydia Substrate type hook framework.
[0089] S102: If the target feature exists, determine whether a hook framework exists in the electronic device.
[0090] In a possible implementation, the Xposed framework and the CydiaSubstrate framework are detected at the Java layer through target features. Among them, when detecting the Xposed framework, a variety of detection methods can be used in combination for detection. As long as Xposed exists in the electronic device through one of the detection methods, it is determined that the Xposed framework exists in the electronic device. It should be noted that the comprehensive use of multiple target features to detect the Xposed framework can make the detection result more accurate. After the detection is completed, the next stage is entered, that is, firstly detection is performed at the Java layer. If the existence of the Frida framework has been detected, there is no need to perform detection at the Native layer. If the existence of the Frida framework is not detected, further detection is performed at the Native layer. The detection results of the Java layer and the Native layer are combined to determine whether the Frida framework exists in the electronic device, thereby saving system resources and shortening the time for hook framework detection.
[0091] Optionally, in a possible implementation, the method further includes step S103:
[0092] S103: Determine the security level of the electronic device according to the number of hook frameworks existing in the electronic device.
[0093] Among them, there is a corresponding relationship between the number of hook frameworks existing in the electronic device and the security level of the electronic device.
[0094] In a possible implementation, the security level of the electronic device can be divided into 4 levels, including safe, slightly dangerous, moderately dangerous, and severely dangerous. The security level of the electronic device can be obtained according to the number of hook frameworks present in the electronic device. In other words, there is a corresponding relationship between the number of hook frameworks present in the electronic device and the security level of the electronic device.
[0095] Table 1
[0096] Serial number Number of hook frames in electronic devices Security Level 1 0 Safety 2 1 Slightly dangerous 3 2 Moderate risk 4 3 Severe danger
[0097] Exemplarily, the corresponding relationship between the number of hook frameworks existing in the electronic device and the evaluation result can be shown in Table 1 above. If the number of hook frameworks existing in the electronic device is 0, the security level of the electronic device is determined to be safe; if the number of hook frameworks existing in the electronic device is 1, the security level of the electronic device is determined to be slightly dangerous; if the number of hook frameworks existing in the electronic device is 2, the security level of the electronic device is determined to be moderately dangerous; if the number of hook frameworks existing in the electronic device is 3, the security level of the electronic device is determined to be severely dangerous.
[0098] It should be noted that, in addition, it should be noted that the specific implementation of the above-mentioned method for detecting the hook framework can be integrated into an application APP, that is, a detection APP. The detection APP is installed in the environment to be detected (for example, the electronic device to be detected or the electronic device where the APP to be detected is located). At this time, the detection APP can be used to detect whether there is a hook framework in the electronic device and the APP in the electronic device. Furthermore, the security level of the electronic device can be evaluated.
[0099] For example, Figure 2 As shown, mobile phones, tablets and other electronic devices are the electronic devices to be detected. After the detection APP is installed in the electronic device to be detected, the detection APP is run to detect whether there is a hook framework in the electronic device through the detection APP, and then the safety level of the electronic device is determined according to the number of hook frameworks in the electronic device. The safety level of the electronic device can be 4 levels, namely the above-mentioned safety, mild danger, moderate danger, and severe danger.
[0100] It should be noted that the technical solution disclosed in the present invention is relatively lightweight, that is, it can be run entirely on the client side (such as the above-mentioned electronic device to be detected), and does not need to establish a connection with the service side (such as a server) to generate additional network connection overhead. Therefore, the technical solution disclosed in the present invention occupies fewer resources and has less impact on the availability of the electronic device.
[0101] In one possible implementation, the electronic device displays the detection result of the hook framework (i.e., the number of hook frameworks present in the electronic device), and / or the electronic device can display the evaluation result of its security (i.e., the security level of the electronic device). In other words, the electronic device displays the number of hook frameworks present in it, or the electronic device displays its security level, or the electronic device displays the number of hook frameworks present in it and the security level of the electronic device. Through this process, the electronic device can directly transmit the detection result of the hook framework and / or the evaluation result of the security of the electronic device to the user, so as to facilitate the user to make the next decision, such as reminding the user of the abnormal environment and / or performing subsequent processing such as Anti-Hook.
[0102] It should be noted that, through the above process, the above target features can be used to detect the hook framework in the electronic device, avoiding the situation where the hook framework modified according to the existing detection method cannot be detected, thereby improving the accuracy of detecting the hook framework and improving the security of the electronic device. And by detecting the package name associated with the variant of the Xposed framework in the above target features, the variant of the Xposed framework can be detected, thereby further improving the accuracy of detecting the hook framework.
[0103] Figure 3 is a block diagram of a device for detecting a hook framework according to an exemplary embodiment. Figure 3 The device includes a detection unit 301, a determination unit 302 and an evaluation unit 303.
[0104] The detection unit 301 is configured to detect whether a target feature exists in the electronic device, where the target feature includes at least one of the following: an Xposed plug-in, an Xposed module, a directory associated with the Xposed framework, and a package name associated with a variant of the Xposed framework.
[0105] In a possible implementation, the directory associated with Xposed is a directory storing an installation package of an Xposed framework and / or a directory storing an installation package of an Xposed module.
[0106] In a possible implementation, the variant of the Xposed framework includes a VirtualXposed framework and / or an EdXposed framework.
[0107] In a possible implementation, the target feature also includes a Cydia Substrate module.
[0108] In a possible implementation, the target feature also includes that the port corresponding to the Frida framework is occupied. At this time, the detection unit 301 is specifically configured to perform a detection on whether there is an Xposed plug-in, an Xposed module, a directory associated with the Xposed framework, and a package name associated with a variant of the Xposed framework in the electronic device; and then detect whether the port of the Frida framework in the electronic device is occupied.
[0109] In a possible implementation, the target feature also includes establishing a connection between the electronic device and the port corresponding to the Frida framework. At this time, the detection unit 301 is specifically configured to perform a detection on whether there is an Xposed plug-in, an Xposed module, a directory associated with the Xposed framework, and a package name associated with a variant of the Xposed framework in the electronic device; and then detect whether a connection is established between the electronic device and the port corresponding to the Frida framework.
[0110] In a possible implementation, the target feature is the Xposed module. The detection unit 301 is specifically configured to perform parsing of at least one application installation package APK on the electronic device, and determine whether a target file exists in the directory of the at least one APK, and the target file is a file in the Xposed module. If the target file exists in the directory of the at least one APK, it is determined that the Xposed module exists in the electronic device.
[0111] In a possible implementation, the detection unit 301 is specifically configured to parse at least one application installation package APK on the electronic device to obtain at least one string. If the at least one string contains a target string, it is determined that a Cydia Substrate module exists in the electronic device, and the target string is a string in the Cydia Substrate framework.
[0112] The determining unit 302 is configured to determine if a hook framework exists in the electronic device if the target feature exists.
[0113] The evaluation unit 303 is configured to evaluate the security of the electronic device according to the number of hook frameworks existing in the electronic device and the corresponding relationship between the number of hook frameworks existing in the electronic device and the security level of the electronic device to obtain the security level of the electronic device.
[0114] Regarding the device in the above embodiment, the specific manner in which each module performs operations, as well as the contents of the target features and preset conditions have been described in detail in the above-mentioned method embodiments and will not be elaborated here.
[0115] Figure 4 4 is a block diagram of an electronic device according to an exemplary embodiment. The electronic device may include at least one processor 401 , a communication bus 402 , a memory 403 and at least one communication interface 404 .
[0116] The processor 401 may be a central processing unit (CPU), a microprocessing unit, an application specific integrated circuit (ASIC), or one or more integrated circuits for controlling the execution of the program of the disclosed solution.
[0117] Communication bus 402 may include a pathway for transmitting information between the above-mentioned components.
[0118] The communication interface 404 uses any transceiver-like device for communicating with other devices or communication networks, such as servers, Ethernet, radio access networks (RAN), wireless local area networks (WLAN), etc.
[0119] The memory 403 may be a read-only memory (ROM) or other types of static storage devices that can store static information and instructions, a random access memory (RAM) or other types of dynamic storage devices that can store information and instructions, or an electrically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disc storage, optical disc storage (including compressed optical disc, laser disc, optical disc, digital versatile disc, Blu-ray disc, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store the desired program code in the form of an instruction or data structure and can be accessed by a computer, but is not limited thereto. The memory may exist independently and be connected to the processing unit through a bus. The memory may also be integrated with the processing unit.
[0120] The memory 403 is used to store application code for executing the solution of the present disclosure, and the execution is controlled by the processor 401. The processor 401 is used to execute the application code stored in the memory 403, so as to realize the functions in the method of the present disclosure.
[0121] In a specific implementation, as an embodiment, the processor 401 may include one or more CPUs, such as Figure 4 CPU0 and CPU1 in.
[0122] In a specific implementation, as an embodiment, the electronic device may include multiple processors, such as Figure 4 401 and processor 405 in FIG. Each of these processors may be a single-CPU processor or a multi-CPU processor. A processor herein may refer to one or more devices, circuits, and / or processing cores for processing data (e.g., computer program instructions).
[0123] In a specific implementation, as an embodiment, the electronic device may further include an input device 406 and an output device 407. The input device 406 communicates with the processor 401 and may receive user input in a variety of ways. For example, the input device 406 is a mouse, a keyboard, a touch screen device, or a sensor device. The output device 407 communicates with the processor 401 and may display information in a variety of ways. For example, the output device 407 may be a liquid crystal display (LCD), a light emitting diode (LED) display device, etc.
[0124] Those skilled in the art will understand that Figure 4 The structure shown in the figure does not constitute a limitation on the electronic device, and may include more or less components than shown in the figure, or combine some components, or adopt a different component arrangement.
[0125] In an exemplary embodiment, a storage medium including instructions is also provided, such as a memory 403 including instructions, and the instructions can be executed by a processor 401 of an electronic device to complete the above method. Optionally, the storage medium can be a non-transitory computer-readable storage medium, for example, the non-transitory computer-readable storage medium can be a ROM, a random access memory RAM, a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0126] In an exemplary embodiment, a computer-readable storage medium including instructions is also provided, such as a memory 403 including instructions, and the instructions can be executed by a processor 401 or a processor 405 of an electronic device to complete the above method. Optionally, the storage medium can be a non-transitory computer-readable storage medium, for example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0127] In an exemplary embodiment, a computer program product including instructions is also provided. When the computer program product is executed on a computer, the computer device executes the method for detecting a hook framework provided in the above-mentioned embodiment.
[0128] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.
[0129] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A method for detecting a hook framework, characterized in that: include: Detect whether there is a target feature in the electronic device; wherein the target feature Includes the following items: Xposed plug-in, Xposed module, directory associated with Xposed framework, package name associated with variant of Xposed framework, the directory associated with Xposed is a directory storing installation package of Xposed framework and / or a directory storing installation package of Xposed module; variant of Xposed framework includes VirtualXposed framework and / or EdXposed framework; If the target feature exists, it is determined that a hook framework exists in the electronic device.
2. The method for detecting a hook framework according to claim 1, characterized in that: The target features also include Cydia Substrate modules.
3. The method for detecting a hook framework according to claim 1, characterized in that: The target feature also includes that the port corresponding to the Frida framework is occupied; The detecting whether the target feature exists in the electronic device comprises: Detecting whether at least one of an Xposed plug-in, an Xposed module, a directory associated with an Xposed framework, and a package name associated with a variant of the Xposed framework exists in the electronic device; Whether the port of the Frida framework in the electronic device is occupied is detected.
4. The method for detecting a hook framework according to claim 3, characterized in that: The target feature also includes establishing a connection between the electronic device and a port corresponding to the Frida framework; The detecting whether the target feature exists in the electronic device comprises: Detecting whether at least one of an Xposed plug-in, an Xposed module, a directory associated with an Xposed framework, and a package name associated with a variant of the Xposed framework exists in the electronic device; It is detected whether the port of the Frida framework in the electronic device is occupied and whether a connection is established between the electronic device and the port corresponding to the Frida framework.
5. The method for detecting a hook framework according to claim 1, characterized in that: The target feature is the Xposed module; and detecting whether the target feature exists in the electronic device includes: Parsing at least one application installation package APK on the electronic device to determine whether a target file exists in a directory of the at least one APK, where the target file is a file in the Xposed module; If the target file exists in the directory of the at least one APK, it is determined that the Xposed module exists in the electronic device.
6. The method for detecting hook framework according to claim 2, characterized in that: The detecting whether the target feature exists in the electronic device comprises: Parsing at least one application installation package APK on the electronic device to obtain at least one character string; If the target string exists in the at least one string, it is determined that a CydiaSubstrate module exists in the electronic device, and the target string is a string in the Cydia Substrate framework.
7. The method for detecting a hook framework according to any one of claims 1 to 6, characterized in that: The method further comprises: The security level of the electronic device is determined according to the number of hook frameworks present in the electronic device.
8. A device for detecting a hook frame, characterized in that: include: The detection unit is configured to detect whether a target feature exists in the electronic device; wherein the target feature includes the following items: an Xposed plug-in, an Xposed module, a directory associated with an Xposed framework, and a package name associated with a variant of the Xposed framework, wherein the directory associated with Xposed is a directory storing an installation package of the Xposed framework and / or a directory storing an installation package of the Xposed module, and the variant of the Xposed framework includes a VirtualXposed framework and / or an EdXposed framework; The determination unit is configured to determine whether a hook framework exists in the electronic device if the target feature exists.
9. The device for detecting hook frames according to claim 8, characterized in that: The target features also include Cydia Substrate modules.
10. The device for detecting hook frames according to claim 8, characterized in that: The target feature also includes that the port corresponding to the Frida framework is occupied; the detection unit is specifically configured to execute: Detecting whether at least one of an Xposed plug-in, an Xposed module, a directory associated with an Xposed framework, and a package name associated with a variant of the Xposed framework exists in the electronic device; Whether the port of the Frida framework in the electronic device is occupied is detected.
11. The device for detecting hook frames according to claim 8, characterized in that: The target feature also includes that the electronic device establishes a connection with a port corresponding to the Frida framework; and the detection unit is specifically configured to execute: Detecting whether at least one of an Xposed plug-in, an Xposed module, a directory associated with an Xposed framework, and a package name associated with a variant of the Xposed framework exists in the electronic device; It is detected whether the port of the Frida framework in the electronic device is occupied and whether a connection is established between the electronic device and the port corresponding to the Frida framework.
12. The device for detecting hook frames according to claim 8, characterized in that: The target feature is the Xposed module; The detection unit is specifically configured to perform parsing of at least one application installation package APK on the electronic device to determine whether a target file exists in a directory of the at least one APK, where the target file is a file in the Xposed module; The detection unit is further configured to determine whether the Xposed module exists in the electronic device if a target file exists in a directory of the at least one APK.
13. The device for detecting hook frames according to claim 9, characterized in that: The detection unit is specifically configured to parse at least one application installation package APK on the electronic device to obtain at least one character string; The detection unit is further configured to determine whether a Cydia Substrate module exists in the electronic device if a target string exists in the at least one string, and the target string is a string in the Cydia Substrate framework.
14. The device for detecting hook frames according to any one of claims 8 to 13, characterized in that: The device further comprises an evaluation unit: The evaluation unit is configured to determine the security level of the electronic device according to the number of hook frameworks existing in the electronic device.
15. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the method for detecting a hook framework as described in any one of claims 1 to 7.
16. A storage medium, characterized in that: When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the method for detecting a hook framework as described in any one of claims 1 to 7.
17. A computer program product comprising computer instructions, characterized in that When the computer instructions are executed by a processor, the method for detecting a hook framework according to any one of claims 1 to 7 is implemented.
