frida-java-bridge 6.1.3 → 6.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +13 -0
- package/lib/android.js +39 -4
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -21,6 +21,19 @@ const jsizeSize = 4;
|
|
|
21
21
|
const pointerSize = Process.pointerSize;
|
|
22
22
|
|
|
23
23
|
class Runtime {
|
|
24
|
+
ACC_PUBLIC = 0x0001;
|
|
25
|
+
ACC_PRIVATE = 0x0002;
|
|
26
|
+
ACC_PROTECTED = 0x0004;
|
|
27
|
+
ACC_STATIC = 0x0008;
|
|
28
|
+
ACC_FINAL = 0x0010;
|
|
29
|
+
ACC_SYNCHRONIZED = 0x0020;
|
|
30
|
+
ACC_BRIDGE = 0x0040;
|
|
31
|
+
ACC_VARARGS = 0x0080;
|
|
32
|
+
ACC_NATIVE = 0x0100;
|
|
33
|
+
ACC_ABSTRACT = 0x0400;
|
|
34
|
+
ACC_STRICT = 0x0800;
|
|
35
|
+
ACC_SYNTHETIC = 0x1000;
|
|
36
|
+
|
|
24
37
|
constructor () {
|
|
25
38
|
this.classFactory = null;
|
|
26
39
|
this.ClassFactory = ClassFactory;
|
package/lib/android.js
CHANGED
|
@@ -242,6 +242,9 @@ function _getApi () {
|
|
|
242
242
|
_ZN3art6mirror5Class13GetDescriptorEPNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE: function (address) {
|
|
243
243
|
this['art::mirror::Class::GetDescriptor'] = address;
|
|
244
244
|
},
|
|
245
|
+
_ZN3art6mirror5Class11GetLocationEv: function (address) {
|
|
246
|
+
this['art::mirror::Class::GetLocation'] = makeCxxMethodWrapperReturningStdStringByValue(address, ['pointer']);
|
|
247
|
+
},
|
|
245
248
|
|
|
246
249
|
_ZN3art9ArtMethod12PrettyMethodEb: function (address) {
|
|
247
250
|
this['art::ArtMethod::PrettyMethod'] = makeCxxMethodWrapperReturningStdStringByValue(address, ['pointer', 'bool']);
|
|
@@ -332,6 +335,7 @@ function _getApi () {
|
|
|
332
335
|
'_ZNK3art12StackVisitor24GetCurrentQuickFrameInfoEv',
|
|
333
336
|
'_ZN3art6Thread18GetLongJumpContextEv',
|
|
334
337
|
'_ZN3art6mirror5Class13GetDescriptorEPNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE',
|
|
338
|
+
'_ZN3art6mirror5Class11GetLocationEv',
|
|
335
339
|
'_ZN3art9ArtMethod12PrettyMethodEb',
|
|
336
340
|
'_ZN3art12PrettyMethodEPNS_9ArtMethodEb',
|
|
337
341
|
'_ZN3art3Dbg13ConfigureJdwpERKNS_4JDWP11JdwpOptionsE',
|
|
@@ -430,6 +434,18 @@ function _getApi () {
|
|
|
430
434
|
temporaryApi.vm = vms.readPointer();
|
|
431
435
|
|
|
432
436
|
if (isArt) {
|
|
437
|
+
const apiLevel = getAndroidApiLevel();
|
|
438
|
+
|
|
439
|
+
let kAccCompileDontBother;
|
|
440
|
+
if (apiLevel >= 27) {
|
|
441
|
+
kAccCompileDontBother = 0x02000000;
|
|
442
|
+
} else if (apiLevel >= 24) {
|
|
443
|
+
kAccCompileDontBother = 0x01000000;
|
|
444
|
+
} else {
|
|
445
|
+
kAccCompileDontBother = 0;
|
|
446
|
+
}
|
|
447
|
+
temporaryApi.kAccCompileDontBother = kAccCompileDontBother;
|
|
448
|
+
|
|
433
449
|
const artRuntime = temporaryApi.vm.add(pointerSize).readPointer();
|
|
434
450
|
temporaryApi.artRuntime = artRuntime;
|
|
435
451
|
const runtimeOffset = getArtRuntimeSpec(temporaryApi).offset;
|
|
@@ -2270,6 +2286,7 @@ typedef struct _ArtStackFrame ArtStackFrame;
|
|
|
2270
2286
|
typedef struct _ArtStackVisitor ArtStackVisitor;
|
|
2271
2287
|
typedef struct _ArtStackVisitorVTable ArtStackVisitorVTable;
|
|
2272
2288
|
|
|
2289
|
+
typedef struct _ArtClass ArtClass;
|
|
2273
2290
|
typedef struct _ArtMethod ArtMethod;
|
|
2274
2291
|
typedef struct _ArtThread ArtThread;
|
|
2275
2292
|
typedef struct _ArtContext ArtContext;
|
|
@@ -2340,6 +2357,12 @@ struct _ArtStackVisitor
|
|
|
2340
2357
|
ArtBacktrace * backtrace;
|
|
2341
2358
|
};
|
|
2342
2359
|
|
|
2360
|
+
struct _ArtMethod
|
|
2361
|
+
{
|
|
2362
|
+
guint32 declaring_class;
|
|
2363
|
+
guint32 access_flags;
|
|
2364
|
+
};
|
|
2365
|
+
|
|
2343
2366
|
extern GumTlsKey current_backtrace;
|
|
2344
2367
|
|
|
2345
2368
|
extern void (* perform_art_thread_state_transition) (JNIEnv * env);
|
|
@@ -2353,6 +2376,7 @@ extern ArtMethod * art_stack_visitor_get_method (ArtStackVisitor * visitor);
|
|
|
2353
2376
|
extern void art_stack_visitor_describe_location (StdString * description, ArtStackVisitor * visitor);
|
|
2354
2377
|
extern ArtMethod * translate_method (ArtMethod * method);
|
|
2355
2378
|
extern void translate_location (ArtMethod * method, guint32 pc, const gchar ** source_file, gint32 * line_number);
|
|
2379
|
+
extern void get_class_location (StdString * result, ArtClass * klass);
|
|
2356
2380
|
extern void cxx_delete (void * mem);
|
|
2357
2381
|
extern unsigned long strtoul (const char * str, char ** endptr, int base);
|
|
2358
2382
|
|
|
@@ -2495,6 +2519,7 @@ _get_frames (ArtBacktrace * backtrace)
|
|
|
2495
2519
|
GString * signature;
|
|
2496
2520
|
gchar * cursor;
|
|
2497
2521
|
ArtMethod * translated_method;
|
|
2522
|
+
StdString location;
|
|
2498
2523
|
gsize dexpc;
|
|
2499
2524
|
const gchar * source_file;
|
|
2500
2525
|
gint32 line_number;
|
|
@@ -2559,6 +2584,8 @@ _get_frames (ArtBacktrace * backtrace)
|
|
|
2559
2584
|
translated_method = translate_method (frame->method);
|
|
2560
2585
|
dexpc = (translated_method == frame->method) ? frame->dexpc : 0;
|
|
2561
2586
|
|
|
2587
|
+
get_class_location (&location, GSIZE_TO_POINTER (translated_method->declaring_class));
|
|
2588
|
+
|
|
2562
2589
|
translate_location (translated_method, dexpc, &source_file, &line_number);
|
|
2563
2590
|
|
|
2564
2591
|
json_builder_begin_object (b);
|
|
@@ -2566,12 +2593,18 @@ _get_frames (ArtBacktrace * backtrace)
|
|
|
2566
2593
|
json_builder_set_member_name (b, "signature");
|
|
2567
2594
|
json_builder_add_string_value (b, signature->str);
|
|
2568
2595
|
|
|
2596
|
+
json_builder_set_member_name (b, "origin");
|
|
2597
|
+
json_builder_add_string_value (b, std_string_get_data (&location));
|
|
2598
|
+
|
|
2569
2599
|
json_builder_set_member_name (b, "className");
|
|
2570
2600
|
json_builder_add_string_value (b, class_name);
|
|
2571
2601
|
|
|
2572
2602
|
json_builder_set_member_name (b, "methodName");
|
|
2573
2603
|
json_builder_add_string_value (b, method_name);
|
|
2574
2604
|
|
|
2605
|
+
json_builder_set_member_name (b, "methodFlags");
|
|
2606
|
+
json_builder_add_int_value (b, translated_method->access_flags);
|
|
2607
|
+
|
|
2575
2608
|
json_builder_set_member_name (b, "fileName");
|
|
2576
2609
|
json_builder_add_string_value (b, source_file);
|
|
2577
2610
|
|
|
@@ -2580,6 +2613,7 @@ _get_frames (ArtBacktrace * backtrace)
|
|
|
2580
2613
|
|
|
2581
2614
|
json_builder_end_object (b);
|
|
2582
2615
|
|
|
2616
|
+
std_string_destroy (&location);
|
|
2583
2617
|
g_string_free (signature, TRUE);
|
|
2584
2618
|
}
|
|
2585
2619
|
|
|
@@ -2691,6 +2725,7 @@ std_string_get_data (StdString * str)
|
|
|
2691
2725
|
art_stack_visitor_describe_location: api['art::StackVisitor::DescribeLocation'],
|
|
2692
2726
|
translate_method: artController.replacedMethods.translate,
|
|
2693
2727
|
translate_location: api['art::Monitor::TranslateLocation'],
|
|
2728
|
+
get_class_location: api['art::mirror::Class::GetLocation'],
|
|
2694
2729
|
cxx_delete: api.$delete,
|
|
2695
2730
|
strtoul: Module.getExportByName('libc.so', 'strtoul')
|
|
2696
2731
|
});
|
|
@@ -3290,6 +3325,8 @@ class ArtMethodMangler {
|
|
|
3290
3325
|
}
|
|
3291
3326
|
|
|
3292
3327
|
replace (impl, isInstanceMethod, argTypes, vm, api) {
|
|
3328
|
+
const { kAccCompileDontBother, artNterpEntryPoint } = api;
|
|
3329
|
+
|
|
3293
3330
|
this.originalMethod = fetchArtMethod(this.methodId, vm);
|
|
3294
3331
|
|
|
3295
3332
|
const originalFlags = this.originalMethod.accessFlags;
|
|
@@ -3307,7 +3344,7 @@ class ArtMethodMangler {
|
|
|
3307
3344
|
|
|
3308
3345
|
patchArtMethod(replacementMethodId, {
|
|
3309
3346
|
jniCode: impl,
|
|
3310
|
-
accessFlags: ((originalFlags & ~(kAccCriticalNative | kAccFastNative | kAccNterpEntryPointFastPathFlag)) | kAccNative) >>> 0,
|
|
3347
|
+
accessFlags: ((originalFlags & ~(kAccCriticalNative | kAccFastNative | kAccNterpEntryPointFastPathFlag)) | kAccNative | kAccCompileDontBother) >>> 0,
|
|
3311
3348
|
quickCode: api.artClassLinker.quickGenericJniTrampoline,
|
|
3312
3349
|
interpreterCode: api.artInterpreterToCompiledCodeBridge
|
|
3313
3350
|
}, vm);
|
|
@@ -3320,15 +3357,13 @@ class ArtMethodMangler {
|
|
|
3320
3357
|
}
|
|
3321
3358
|
|
|
3322
3359
|
patchArtMethod(hookedMethodId, {
|
|
3323
|
-
accessFlags: (originalFlags & ~(hookedMethodRemovedFlags)) >>> 0
|
|
3360
|
+
accessFlags: ((originalFlags & ~(hookedMethodRemovedFlags)) | kAccCompileDontBother) >>> 0
|
|
3324
3361
|
}, vm);
|
|
3325
3362
|
|
|
3326
3363
|
const quickCode = this.originalMethod.quickCode;
|
|
3327
3364
|
|
|
3328
3365
|
// Replace Nterp quick entrypoints with art_quick_to_interpreter_bridge to force stepping out
|
|
3329
3366
|
// of ART's next-generation interpreter and use the quick stub instead.
|
|
3330
|
-
const { artNterpEntryPoint } = api;
|
|
3331
|
-
|
|
3332
3367
|
if (artNterpEntryPoint !== undefined && quickCode.equals(artNterpEntryPoint)) {
|
|
3333
3368
|
patchArtMethod(hookedMethodId, {
|
|
3334
3369
|
quickCode: api.artQuickToInterpreterBridge
|