MainActivity.java: сильный>
Код: Выделить всё
package com.example.fridatest;
import android.os.Bundle;
import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
public class MainActivity extends AppCompatActivity {
private MyClass mMyClass;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
EdgeToEdge.enable(this);
setContentView(R.layout.activity_main);
mMyClass = new MyClass();
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
return insets;
});
}
}
Код: Выделить всё
package com.example.fridatest;
public class MyClass {
private static int mNextId = 0;
private int mId;
public MyClass() {
mId = mNextId ++;
}
public int getId() {
return mId;
}
}
Код: Выделить всё
frida -U -l hook5.js -p 3507
Код: Выделить всё
Java.perform(function() {
try {
Java.choose( "com.example.fridatest.MyClass", {
onMatch: function(instance) {
console.log("[ * ] Instance found in memory: " + instance);
},
onComplete: function() {
console.log("[ * ] onComplete ");
}
});
} catch( e ) {
console.log("[ * ] Instance NOT found");
}
});

Когда я запускаю скрипт, приложение вылетает. То же самое происходит и с другими приложениями — я просто быстро собрал этот пример, чтобы понять, почему.
Logcat:
Код: Выделить всё
12-06 17:09:47.476947 3507 3801 F libc : Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x6ee6f038 in tid 3801 (Thread-3), pid 3507 (ample.fridatest)
--------- switch to main
12-06 17:09:47.257137 527 328 I chatty : uid=1010 wifi@1.0-servic identical 11 lines
12-06 17:09:47.649315 3804 3804 I crash_dump32: obtaining output fd from tombstoned, type: kDebuggerdTombstone
12-06 17:09:47.650453 741 741 I /system/bin/tombstoned: received crash request for pid 3801
12-06 17:09:47.651681 3804 3804 I crash_dump32: performing dump of process 3507 (target tid = 3801)
--------- switch to crash
12-06 17:09:48.069687 3804 3804 F DEBUG : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
12-06 17:09:48.069951 3804 3804 F DEBUG : Build fingerprint: REDACTED
12-06 17:09:48.070011 3804 3804 F DEBUG : Revision: '0'
12-06 17:09:48.070065 3804 3804 F DEBUG : ABI: 'arm'
12-06 17:09:48.103819 3804 3804 F DEBUG : Timestamp: 2024-12-06 17:09:48+1300
12-06 17:09:48.103939 3804 3804 F DEBUG : pid: 3507, tid: 3801, name: Thread-3 >>> com.example.fridatest
Подробнее здесь: [url]https://stackoverflow.com/questions/79256834/frida-crashes-android-app-when-trying-to-get-class-instance[/url]
Мобильная версия