I’m tried to replace the impl of $init method in the java.lang.String class, but when I load the script I get an error: “Error: Unable to make thread_from_jni_environment() helper for the current architecture”
System:
- Ubuntu 23.10
Env:
$ java --version
openjdk 17.0.10 2024-01-16
OpenJDK Runtime Environment (build 17.0.10+7-Ubuntu-123.10.1)
OpenJDK 64-Bit Server VM (build 17.0.10+7-Ubuntu-123.10.1, mixed mode, sharing)
$ frida --version
16.2.1
Script:
console.log("java status:", Java.available) // True
Java.perform(() => {
const groups = Java.enumerateMethods('*java.lang.String!*')
console.log(JSON.stringify(groups, null, 2))
groups[0]['classes'].forEach(element => {
var obj = Java.use(element['name'])
obj.$init.overload('java.lang.String').implementation = function (inp) {
console.log(inp)
return this.$init(arg1)
}
});
});
Output
____
/ _ | Frida 16.2.1 - A world-class dynamic instrumentation toolkit
| (_| |
> _ | Commands:
/_/ |_| help -> Displays the help system
. . . . object? -> Display information about 'object'
. . . . exit/quit -> Exit
. . . .
. . . . More info at https://frida.re/docs/home/
. . . .
. . . . Connected to Local System (id=local)
Attaching...
java status: true
[
{
"loader": null,
"classes": [
{
"name": "java.lang.String",
"methods": [
/* Methods */
]
}
]
}
]
Error: Unable to make thread_from_jni_environment() helper for the current architecture
at Object.JavaThread::thread_from_jni_environment (frida/node_modules/frida-java-bridge/lib/jvm.js:191:1)
at frida/node_modules/frida-java-bridge/lib/jvm.js:235:1
at c.perform (frida/node_modules/frida-java-bridge/lib/vm.js:12:1)
at R (frida/node_modules/frida-java-bridge/lib/jvm.js:234:1)
I’ve tried using different versions of Java:
- 17 (Error from header)
- 19 (New error)
- 22 (New error)
With the last two I was getting a new error:
Error: Java API only partially available; please file a bug. Missing: _ZN6Method4sizeEb, _ZN6Method19set_native_functionEPhb, _ZN6Method21clear_native_functionEv, _ZN6Method10jmethod_idEv, _ZN20ClassLoaderDataGraph10classes_doEP12KlassClosure, _ZN8VMThread7executeEP12VM_Operation, _ZN11OopMapCache22flush_obsolete_entriesEv, _ZN14NMethodSweeper16sweep_code_cacheEv, _ZTV18VM_RedefineClasses, _ZN18VM_RedefineClasses4doitEv, _ZN18VM_RedefineClasses13doit_prologueEv, _ZN18VM_RedefineClasses13doit_epilogueEv, _ZNK18VM_RedefineClasses26allow_nested_vm_operationsEv, _ZN19Abstract_VM_Version19jre_release_versionEv, _ZN14NMethodSweeper11_traversalsE, _ZN14NMethodSweeper13_should_sweepE
at E (frida/node_modules/frida-java-bridge/lib/jvm.js:146)
at b (frida/node_modules/frida-java-bridge/lib/jvm.js:10)
at _tryInitialize (frida/node_modules/frida-java-bridge/index.js:29)
at _ (frida/node_modules/frida-java-bridge/index.js:21)
at <anonymous> (frida/node_modules/frida-java-bridge/index.js:332)
at call (native)
at o (/_java.js)
at <anonymous> (/_java.js)
at <anonymous> (frida/runtime/java.js:1)
at call (native)
at o (/_java.js)
at r (/_java.js)
at <eval> (frida/runtime/java.js:3)
at _loadJava (native)
at get (frida/runtime/core.js:134)
New contributor
Nik is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.