-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathlog_interceptor.js
More file actions
119 lines (117 loc) · 3.99 KB
/
log_interceptor.js
File metadata and controls
119 lines (117 loc) · 3.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/**
* This Frida script intercepts and logs all calls to Android's logging functions at both the Java and native layers
*
* @returns {void}
*/
import Java from "frida-java-bridge";
rpc.exports = {
run: function () {
Java.performNow(function () {
let Log = Java.use("android.util.Log");
Log.d.overload("java.lang.String", "java.lang.String").implementation = function (a, b) {
send(a.toString());
send(b.toString());
return this.d(a, b);
};
Log.d.overload("java.lang.String", "java.lang.String", "java.lang.Throwable").implementation = function (
a,
b,
c,
) {
send(a.toString());
send(b.toString());
return this.d(a, b, c);
};
Log.v.overload("java.lang.String", "java.lang.String").implementation = function (a, b) {
send(a.toString());
send(b.toString());
return this.v(a, b);
};
Log.v.overload("java.lang.String", "java.lang.String", "java.lang.Throwable").implementation = function (
a,
b,
c,
) {
send(a.toString());
send(b.toString());
return this.v(a, b, c);
};
Log.i.overload("java.lang.String", "java.lang.String").implementation = function (a, b) {
send(a.toString());
send(b.toString());
return this.i(a, b);
};
Log.i.overload("java.lang.String", "java.lang.String", "java.lang.Throwable").implementation = function (
a,
b,
c,
) {
send(a.toString());
send(b.toString());
return this.i(a, b, c);
};
Log.e.overload("java.lang.String", "java.lang.String").implementation = function (a, b) {
send(a.toString());
send(b.toString());
return this.e(a, b);
};
Log.e.overload("java.lang.String", "java.lang.String", "java.lang.Throwable").implementation = function (
a,
b,
c,
) {
send(a.toString());
send(b.toString());
return this.e(a, b, c);
};
Log.w.overload("java.lang.String", "java.lang.String").implementation = function (a, b) {
send(a.toString());
send(b.toString());
return this.w(a, b);
};
Log.w.overload("java.lang.String", "java.lang.Throwable").implementation = function (a, b) {
send(a.toString());
return this.w(a, b);
};
Log.w.overload("java.lang.String", "java.lang.String", "java.lang.Throwable").implementation = function (
a,
b,
c,
) {
send(a.toString());
send(b.toString());
return this.w(a, b, c);
};
Log.wtf.overload("java.lang.String", "java.lang.String").implementation = function (a, b) {
send(a.toString());
send(b.toString());
return this.wtf.overload("java.lang.String", "java.lang.String").call(this, a, b);
};
Log.println.overload("int", "java.lang.String", "java.lang.String").implementation = function (a, b, c) {
send(a.toString());
send(b.toString());
send(c.toString());
return this.println(a, b, c);
};
});
let LogPrint = Module.findExportByName("liblog.so", "__android_log_print");
let LogWrite = Module.findExportByName("liblog.so", "__android_log_write");
let LogVPrint = Module.findExportByName("liblog.so", "__android_log_vprint");
let LogAssert = Module.findExportByName("liblog.so", "__android_log_assert");
Interceptor.attach(LogPrint, function (args) {
send("Print : ", args[1].readCString(), args[2].readCString());
});
Interceptor.attach(LogWrite, function (args) {
send("Write : ", args[1].readCString(), args[2].readCString());
});
Interceptor.attach(LogVPrint, function (args) {
send("VPrint : ", args[1].readCString(), args[2].readCString());
});
Interceptor.attach(LogAssert, function (args) {
send("Assert : ", args[0].readCString(), args[1].readCString());
});
},
schema: function () {
return null;
},
};