diff --git a/examples/retransform-class/.gitignore b/examples/retransform-class/.gitignore index 065160f..89e5bd4 100644 --- a/examples/retransform-class/.gitignore +++ b/examples/retransform-class/.gitignore @@ -3,5 +3,5 @@ out/ # Do not ignore root build artifacts: !new_target.class -!playload.jar +!payload.jar !target.jar diff --git a/examples/retransform-class/HowToUse.md b/examples/retransform-class/HowToUse.md index 07a65b1..7dc1085 100644 --- a/examples/retransform-class/HowToUse.md +++ b/examples/retransform-class/HowToUse.md @@ -10,10 +10,10 @@ | `config.toml` | Injection config | | `build.bat` | Build script | | `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`) | | `new_target.class` | Retransformed bytecode (built by `build.bat`) | -| `playload/` | Payload source | +| `payload/` | Payload source | | `target/` | Target source | | `new_target/` | Modified copy of target source | @@ -31,7 +31,7 @@ Hello! 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 `JuiceAgent.retransformClassByName("target", ...)` to swap the already-loaded `target` class on the fly. After that, `say()` starts printing the new message @@ -41,14 +41,14 @@ without restarting the JVM. ### 1. Build (optional) -`playload.jar` and `target.jar` are already included by default. -If you modified `playload/`, `target/` or `new_target/`, run: +`payload.jar` and `target.jar` are already included by default. +If you modified `payload/`, `target/` or `new_target/`, run: ``` 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 @@ -77,8 +77,8 @@ Input PID: 6644 Go back to the target window. Injection succeeded if you see: ``` -Playload loaded! -Playload executed! +Payload loaded! +Payload executed! ``` and the output of `say()` changes from `Hello!` to: @@ -92,8 +92,8 @@ Retransformed! | Key | Description | | --- | --- | -| `JarPath` | JAR path to inject (default: `./playload.jar`) | -| `EntryClass` | Entry class (default: `playload`) | +| `JarPath` | JAR path to inject (default: `./payload.jar`) | +| `EntryClass` | Entry class (default: `payload`) | | `EntryMethod` | Entry method, must be `public static void entry()` | ## Troubleshooting @@ -102,8 +102,8 @@ Retransformed! Install a JDK and add its `bin` directory to `PATH`. - `injector.exe` reports injection failure: 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. - `say()` output does not change: 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. diff --git a/examples/retransform-class/HowToUse.txt b/examples/retransform-class/HowToUse.txt index 4e63285..a498fbd 100644 --- a/examples/retransform-class/HowToUse.txt +++ b/examples/retransform-class/HowToUse.txt @@ -9,10 +9,10 @@ Directory Files: config.toml - injection config build.bat - build script 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) new_target.class - retransformed bytecode (built by build.bat) - playload/ - payload source + payload/ - payload source target/ - 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: 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 JuiceAgent.retransformClassByName("target", ...) to swap the already-loaded "target" class on the fly. After that, say() starts printing the new message @@ -37,10 +37,10 @@ without restarting the JVM. ============================================ 1. Build (optional) - playload.jar and target.jar are already included by default. - If you modified playload/, target/ or new_target/, run: + payload.jar and target.jar are already included by default. + If you modified payload/, target/ or new_target/, run: 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 Double-click run.bat (or run: java -jar target.jar). A black window @@ -57,8 +57,8 @@ without restarting the JVM. 4. Verify Go back to the target window. Injection succeeded if you see: - Playload loaded! - Playload executed! + Payload loaded! + Payload executed! and the output of say() changes from "Hello!" to: Hello! Retransformed! @@ -67,8 +67,8 @@ without restarting the JVM. Config / config.toml ============================================ - JarPath - JAR path to inject (default: ./playload.jar) - EntryClass - Entry class (default: playload) + JarPath - JAR path to inject (default: ./payload.jar) + EntryClass - Entry class (default: payload) 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. - injector.exe reports injection failure: 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. - say() output does not change: 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. diff --git a/examples/retransform-class/build.bat b/examples/retransform-class/build.bat index b186df3..dc6c6b9 100644 --- a/examples/retransform-class/build.bat +++ b/examples/retransform-class/build.bat @@ -1,13 +1,13 @@ @echo off setlocal -set "API_JAR=playload\JuiceAgent-API-1.4.1+build.1.jar" -set "PAYLOAD_JAR=playload.jar" +set "API_JAR=payload\JuiceAgent-API-1.4.1+build.1.jar" +set "PAYLOAD_JAR=payload.jar" set "TARGET_JAR=target.jar" set "OUT=out" set "OUT_NT=%OUT%\new_target" -set "OUT_PL=%OUT%\playload" +set "OUT_PL=%OUT%\payload" set "OUT_TG=%OUT%\target" 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%" if errorlevel 1 goto :error -echo === Compiling playload === -javac -encoding UTF-8 --release 8 -cp "%API_JAR%" -d "%OUT_PL%" playload\playload.java +echo === Compiling payload === +javac -encoding UTF-8 --release 8 -cp "%API_JAR%" -d "%OUT_PL%" payload\payload.java if errorlevel 1 goto :error echo === Compiling target === @@ -38,7 +38,7 @@ javac -encoding UTF-8 --release 8 -d "%OUT_TG%" target\target.java if errorlevel 1 goto :error 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 echo === Packaging target jar === diff --git a/examples/retransform-class/config.toml b/examples/retransform-class/config.toml index b5213ff..4dbf7c9 100644 --- a/examples/retransform-class/config.toml +++ b/examples/retransform-class/config.toml @@ -14,6 +14,6 @@ Mode = "BuiltIn" # InjectionDir only works when Mode is BuiltIn InjectionDir = "./injection" -JarPath = "./playload.jar" -EntryClass = "playload" +JarPath = "./payload.jar" +EntryClass = "payload" EntryMethod = "entry" diff --git a/examples/retransform-class/payload.jar b/examples/retransform-class/payload.jar new file mode 100644 index 0000000..807bffc Binary files /dev/null and b/examples/retransform-class/payload.jar differ diff --git a/examples/retransform-class/playload/JuiceAgent-API-1.4.1+build.1.jar b/examples/retransform-class/payload/JuiceAgent-API-1.4.1+build.1.jar similarity index 100% rename from examples/retransform-class/playload/JuiceAgent-API-1.4.1+build.1.jar rename to examples/retransform-class/payload/JuiceAgent-API-1.4.1+build.1.jar diff --git a/examples/retransform-class/playload/playload.java b/examples/retransform-class/payload/payload.java similarity index 83% rename from examples/retransform-class/playload/playload.java rename to examples/retransform-class/payload/payload.java index 45f6d90..24d61ef 100644 --- a/examples/retransform-class/playload/playload.java +++ b/examples/retransform-class/payload/payload.java @@ -1,8 +1,8 @@ import cn.xiaozhou233.juiceagent.api.JuiceAgent; -public class playload { +public class payload { 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.ByteArrayOutputStream out = new java.io.ByteArrayOutputStream(); @@ -20,6 +20,6 @@ public class playload { bytes.length ); - System.out.println("Playload executed!"); + System.out.println("Payload executed!"); } } \ No newline at end of file diff --git a/examples/retransform-class/playload.jar b/examples/retransform-class/playload.jar deleted file mode 100644 index 268275f..0000000 Binary files a/examples/retransform-class/playload.jar and /dev/null differ diff --git a/examples/retransform-class/如何使用.md b/examples/retransform-class/如何使用.md index 4ed9a70..17a022e 100644 --- a/examples/retransform-class/如何使用.md +++ b/examples/retransform-class/如何使用.md @@ -10,10 +10,10 @@ | `config.toml` | 注入配置 | | `build.bat` | 构建脚本 | | `run.bat` | 运行目标 JVM | -| `playload.jar` | 注入用的 JAR(由 `build.bat` 生成) | +| `payload.jar` | 注入用的 JAR(由 `build.bat` 生成) | | `target.jar` | 目标 JVM 程序(由 `build.bat` 生成) | | `new_target.class` | 重变换后的字节码(由 `build.bat` 生成) | -| `playload/` | payload 源码 | +| `payload/` | payload 源码 | | `target/` | 目标类源码 | | `new_target/` | target 的修改版源码 | @@ -31,7 +31,7 @@ Hello! Retransformed! ``` -本示例把 `playload.jar` 注入到运行中的 JVM。payload 从自己的 JAR 中读取 +本示例把 `payload.jar` 注入到运行中的 JVM。payload 从自己的 JAR 中读取 `new_target.class`,调用 `JuiceAgent.retransformClassByName("target", ...)` 在运行时动态替换已加载的 `target` 类。之后 `say()` 无需重启 JVM 就会输出新内容。 @@ -39,14 +39,14 @@ Retransformed! ### 1. 构建(可选) -`playload.jar` 和 `target.jar` 默认已包含。 -如果修改了 `playload/`、`target/` 或 `new_target/`,运行: +`payload.jar` 和 `target.jar` 默认已包含。 +如果修改了 `payload/`、`target/` 或 `new_target/`,运行: ``` build.bat ``` -重新生成 `playload.jar`、`target.jar` 和 `new_target.class`。 +重新生成 `payload.jar`、`target.jar` 和 `new_target.class`。 ### 2. 运行目标 JVM @@ -72,8 +72,8 @@ Input PID: 6644 回到目标窗口,注入成功应看到: ``` -Playload loaded! -Playload executed! +Payload loaded! +Payload executed! ``` 并且 `say()` 的输出从 `Hello!` 变为: @@ -87,8 +87,8 @@ Retransformed! | 配置项 | 说明 | | --- | --- | -| `JarPath` | 注入的 JAR 路径(默认 `./playload.jar`) | -| `EntryClass` | 入口类(默认 `playload`) | +| `JarPath` | 注入的 JAR 路径(默认 `./payload.jar`) | +| `EntryClass` | 入口类(默认 `payload`) | | `EntryMethod` | 入口方法,必须为 `public static void entry()` | ## 常见问题 @@ -97,8 +97,8 @@ Retransformed! 安装 JDK 并将 `bin` 目录加入 `PATH`。 - `injector.exe` 提示注入失败: 确认目标 JVM 正在运行且 PID 正确。 -- 没有出现 `Playload loaded!` 输出: +- 没有出现 `Payload loaded!` 输出: 查看本目录下的 `libagent.log` 和 `libloader.log` 定位原因。 - `say()` 输出没有变化: - 确认修改 `new_target/` 后重新运行过 `build.bat`,且 `playload.jar` 内的 + 确认修改 `new_target/` 后重新运行过 `build.bat`,且 `payload.jar` 内的 `new_target.class` 是最新的。 diff --git a/examples/retransform-class/如何使用.txt b/examples/retransform-class/如何使用.txt index 74fe9ad..fbc40cc 100644 --- a/examples/retransform-class/如何使用.txt +++ b/examples/retransform-class/如何使用.txt @@ -9,10 +9,10 @@ config.toml - 注入配置 build.bat - 构建脚本 run.bat - 运行目标 JVM - playload.jar - 注入用的 JAR (由 build.bat 生成) + payload.jar - 注入用的 JAR (由 build.bat 生成) target.jar - 目标 JVM 程序 (由 build.bat 生成) new_target.class - 重变换后的字节码 (由 build.bat 生成) - playload/ - payload 源码 + payload/ - payload 源码 target/ - 目标类源码 new_target/ - target 的修改版源码 @@ -26,7 +26,7 @@ new_target/target.java 是它的修改版, 额外打印: Retransformed! -本示例把 playload.jar 注入到运行中的 JVM。payload 从自己的 JAR 中读取 +本示例把 payload.jar 注入到运行中的 JVM。payload 从自己的 JAR 中读取 new_target.class, 调用 JuiceAgent.retransformClassByName("target", ...) 在运行时动态替换已加载的 "target" 类。之后 say() 无需重启 JVM 就会输出新内容。 @@ -35,10 +35,10 @@ new_target.class, 调用 JuiceAgent.retransformClassByName("target", ...) ============================================ 1. 构建 (可选) - playload.jar 和 target.jar 默认已包含。 - 如果修改了 playload/、target/ 或 new_target/, 运行: + payload.jar 和 target.jar 默认已包含。 + 如果修改了 payload/、target/ 或 new_target/, 运行: build.bat - 重新生成 playload.jar、target.jar 和 new_target.class。 + 重新生成 payload.jar、target.jar 和 new_target.class。 2. 运行目标 JVM 双击 run.bat (或执行: java -jar target.jar)。黑窗口出现并每秒打印: @@ -53,8 +53,8 @@ new_target.class, 调用 JuiceAgent.retransformClassByName("target", ...) 4. 验证 回到目标窗口, 注入成功应看到: - Playload loaded! - Playload executed! + Payload loaded! + Payload executed! 并且 say() 的输出从 "Hello!" 变为: Hello! Retransformed! @@ -63,8 +63,8 @@ new_target.class, 调用 JuiceAgent.retransformClassByName("target", ...) 配置 / config.toml ============================================ - JarPath - 注入的 JAR 路径 (默认: ./playload.jar) - EntryClass - 入口类 (默认: playload) + JarPath - 注入的 JAR 路径 (默认: ./payload.jar) + EntryClass - 入口类 (默认: payload) EntryMethod - 入口方法, 必须为 public static void entry() ============================================ @@ -75,8 +75,8 @@ new_target.class, 调用 JuiceAgent.retransformClassByName("target", ...) 安装 JDK 并将 bin 目录加入 PATH。 - injector.exe 提示注入失败: 确认目标 JVM 正在运行且 PID 正确。 -- 没有出现 "Playload loaded!" 输出: +- 没有出现 "Payload loaded!" 输出: 查看本目录下的 libagent.log 和 libloader.log 定位原因。 - say() 输出没有变化: - 确认修改 new_target/ 后重新运行过 build.bat, 且 playload.jar 内的 + 确认修改 new_target/ 后重新运行过 build.bat, 且 payload.jar 内的 new_target.class 是最新的。