BugFix: fix playload typo in retransform-class example [skip ci]

- examples: rename playload to payload (directory, class, jar, config, docs)

- payload.jar: rebuild with payload.class
This commit is contained in:
xiaozhou233 committed 2026-10-17 13:21:42 +08:00
1 parent 8cd4c54c07
commit 6a43b3437a
11 files changed
+60 -60

No files matched your search

+1 -1
View File
@@ -3,5 +3,5 @@ out/
# Do not ignore root build artifacts: # Do not ignore root build artifacts:
!new_target.class !new_target.class
!playload.jar !payload.jar
!target.jar !target.jar
+12 -12
View File
@@ -10,10 +10,10 @@
| `config.toml` | Injection config | | `config.toml` | Injection config |
| `build.bat` | Build script | | `build.bat` | Build script |
| `run.bat` | Run target JVM | | `run.bat` | Run target JVM |
| `playload.jar` | JAR to inject (built by `build.bat`) | | `payload.jar` | JAR to inject (built by `build.bat`) |
| `target.jar` | Target JVM program (built by `build.bat`) | | `target.jar` | Target JVM program (built by `build.bat`) |
| `new_target.class` | Retransformed bytecode (built by `build.bat`) | | `new_target.class` | Retransformed bytecode (built by `build.bat`) |
| `playload/` | Payload source | | `payload/` | Payload source |
| `target/` | Target source | | `target/` | Target source |
| `new_target/` | Modified copy of target source | | `new_target/` | Modified copy of target source |
@@ -31,7 +31,7 @@ Hello!
Retransformed! Retransformed!
``` ```
This example injects `playload.jar` into a running JVM. The payload reads This example injects `payload.jar` into a running JVM. The payload reads
`new_target.class` from its own JAR and calls `new_target.class` from its own JAR and calls
`JuiceAgent.retransformClassByName("target", ...)` to swap the already-loaded `JuiceAgent.retransformClassByName("target", ...)` to swap the already-loaded
`target` class on the fly. After that, `say()` starts printing the new message `target` class on the fly. After that, `say()` starts printing the new message
@@ -41,14 +41,14 @@ without restarting the JVM.
### 1. Build (optional) ### 1. Build (optional)
`playload.jar` and `target.jar` are already included by default. `payload.jar` and `target.jar` are already included by default.
If you modified `playload/`, `target/` or `new_target/`, run: If you modified `payload/`, `target/` or `new_target/`, run:
``` ```
build.bat build.bat
``` ```
to regenerate `playload.jar`, `target.jar` and `new_target.class`. to regenerate `payload.jar`, `target.jar` and `new_target.class`.
### 2. Run the target JVM ### 2. Run the target JVM
@@ -77,8 +77,8 @@ Input PID: 6644
Go back to the target window. Injection succeeded if you see: Go back to the target window. Injection succeeded if you see:
``` ```
Playload loaded! Payload loaded!
Playload executed! Payload executed!
``` ```
and the output of `say()` changes from `Hello!` to: and the output of `say()` changes from `Hello!` to:
@@ -92,8 +92,8 @@ Retransformed!
| Key | Description | | Key | Description |
| --- | --- | | --- | --- |
| `JarPath` | JAR path to inject (default: `./playload.jar`) | | `JarPath` | JAR path to inject (default: `./payload.jar`) |
| `EntryClass` | Entry class (default: `playload`) | | `EntryClass` | Entry class (default: `payload`) |
| `EntryMethod` | Entry method, must be `public static void entry()` | | `EntryMethod` | Entry method, must be `public static void entry()` |
## Troubleshooting ## Troubleshooting
@@ -102,8 +102,8 @@ Retransformed!
Install a JDK and add its `bin` directory to `PATH`. Install a JDK and add its `bin` directory to `PATH`.
- `injector.exe` reports injection failure: - `injector.exe` reports injection failure:
Make sure the target JVM is running and the PID is correct. Make sure the target JVM is running and the PID is correct.
- No `Playload loaded!` output appears: - No `Payload loaded!` output appears:
Check `libagent.log` and `libloader.log` in this directory for the cause. Check `libagent.log` and `libloader.log` in this directory for the cause.
- `say()` output does not change: - `say()` output does not change:
Make sure `build.bat` was run after editing `new_target/`, and that Make sure `build.bat` was run after editing `new_target/`, and that
`new_target.class` inside `playload.jar` is up to date. `new_target.class` inside `payload.jar` is up to date.
+12 -12
View File
@@ -9,10 +9,10 @@ Directory Files:
config.toml - injection config config.toml - injection config
build.bat - build script build.bat - build script
run.bat - run target JVM run.bat - run target JVM
playload.jar - JAR to inject (built by build.bat) payload.jar - JAR to inject (built by build.bat)
target.jar - target JVM program (built by build.bat) target.jar - target JVM program (built by build.bat)
new_target.class - retransformed bytecode (built by build.bat) new_target.class - retransformed bytecode (built by build.bat)
playload/ - payload source payload/ - payload source
target/ - target source target/ - target source
new_target/ - modified copy of target source new_target/ - modified copy of target source
@@ -26,7 +26,7 @@ The target class "target" has a method say() that prints:
new_target/target.java is a modified copy that also prints: new_target/target.java is a modified copy that also prints:
Retransformed! Retransformed!
This example injects playload.jar into a running JVM. The payload reads This example injects payload.jar into a running JVM. The payload reads
new_target.class from its own JAR and calls new_target.class from its own JAR and calls
JuiceAgent.retransformClassByName("target", ...) to swap the already-loaded JuiceAgent.retransformClassByName("target", ...) to swap the already-loaded
"target" class on the fly. After that, say() starts printing the new message "target" class on the fly. After that, say() starts printing the new message
@@ -37,10 +37,10 @@ without restarting the JVM.
============================================ ============================================
1. Build (optional) 1. Build (optional)
playload.jar and target.jar are already included by default. payload.jar and target.jar are already included by default.
If you modified playload/, target/ or new_target/, run: If you modified payload/, target/ or new_target/, run:
build.bat build.bat
to regenerate playload.jar, target.jar and new_target.class. to regenerate payload.jar, target.jar and new_target.class.
2. Run the target JVM 2. Run the target JVM
Double-click run.bat (or run: java -jar target.jar). A black window Double-click run.bat (or run: java -jar target.jar). A black window
@@ -57,8 +57,8 @@ without restarting the JVM.
4. Verify 4. Verify
Go back to the target window. Injection succeeded if you see: Go back to the target window. Injection succeeded if you see:
Playload loaded! Payload loaded!
Playload executed! Payload executed!
and the output of say() changes from "Hello!" to: and the output of say() changes from "Hello!" to:
Hello! Hello!
Retransformed! Retransformed!
@@ -67,8 +67,8 @@ without restarting the JVM.
Config / config.toml Config / config.toml
============================================ ============================================
JarPath - JAR path to inject (default: ./playload.jar) JarPath - JAR path to inject (default: ./payload.jar)
EntryClass - Entry class (default: playload) EntryClass - Entry class (default: payload)
EntryMethod - Entry method, must be public static void entry() EntryMethod - Entry method, must be public static void entry()
============================================ ============================================
@@ -79,8 +79,8 @@ without restarting the JVM.
Install a JDK and add its bin directory to PATH. Install a JDK and add its bin directory to PATH.
- injector.exe reports injection failure: - injector.exe reports injection failure:
Make sure the target JVM is running and the PID is correct. Make sure the target JVM is running and the PID is correct.
- No "Playload loaded!" output appears: - No "Payload loaded!" output appears:
Check libagent.log and libloader.log in this directory for the cause. Check libagent.log and libloader.log in this directory for the cause.
- say() output does not change: - say() output does not change:
Make sure build.bat was run after editing new_target/, and that Make sure build.bat was run after editing new_target/, and that
new_target.class inside playload.jar is up to date. new_target.class inside payload.jar is up to date.
+6 -6
View File
@@ -1,13 +1,13 @@
@echo off @echo off
setlocal setlocal
set "API_JAR=playload\JuiceAgent-API-1.4.1+build.1.jar" set "API_JAR=payload\JuiceAgent-API-1.4.1+build.1.jar"
set "PAYLOAD_JAR=playload.jar" set "PAYLOAD_JAR=payload.jar"
set "TARGET_JAR=target.jar" set "TARGET_JAR=target.jar"
set "OUT=out" set "OUT=out"
set "OUT_NT=%OUT%\new_target" set "OUT_NT=%OUT%\new_target"
set "OUT_PL=%OUT%\playload" set "OUT_PL=%OUT%\payload"
set "OUT_TG=%OUT%\target" set "OUT_TG=%OUT%\target"
set "NEW_TARGET_CLASS=new_target.class" set "NEW_TARGET_CLASS=new_target.class"
@@ -29,8 +29,8 @@ if errorlevel 1 goto :error
copy /y "%OUT_NT%\new_target.class" "%NEW_TARGET_CLASS%" copy /y "%OUT_NT%\new_target.class" "%NEW_TARGET_CLASS%"
if errorlevel 1 goto :error if errorlevel 1 goto :error
echo === Compiling playload === echo === Compiling payload ===
javac -encoding UTF-8 --release 8 -cp "%API_JAR%" -d "%OUT_PL%" playload\playload.java javac -encoding UTF-8 --release 8 -cp "%API_JAR%" -d "%OUT_PL%" payload\payload.java
if errorlevel 1 goto :error if errorlevel 1 goto :error
echo === Compiling target === echo === Compiling target ===
@@ -38,7 +38,7 @@ javac -encoding UTF-8 --release 8 -d "%OUT_TG%" target\target.java
if errorlevel 1 goto :error if errorlevel 1 goto :error
echo === Packaging payload jar === echo === Packaging payload jar ===
jar --create --file "%PAYLOAD_JAR%" -C "%OUT_PL%" playload.class jar --create --file "%PAYLOAD_JAR%" -C "%OUT_PL%" payload.class
if errorlevel 1 goto :error if errorlevel 1 goto :error
echo === Packaging target jar === echo === Packaging target jar ===
+2 -2
View File
@@ -14,6 +14,6 @@ Mode = "BuiltIn"
# InjectionDir only works when Mode is BuiltIn # InjectionDir only works when Mode is BuiltIn
InjectionDir = "./injection" InjectionDir = "./injection"
JarPath = "./playload.jar" JarPath = "./payload.jar"
EntryClass = "playload" EntryClass = "payload"
EntryMethod = "entry" EntryMethod = "entry"
Binary file not shown.
@@ -1,8 +1,8 @@
import cn.xiaozhou233.juiceagent.api.JuiceAgent; import cn.xiaozhou233.juiceagent.api.JuiceAgent;
public class playload { public class payload {
public static void entry() throws java.io.IOException { public static void entry() throws java.io.IOException {
System.out.println("Playload loaded!"); System.out.println("Payload loaded!");
java.io.InputStream in = new java.io.FileInputStream("new_target.class"); java.io.InputStream in = new java.io.FileInputStream("new_target.class");
java.io.ByteArrayOutputStream out = new java.io.ByteArrayOutputStream(); java.io.ByteArrayOutputStream out = new java.io.ByteArrayOutputStream();
@@ -20,6 +20,6 @@ public class playload {
bytes.length bytes.length
); );
System.out.println("Playload executed!"); System.out.println("Payload executed!");
} }
} }
Binary file not shown.
+12 -12
View File
@@ -10,10 +10,10 @@
| `config.toml` | 注入配置 | | `config.toml` | 注入配置 |
| `build.bat` | 构建脚本 | | `build.bat` | 构建脚本 |
| `run.bat` | 运行目标 JVM | | `run.bat` | 运行目标 JVM |
| `playload.jar` | 注入用的 JAR(由 `build.bat` 生成) | | `payload.jar` | 注入用的 JAR(由 `build.bat` 生成) |
| `target.jar` | 目标 JVM 程序(由 `build.bat` 生成) | | `target.jar` | 目标 JVM 程序(由 `build.bat` 生成) |
| `new_target.class` | 重变换后的字节码(由 `build.bat` 生成) | | `new_target.class` | 重变换后的字节码(由 `build.bat` 生成) |
| `playload/` | payload 源码 | | `payload/` | payload 源码 |
| `target/` | 目标类源码 | | `target/` | 目标类源码 |
| `new_target/` | target 的修改版源码 | | `new_target/` | target 的修改版源码 |
@@ -31,7 +31,7 @@ Hello!
Retransformed! Retransformed!
``` ```
本示例把 `playload.jar` 注入到运行中的 JVM。payload 从自己的 JAR 中读取 本示例把 `payload.jar` 注入到运行中的 JVM。payload 从自己的 JAR 中读取
`new_target.class`,调用 `JuiceAgent.retransformClassByName("target", ...)` `new_target.class`,调用 `JuiceAgent.retransformClassByName("target", ...)`
在运行时动态替换已加载的 `target` 类。之后 `say()` 无需重启 JVM 就会输出新内容。 在运行时动态替换已加载的 `target` 类。之后 `say()` 无需重启 JVM 就会输出新内容。
@@ -39,14 +39,14 @@ Retransformed!
### 1. 构建(可选) ### 1. 构建(可选)
`playload.jar` 和 `target.jar` 默认已包含。 `payload.jar` 和 `target.jar` 默认已包含。
如果修改了 `playload/`、`target/` 或 `new_target/`,运行: 如果修改了 `payload/`、`target/` 或 `new_target/`,运行:
``` ```
build.bat build.bat
``` ```
重新生成 `playload.jar`、`target.jar` 和 `new_target.class`。 重新生成 `payload.jar`、`target.jar` 和 `new_target.class`。
### 2. 运行目标 JVM ### 2. 运行目标 JVM
@@ -72,8 +72,8 @@ Input PID: 6644
回到目标窗口,注入成功应看到: 回到目标窗口,注入成功应看到:
``` ```
Playload loaded! Payload loaded!
Playload executed! Payload executed!
``` ```
并且 `say()` 的输出从 `Hello!` 变为: 并且 `say()` 的输出从 `Hello!` 变为:
@@ -87,8 +87,8 @@ Retransformed!
| 配置项 | 说明 | | 配置项 | 说明 |
| --- | --- | | --- | --- |
| `JarPath` | 注入的 JAR 路径(默认 `./playload.jar`) | | `JarPath` | 注入的 JAR 路径(默认 `./payload.jar`) |
| `EntryClass` | 入口类(默认 `playload`) | | `EntryClass` | 入口类(默认 `payload`) |
| `EntryMethod` | 入口方法,必须为 `public static void entry()` | | `EntryMethod` | 入口方法,必须为 `public static void entry()` |
## 常见问题 ## 常见问题
@@ -97,8 +97,8 @@ Retransformed!
安装 JDK 并将 `bin` 目录加入 `PATH`。 安装 JDK 并将 `bin` 目录加入 `PATH`。
- `injector.exe` 提示注入失败: - `injector.exe` 提示注入失败:
确认目标 JVM 正在运行且 PID 正确。 确认目标 JVM 正在运行且 PID 正确。
- 没有出现 `Playload loaded!` 输出: - 没有出现 `Payload loaded!` 输出:
查看本目录下的 `libagent.log` 和 `libloader.log` 定位原因。 查看本目录下的 `libagent.log` 和 `libloader.log` 定位原因。
- `say()` 输出没有变化: - `say()` 输出没有变化:
确认修改 `new_target/` 后重新运行过 `build.bat`,且 `playload.jar` 内的 确认修改 `new_target/` 后重新运行过 `build.bat`,且 `payload.jar` 内的
`new_target.class` 是最新的。 `new_target.class` 是最新的。
+12 -12
View File
@@ -9,10 +9,10 @@
config.toml - 注入配置 config.toml - 注入配置
build.bat - 构建脚本 build.bat - 构建脚本
run.bat - 运行目标 JVM run.bat - 运行目标 JVM
playload.jar - 注入用的 JAR (由 build.bat 生成) payload.jar - 注入用的 JAR (由 build.bat 生成)
target.jar - 目标 JVM 程序 (由 build.bat 生成) target.jar - 目标 JVM 程序 (由 build.bat 生成)
new_target.class - 重变换后的字节码 (由 build.bat 生成) new_target.class - 重变换后的字节码 (由 build.bat 生成)
playload/ - payload 源码 payload/ - payload 源码
target/ - 目标类源码 target/ - 目标类源码
new_target/ - target 的修改版源码 new_target/ - target 的修改版源码
@@ -26,7 +26,7 @@
new_target/target.java 是它的修改版, 额外打印: new_target/target.java 是它的修改版, 额外打印:
Retransformed! Retransformed!
本示例把 playload.jar 注入到运行中的 JVM。payload 从自己的 JAR 中读取 本示例把 payload.jar 注入到运行中的 JVM。payload 从自己的 JAR 中读取
new_target.class, 调用 JuiceAgent.retransformClassByName("target", ...) new_target.class, 调用 JuiceAgent.retransformClassByName("target", ...)
在运行时动态替换已加载的 "target" 类。之后 say() 无需重启 JVM 就会输出新内容。 在运行时动态替换已加载的 "target" 类。之后 say() 无需重启 JVM 就会输出新内容。
@@ -35,10 +35,10 @@ new_target.class, 调用 JuiceAgent.retransformClassByName("target", ...)
============================================ ============================================
1. 构建 (可选) 1. 构建 (可选)
playload.jar 和 target.jar 默认已包含。 payload.jar 和 target.jar 默认已包含。
如果修改了 playload/、target/ 或 new_target/, 运行: 如果修改了 payload/、target/ 或 new_target/, 运行:
build.bat build.bat
重新生成 playload.jar、target.jar 和 new_target.class。 重新生成 payload.jar、target.jar 和 new_target.class。
2. 运行目标 JVM 2. 运行目标 JVM
双击 run.bat (或执行: java -jar target.jar)。黑窗口出现并每秒打印: 双击 run.bat (或执行: java -jar target.jar)。黑窗口出现并每秒打印:
@@ -53,8 +53,8 @@ new_target.class, 调用 JuiceAgent.retransformClassByName("target", ...)
4. 验证 4. 验证
回到目标窗口, 注入成功应看到: 回到目标窗口, 注入成功应看到:
Playload loaded! Payload loaded!
Playload executed! Payload executed!
并且 say() 的输出从 "Hello!" 变为: 并且 say() 的输出从 "Hello!" 变为:
Hello! Hello!
Retransformed! Retransformed!
@@ -63,8 +63,8 @@ new_target.class, 调用 JuiceAgent.retransformClassByName("target", ...)
配置 / config.toml 配置 / config.toml
============================================ ============================================
JarPath - 注入的 JAR 路径 (默认: ./playload.jar) JarPath - 注入的 JAR 路径 (默认: ./payload.jar)
EntryClass - 入口类 (默认: playload) EntryClass - 入口类 (默认: payload)
EntryMethod - 入口方法, 必须为 public static void entry() EntryMethod - 入口方法, 必须为 public static void entry()
============================================ ============================================
@@ -75,8 +75,8 @@ new_target.class, 调用 JuiceAgent.retransformClassByName("target", ...)
安装 JDK 并将 bin 目录加入 PATH。 安装 JDK 并将 bin 目录加入 PATH。
- injector.exe 提示注入失败: - injector.exe 提示注入失败:
确认目标 JVM 正在运行且 PID 正确。 确认目标 JVM 正在运行且 PID 正确。
- 没有出现 "Playload loaded!" 输出: - 没有出现 "Payload loaded!" 输出:
查看本目录下的 libagent.log 和 libloader.log 定位原因。 查看本目录下的 libagent.log 和 libloader.log 定位原因。
- say() 输出没有变化: - say() 输出没有变化:
确认修改 new_target/ 后重新运行过 build.bat, 且 playload.jar 内的 确认修改 new_target/ 后重新运行过 build.bat, 且 payload.jar 内的
new_target.class 是最新的。 new_target.class 是最新的。