Docs: Readme

This commit is contained in:
xiaozhou233 committed 2026-04-21 14:55:24 +08:00
1 parent 92837c9597
commit bc2440eeab
3 files changed
+27 -153

No files matched your search

+26 -6
View File
@@ -1,6 +1,8 @@
# JuiceAgent
JuiceAgent is an advanced JVMTI-based injection framework designed for runtime JAR loading, bytecode transformation, and deep JVM instrumentation, even with DisableAttachMechanism enabled.
JuiceAgent is an advanced JVMTI-based injection framework designed for runtime JAR loading, bytecode transformation, and runtime JVM instrumentation, even when DisableAttachMechanism is enabled.
**Warning**: This project is still experimental and is not recommended for production use. Use it at your own risk.
![License](https://img.shields.io/github/license/xiaozhou233/JuiceAgent)
![Release](https://img.shields.io/github/v/release/xiaozhou233/JuiceAgent)
@@ -19,16 +21,34 @@ JuiceAgent is an advanced JVMTI-based injection framework designed for runtime J
![Attach](https://img.shields.io/badge/DisableAttach-Bypass-important)
## Introduction
JuiceAgent is a JVMTI-native injection framework for loading external JARs and redefining or retransformation Java bytecode in a target JVM without requiring a javaagent. It also works when DisableAttachMechanism=true.
JuiceAgent is a JVMTI-native injection framework for loading external JARs and redefining or retransformation of Java classes in a target JVM without requiring -javaagent startup arguments or attach javaagent. It also works when DisableAttachMechanism=true.
With JuiceAgent, developers can:
- Dynamically load external JARs into a running JVM process
- Execute custom Java code after injection
- Invoke a specified entry class and method after injection
- Redefine already loaded classes at runtime
- Retransform bytecode for instrumentation or modification
- And more...
## Index
- [JuiceAgent](#juiceagent)
- [Introduction](#introduction)
- [Index](#index)
- [Features](#features)
- [Quick Start](#quick-start)
- [1. Download Release](#1-download-release)
- [2. Copy your custom JAR/Dependencies to Directory](#2-copy-your-custom-jardependencies-to-directory)
- [3. Write Config](#3-write-config)
- [4. Run the Injector](#4-run-the-injector)
- [Method A: Use `injector.exe`](#method-a-use-injectorexe)
- [Method B: Use JNI to call `inject`](#method-b-use-jni-to-call-inject)
- [5. Done](#5-done)
- [How To Build](#how-to-build)
- [Requirements](#requirements)
- [Build with CMake Presets](#build-with-cmake-presets)
- [Manual Build](#manual-build)
- [Full Disclaimer](#full-disclaimer)
- [Acknowledgements](#acknowledgements)
## Features
This project is the native implementation of JuiceAgent-API. See [JuiceAgent.java](https://github.com/xiaozhou233/JuiceAgent-API/blob/master/src/main/java/cn/xiaozhou233/juiceagent/api/JuiceAgent.java) for the API definition.
@@ -62,7 +82,7 @@ Put the downloaded files into the same directory.
- libinject.dll
- libloader.dll
- injector.exe
- **MyCustonJar.jar**
- **MyCustomJar.jar**
- **injection**
- **Dependencies1.jar**
- **Dependencies2.jar**
@@ -86,7 +106,7 @@ Enabled = true
# Path to the Injection JAR files to be loaded
InjectionDir = "./injection"
# Path to the JAR file to be loaded
JarPath = "./MyCustonJar.jar"
JarPath = "./MyCustomJar.jar"
# Entry class to be executed after loading the JAR
EntryClass = "Example.Main"
# Entry method to be executed after loading the JAR
@@ -102,7 +122,7 @@ Save the config file as `config.toml`.
- libinject.dll
- libloader.dll
- injector.exe
- MyCustonJar.jar
- MyCustomJar.jar
- injection
- Dependencies1.jar
- Dependencies2.jar
-146
View File
@@ -1,146 +0,0 @@
# JuiceAgent
[English](https://github.com/xiaozhou233/JuiceAgent/blob/main/README.md) | [中文](https://github.com/xiaozhou233/JuiceAgent/blob/main/README_zh.md)
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.3 Build 1**.
**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](https://github.com/xiaozhou233/JuiceAgent-API/blob/master/src/main/java/cn/xiaozhou233/juiceagent/api/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](https://github.com/xiaozhou233/JuiceAgent/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](https://github.com/xiaozhou233/JuiceAgent-API/releases) and place it in `YourDir`.
### 2. Write the Config File
Create a file named `config.toml` in `YourDir`.
```toml
[JuiceAgent]
Version = 1
[JuiceAgent.Loader]
JuiceAgentAPIJarPath = ""
JuiceAgentNativeLibraryPath = ""
[JuiceAgent.Modules]
[JuiceAgent.Modules.JarLoader]
Enabled = true
InjectionDir = ""
JarPath = ""
EntryClass = ""
EntryMethod = ""
```
### 3. Run the Injector
#### Method A: Use `injector.exe`
Run `injector.exe` from `YourDir`.
```text
<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:
```java
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:
```java
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
```powershell
git clone https://github.com/xiaozhou233/JuiceAgent.git
cd JuiceAgent
cmake --preset ninja-release
cmake --build build
```
### Manual Build
```powershell
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](https://github.com/xiaozhou233/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](https://github.com/stephenfewer/ReflectiveDLLInjection) - DLL injection implementation
- [plog](https://github.com/SergiusTheBest/plog) - Portable, simple, and extensible C++ logging library
- [tinytoml](https://github.com/mayah/tinytoml) - Header-only C++11 TOML parser
- [eventpp](https://github.com/wqking/eventpp) - C++ library for event dispatchers and callback lists
+1 -1
View File
@@ -19,4 +19,4 @@
- [x] 统一调用 module的Java实现
## 2026-04-20
- [ ] 修改文档
- [x] 修改文档