Skip to content

Repository files navigation

Android-Mem-Kit

A Lightweight Native Instrumentation Library for Android Security Research

License: MIT Platform: Android 5.0+ NDK: r25b+

Android-Mem-Kit is a minimal-overhead, pure C library for Android native instrumentation. It provides memory patching, function hooking, and symbol resolution capabilities for security research, debugging, and educational purposes.


Features

Feature Implementation Description
Function Hooking ShadowHook Inline hook with intercept, proxy chaining, and records
Symbol Resolution XDL Bypasses Android 7+ linker restrictions
JIT Code Generation SLJIT Platform-independent runtime code generation

Why Pure C?

  • Small Binary Size: <100KB overhead
  • Simple NDK Integration: No FFI bridge or complex build setup
  • Direct JNI/NDK Access: Native C integration with Android frameworks
  • Modern Tooling: Leverages battle-tested libraries (ShadowHook, XDL, SLJIT)

Documentation

Document Content
docs/GENERAL.md Quick start: prerequisites, setup, build, and basic usage
docs/USAGE.md Complete API reference: memory, hooking, intercept, records, JIT, IL2CPP, XDL, DL callbacks
docs/RECIPES.md Common patterns: integrity checks, SSL pinning bypass, JIT code generation

Known Issues

ShadowHook Error 12

When using ShadowHook on building shared library, you may encounter error code 12 (MK_ERRNO_INIT_LINKER) during memkit_hook_init(). This is caused by missing libshadowhook_nothing.so.

Root Cause: ShadowHook requires libshadowhook_nothing.so to be present alongside libshadowhook.so for proper shared library compatibility. When building from local sources (USE_LOCAL_DEPS=ON), this library is now automatically built as part of the CMake build process.

Subproject Builds

When building memkit as a subproject via add_subdirectory() in your parent project's CMakeLists.txt:

enable_language(ASM)  # Required for shadowhook assembly (sh_glue.S). Needs CMake 3.9+.
add_subdirectory(path/to/Android-Mem-Kit)
target_link_libraries(your_lib)

Set -DMEMKIT_BUILD_SHARED=OFF to build a static library. The default is OFF for subprojects and ON for standalone builds.

Build Output

The build process produces two files in build/<ABI>/lib/:

  • libmemkit.so - Main memkit library (~190KB for arm64-v8a with JIT)
  • libshadowhook_nothing.so - Required companion library for shared library compatibility (~1.5KB)

Both files must be packaged together in your lib/<ABI>/ directory.


Credits

This project utilizes excellent open-source libraries:

  • ShadowHook by ByteDance - Inline hooking for Android
  • XDL by HexHacking - Dynamic linker bypass
  • SLJIT - Platform-independent JIT code generation

License

MIT License - See LICENSE file for details.


Contributing

Contributions are welcome! Please read CONTRIBUTING.md first.


Support


Built for the security research community. Use responsibly.

About

A comprehensive llibrary for Android memory instrumentation.

Topics

Resources

Contributing

Security policy

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages