English | 日本語
hermes is an Android dynamic method hooking playground project.
It combines Kotlin/Java APIs with a Rust native core to test ART method interception and replacement.
It supports Android 8.0+ and the following ABIs: armeabi-v7a, arm64-v8a, x86, x86_64.
Repository layout:
hermes/: core library (Kotlin + Rust)app/: sample app (Jetpack Compose UI for visual hook testing)
Hermes is published on Maven Central:
Add dependency in your app/library module:
dependencies {
implementation("io.github.enuwbt:hermes:0.1.1")
implementation(kotlin("reflect")) // required for KFunction-based APIs
}If needed, ensure repositories include Maven Central:
dependencyResolutionManagement {
repositories {
google()
mavenCentral()
}
}import io.github.enuwbt.hermes.defineInterceptsOf
MyClass::class.defineInterceptsOf {
method("sum", Int::class, Int::class) {
implementation = { a: Int, b: Int ->
self.memberFunction()
val originalValue = original(a, b) as Int
originalValue + 1
}
}
}import io.github.enuwbt.hermes.Hermes
import io.github.enuwbt.hermes.InterceptCallback
val method = MyClass::class.java.getDeclaredMethod("sum", Int::class.javaPrimitiveType, Int::class.javaPrimitiveType)
Hermes.intercept(method, object : InterceptCallback() {
override fun onInvoke(receiver: Any?, args: Array<out Any?>): Any? {
val originalValue = original(receiver, args) as Int
return originalValue + 10
}
})import io.github.enuwbt.hermes.intercept
import io.github.enuwbt.hermes.InterceptCallback
MyClass::sum.intercept(object : InterceptCallback() {
override fun onInvoke(receiver: Any?, args: Array<out Any?>): Any? {
val originalValue = original(receiver, args) as Int
return originalValue + 100
}
})- Android Studio (latest stable recommended)
- JDK 11
- Android SDK / NDK (as required by Gradle config)
- Rust toolchain (
cargo) - Rust Android targets (e.g.
armv7-linux-androideabi,i686-linux-android,x86_64-linux-android,aarch64-linux-android)
./gradlew cargoNdkBuild
./gradlew assembleDebug- Install the
appmodule on a device/emulator - Open the app and use each test item:
Call: run current implementationHook: install interception for that methodResult: show execution result
- This project is intended for research/testing purposes.
- Behavior may vary depending on Android version and CPU architecture.
- Do not commit
local.properties(environment-specific).
- LSPlant (https://github.com/LSPosed/LSPlant)
- pine (https://github.com/canyie/pine)
- xz-embedded: 0BSD (
hermes/src/main/rust/third_party/xz-embedded)
This project is licensed under the MIT License.
See LICENSE for details.