-
Notifications
You must be signed in to change notification settings - Fork 10
/
11828_hook.js
54 lines (50 loc) · 1.54 KB
/
11828_hook.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
44
45
46
47
48
49
50
51
52
53
54
String.prototype.format = function () {
var values = arguments;
return this.replace(/\{(\d+)\}/g, function (match, index) {
if (values.length > index) {
return values[index];
} else {
return "";
}
});
}
// Memory.readUtf8String
var mru8s = function(addr) {return Memory.readUtf8String(addr)}
// Memory.readPointer
var mrp = function(addr) {return Memory.readPointer(addr)}
// Memory.allocUtf8String
var mau8s = function(addr) {return Memory.allocUtf8String(addr)}
// read process memory
var rpm = function(addr, size) {
var buf = Memory.readByteArray(ptr('0x' + addr), size);
console.log(hexdump(buf, {
offset: 0,
length: size,
header: true,
ansi: false
}));
}
var JNI_OnLoad;
var exports = Module.enumerateExportsSync("libuserinfo.so");
for (var i = 0; i < exports.length; i++) {
var name = exports[i].name;
var addr = exports[i].address;
if (name == 'JNI_OnLoad') {
JNI_OnLoad = addr;
}
}
var BASE_ADDR = parseInt(JNI_OnLoad) - parseInt("0x14504");
var addr = '0x' + parseInt(BASE_ADDR + parseInt('0x11828')).toString(16);
var i = 0;
Interceptor.attach(new NativePointer(addr), {
onEnter: function(args) {
i++;
var msg = '===============' + i + '===============\n' +
'参数1 > {0}\n参数2 > {1}\n参数3 > {2}\n'
.format(args[0], mru8s(args[1]), mru8s(args[2]));
console.log(msg);
},
onLeave: function(retval) {
console.log('retval > ', mru8s(retval));
}
});