-
Notifications
You must be signed in to change notification settings - Fork 10
/
3f36c_hook.js
61 lines (55 loc) · 1.94 KB
/
3f36c_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
55
56
57
58
59
60
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('0x3F36C')).toString(16);
var i = 0;
Interceptor.attach(new NativePointer(addr), {
onEnter: function(args) {
console.log('{0}======================='.format(addr));
console.log('[{0}]({1})({2}) 参数1 > {3}\n'.format(args[0],
mrp(args[0]),
mrp(mrp(args[0])),
mru8s(mrp(args[0]))));
console.log('[{0}]({1}) 参数2 > {2}\n'.format(args[1],
mrp(args[1]),
mru8s(mrp(args[1]))));
},
onLeave: function(retval) {
console.log('retval > ', retval);
console.log('\n');
}
});