-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathstalker.js
43 lines (43 loc) · 1.33 KB
/
stalker.js
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
Interceptor.attach(ObjC.classes.MyClass['- myMethod:param1'].implementation, {
onEnter: function (args) {
console.warn(JSON.stringify({
fname: args[1].readCString(),
text: new ObjC.Object(args[2]).toString(),
backtrace: Thread.backtrace(this.context, Backtracer.ACCURATE).map(DebugSymbol.fromAddress).map(m => m.moduleName+'!'+m.name),
ctx: this.context
}, null, 2));
var tid = Process.getCurrentThreadId();
this.tid = tid;
Stalker.follow(tid, {
events: {
call: true
},
/*
onCallSummary: function (summary) {
Object.keys(summary).forEach(s => {
var sym = DebugSymbol.fromAddress(ptr(s));
if (sym.moduleName == 'Viber')
console.log(summary[s], sym.name);
})
}
*/
transform: function (iterator) {
var instruction;
while ((instruction = iterator.next()) !== null) {
iterator.keep();
if (instruction.mnemonic.startsWith('bl')) {
try {
console.log('#' + tid + ':' + DebugSymbol.fromAddress(ptr(instruction.operands[0].value)));
} catch (e) {
// ignoring branch&link to register
}
}
}
}
});
},
onLeave: function (retval) {
Stalker.unfollow(this.tid);
Stalker.garbageCollect();
}
})