Skip to content

Dynamic java method hook for Android,Implemented by jvmti

License

Notifications You must be signed in to change notification settings

CrackerCat/jtik

Repository files navigation

Jtik

中文版本

Introduction

Jtik is a runtime dynamic hook framework on the Android platform that operates at the granularity of Java methods.Its implementation is based on ART TI and it is capable of hooking both the application itself and system Java methods. Since it utilizes publicly available system interfaces and does not involve modifications to internal memory structures of the ART virtual machine, such as ArtMethod, it theoretically has strong compatibility.

Usage

1. Add dependency

repositories {
        maven { url 'https://jitpack.io' }
}
dependencies {
   implementation 'com.github.chancerly:jtik:0.0.1-Beta'
}

2. Initialization

//if you want hook framework method,like Activity.onCreate
//JtikConfig.needHookSystemClass = true; 

Jtik.init(context);

3. hook target method:

for example:as a class Test

public class Test {
   public int run(int aint b){
	...
   }
}

hook the method run of class Test

Jtik.hook(classLoader.loadClass("Test").getDeclaredMethod("run", int.class, int.class),
		new com.zxc.jtik.MethodHook.Builder().setMethodEnterListener((o, objects) -> {
            //do something on method enter...
        }).setMethodExitListener((o, o1) -> {
            //do something on method exit...
	        return o1;
        }).setParamModifier(0, (thisObject, inParam) -> {
            //do something if you want to modify the parameter...
	    return 6;//the parameter value you chage to
        }).build());

Support platforms:

Theoretically, Android 8.0+ are fully supported

Reference

  1. ART TI
  2. slicer
  3. android studio
  4. JVMTI Tool Interface

About

Dynamic java method hook for Android,Implemented by jvmti

Resources

License

Stars

Watchers

Forks

Packages

No packages published