2026-04-19 19:03:48 +08:00
2026-04-19 15:44:06 +08:00
2026-04-19 16:41:39 +08:00
2026-04-19 19:03:48 +08:00
2025-10-20 05:17:25 +08:00
2026-04-02 12:51:23 +08:00
2025-10-08 16:51:16 +08:00
2026-04-16 15:35:41 +08:00
2026-04-16 15:35:41 +08:00
2026-04-17 14:24:48 +08:00

JuiceAgent

English | 中文

JuiceAgent is a JVMTI-based injection library for loading external JARs and transforming Java bytecode, even when DisableAttachMechanism is enabled.

Notice: Currently, only Windows is supported. Linux support may be added in the future.

Notice: The current repository version is Version 3.1 Build 3.

Warning: This project is still experimental and is not recommended for production use. Use it at your own risk.

Summary

JuiceAgent is a JVMTI-native injection framework that injects native code into a target JVM to dynamically load external JARs and perform bytecode redefinition or retransformation without requiring a javaagent. It can still work when DisableAttachMechanism=true.

Features

This project is the native implementation of JuiceAgent-API. For the API definition, see JuiceAgent.java.

  • addToBootstrapClassLoaderSearch
  • addToSystemClassLoaderSearch
  • addToClassLoader
  • defineClass
  • redefineClass(ByName)
  • retransformClass(ByName)
  • getLoadedClasses
  • getClassByName
  • getClassBytes(ByName)

How To Use

1. Download Files

Download the following files from Releases and place them in YourDir:

  • libagent.dll
  • libinject.dll
  • libloader.dll
  • injector.exe

Download JuiceAgent-API-X.X.X+build.X.jar from JuiceAgent-API Releases and place it in YourDir.

2. Write the Config File

Create a file named config.toml in YourDir.

[JuiceAgent]
# Default value: YourDir/JuiceAgent-API.jar
JuiceAgentAPIJarPath = ""
# Default value: YourDir/libagent.dll
JuiceAgentNativePath = ""

[Entry]
# Default value: YourDir/Entry.jar
EntryJarPath = ""
# Default value: com.example.Entry
EntryClass = ""
# Default value: start
EntryMethod = "start"

[Runtime]
# Default value: YourDir/injection
InjectionDir = ""

3. Run the Injector

Method A: Use injector.exe

Run injector.exe from YourDir.

<jps output>
Input PID:

Enter the PID of the target JVM process and press Enter.

Method B: Use JNI to call inject

Create cn/xiaozhou233/juiceagent/injector/InjectorNative.java in your project:

package cn.xiaozhou233.juiceagent.injector;

public class InjectorNative {
    /*
     * @param pid target process id
     * @param path injection DLL path
     */
    public native boolean inject(int pid, String path);

    /*
     * @param pid target process id
     * @param path injection DLL path
     * @param configDir directory containing config.toml
     */
    public native boolean inject(int pid, String path, String configDir);
}

Example:

import cn.xiaozhou233.juiceagent.injector.InjectorNative;

System.load("<path-to-libinject>");
InjectorNative injectorNative = new InjectorNative();

injectorNative.inject(<pid>, "<path-to-libloader>", "<path-to-config-directory>");

4. Done

If the injection succeeds, the target process will load Entry.jar (or the file specified by EntryJarPath) and invoke EntryClass.EntryMethod (default: com.example.Entry.start).

How To Build

Requirements

  • Java 8+
  • MinGW
  • CMake 3.15+
  • Ninja

Build with CMake Presets

git clone https://github.com/xiaozhou233/JuiceAgent.git
cd JuiceAgent

cmake --preset ninja-release
cmake --build build

Manual Build

git clone https://github.com/xiaozhou233/JuiceAgent.git
cd JuiceAgent

cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release
cmake --build build

The generated binaries will be placed in build/bin.

JuiceAgent-API.jar can be built from or downloaded from JuiceAgent-API.

Full Disclaimer

This project is intended for learning and research in controlled environments only. The author is not responsible for any consequences arising from unauthorized use, modification, cracking, or violation of any applicable agreements or laws. Users are responsible for ensuring that their actions are legal and compliant.

Acknowledgements

  • ReflectiveDLLInjection - DLL injection implementation
  • plog - Portable, simple, and extensible C++ logging library
  • tinytoml - Header-only C++11 TOML parser
  • eventpp - C++ library for event dispatchers and callback lists
Languages
C++ 83%
C 15.5%
Java 0.6%
Shell 0.3%
PowerShell 0.3%
Other 0.3%