### Common RustFrida Workflows Source: https://github.com/kkkbbb/rustfrida/blob/master/README.md Examples of common RustFrida workflows, including injecting into running processes, spawning applications, and entering an interactive session. ```bash # 已运行的进程 ./rustfrida --pid -l script.js # 从启动阶段注入,适合抓 Application / ClassLoader 初始化 ./rustfrida --spawn com.example.app -l script.js # 先进入交互,再手动 loadjs / jseval ./rustfrida --pid ``` -------------------------------- ### Remote Call Example with curl Source: https://github.com/kkkbbb/rustfrida/blob/master/README.md Demonstrates how to forward a local port and use `curl` to make RPC calls to a RustFrida script running with `--rpc-port`. This is a common way to interact with persistent agents. ```bash adb forward tcp:9191 tcp:9191 ./rustfrida --pid -l script.js --rpc-port 9191 curl -X POST http://127.0.0.1:9191/rpc/0/ping ``` -------------------------------- ### Successful Validation Output Example Source: https://github.com/kkkbbb/rustfrida/blob/master/doc/managed-dsl.md Example of successful route stats output indicating zero orig-bypass hits and no failures. The exact counts may vary. ```text managed=354184,orig=0,set=0,fail=0,active=0,backup=0 ``` -------------------------------- ### Documentation Structure Hierarchy Source: https://github.com/kkkbbb/rustfrida/blob/master/_autodocs/COMPLETION-REPORT.md Illustrates the hierarchical organization of the generated rustfrida documentation, starting from the main README.md and branching out to specific module documentation files. ```markdown README.md(总览) ├── api-architecture.md(架构) ├── command-line-interface.md(CLI) ├── javascript-api.md(JS API) ├── java-hook-api.md(Java 操作) ├── jni-api.md(JNI 访问) ├── http-rpc-api.md(RPC 服务) ├── process-and-injection.md(注入机制) ├── types-and-structures.md(类型定义) └── build-and-configuration.md(构建) ``` -------------------------------- ### Hook Java Method and Call Original Implementation Source: https://github.com/kkkbbb/rustfrida/blob/master/README.md Example of hooking a Java method, logging its arguments, and then calling the original implementation using `$orig()`. This is useful for observing behavior while maintaining original functionality. ```javascript Java.ready(function() { var Log = Java.use("android.util.Log"); Log.i.overload("java.lang.String", "java.lang.String").impl = function(tag, msg) { console.log("[Log.i]", tag, msg); return this.$orig(tag, msg); }; }); ``` -------------------------------- ### Basic HashMap put Hook with Managed DSL Source: https://github.com/kkkbbb/rustfrida/blob/master/doc/managed-dsl.md Demonstrates hooking the `put` method of `java.util.HashMap` using the Managed DSL. It compiles the hook logic into a dex helper for high-frequency scenarios. Ensure `Java.ready` is used to wrap the hook setup. ```javascript Java.ready(function () { Java.compileMethod( "java.util.HashMap", "put", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", "auto" ); Java._resetArtRouteStats(); Java.managedHookDsl({ className: "java.util.HashMap", methodName: "put", signature: "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", dsl: "let n: int = this.size();" + "let plus: int = n + 1;" + "let sb: java.lang.StringBuilder = java.lang.StringBuilder.$new(\"seed\");" + "if (arg0 instanceof java.lang.String) {" + " let keyLen: int = (arg0 as java.lang.String).length();" + " sb.append(arg0);" + "}" + "new int[](3);" + "let a: int[] = last;" + "a[0] = plus;" + "if (plus > 0) {" + " return orig(arg0, arg1);" + "} else {" + " return orig(arg0, arg1);" + "}" }); }); ``` -------------------------------- ### GET /sessions Source: https://github.com/kkkbbb/rustfrida/blob/master/_autodocs/http-rpc-api.md Lists all active sessions. The response format differs slightly between legacy and server modes. ```APIDOC ## GET /sessions ### Description Lists all active sessions. The response format may vary depending on the operating mode (legacy vs. server). ### Method GET ### Endpoint /sessions ### Response #### Success Response (200) - **id** (integer) - The session identifier. - **pid** (integer) - The Process ID (PID) of the target process. - **label** (string) - A display label for the session (e.g., "PID:1234" or package name). - **status** (string) - The connection status of the session (e.g., "connected", "disconnected"). #### Response Example (Legacy Mode) ```json [ { "id": 0, "pid": 1234, "label": "PID:1234", "status": "connected" } ] ``` #### Response Example (Server Mode) ```json [ { "id": 0, "pid": 2000, "label": "...", "status": "connected" }, { "id": 1, "pid": 2001, "label": "...", "status": "connected" }, { "id": 2, "pid": 2002, "label": "...", "status": "disconnected" } ] ``` ``` -------------------------------- ### Get Java Class Reference Source: https://github.com/kkkbbb/rustfrida/blob/master/_autodocs/java-hook-api.md Use `Java.use` to obtain a wrapper for a Java class. This wrapper allows access to static methods, fields, and constructors. ```javascript var Activity = Java.use("android.app.Activity"); var Log = Java.use("android.util.Log"); var String = Java.use("java.lang.String"); ``` -------------------------------- ### Call RPC Exported Method (No Arguments) Source: https://github.com/kkkbbb/rustfrida/blob/master/_autodocs/http-rpc-api.md Invoke an exported RPC method on a specific session using POST /rpc//. This example shows calling a method without any arguments. ```bash # 无参数 curl -X POST http://127.0.0.1:9191/rpc/0/ping ``` -------------------------------- ### GET / Source: https://github.com/kkkbbb/rustfrida/blob/master/_autodocs/http-rpc-api.md Health check endpoint for the RPC API. Returns a simple JSON object indicating the service is running. ```APIDOC ## GET / ### Description Health check endpoint. Returns a JSON object indicating the service is operational. ### Method GET ### Endpoint / ### Response #### Success Response (200) - **ok** (boolean) - Indicates if the service is healthy. - **message** (string) - A message from the service, typically "rustfrida-rpc". #### Response Example ```json { "ok": true, "message": "rustfrida-rpc" } ``` ``` -------------------------------- ### Hook Native Function and Modify Arguments Source: https://github.com/kkkbbb/rustfrida/blob/master/README.md Example of hooking the native 'open' function in libc.so. It reads the path argument, logs it, and replaces it with a fake path if it matches '/proc/self/maps'. This demonstrates modifying arguments before the original function is called. ```javascript var open = Module.findExportByName("libc.so", "open"); Interceptor.attach(open, { onEnter(args) { var path = args[0].readCString(); console.log("open", path); if (path.indexOf("/proc/self/maps") >= 0) { args[0] = Memory.allocUtf8String("/data/local/tmp/fake_maps"); } } }); ``` -------------------------------- ### List Sessions Endpoint Source: https://github.com/kkkbbb/rustfrida/blob/master/_autodocs/http-rpc-api.md Use the GET /sessions endpoint to retrieve a list of all active and disconnected sessions. The response format differs between legacy and server modes. ```bash curl http://127.0.0.1:9191/sessions ``` -------------------------------- ### Environment Variables for Android NDK and Clang Source: https://github.com/kkkbbb/rustfrida/blob/master/_autodocs/build-and-configuration.md Set environment variables for the Android NDK and clang toolchain. Ensure ANDROID_NDK_HOME points to your NDK installation and add the clang binary path to your system's PATH. ```bash export ANDROID_NDK_HOME=~/Android/Sdk/ndk/25.1.8937393 export CLANG_PATH=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin export PATH=$CLANG_PATH:$PATH ``` -------------------------------- ### Expose Script Capabilities via RPC Source: https://github.com/kkkbbb/rustfrida/blob/master/README.md Example of defining exported functions using `rpc.exports` in a RustFrida script. These functions can be called remotely from a host process, enabling tools or UIs to trigger script functionality. ```javascript rpc.exports = { ping: function() { return "pong"; }, app: function() { var ActivityThread = Java.use("android.app.ActivityThread"); var app = ActivityThread.currentApplication(); return String(app.getPackageName()); } }; ``` -------------------------------- ### Hook Java Method and Modify Return Value Source: https://github.com/kkkbbb/rustfrida/blob/master/README.md Example of hooking a Java method to log arguments and directly return true, bypassing the original implementation. Ensure this code is placed within `Java.ready()` for spawn mode. ```javascript Java.ready(function() { var Login = Java.use("com.example.LoginManager"); Login.checkPassword.impl = function(user, pass) { console.log("checkPassword", user, pass); return true; // 直接改返回值,不调原方法 }; }); ``` -------------------------------- ### Cargo Configuration for Android Cross-Compilation Source: https://github.com/kkkbbb/rustfrida/blob/master/_autodocs/build-and-configuration.md Configure Cargo for aarch64-linux-android target, specifying the linker and archiver. This setup is crucial for cross-compiling Rust code for Android devices. ```toml [target.aarch64-linux-android] linker = "aarch64-linux-android-clang" ar = "aarch64-linux-android-ar" rustflags = [ "-C", "link-arg=--target=aarch64-linux-android31", ] [build] target = "aarch64-linux-android" ``` -------------------------------- ### Conditionally Call Original Native Function Source: https://github.com/kkkbbb/rustfrida/blob/master/README.md Example using the `hook()` function to conditionally call the original native 'getpid' function or return a fixed value. This allows for dynamic control over whether the original function executes. ```javascript var getpid = Module.findExportByName("libc.so", "getpid"); hook(getpid, function() { if (Date.now() & 1) { return this.$orig(); // 调原函数,参数默认来自当前寄存器 } return 12345; // 跳过原函数 }); ``` -------------------------------- ### GET /health Source: https://github.com/kkkbbb/rustfrida/blob/master/_autodocs/http-rpc-api.md Alias for the health check endpoint. Provides the same functionality as GET /. ```APIDOC ## GET /health ### Description Health check endpoint (alias). Provides the same functionality as the GET / endpoint. ### Method GET ### Endpoint /health ### Response #### Success Response (200) - **ok** (boolean) - Indicates if the service is healthy. - **message** (string) - A message from the service, typically "rustfrida-rpc". #### Response Example ```json { "ok": true, "message": "rustfrida-rpc" } ``` ``` -------------------------------- ### Build Agent with QBDI Support Source: https://github.com/kkkbbb/rustfrida/blob/master/_autodocs/build-and-configuration.md Build the agent library with QBDI support by first compiling the qbdi-helper and then building the agent with the 'qbd' feature flag enabled. This is necessary if QBDI functionality is required. ```bash # 如需 QBDI 支持,先构建 qbdi-helper cargo build -p qbdi-helper --release cargo build -p agent --release --features qbdi ``` -------------------------------- ### RustFrida Build Process with QBDI Enabled Source: https://github.com/kkkbbb/rustfrida/blob/master/_autodocs/build-and-configuration.md Build RustFrida with QBDI support. This requires building the qbdi-helper first, then compiling the agent and RustFrida with the 'qbdi' feature flag. ```bash # 1. 构建 qbdi-helper cargo build -p qbdi-helper --release # 2. 构建 agent(带 qbdi) cargo build -p agent --release --features qbdi # 3. 构建 rustfrida(带 qbdi) cargo build -p rust_fr_ida --release --features qbdi ``` -------------------------------- ### Build RustFrida with QBDI Support Source: https://github.com/kkkbbb/rustfrida/blob/master/_autodocs/build-and-configuration.md Compile the main rustfrida program with QBDI support enabled by using the '--features qbdi' flag during the Cargo build process. ```bash # 带 QBDI cargo build -p rust_frida --release --features qbdi ``` -------------------------------- ### Build and Push Agent and Rust Frida Source: https://github.com/kkkbbb/rustfrida/blob/master/doc/managed-dsl.md Builds the agent and rust_frida binaries in release mode and pushes the rustfrida binary to the device. Ensures the pushed binary has execute permissions. ```bash cargo build --release -p agent cargo build --release -p rust_frida ``` ```bash adb -s push target/aarch64-linux-android/release/rustfrida /data/local/tmp/rustfrida ``` ```bash adb -s shell "su -c 'sh -c "chmod 755 /data/local/tmp/rustfrida"'" ``` -------------------------------- ### Build Agent Library (libagent.so) Source: https://github.com/kkkbbb/rustfrida/blob/master/_autodocs/build-and-configuration.md Compile the agent library for Android using Cargo. This command builds the libagent.so file, which includes QuickJS, the Hook engine, and Java JNI interfaces. ```bash cargo build -p agent --release # 输出:target/aarch64-linux-android/release/libagent.so ``` -------------------------------- ### Feature Compilation for Agent Source: https://github.com/kkkbbb/rustfrida/blob/master/_autodocs/build-and-configuration.md Demonstrates how to build the agent library with and without QBDI support using Cargo feature flags. The default build does not include QBDI. ```bash # 不带 QBDI(默认) cargo build -p agent --release # 启用 QBDI(需 qbdi-helper.so) cargo build -p agent --release --features qbdi ``` -------------------------------- ### Health Check Endpoint Source: https://github.com/kkkbbb/rustfrida/blob/master/_autodocs/http-rpc-api.md Use the GET / endpoint for a basic health check of the RPC server. It returns a JSON object indicating the server's status. ```bash curl http://127.0.0.1:9191/ ``` -------------------------------- ### Push and Run RustFrida Commands Source: https://github.com/kkkbbb/rustfrida/blob/master/README.md Commands to push the RustFrida binary to the device and inject into running processes or spawn new ones. Use the -l flag to load a JavaScript script. ```bash adb push target/aarch64-linux-android/release/rustfrida /data/local/tmp/ # PID 注入 ./rustfrida --pid ./rustfrida --pid -l script.js # Spawn 模式(启动时注入) ./rustfrida --spawn com.example.app ./rustfrida --spawn com.example.app -l script.js # 等待 SO 加载后注入(eBPF) ./rustfrida --watch-so libnative.so # 详细日志 ./rustfrida --pid --verbose # 同步输出日志到文件(终端仍正常输出,文件为纯文本) ./rustfrida --pid -l script.js -o /data/local/tmp/rustfrida.log ``` -------------------------------- ### Standard RustFrida Build Process Source: https://github.com/kkkbbb/rustfrida/blob/master/_autodocs/build-and-configuration.md Build RustFrida without QBDI. This involves updating submodules, building the loader shellcode, and then compiling the agent and RustFrida itself in release mode. ```bash # 1. 更新子仓库(首次) git submodule update --init --recursive # 2. 构建 loader shellcode cd loader && python3 build_helpers.py && cd .. # 3. 构建 agent cargo build -p agent --release # 4. 构建 rustfrida cargo build -p rust_fr_ida --release # 验证 ls -la target/aarch64-linux-android/release/rustfrida ``` -------------------------------- ### RustFrida Build and Deployment Commands Source: https://github.com/kkkbbb/rustfrida/blob/master/WALKSTACK_ROOT_CAUSE.md Commands to build the agent and rust_frida crates, deploy the rustfrida binary to an Android device, and run it with a specific JavaScript hook. This is used to test the fix for the 'StackMap not found' error. ```bash cd /home/wwb/RustroverProjects/rustFrida/.claude/worktrees/agent-a78f9f0b cargo build -p agent --release cargo build -p rust_frida --release adb -s 10.0.0.44:5556 push target/aarch64-linux-android/release/rustfrida /data/local/tmp/ # 在 Pixel 6 (API 36) 上: ./rustfrida --name com.example -l test_hashmap_put_hook.js # 触发 HashMap.put 大量调用 + Throwable.fillInStackTrace # 预期: 不再 LOG(FATAL) "StackMap not found for 0 in HashMap.put" ``` -------------------------------- ### RustFrida Compilation Dependencies Source: https://github.com/kkkbbb/rustfrida/blob/master/_autodocs/api-architecture.md Illustrates the compilation dependencies between the bootstrapper, rustfrida-loader, and the main rustfrida executable, showing how they are linked together. ```text bootstrapper.bin (ARM64 bare-metal) ┐ ├─→ rustfrida-loader.bin ┐ │ ├─→ rustfrida (主程序) agent/libagent.so (QuickJS + Hook) ┘────────────────────────┘ ``` -------------------------------- ### Monitor JNI RegisterNatives Calls Source: https://github.com/kkkbbb/rustfrida/blob/master/README.md Example of hooking the JNI `RegisterNatives` function to log class names and the details of native methods being registered. This helps in identifying the mapping between Java methods and their native implementations. ```javascript Interceptor.attach(Jni.addr("RegisterNatives"), { onEnter(args) { var cls = Jni.env.getClassName(args[1]); var methods = Jni.structs.JNINativeMethod.readArray(args[2], Number(args[3])); console.log("RegisterNatives:", cls); methods.forEach(function(m) { var mod = Module.findByAddress(m.fnPtr); var where = mod ? mod.name + "+" + m.fnPtr.sub(mod.base) : m.fnPtr.toString(); console.log(" " + m.name + " " + m.sig + " -> " + where); }); } }); ``` -------------------------------- ### agent Package Configuration Source: https://github.com/kkkbbb/rustfrida/blob/master/_autodocs/build-and-configuration.md Configures the agent package, specifying its name, version, edition, features (defaulting to quickjs), and dependencies. It also defines the crate type as a dynamic library. ```toml [package] name = "agent" version = "0.1.0" edition = "2021" [features] default = ["quickjs"] quickjs = [] # QuickJS 引擎 qbdi = [] # QBDI 支持(可选) [dependencies] quickjs-hook = { path = "../quickjs-hook" } frida-gum = { path = "../frida-gum" } libc = "0.2" [[lib]] name = "agent" crate-type = ["cdylib"] # 编译成动态库 ``` -------------------------------- ### Build Loader Shellcode Source: https://github.com/kkkbbb/rustfrida/blob/master/_autodocs/build-and-configuration.md Navigate to the loader directory and execute the build_helpers.py script to compile the bootstrapper and loader into binary files. This step generates bootstrapper.bin and rustfrida-loader.bin. ```bash cd loader python3 build_helpers.py # 输出:build/bootstrapper.bin, build/rustfrida-loader.bin ``` -------------------------------- ### quickjs-hook Package Configuration Source: https://github.com/kkkbbb/rustfrida/blob/master/_autodocs/build-and-configuration.md Configures the quickjs-hook package, including its name, version, edition, features, dependencies, and build dependencies for C code compilation and binding generation. ```toml [package] name = "quickjs-hook" version = "0.1.0" edition = "2021" [features] default = [] std = [] # 标准库支持 qbdi = [] # QBDI 支持 [dependencies] libc = "0.2" [build-dependencies] cc = "1" # C 代码编译 bindgen = "0.70" # 生成 C 绑定 ``` -------------------------------- ### rustfrida Core Module Structure Source: https://github.com/kkkbbb/rustfrida/blob/master/_autodocs/api-architecture.md Illustrates the directory layout and primary components of the rustfrida project, including the main program, agent library, and bindings to external frameworks. ```tree rustfrida/ ├── rust_frida/ # 主程序:命令行工具,注入器,REPL │ └── src/ │ ├── main.rs # 主函数,参数解析,生命周期管理 │ ├── args.rs # 命令行参数定义 │ ├── injection.rs # ptrace 注入流程 │ ├── process.rs # 进程操作(attach、call、wait) │ ├── server.rs # 多 session daemon 模式 │ ├── http_rpc.rs # HTTP RPC 服务器 │ └── repl.rs # 交互式 REPL 和命令处理 │ ├── agent/ # 注入到目标进程的动态库 │ └── src/ │ ├── lib.rs # agent 入口、命令处理、生命周期 │ ├── quickjs_loader.rs # QuickJS 引擎初始化 │ ├── exec_mem.rs # 可执行内存管理 │ ├── linker.rs # 目标进程 linker 操作 │ └── [其他功能模块] │ ├── quickjs-hook/ # QuickJS JavaScript 引擎 + Hook API │ └── src/ │ ├── lib.rs # 导出的公共 API │ ├── jsapi/ # JavaScript API(Hook、Java、JNI、Memory 等) │ ├── runtime.rs # JS 运行时 │ ├── context.rs # JS 上下文 │ └── value.rs # JS 值表示 │ ├── frida-gum/ # Frida Gum 库的 Rust 绑定 │ └── src/ │ ├── lib.rs # Gum 核心 │ ├── interceptor.rs # Hook 拦截器 │ ├── stalker.rs # 指令跟踪 │ ├── module.rs # 模块信息 │ └── [其他工具模块] │ ├── qbdi/ # QBDI DBI 框架的 Rust 绑定 ├── ldmonitor/ # eBPF SO 加载监控 └── loader/ # Bare-metal ARM64 bootstrap 代码 ``` -------------------------------- ### JavaClassWrapper.$new(...args) Source: https://github.com/kkkbbb/rustfrida/blob/master/_autodocs/java-hook-api.md Creates a new instance of a Java class by calling its constructor. ```APIDOC ## JavaClassWrapper.$new(...args) ### Description Creates an object instance (calls the constructor). ### Method Signature ```javascript function $new(...args: any[]): JavaObjectProxy ``` ### Parameters * `...args` (any[]) - Arguments are marshalled according to the Java constructor signature. ### Returns * `JavaObjectProxy` - An instance proxy. ### Example ```javascript var String = Java.use("java.lang.String"); var s = String.$new("hello"); var ArrayList = Java.use("java.util.ArrayList"); var list = ArrayList.$new(); ``` ``` -------------------------------- ### Hook Native Function and Modify Return Value Source: https://github.com/kkkbbb/rustfrida/blob/master/README.md Example of hooking the native 'getuid' function in libc.so. It logs the original return value and then replaces it with 0 using `retval.replace(0)`. This is useful for altering the outcome of a native function call. ```javascript var getuid = Module.findExportByName("libc.so", "getuid"); Interceptor.attach(getuid, { onLeave(retval) { console.log("getuid =>", retval.toUInt32()); retval.replace(0); } }); ``` -------------------------------- ### API Quick Reference Source: https://github.com/kkkbbb/rustfrida/blob/master/_autodocs/process-and-injection.md A quick reference table for the available API functions, their parameters, return values, and descriptions. ```APIDOC ## API Quick Reference | Function | Parameters | Returns | Description | |---|---|---|---| | `attach_to_process(tid)` | i32 | Result<()> | ptrace attach | | `detach_from_process(tid, sig)` | i32, i32 | Result<()> | ptrace detach | | `call_target_function(tid, func, args, timeout)` | i32, usize, &[usize], Option | Result | Remote function call | | `find_pid_by_name(name)` | &str | Result | Process name lookup | | `inject_via_bootstrapper(pid, args)` | i32, &InjectionArgs | Result | Main injection function | | `choose_injection_thread(pid)` | i32 | Result | Choose injection thread | | `watch_and_inject(so, args)` | &str, &InjectionArgs | Result<()> | SO load monitoring | ``` -------------------------------- ### Fix: Loader Build Directory Not Found Source: https://github.com/kkkbbb/rustfrida/blob/master/_autodocs/build-and-configuration.md Addresses the error 'failed to read file: ./loader/build/bootstrapper.bin' by ensuring the loader build directory is created. Navigate to the loader directory and run the build script, then rebuild RustFrida. ```bash cd loader python3 build_helpers.py cd .. cargo build -p rust_fr_ida --release ``` -------------------------------- ### Output File Locations Source: https://github.com/kkkbbb/rustfrida/blob/master/_autodocs/COMPLETION-REPORT.md Lists the generated documentation files and their corresponding purposes within the output directory. ```text /workspace/home/output/ ├── README.md # 导航和概述 ├── api-architecture.md # 架构参考 ├── build-and-configuration.md # 构建配置 ├── command-line-interface.md # CLI 参考 ├── http-rpc-api.md # HTTP RPC ├── java-hook-api.md # Java Hook ├── javascript-api.md # JavaScript API ├── jni-api.md # JNI API ├── process-and-injection.md # 注入流程 ├── types-and-structures.md # 类型定义 ├── 00-CONTENTS.txt # 内容清单 └── COMPLETION-REPORT.md # 本报告 ``` -------------------------------- ### RustFrida Injection Flow Source: https://github.com/kkkbbb/rustfrida/blob/master/_autodocs/api-architecture.md Outlines the steps involved in injecting the RustFrida agent into a target process using ptrace and a bootstrap shellcode. ```text rustfrida(主程序) ├─ 解析命令行参数 ├─ 查找目标进程 PID ├─ Attach to process (ptrace) ├─ 注入 bootstrap shellcode(arm64 bare-metal) │ └─ Bootstrap 在目标进程加载 rustfrida-loader │ └─ Loader 在目标进程加载 libagent.so ├─ 调用 agent 的 hello_entry(args) │ └─ Agent 初始化 QuickJS、Hook 引擎、JNI 环境 ├─ 启动 socketpair 通信(host ↔ agent) ├─ 加载脚本(可选) └─ 进入 REPL 或 HTTP 服务模式 ``` -------------------------------- ### Python Build Helper Script Logic Source: https://github.com/kkkbbb/rustfrida/blob/master/_autodocs/build-and-configuration.md The build_helpers.py script orchestrates the compilation and linking of assembly and C source files into executable binaries, followed by stripping and copying bootstrap code. ```python def main(): # 1. 编译 bootstrapper.S → bootstrapper.o # 2. 编译 loader.c → loader.o # 3. 链接 → rustfrida-loader.elf # 4. Strip → rustfrida-loader.bin # 5. 复制 bootstrap 部分到 bootstrapper.bin ``` -------------------------------- ### rust_frida Package Configuration Source: https://github.com/kkkbbb/rustfrida/blob/master/_autodocs/build-and-configuration.md Configures the rust_frida package, including its name, version, edition, description, features, dependencies, and binary path. ```toml [package] name = "rust_frida" version = "0.1.0" edition = "2021" description = "ARM64 Android 动态插桩工具" [features] # 暂未使用,预留用于条件编译 [dependencies] ldmonitor = { path = "../ldmonitor" } clap = { version = "4.5", features = ["derive"] } nix = { version = "0.30.1", features = ["ptrace", "socket", "uio"] } goblin = "0.9" # ELF 解析 once_cell = "1.21" # 全局单例 rustyline = "15" # REPL 编辑 [[bin]] name = "rustfrida" path = "src/main.rs" ``` -------------------------------- ### Build ldmonitor Command-Line Tool Source: https://github.com/kkkbbb/rustfrida/blob/master/_autodocs/build-and-configuration.md Independently build the ldmonitor command-line tool. ldmonitor is a dependency of rust_frida, but this command allows for its separate compilation. ```bash # ldmonitor 已在 rust_frida 依赖中,无需单独编译 # 但可独立构建 ldmonitor 命令行工具 cargo build -p ldmonitor --release ``` -------------------------------- ### RustFrida REPL Commands Source: https://github.com/kkkbbb/rustfrida/blob/master/README.md Commands available within the RustFrida interactive REPL for managing the JavaScript engine and executing scripts. ```bash jsinit # 初始化 JS 引擎 jseval # 求值表达式 loadjs