frida / frida-website

Frida's website
MIT License
83 stars 191 forks source link

ClassNotFoundException: Didn't find class #258

Open USTCerirl opened 1 year ago

USTCerirl commented 1 year ago

Hi there, I m new to frida and I wanna try my first frida hook to log out "Hello Frida!", but every method I wanna hook will throw this exception, I have no idea wut to do rn. can anyone help me? I d appreciate it!

This is the frida frag I copy from jadx: let StartActivity = Java.use("com.e4a.runtime.android.StartActivity"); StartActivity["onCreate"].implementation = function (bundle) { console.log(StartActivity.onCreate is called: bundle=${bundle}); console.log('Hello Frida'); this"onCreate"; };

This is the command I type in cmd: frida -U -l hello.js -f com.example.lof (cuz I try to hook a oncreate method, so I try to start it in spawn mode.)

This is the result I get:
Error: java.lang.ClassNotFoundException: Didn't find class "com.e4a.runtime.android.StartActivity" on path: DexPathList[[directory "."],nativeLibraryDirectories=[/system/lib64, /system/vendor/lib64, /system/lib64, /system/vendor/lib64]] at (frida/node_modules/frida-java-bridge/lib/env.js:124) at (frida/node_modules/frida-java-bridge/lib/env.js:115) at apply (native) at (frida/node_modules/frida-java-bridge/lib/env.js:97) at (frida/node_modules/frida-java-bridge/lib/class-factory.js:488) at value (frida/node_modules/frida-java-bridge/lib/class-factory.js:945) at value (frida/node_modules/frida-java-bridge/lib/class-factory.js:950) at _make (frida/node_modules/frida-java-bridge/lib/class-factory.js:165) at use (frida/node_modules/frida-java-bridge/lib/class-factory.js:62) at use (frida/node_modules/frida-java-bridge/index.js:258) at main (D:\Desktop\frida_demo\hello.js:2) at apply (native) at (frida/runtime/core.js:51)

1trackprojects1 commented 4 months ago

I'm getting the same issue, anyone else?

Update: FIXED IT!!! - basically just wrap your code around with another function like this:

Java.perform(function () {
    // code here
});