Method and device for realizing hook

A unique and unique technology, applied in the field of Android security, which can solve the problems of hardening server overhead, high configuration complexity, and long APK hardening time.

Active Publication Date: 2018-09-25
CHINA MOBILEHANGZHOUINFORMATION TECH CO LTD +1
View PDF4 Cites 0 Cited by
  • Summary
  • Abstract
  • Description
  • Claims
  • Application Information

AI Technical Summary

Problems solved by technology

[0007] The embodiment of the present application provides a method and device for implementing hooks, which are used to solve the problems in the pr

Method used

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
View more

Image

Smart Image Click on the blue labels to locate them in the text.
Viewing Examples
Smart Image
  • Method and device for realizing hook
  • Method and device for realizing hook
  • Method and device for realizing hook

Examples

Experimental program
Comparison scheme
Effect test

Embodiment 1

[0062] like figure 1 As shown, it is a flowchart of a method for implementing hook provided in Embodiment 1 of the present application, including the following steps:

[0063] Step 101: Determine the return value type of the hook function to be generated.

[0064] In the specific implementation, since the return value type between the hooked Java function and the hook function needs to be consistent when hooking the Java layer function, the return value of the Java function can be determined first before generating the hook function type, and then it can be determined that the type of the return value of the hook function to be generated is the same as the type of the return value of the determined Java function.

[0065] Specifically, there are 10 return value types of the determined Java function, and correspondingly, the following 10 return value types of hook functions need to be generated respectively. Wherein, the corresponding relationship between the hook function to...

Embodiment 2

[0088] When the terminal device runs any repackaged APK, it can refer to the following figure 2 The steps shown to hook:

[0089] Step 201: The terminal device loads the so library according to the instruction for loading the so library included in the Android installation package APK of the hook, wherein the so library contains different return value types and the parameter types are all variable parameters. hook function.

[0090] Step 202: traverse all Java functions that need to be hooked in the APK, and execute steps 203 to 204 for each Java function that needs to be hooked.

[0091] Step 203: Select an unused hook function that has the same return value type as the Java function from the so library.

[0092] In the specific implementation, according to the return value type extracted from the APK corresponding to the Java function that needs to be hooked, select the same return value type from the hook functions pointed to by the 10 function pointer arrays in the so l...

Embodiment 3

[0100] like image 3 As shown, the schematic structural diagram of the device for implementing hook provided in Embodiment 3 of the present application includes:

[0101] Determine module 31, be used for determining the return value type of the hook function that needs to generate;

[0102] The first generation module 32 is used to generate a hook function whose parameter type is a variable parameter and has the return value type for each return value type;

[0103] The second generation module 33 is used to generate the so library based on the hook function corresponding to each return value type;

[0104] The extraction module 34 is used for each Android installation package APK that needs to be hooked, and extracts the return value type of each Java function that needs to be hooked in the APK and saves it in the APK, so that when the terminal runs the APK, from Select an unused hook function that has the same return value type as the Java function that needs to be hooked ...

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to view more

PUM

No PUM Login to view more

Abstract

The invention relates to the technical field of Android security, in particular to a method and device for realizing hook, which are used for solving the problem that the time of the APK reinforcementexisting in the prior art is too long, and the cost and the configuration complexity of the reinforcing server are also large. The method for realizing the hook comprises the following steps of: determining a return value type of the hook function to be generated; for each return value type, generating a variable parameter type and a hook function of the return value type; generating a so librarybased on the hook function corresponding to each return value type; for each Android installation package that needs to be hook, extracting the return value type of each Java function that needs to be hooked in the APK and storing in the APK.

Description

technical field [0001] The invention relates to the field of Android security technology, in particular to a method and device for realizing hooks. Background technique [0002] At present, the application (Application, APP) reinforcement technology on Android has entered the virtual machine reinforcement (Virtual Machine Protect, VMP) stage. When using VMP for APP hardening work, it is often necessary to use the hook (Hook) technology to convert the original function into a set of instruction codes interpreted by the internal hardened virtual machine, and replace the original function that needs to be hooked with an internal hardened virtual machine. Executable hook function. [0003] In the prior art, the RegisterNatives technology is often used to realize the above-mentioned Hook. The specific method is: for each Java function to be Hooked in the Android installation package (AndroidPackage, APK), first modify the function method into a local method in the Dex file of th...

Claims

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to view more

Application Information

Patent Timeline
no application Login to view more
IPC IPC(8): G06F21/50
CPCG06F21/50
Inventor 曾英佩
Owner CHINA MOBILEHANGZHOUINFORMATION TECH CO LTD
Who we serve
  • R&D Engineer
  • R&D Manager
  • IP Professional
Why Eureka
  • Industry Leading Data Capabilities
  • Powerful AI technology
  • Patent DNA Extraction
Social media
Try Eureka
PatSnap group products