Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork817
Dynamic java method AOP hook for Android(continution of Dexposed on ART), Supporting 5.0~11
License
tiann/epic
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Epic is the continuation ofDexposed on ART (Supports 5.0 ~ 11).
Dexposed is a powerful yet non-invasive runtimeAOP (Aspect-oriented Programming) frameworkfor Android app development, based on the work of open-sourceXposedframework project.
The AOP of Dexposed is implemented purely non-invasive, without any annotation processor,weaver or bytecode rewriter. The integration is as simple as loading a small JNI libraryin just one line of code at the initialization phase of your app.
Not only the code of your app, but also the code of Android framework that running in yourapp process can be hooked.
Epic keeps the same API and all capability of Dexposed, you can do anything which is supported by Dexposed.
- Classic AOP programming
- Instrumentation (for testing, performance monitoring and etc.)
- Security audit (sensitive api check,Smash shell)
- Just for fun :)
Directly add epic aar to your project as compile libraries, Gradle dependency like following(jitpack):
dependencies { compile'com.github.tiann:epic:0.11.2'}Everything is ready.
There are three injection points for a given method:before,after,origin.
Example 1: monitor the creation and destroy of java thread
classThreadMethodHookextendsXC_MethodHook{@OverrideprotectedvoidbeforeHookedMethod(MethodHookParamparam)throwsThrowable {super.beforeHookedMethod(param);Threadt = (Thread)param.thisObject;Log.i(TAG,"thread:" +t +", started.."); }@OverrideprotectedvoidafterHookedMethod(MethodHookParamparam)throwsThrowable {super.afterHookedMethod(param);Threadt = (Thread)param.thisObject;Log.i(TAG,"thread:" +t +", exit.."); }}DexposedBridge.hookAllConstructors(Thread.class,newXC_MethodHook() {@OverrideprotectedvoidafterHookedMethod(MethodHookParamparam)throwsThrowable {super.afterHookedMethod(param);Threadthread = (Thread)param.thisObject;Class<?>clazz =thread.getClass();if (clazz !=Thread.class) {Log.d(TAG,"found class extend Thread:" +clazz);DexposedBridge.findAndHookMethod(clazz,"run",newThreadMethodHook()); }Log.d(TAG,"Thread: " +thread.getName() +" class:" +thread.getClass() +" is created."); }});DexposedBridge.findAndHookMethod(Thread.class,"run",newThreadMethodHook());
Example 2: Intercept the dex loading behavior
DexposedBridge.findAndHookMethod(DexFile.class,"loadDex",String.class,String.class,int.class,newXC_MethodHook() {@OverrideprotectedvoidbeforeHookedMethod(MethodHookParamparam)throwsThrowable {super.beforeHookedMethod(param);Stringdex = (String)param.args[0];Stringodex = (String)param.args[1];Log.i(TAG,"load dex, input:" +dex +", output:" +odex); }});
Checkout thesample project to find out more.
Epic supports ART thumb2 and arm64 architecture from Android 5.0 ~ 11. arm32, x86, x86_64 and mips are not supported now (Thus it cannot work on android emulator).
- Short method (instruction less 8 bytes on thumb2 or less 16bytes in ARM64) are not supported.
- Fully inline methods are not supported.
We are open to constructive contributions from the community, especially pull requestand quality bug report.Currently, the implementation for ART is not proved in large scale, we value your help to test or improve the implementation.
You can clone this project, build and install the sample app, just make some click in your device, if some bugs/crash occurs, please file an issue or a pull request, I would appreciate it :)
About
Dynamic java method AOP hook for Android(continution of Dexposed on ART), Supporting 5.0~11
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Contributors10
Uh oh!
There was an error while loading.Please reload this page.