sensepost / objection

📱 objection - runtime mobile exploration
GNU General Public License v3.0
7.43k stars 852 forks source link

Error: java.lang.ClassNotFoundException: #405

Open biaolv opened 4 years ago

biaolv commented 4 years ago

in Android 9.0 , I try to list method of com.yy.leopard.http.AppNetHelper . use cmd string “ndroid hooking watch class_method com.yy.leopard.http.AppNetHelper --dump-args --dump-backtrace --dump-return ”。、 An error occurred。

“- [incoming message] ------------------
{
  "payload": "Attempting to watch class \u001b[32mcom.yy.leopard.http\u001b[39m and method \u001b[32mAppNetHelper\u001b[39m.",
  "type": "send"
}
- [./incoming message] ----------------
(agent) Attempting to watch class com.yy.leopard.http and method AppNetHelper.
A Frida agent exception has occurred.
Error: java.lang.ClassNotFoundException: Didn't find class "com.yy.leopard.http" on path: DexPathList[[dex file "InMemoryDexFile[cookie=[0, 3901508128]]", zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/com.yobolove.tcyyh2-o7dLH6qNQHSPZEPsZnrPFQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.yobolove.tcyyh2-o7dLH6qNQHSPZEPsZnrPFQ==/lib/arm, /data/app/com.yobolove.tcyyh2-o7dLH6qNQHSPZEPsZnrPFQ==/base.apk!/lib/armeabi-v7a, /system/lib]]
    at frida/node_modules/frida-java-bridge/lib/env.js:126
    at frida/node_modules/frida-java-bridge/lib/class-factory.js:459
    at frida/node_modules/frida-java-bridge/lib/class-factory.js:840
    at frida/node_modules/frida-java-bridge/lib/class-factory.js:128
    at frida/node_modules/frida-java-bridge/lib/class-factory.js:83
    at src/android/hooking.ts:116
    at src/android/lib/libjava.ts:9
    at frida/node_modules/frida-java-bridge/lib/vm.js:11
    at frida/node_modules/frida-java-bridge/index.js:358
”
but 。 use js Scripts 
“ Java.perform(function (){
        Java.enumerateClassLoaders({
            onMatch: function (loader) {
                if (loader.toString().indexOf("zip") > -1) {
                    Java.classFactory.loader = loader;
                    var AppNetHelper = Java.use("com.yy.leopard.http.AppNetHelper");
                    console.log("AppNetHelper.getPlatformInfo:" + AppNetHelper.getPlatformInfo());
                }
            },
            onComplete: function () {
            }
        });
      });”

it can work sucessfully.

leonjza commented 4 years ago

Thanks for the report! So the crash happens here, but you have already debugged why as well with your script. objection currently does not enumerate extra class loaders before attempting to use the target class.

This would need to be extended in the objection agent to better handle these cases.