• Stars
    star
    4,390
  • Rank 9,760 (Top 0.2 %)
  • Language
    Java
  • License
    Other
  • Created over 7 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Dynamic java method AOP hook for Android(continution of Dexposed on ART), Supporting 5.0~11

Download Join the chat at https://gitter.im/android-hacker/epic

中文文档入口

What is it?

Epic is the continuation of Dexposed on ART (Supports 5.0 ~ 11).

Dexposed is a powerful yet non-invasive runtime AOP (Aspect-oriented Programming) framework for Android app development, based on the work of open-source Xposed framework 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 library in 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 your app process can be hooked.

Epic keeps the same API and all capability of Dexposed, you can do anything which is supported by Dexposed.

Typical use-cases

  • Classic AOP programming
  • Instrumentation (for testing, performance monitoring and etc.)
  • Security audit (sensitive api check,Smash shell)
  • Just for fun :)

Integration

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.

Basic usage

There are three injection points for a given method: before, after, origin.

Example 1: monitor the creation and destroy of java thread

class ThreadMethodHook extends XC_MethodHook{
    @Override
    protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
        super.beforeHookedMethod(param);
        Thread t = (Thread) param.thisObject;
        Log.i(TAG, "thread:" + t + ", started..");
    }

    @Override
    protected void afterHookedMethod(MethodHookParam param) throws Throwable {
        super.afterHookedMethod(param);
        Thread t = (Thread) param.thisObject;
        Log.i(TAG, "thread:" + t + ", exit..");
    }
}

DexposedBridge.hookAllConstructors(Thread.class, new XC_MethodHook() {
    @Override
    protected void afterHookedMethod(MethodHookParam param) throws Throwable {
        super.afterHookedMethod(param);
        Thread thread = (Thread) param.thisObject;
        Class<?> clazz = thread.getClass();
        if (clazz != Thread.class) {
            Log.d(TAG, "found class extend Thread:" + clazz);
            DexposedBridge.findAndHookMethod(clazz, "run", new ThreadMethodHook());
        }
        Log.d(TAG, "Thread: " + thread.getName() + " class:" + thread.getClass() +  " is created.");
    }
});
DexposedBridge.findAndHookMethod(Thread.class, "run", new ThreadMethodHook());

Example 2: Intercept the dex loading behavior

DexposedBridge.findAndHookMethod(DexFile.class, "loadDex", String.class, String.class, int.class, new XC_MethodHook() {
    @Override
    protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
        super.beforeHookedMethod(param);
        String dex = (String) param.args[0];
        String odex = (String) param.args[1];
        Log.i(TAG, "load dex, input:" + dex + ", output:" + odex);
    }
});

Checkout the sample project to find out more.

Support

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).

Known Issues

  1. Short method (instruction less 8 bytes on thumb2 or less 16bytes in ARM64) are not supported.
  2. Fully inline methods are not supported.

Contribute

We are open to constructive contributions from the community, especially pull request and 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 :)

Thanks

  1. Dexposed
  2. Xposed
  3. mar-v-in/ArtHook
  4. Nougat_dlfunctions

Contact me

[email protected]

Join discussion

More Repositories

1

KernelSU

A Kernel based root solution for Android
Kotlin
10,005
star
2

FreeReflection

A library that lets you use reflection without any restriction above Android P
C++
2,914
star
3

understand-plugin-framework

demos to help understand plugin framwork
Java
2,634
star
4

Leoric

PoC of fighting against force-stop kill process on Android
Java
1,811
star
5

eadb

eBPF Android Debug Bridge
Rust
444
star
6

markdown-img-upload

markdown图片实用工具
Python
417
star
7

super-adb

Enhance the adb shell using busybox, supporting vi、grep and awk etc. No need root.
Python
291
star
8

DirtyPipeRoot

Using DirtyPipe to gain temporary root access for Android devices.
Java
239
star
9

adb_root

Shell
155
star
10

android-native-debug

Debug Android Framework Native Code Tutorial.
C++
148
star
11

AnyLauncher

Any Launcher is OK for MIUI!
Java
50
star
12

VirtualAndroid

An Android emulator for Android device
32
star
13

graph-easy-cn

Perl 模块 Graph::Easy 中文文档
HTML
26
star
14

everything-in-python

The python implement of [everything](https://www.voidtools.com/)
25
star
15

ebpf-jnitrace

Trace jni calls with eBPF on Android
24
star
16

art-dex-interpret

Load dex on ART in interpret mode
Java
17
star
17

tiann.github.io

my personal blog
HTML
17
star
18

tiann

15
star
19

genshin_launch

原神启动 for KernelSU!
HTML
12
star
20

docker-build-android-kernel

Build Android kernel with Docker.
9
star
21

PtyProcess

PtyProcess for Android
C++
7
star
22

KernelSU_website

7
star
23

repo-mirror

Python
4
star
24

cmi-r-oss

C
4
star
25

hehe

3
star
26

onedrive

HTML
3
star
27

haskell-learning

my way to haskell
Haskell
2
star
28

arts

2
star
29

SyncService

1
star
30

ideas

inspiration
1
star
31

cross-paste

cross platform copy&paste tool
Python
1
star
32

py-luchchy-go

Py-launchy-Go is a Launchy python plugin that activates open windows from Launchy. It’s a python remake of an old Launchy plugin called Go-Y.
Python
1
star