frida / frida

Clone this repo to build Frida
https://frida.re
Other
15.21k stars 1.58k forks source link

Unable to make thread_from_jni_environment() helper for the current architecture #2868

Open Holpak opened 1 month ago

Holpak commented 1 month ago

I'm tried to replace the $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"

$ 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)
        }
    });
});

Ouput:

     ____
    / _  |   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 <anonymous> (frida/node_modules/frida-java-bridge/lib/jvm.js:191)
    at <anonymous> (frida/node_modules/frida-java-bridge/lib/jvm.js:235)
    at <anonymous> (frida/node_modules/frida-java-bridge/lib/vm.js:12)
    at R (frida/node_modules/frida-java-bridge/lib/jvm.js:250)