랭킹으로 돌아가기

tiann/epic

Java

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

arthookaopdexposedandroidepicxposed
스타 성장
스타
4.6k
포크
818
주간 성장
이슈
0
3k3.5k4k4.5k
2017년 3월2020년 4월2023년 6월2026년 7월
아티팩트Mavengit clone https://github.com/tiann/epic.git
README

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

twsxtd@gmail.com

Join discussion

관련 저장소
GraphiteEditor/Graphite

Community-built comprehensive 2D content creation appplication for graphic design, digital art, and interactive real-time motion graphics powered by a node-based procedural graphics engine

Rustcrates.ioApache License 2.0graphics-editorphoto-editor
graphite.art
26.6k1.2k
processing/p5.js

p5.js is a client-side JS platform that empowers artists, designers, students, and anyone to learn to code and express themselves creatively on the web. It is based on the core principles of Processing. Looking for p5.js 2.0? http://beta.p5js.org

JavaScriptnpmGNU Lesser General Public License v2.1javascriptgraphics
p5js.org
23.8k3.8k
ellisonleao/magictools

:video_game: :pencil: A list of Game Development resources to make magic happen.

MarkdownMIT Licensegame-developmentgamedev
17k1.2k
terkelg/awesome-creative-coding

Creative Coding: Generative Art, Data visualization, Interaction Design, Resources.

HTMLawesomecreative-coding
15.1k964
fogleman/primitive

Reproducing images with geometric primitives.

GoGo ModulesMIT Licensegographics
primitive.lol
13.2k648
sonic-pi-net/sonic-pi

Code. Music. Live.

C++Otherlivecodingmusic
sonic-pi.net
11.9k980
easydiffusion/easydiffusion

An easy 1-click way to create beautiful artwork on your PC using AI, with no tech knowledge. Provides a browser UI for generating images from text prompts and images. Just enter your text prompt, and see the generated image.

JavaScriptnpmOtherartdiffusion
easydiffusion.github.io
10.4k857
Orama-Interactive/Pixelorama

Unleash your creativity with Pixelorama, a powerful and accessible open-source pixel art multitool. Whether you want to create sprites, tiles, animations, or just express yourself in the language of pixel art, this software will realize your pixel-perfect dreams with a vast toolbox of features. Available on Windows, Linux, macOS and the Web!

GDScriptMIT Licensegodot-enginegamedev
pixelorama.org
9.9k526
gelstudios/gitfiti

abusing github commit history for the lulz

PythonPyPIMIT Licensegitfitipython
8.4k1.1k
AbdullahAlfaraj/Auto-Photoshop-StableDiffusion-Plugin

A user-friendly plug-in that makes it easy to generate stable diffusion images inside Photoshop using either Automatic or ComfyUI as a backend.

TypeScriptnpmMIT Licenseaiart
7.3k529
CodingTrain/website-archive

Archive of the Coding Train website (first version)

JavaScriptnpmMIT Licenselearningyoutube
codingtrain.github.io/website-archive/
5.7k5.5k
LingDong-/shan-shui-inf

Procedurally generated Chinese landscape painting.

HTMLMIT Licenseprocedural-generationscrollable
5.6k448